[pocl] 01/02: Imported Upstream version 0.12

Andreas Beckmann anbe at moszumanska.debian.org
Mon Apr 25 09:11:36 UTC 2016


This is an automated email from the git hooks/post-receive script.

anbe pushed a commit to branch upstream
in repository pocl.

commit 3b4c58de359427b3206b75d6ebcc388404eb5362
Author: Andreas Beckmann <anbe at debian.org>
Date:   Sat Mar 19 21:44:26 2016 +0100

    Imported Upstream version 0.12
---
 CHANGES                                            |   39 +-
 CMakeLists.txt                                     |  128 +-
 CREDITS                                            |    5 +
 Makefile.am                                        |   10 +-
 Makefile.in                                        |   79 +-
 README.mips                                        |   13 +-
 README.mipsel                                      |   14 +
 TODO                                               |   32 +-
 aclocal.m4                                         |   57 +-
 cmake/LLVM.cmake                                   |  135 +-
 cmake/bitcode_rules.cmake                          |   32 +-
 cmake/kernellib_hash.cmake                         |    7 +
 config.h.in                                        |   23 +-
 config.h.in.cmake                                  |   12 +-
 config/ar-lib                                      |    2 +-
 config/compile                                     |    2 +-
 config/config.guess                                |   11 +-
 config/config.sub                                  |   12 +-
 config/depcomp                                     |    2 +-
 config/install-sh                                  |  366 +-
 config/ltmain.sh                                   | 5508 +++++++-----
 config/missing                                     |    2 +-
 configure                                          | 3618 +++++---
 configure.ac                                       |  216 +-
 doc/sphinx/source/conf.py                          |    4 +-
 doc/sphinx/source/development.rst                  |    4 +-
 doc/sphinx/source/env_variables.rst                |   39 +-
 doc/sphinx/source/faq.rst                          |   62 +
 doc/sphinx/source/hsa.rst                          |  106 +
 doc/sphinx/source/index.rst                        |    3 +
 doc/sphinx/source/kernel_compiler.rst              |   21 +
 doc/sphinx/source/releasing.rst                    |    1 +
 doc/sphinx/source/using.rst                        |    7 +-
 examples/AMD/AMDSDK.patch                          |   17 +-
 examples/AMD/Makefile.in                           |   26 +-
 examples/AMDSDK2.9/AMDSDK2_9.patch                 |   18 +-
 examples/AMDSDK2.9/Makefile.in                     |   26 +-
 examples/CloverLeaf/Makefile.in                    |   26 +-
 examples/EinsteinToolkit/Makefile.in               |   27 +-
 examples/Halide/Makefile.in                        |   26 +-
 examples/Makefile.am                               |    8 +-
 examples/Makefile.in                               |   34 +-
 examples/OpenCV/Makefile.am                        |  263 +
 examples/OpenCV/Makefile.in                        |  783 ++
 examples/OpenCV/README                             |   24 +
 examples/Parboil/Makefile.in                       |   26 +-
 examples/PyOpenCL/README                           |   49 +
 examples/Rodinia/Makefile.am                       |    2 +
 examples/Rodinia/Makefile.in                       |   27 +-
 examples/Rodinia/Rodinia.patch                     |   16 +
 examples/VexCL/Makefile.in                         |   26 +-
 examples/ViennaCL/Makefile.in                      |   26 +-
 examples/example1-spir32/Makefile.in               |   27 +-
 examples/example1-spir32/example1.c                |   16 +-
 examples/example1-spir32/example1_exec.c           |    2 +-
 examples/example1-spir64/Makefile.in               |   27 +-
 examples/example1-spir64/example1.c                |   16 +-
 examples/example1-spir64/example1_exec.c           |    2 +-
 examples/example1/Makefile.in                      |   27 +-
 examples/example1/example1.c                       |   24 +-
 examples/example1/example1_exec.c                  |    2 +-
 examples/example2/Makefile.in                      |   27 +-
 examples/example2/example2.c                       |    4 +-
 examples/example2a/Makefile.in                     |   27 +-
 examples/example2a/example2a.c                     |    4 +-
 .../opencl-book-samples/HelloBinaryWorld.stdout    |    9 +
 examples/opencl-book-samples/HelloWorld.stdout     |    2 +
 examples/opencl-book-samples/ImageFilter2D.cl      |   34 +
 examples/opencl-book-samples/Makefile.am           |    4 +
 examples/opencl-book-samples/Makefile.in           |   29 +-
 .../OpenCLConvolutionChap3.stdout                  |    8 +
 .../SimpleBufferSubBuffer.stdout                   |    6 +
 examples/opencl-book-samples/VectorAdd.stdout      |    1 +
 examples/piglit/Makefile.am                        |    2 +
 examples/piglit/Makefile.in                        |   27 +-
 examples/piglit/README                             |    2 +-
 examples/piglit/produce_results.sh                 |    8 +
 examples/scalarwave/Makefile.in                    |   27 +-
 examples/scalarwave/scalarwave.c                   |    7 +-
 examples/standalone/Makefile.in                    |   26 +-
 examples/trig/Makefile.in                          |   27 +-
 examples/trig/trig.c                               |    8 +-
 examples/trig/trig_exec.c                          |    2 +-
 include/CL/CMakeLists.txt                          |    4 +-
 include/CL/Makefile.am                             |    3 +-
 include/CL/Makefile.in                             |   33 +-
 include/CL/cl.hpp.in                               |   12 +-
 include/CL/cl2.hpp                                 | 8926 ++++++++++++++++++++
 include/CL/cl_platform.h                           |   20 +-
 include/CMakeLists.txt                             |    2 +-
 include/Makefile.am                                |    6 +-
 include/Makefile.in                                |   34 +-
 include/OpenCL/Makefile.in                         |   28 +-
 include/_kernel.h                                  |   97 +-
 include/_kernel_c.h                                |   78 +-
 include/_kernel_constants.h                        |   88 +
 include/pocl.h                                     |   18 +-
 include/pocl_cache.h                               |  132 +
 include/pocl_features.h                            |    4 +-
 include/pocl_file_util.h                           |   85 +
 include/poclu.h                                    |    4 +
 include/vccompat.hpp                               |    2 +
 lib/CL/CMakeLists.txt                              |   10 +-
 lib/CL/Makefile.am                                 |   18 +-
 lib/CL/Makefile.in                                 |  134 +-
 lib/CL/clBuildProgram.c                            |  312 +-
 lib/CL/clCreateBuffer.c                            |    2 +-
 lib/CL/clCreateCommandQueue.c                      |    9 +-
 lib/CL/clCreateContext.c                           |   33 +-
 lib/CL/clCreateContextFromType.c                   |    8 +-
 lib/CL/clCreateImage.c                             |    6 +-
 lib/CL/clCreateKernel.c                            |   55 +-
 lib/CL/clCreateKernelsInProgram.c                  |   90 +-
 lib/CL/clCreateProgramWithBinary.c                 |   69 +-
 lib/CL/clCreateProgramWithSource.c                 |   38 +-
 lib/CL/clCreateSubBuffer.c                         |    4 +-
 lib/CL/clCreateSubDevices.c                        |  156 +-
 lib/CL/clCreateUserEvent.c                         |   25 +-
 lib/CL/clEnqueueCopyBuffer.c                       |   17 +-
 lib/CL/clEnqueueCopyBufferRect.c                   |   23 +-
 lib/CL/clEnqueueCopyBufferToImage.c                |    2 +-
 lib/CL/clEnqueueFillImage.c                        |    1 -
 lib/CL/clEnqueueMapBuffer.c                        |   26 +-
 lib/CL/clEnqueueMapImage.c                         |   54 +-
 lib/CL/clEnqueueMarkerWithWaitList.c               |    9 +-
 lib/CL/clEnqueueNDRangeKernel.c                    |   74 +-
 lib/CL/clEnqueueNativeKernel.c                     |   36 +-
 lib/CL/clEnqueueReadBuffer.c                       |    2 +-
 lib/CL/clEnqueueReadBufferRect.c                   |   17 +-
 lib/CL/clEnqueueReadImage.c                        |    6 +-
 lib/CL/clEnqueueUnmapMemObject.c                   |   24 +-
 lib/CL/clEnqueueWriteBuffer.c                      |    2 +-
 lib/CL/clEnqueueWriteBufferRect.c                  |    6 +-
 lib/CL/clEnqueueWriteImage.c                       |    2 -
 lib/CL/clFinish.c                                  |  140 +-
 lib/CL/clGetDeviceIDs.c                            |   23 +-
 lib/CL/clGetDeviceInfo.c                           |   15 +-
 lib/CL/clGetEventInfo.c                            |    2 +-
 lib/CL/clGetKernelWorkGroupInfo.c                  |    4 +-
 lib/CL/clGetPlatformIDs.c                          |   10 +-
 lib/CL/clGetPlatformInfo.c                         |    2 +-
 lib/CL/clGetProgramBuildInfo.c                     |   42 +-
 lib/CL/clGetProgramInfo.c                          |   47 +-
 lib/CL/clGetSupportedImageFormats.c                |   21 +-
 lib/CL/clReleaseCommandQueue.c                     |    2 +
 lib/CL/clReleaseContext.c                          |    2 +-
 lib/CL/clReleaseDevice.c                           |   11 +-
 lib/CL/clReleaseEvent.c                            |    6 +-
 lib/CL/clReleaseKernel.c                           |    3 +-
 lib/CL/clReleaseProgram.c                          |   29 +-
 lib/CL/clRetainDevice.c                            |    3 +
 lib/CL/clRetainEvent.c                             |    2 -
 lib/CL/clSetKernelArg.c                            |    5 +
 lib/CL/clSetUserEventStatus.c                      |   11 +-
 lib/CL/clWaitForEvents.c                           |   14 +-
 lib/CL/devices/CMakeLists.txt                      |    9 +-
 lib/CL/devices/Makefile.am                         |    5 +
 lib/CL/devices/Makefile.in                         |   38 +-
 lib/CL/devices/basic/Makefile.in                   |   27 +-
 lib/CL/devices/basic/basic.c                       |  185 +-
 lib/CL/devices/bufalloc.h                          |    8 +-
 lib/CL/devices/cellspu/Makefile.in                 |   27 +-
 lib/CL/devices/cellspu/cellspu.c                   |   20 +-
 lib/CL/devices/common.c                            |   73 +-
 lib/CL/devices/common.h                            |    2 +
 lib/CL/devices/cpuinfo.c                           |   73 +-
 lib/CL/devices/dev_image.h                         |    3 +-
 lib/CL/devices/devices.c                           |   39 +-
 lib/CL/devices/devices.h                           |    4 +
 {include => lib/CL/devices/hsa}/CMakeLists.txt     |   16 +-
 lib/CL/devices/{tce/ttasim => hsa}/Makefile.am     |   29 +-
 lib/CL/devices/{basic => hsa}/Makefile.in          |   94 +-
 lib/CL/devices/hsa/pocl-hsa.c                      |  990 +++
 .../{clRetainDevice.c => devices/hsa/pocl-hsa.h}   |   30 +-
 lib/CL/devices/prototypes.inc                      |    5 +-
 lib/CL/devices/pthread/Makefile.in                 |   27 +-
 lib/CL/devices/pthread/pthread.c                   |  146 +-
 lib/CL/devices/tce/Makefile.am                     |    2 +
 lib/CL/devices/tce/Makefile.in                     |   37 +-
 lib/CL/devices/tce/tce_common.cc                   |   29 +-
 lib/CL/devices/tce/ttasim/Makefile.am              |    4 +
 lib/CL/devices/tce/ttasim/Makefile.in              |   34 +-
 lib/CL/devices/tce/ttasim/ttasim.cc                |   23 +-
 lib/CL/devices/topology/Makefile.in                |   27 +-
 lib/CL/devices/topology/pocl_topology.c            |   65 +-
 lib/CL/devices/topology/pocl_topology.h            |    8 +-
 lib/CL/pocl_cache.c                                |  580 ++
 lib/CL/pocl_cl.h                                   |  212 +-
 lib/CL/pocl_debug.c                                |   56 +
 lib/CL/pocl_debug.h                                |  146 +
 lib/CL/pocl_hash.c                                 |    2 +
 lib/CL/pocl_hash.h                                 |   16 +
 lib/CL/pocl_image_util.c                           |    8 +-
 lib/CL/pocl_image_util.h                           |    5 +-
 lib/CL/pocl_llvm.h                                 |   42 +-
 lib/CL/pocl_llvm_api.cc                            |  691 +-
 lib/CL/pocl_queue_util.c                           |  131 +
 .../topology/pocl_topology.h => pocl_queue_util.h} |   42 +-
 lib/CL/pocl_util.c                                 |  351 +-
 lib/CL/pocl_util.h                                 |   58 +-
 lib/CMakeLists.txt                                 |    1 -
 lib/Makefile.in                                    |   26 +-
 lib/kernel/CMakeLists.txt                          |   23 +
 lib/kernel/Makefile.am                             |   17 +-
 lib/kernel/Makefile.in                             |   39 +-
 lib/kernel/cellspu/Makefile                        |  153 +-
 lib/kernel/cellspu/Makefile.in                     |   53 +-
 lib/kernel/divide.cl                               |    1 -
 lib/kernel/exp.cl                                  |    1 -
 lib/kernel/exp10.cl                                |    1 -
 lib/kernel/exp2.cl                                 |    1 -
 lib/kernel/get_image_depth.cl                      |    5 -
 .../{get_image_width.cl => get_image_dim.cl}       |   36 +-
 lib/kernel/get_image_height.cl                     |    5 -
 lib/kernel/get_image_width.cl                      |    5 -
 lib/kernel/host/CMakeLists.txt                     |    7 +-
 lib/kernel/host/Makefile.in                        |   69 +-
 lib/kernel/hsail64/CMakeLists.txt                  |   68 +
 .../tce/ttasim => lib/kernel/hsail64}/Makefile.am  |   34 +-
 lib/kernel/{tce => hsail64}/Makefile.in            |   84 +-
 lib/kernel/{exp10.cl => hsail64/acos.cl}           |   28 +-
 lib/kernel/{native_log2.cl => hsail64/acosh.cl}    |   14 +-
 lib/kernel/{log.cl => hsail64/asin.cl}             |   28 +-
 lib/{CL/pocl_hash.h => kernel/hsail64/asinh.cl}    |   33 +-
 lib/kernel/hsail64/atan.cl                         |  103 +
 lib/kernel/hsail64/atan2.cl                        |  187 +
 lib/{CL/pocl_hash.h => kernel/hsail64/atanh.cl}    |   32 +-
 lib/kernel/hsail64/atomic_impl.ll                  |  276 +
 lib/kernel/hsail64/atomics.cl                      |  130 +
 lib/kernel/hsail64/barrier.c                       |   56 +
 lib/kernel/{native_log2.cl => hsail64/cbrt.cl}     |   14 +-
 lib/kernel/{native_log2.cl => hsail64/copysign.cl} |   15 +-
 lib/kernel/hsail64/cos.cl                          |  119 +
 lib/kernel/{native_log2.cl => hsail64/cosh.cl}     |   15 +-
 lib/kernel/hsail64/exp.cl                          |  102 +
 lib/kernel/{exp.cl => hsail64/exp10.cl}            |   20 +-
 lib/kernel/hsail64/exp2.cl                         |  150 +
 lib/kernel/{native_log2.cl => hsail64/expm1.cl}    |   14 +-
 lib/kernel/{native_log2.cl => hsail64/fabs.cl}     |   15 +-
 lib/kernel/{native_log2.cl => hsail64/floor.cl}    |   15 +-
 lib/kernel/{native_log2.cl => hsail64/fma.cl}      |   15 +-
 .../clReleaseEvent.c => kernel/hsail64/fract.cl}   |   62 +-
 lib/kernel/{exp10.cl => hsail64/frexp.cl}          |   32 +-
 lib/kernel/hsail64/frexp.inc                       |   63 +
 .../hsail64/get_global_id.c}                       |   26 +-
 .../hsail64/get_global_size.c}                     |   41 +-
 .../hsail64/get_group_id.c}                        |   27 +-
 .../hsail64/get_local_id.c}                        |   26 +-
 .../hsail64/get_local_size.c}                      |   26 +-
 .../hsail64/get_num_groups.c}                      |   25 +-
 .../{native_log2.cl => hsail64/get_work_dim.c}     |   18 +-
 lib/kernel/hsail64/hsail_templates.h               |  304 +
 lib/kernel/{divide.cl => hsail64/hypot.cl}         |   13 +-
 lib/kernel/hsail64/ilogb.cl                        |   75 +
 lib/kernel/hsail64/ldexp.cl                        |   83 +
 lib/kernel/{ => hsail64}/log.cl                    |   19 +-
 lib/kernel/{ => hsail64}/log10.cl                  |   19 +-
 lib/kernel/{native_log2.cl => hsail64/log1p.cl}    |   14 +-
 lib/kernel/hsail64/log2.cl                         |   99 +
 lib/kernel/{native_log2.cl => hsail64/mad.cl}      |   14 +-
 lib/kernel/{native_log2.cl => hsail64/mad24.cl}    |   16 +-
 lib/kernel/{exp.cl => hsail64/mad_hi.cl}           |   20 +-
 lib/kernel/{native_log2.cl => hsail64/mul24.cl}    |   16 +-
 lib/kernel/{native_log2.cl => hsail64/mul_hi.cl}   |   15 +-
 lib/kernel/{ => hsail64}/native_cos.cl             |   12 +-
 .../{native_log2.cl => hsail64/native_exp.cl}      |   14 +-
 lib/kernel/{exp.cl => hsail64/native_exp10.cl}     |   20 +-
 .../{native_log2.cl => hsail64/native_exp2.cl}     |   14 +-
 lib/kernel/{log.cl => hsail64/native_log.cl}       |   23 +-
 lib/kernel/{exp.cl => hsail64/native_log10.cl}     |   21 +-
 lib/kernel/{ => hsail64}/native_log2.cl            |   12 +-
 .../{native_log2.cl => hsail64/native_recip.cl}    |   15 +-
 .../{native_log2.cl => hsail64/native_rsqrt.cl}    |   14 +-
 .../{native_log2.cl => hsail64/native_sin.cl}      |   14 +-
 .../{native_log2.cl => hsail64/native_sqrt.cl}     |   14 +-
 lib/kernel/{powr.cl => hsail64/pow.cl}             |   56 +-
 lib/kernel/{exp.cl => hsail64/remainder.cl}        |   15 +-
 lib/kernel/{native_log2.cl => hsail64/rint.cl}     |   15 +-
 lib/kernel/hsail64/sin.cl                          |  123 +
 lib/kernel/{native_log2.cl => hsail64/sinh.cl}     |   16 +-
 lib/kernel/hsail64/sqrt.cl                         |   53 +
 lib/kernel/hsail64/sqrt_default.ll                 |   19 +
 lib/kernel/hsail64/tan.cl                          |  141 +
 lib/kernel/{native_log2.cl => hsail64/tanh.cl}     |   15 +-
 lib/kernel/{native_log2.cl => hsail64/trunc.cl}    |   15 +-
 lib/kernel/hsail64/vml_constants.h                 |   38 +
 lib/kernel/log.cl                                  |    1 -
 lib/kernel/log10.cl                                |    1 -
 lib/kernel/native_cos.cl                           |    8 +-
 lib/kernel/{native_log2.cl => native_divide.cl}    |   10 +-
 lib/kernel/{native_log2.cl => native_exp.cl}       |   10 +-
 lib/kernel/{native_log2.cl => native_exp10.cl}     |   10 +-
 lib/kernel/{native_log2.cl => native_exp2.cl}      |   10 +-
 lib/kernel/{native_log2.cl => native_log.cl}       |   10 +-
 lib/kernel/{native_log2.cl => native_log10.cl}     |   10 +-
 lib/kernel/native_log2.cl                          |    6 +-
 lib/kernel/{native_log2.cl => native_powr.cl}      |   10 +-
 lib/kernel/{native_log2.cl => native_recip.cl}     |   10 +-
 lib/kernel/{native_log2.cl => native_rsqrt.cl}     |   10 +-
 lib/kernel/{native_log2.cl => native_sin.cl}       |   10 +-
 lib/kernel/{native_log2.cl => native_sqrt.cl}      |   10 +-
 lib/kernel/{native_log2.cl => native_tan.cl}       |   10 +-
 lib/kernel/powr.cl                                 |    1 -
 lib/kernel/recip.cl                                |    1 -
 lib/kernel/rsqrt.cl                                |    1 -
 lib/kernel/sin.cl                                  |    1 -
 lib/kernel/sources-vml.mk                          |   15 +-
 lib/kernel/sources.mk                              |   12 +
 lib/kernel/sqrt.cl                                 |    1 -
 lib/kernel/tan.cl                                  |    1 -
 lib/kernel/tce/Makefile                            |  153 +-
 lib/kernel/tce/Makefile.in                         |   53 +-
 lib/kernel/vecmathlib-pocl/frexp.cl                |  324 +-
 lib/kernel/vecmathlib-pocl/generate-files.py       |   24 +-
 lib/kernel/vecmathlib-pocl/kernel-vecmathlib.h     |  384 +
 lib/kernel/vecmathlib-pocl/length.cl               |   69 +-
 lib/kernel/vecmathlib-pocl/normalize.cl            |   36 +-
 lib/kernel/vecmathlib/vecmathlib.rst               |   64 +
 lib/llvmopencl/AutomaticLocals.cc                  |   14 +-
 lib/llvmopencl/Barrier.h                           |    3 +
 lib/llvmopencl/BarrierTailReplication.cc           |   29 +-
 lib/llvmopencl/BarrierTailReplication.h            |    8 +
 lib/llvmopencl/BreakConstantGEPs.cpp               |   31 +-
 lib/llvmopencl/CMakeLists.txt                      |    2 +-
 lib/llvmopencl/CanonicalizeBarriers.cc             |   43 +-
 .../{LoopBarriers.h => CompilerWarnings.h}         |   58 +-
 lib/llvmopencl/DebugHelpers.cc                     |   11 +
 lib/llvmopencl/DebugHelpers.h                      |    9 +
 lib/llvmopencl/Flatten.cc                          |    6 +
 lib/llvmopencl/GenerateHeader.cc                   |   57 +-
 lib/llvmopencl/ImplicitConditionalBarriers.cc      |    5 +
 lib/llvmopencl/ImplicitConditionalBarriers.h       |    1 -
 lib/llvmopencl/ImplicitLoopBarriers.h              |    1 -
 lib/llvmopencl/IsolateRegions.cc                   |   18 +-
 lib/llvmopencl/Kernel.cc                           |   25 +-
 lib/llvmopencl/LLVMFileUtils.cc                    |  335 +
 lib/llvmopencl/LLVMUtils.h                         |    4 +-
 lib/llvmopencl/LoopBarriers.cc                     |   18 +-
 lib/llvmopencl/LoopBarriers.h                      |    5 +
 lib/llvmopencl/Makefile.am                         |    6 +-
 lib/llvmopencl/Makefile.in                         |   39 +-
 lib/llvmopencl/PHIsToAllocas.cc                    |   17 +-
 lib/llvmopencl/ParallelRegion.cc                   |   44 +-
 lib/llvmopencl/ParallelRegion.h                    |    4 +-
 lib/llvmopencl/TargetAddressSpaces.cc              |  110 +-
 lib/llvmopencl/VariableUniformityAnalysis.cc       |   20 +-
 lib/llvmopencl/WorkItemAliasAnalysis.cc            |   43 +-
 lib/llvmopencl/Workgroup.cc                        |   87 +-
 lib/llvmopencl/WorkitemHandler.cc                  |   50 +-
 lib/llvmopencl/WorkitemHandler.h                   |   11 +-
 lib/llvmopencl/WorkitemHandlerChooser.cc           |    4 +-
 lib/llvmopencl/WorkitemLoops.cc                    |   62 +-
 lib/llvmopencl/WorkitemLoops.h                     |    6 +
 lib/llvmopencl/WorkitemReplication.cc              |   61 +-
 lib/llvmopencl/WorkitemReplication.h               |   13 +-
 lib/llvmopencl/linker.cpp                          |   12 +-
 lib/poclu/CMakeLists.txt                           |    3 +-
 lib/poclu/Makefile.in                              |   27 +-
 lib/poclu/bswap.c                                  |    2 +-
 lib/poclu/misc.c                                   |   18 +
 m4/libtool.m4                                      | 2546 +++---
 m4/ltoptions.m4                                    |  127 +-
 m4/ltsugar.m4                                      |    7 +-
 m4/ltversion.m4                                    |   12 +-
 m4/lt~obsolete.m4                                  |    7 +-
 scripts/CMakeLists.txt                             |    6 +-
 scripts/Makefile.in                                |   26 +-
 scripts/pocl-standalone.in                         |    3 +-
 scripts/pocl-standalone.in.cmake                   |    2 +-
 tests/Makefile.am                                  |    9 +-
 tests/Makefile.in                                  |   35 +-
 tests/atlocal.in                                   |    3 +
 tests/cell/Makefile.in                             |   26 +-
 tests/cell/hello/Makefile.am                       |    2 +-
 tests/cell/hello/Makefile.in                       |   29 +-
 tests/cell/hello/host.cpp                          |    8 +-
 tests/kernel/CMakeLists.txt                        |   18 +-
 tests/kernel/Makefile.am                           |    2 +-
 tests/kernel/Makefile.in                           |   29 +-
 tests/kernel/image_query_funcs.c                   |   51 +-
 tests/kernel/sampler_address_clamp.c               |   10 +-
 tests/kernel/test_frexp_modf.cl                    |   10 +
 tests/kernel/test_image_query_funcs.cl             |   33 +-
 tests/kernel/test_length_distance.cl               |   68 +
 tests/kernel/test_local_struct_array.cl            |   17 +
 tests/kernel/test_shuffle.cc                       |    4 +-
 tests/package.m4                                   |    4 +-
 tests/regression/CMakeLists.txt                    |    2 +-
 tests/regression/Makefile.am                       |    8 +-
 tests/regression/Makefile.in                       |   53 +-
 tests/regression/test_barrier_before_return.cpp    |   21 +-
 .../regression/test_barrier_between_for_loops.cpp  |   22 +-
 tests/regression/test_constant_array.cpp           |    8 +-
 tests/regression/test_early_return.cpp             |   23 +-
 .../test_for_with_var_iteration_count.cpp          |   23 +-
 .../test_fors_with_var_iteration_counts.cpp        |   10 +-
 tests/regression/test_id_dependent_computation.cpp |   25 +-
 tests/regression/test_infinite_loop.cpp            |    8 +-
 tests/regression/test_issue_231.cpp                |   94 +
 tests/regression/test_locals.cpp                   |   10 +-
 tests/regression/test_loop_phi_replication.cpp     |   23 +-
 .../test_multi_level_loops_with_barriers.cpp       |   23 +-
 tests/regression/test_null_arg.cpp                 |   23 +-
 tests/regression/test_setargs.cpp                  |    8 +-
 .../regression/test_simple_for_with_a_barrier.cpp  |   10 +-
 tests/regression/test_structs_as_args.cpp          |    8 +-
 tests/regression/test_undominated_variable.cpp     |   23 +-
 tests/regression/test_vectors_as_args.cpp          |    8 +-
 tests/runtime/CMakeLists.txt                       |   22 +-
 tests/runtime/Makefile.am                          |    4 +
 tests/runtime/Makefile.in                          |  102 +-
 tests/runtime/test_clBuildProgram.c                |  103 +-
 tests/runtime/test_clCreateKernel.c                |    3 +-
 tests/runtime/test_clCreateKernelsInProgram.c      |   20 +-
 tests/runtime/test_clCreateProgramWithBinary.c     |   14 +-
 tests/runtime/test_clCreateSubDevices.c            |  381 +
 tests/runtime/test_clEnqueueNativeKernel.c         |    6 +-
 tests/runtime/test_clGetEventInfo.c                |   89 +-
 tests/runtime/test_event_cycle.c                   |  147 +
 tests/runtime/test_event_free.c                    |  216 +
 tests/runtime/test_kernel_cache_includes.c         |   80 +
 tests/runtime/test_kernel_cache_includes.cl        |    7 +
 .../runtime/test_kernel_cache_includes_expout.txt  |    4 +
 .../{test_clBuildProgram.c => test_link_error.c}   |   45 +-
 tests/runtime/test_read-copy-write-buffer.c        |  121 +
 tests/tce/Makefile.in                              |   26 +-
 tests/tce/fp16/Makefile.am                         |    2 +-
 tests/tce/fp16/Makefile.in                         |   29 +-
 tests/tce/fp16/host.cpp                            |    8 +-
 tests/tce/tcemc/Makefile.am                        |    2 +-
 tests/tce/tcemc/Makefile.in                        |   29 +-
 tests/tce/tcemc/host.cpp                           |    8 +-
 tests/tce/ttasim/Makefile.am                       |    2 +-
 tests/tce/ttasim/Makefile.in                       |   29 +-
 tests/tce/ttasim/host.cpp                          |    8 +-
 tests/testsuite                                    | 8575 ++++++++++++-------
 tests/testsuite-amd.at                             |    8 -
 tests/testsuite-amdsdk2_9.at                       |   47 +-
 tests/testsuite-opencv.at                          |  327 +
 tests/testsuite-piglit.at                          |   14 +-
 tests/testsuite-regression.at                      |   23 +
 tests/testsuite-runtime.at                         |   35 +
 tests/testsuite-tce.at                             |    2 +-
 tests/testsuite-viennacl.at                        |    2 -
 tests/testsuite.at                                 |   30 +-
 tests/workgroup/Makefile.in                        |   27 +-
 tests/workgroup/run_kernel.c                       |    2 +-
 tools/patches/clang-3.7-hsail-branch.patch         | 2139 +++++
 tools/patches/khronos-icd-loader.patch             |   86 +
 tools/patches/llvm-3.7-hsail-branch.patch          |   32 +
 tools/scripts/devel-envs.sh                        |   25 +
 include/Makefile.am => tools/scripts/run_hsa_tests |   28 +-
 452 files changed, 39200 insertions(+), 11691 deletions(-)

diff --git a/CHANGES b/CHANGES
index 89ca237..0d2e7f2 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,19 +1,42 @@
-0.12 unreleased
+0.12 October 2015
+===============
 
 Highlights
 ----------
-
-Kernel compiler
----------------
+- Support for HSA-compliant devices (kernel agents). The GPU of AMD Kaveri
+  now works through pocl with a bunch of test cases in the AMD SDK 2.9 example
+  suite.
+- New and improved kernel cache system that enables caching
+  kernels with #includes.
+- Support for LLVM/Clang 3.7.
+- Little endian MIPS32 now passes almost all pocl testsuite tests.
 
 OpenCL Runtime/Platform API support
 -----------------------------------
--Transferred buffer read/write/copy offset calculation to device driver side.
- - these driver api functions have changed; got offset as a new argument.
+- Transferred buffer read/write/copy offset calculation to device driver side.
+  - these driver api functions have changed; got offset as a new argument.
+- Maximum allocation is not limited to 1/4th of total memory size.
+- Maximum image dimensions grow to fit maximum allocation.
+- clGetDeviceInfo() reports better information about CPU vendor and cache.
+- experimental clCreateSubDevices() for pthread CPU device.
 
-0.11 unreleased
-===============
+OpenCL C Builtin Function Implementations
+-----------------------------------------
+- Implemented get_image_dim().
 
+Bugfixes
+--------
+- Avoid infinite loops when users recycle an event waiting list.
+- Correctly report the base address alignment.
+- Lots of others.
+
+Misc
+----
+- Tests now using new cl2.hpp, removing dependency on OpenGL headers
+
+
+0.11 March 2015
+===============
 
 Highlights
 ----------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 835f030..8fe68ce 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,7 +27,7 @@ cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
 
 project(pocl)
 set(MAJOR_VERSION 0)
-set(MINOR_VERSION 11)
+set(MINOR_VERSION 12)
 set(VERSION_SUFFIX "")
 set(VERSION_STRING ${MAJOR_VERSION}.${MINOR_VERSION}${VERSION_SUFFIX})
 set(POCL_VERSION ${VERSION_STRING})
@@ -40,14 +40,13 @@ if(UNIX)
   include(GNUInstallDirs)
 else()
   if (WIN32)
-    set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install)
     set(${CMAKE_INSTALL_LIBDIR} "lib")
     set(${CMAKE_INSTALL_DATADIR} "share")
     set(${CMAKE_INSTALL_INCLUDEDIR} "include")
     set(${CMAKE_INSTALL_BINDIR} "bin")
     message(STATUS "Setting installation destination on Windows to: ${CMAKE_INSTALL_PREFIX}")
   else()
-    message(FATAL_ERROR "not implemented yet")    
+    message(FATAL_ERROR "System not UNIX nor WIN32 - not implemented yet")
   endif()
 endif()
 
@@ -94,12 +93,17 @@ option(BUILD_SHARED_LIBS "ON=Build shared libs, OFF=static libs" ON)
 option(
   POCL_DEBUG_MESSAGES
   "Enable debug messages from pocl (useful for OpenCL developers), must be enabled at runtime, with env var POCL_DEBUG"
-  OFF)
+  ON)
 
 # required b/c SHARED libs defaults to ON while OBJECT defaults to OFF
 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
 
 ######################################################################################
+
+# AMD HSA
+option(ENABLE_HSA "Enable the HSA device driver for AMD GCN devices" OFF)
+
+######################################################################################
 # AC_CONFIG_TESTDIR([tests])
 enable_testing()
 
@@ -218,15 +222,24 @@ setup_cached_var(ENABLE_DOCS "Documentation building"
 
 ######################################################################################
 
-include(CheckCSourceCompiles)
-CHECK_C_SOURCE_COMPILES("
+if(UNIX)
+  include(CheckCSourceCompiles)
+  CHECK_C_SOURCE_COMPILES("
 #include <time.h>
 int main() {
   struct timespec pocl_debug_timespec;
   clock_gettime(CLOCK_REALTIME, &pocl_debug_timespec);
   return 0;
 }
-" HAVE_CLOCK_GETTIME)
+  " HAVE_CLOCK_GETTIME)
+else()
+  if(WIN32)
+    message(STATUS "Using GetSystemTime...() on Win32")
+    set(HAVE_CLOCK_GETTIME 1)
+  else()
+    set(HAVE_CLOCK_GETTIME 0)
+  endif()
+endif()
 
 ######################################################################################
 
@@ -267,7 +280,9 @@ if(UNIX)
   else()
     set(DEFAULT_HOST_LD_FLAGS "-shared -lm")
   endif()
-  # TODO win..
+  set(LIBMATH "-lm")
+elseif(WIN32)
+  set(LIBMATH)
 endif()
 
 ######################################################################################
@@ -305,8 +320,7 @@ if(STATIC_LLVM)
   set(POCL_LLVM_LIBS ${LLVM_LIBFILES})
 else()
   message(STATUS "Trying to link LLVM dynamically")
-  set(POCL_LLVM_LIBS "-lLLVM-${LLVM_VERSION}")
-  find_library(LLVM_SHARED_LIB_FILE "LLVM-${LLVM_VERSION}" HINTS "${LLVM_LIBDIR}")
+  find_library(LLVM_SHARED_LIB_FILE NAMES "LLVM-${LLVM_VERSION}" "LLVM" PATHS "${LLVM_LIBDIR}" NO_DEFAULT_PATH)
   if(LLVM_SHARED_LIB_FILE AND EXISTS "${LLVM_SHARED_LIB_FILE}")
     message(STATUS "..using ${LLVM_SHARED_LIB_FILE}")
     set(POCL_LLVM_LIBS "${LLVM_SHARED_LIB_FILE}")
@@ -317,6 +331,11 @@ else()
   endif()
 endif()
 
+if (MSVC)
+  string(REPLACE "-L${LLVM_LIBDIR}" "" LLVM_LDFLAGS "${LLVM_LDFLAGS}")
+  string(STRIP "${LLVM_LDFLAGS}" LLVM_LDFLAGS)
+endif()
+
 ######################################################################################
 
 option(CUSTOM_BUFFER_ALLOCATOR "Use a custom OpenCL optimized region-based memory allocator instead of allocating buffers with malloc directly" ON)
@@ -491,24 +510,10 @@ endif()
 # TODO Check cl.hpp usability. It is broken on a few platforms.
 
 if(DEFINED HAVE_OPENCL_HPP)
-  message(STATUS "OpenCL.hpp + OpenGL (cached): ${HAVE_OPENCL_HPP}")
+  message(STATUS "cl2.hpp (cached): ${HAVE_OPENCL_HPP}")
 else()
-  find_file(OPENCL_HPP cl.hpp PATH_SUFFIXES CL OpenCL)
-  find_package(OpenGL MODULE)
-  set(_OPENCL_HPP 0)
-  if(OPENGL_FOUND)
-    set(_OPENCL_HPP 1)
-    if(OPENCL_HPP)
-      message(STATUS "cl.hpp found, OpenGL too, enabling OPENCL_HPP")
-    else()
-      message(STATUS "cl.hpp not found, OpenGL found, tests will use pocl's own cl.hpp")
-    endif()
-  else()
-    message(WARNING "OpenGL NOT found")
-    message(WARNING "Please install an OpenGL implementation with gl.h or OpenGL.h. It is required by the C++ bindings")
-    message(WARNING "Disabling OPENCL_HPP, a few tests will be skipped")
-  endif()
-  set(HAVE_OPENCL_HPP ${_OPENCL_HPP} CACHE INTERNAL "Opencl.hpp found & usable")
+  message(STATUS "tests will use pocl's own cl2.hpp")
+  set(HAVE_OPENCL_HPP ${_OPENCL_HPP} CACHE INTERNAL "cl2.hpp found & usable")
 endif()
 
 ######################################################################################
@@ -527,11 +532,13 @@ if (MSVC)
   message(STATUS "libGLEW not found. A few tests will not work")
 else()
   pkg_check_modules(GLEW glew)
-  if(NOT GLEW_FOUND)
-    message(WARNING "libGLEW not found. A few tests will not work")
-  else()
-    set(HAVE_GLEW 1)
-  endif()
+endif()
+
+if(NOT GLEW_FOUND)
+  set(HAVE_GLEW 0)
+  message(WARNING "libGLEW not found. A few tests will not work")
+else()
+  set(HAVE_GLEW 1)
 endif()
 
 ######################################################################################
@@ -543,7 +550,9 @@ if(KERNEL_CACHE)
 else()
   set(POCL_BUILD_KERNEL_CACHE 0)
 endif()
+
 string(TIMESTAMP POCL_BUILD_TIMESTAMP "%d%m%Y%H%M%S")
+file(WRITE "${CMAKE_BINARY_DIR}/pocl_build_timestamp.h" "#define POCL_BUILD_TIMESTAMP \"${POCL_BUILD_TIMESTAMP}\"")
 
 ######################################################################################
 # DONE
@@ -748,6 +757,16 @@ endif()
 
 ##########################################################
 
+if(ENABLE_HSA)
+  set(OCL_DRIVERS "${OCL_DRIVERS} hsa")
+  set(OCL_TARGETS "${OCL_TARGETS} hsail64")
+  # this is for config.h
+  # TODO unify with autotools
+  set(BUILD_HSA 1)
+endif()
+
+##########################################################
+
 message(STATUS "Building the following device drivers: ${OCL_DRIVERS}")
 
 set(BUILDDIR "${CMAKE_BINARY_DIR}")
@@ -849,10 +868,11 @@ endif()
 # 3:0:2 == 0.9 (currently backwards compatible with 0.7, thus age = 2).
 # 4:0:3 == 0.10 (currently backwards compatible with 0.7, thus age = 3).
 # 5:0:4 == 0.11 (currently backwards compatible with 0.7, thus age = 4).
+# 6:0:5 == 0.12 (currently backwards compatible with 0.7, thus age = 5).
 
-set(LIB_CURRENT_VERSION 5)
+set(LIB_CURRENT_VERSION 6)
 set(LIB_REVISION_VERSION 0)
-set(LIB_AGE_VERSION 4)
+set(LIB_AGE_VERSION 5)
 
 # LIB_FIRST_VERSION=$(($LIB_CURRENT_VERSION - $LIB_AGE_VERSION))
 math(EXPR LIB_FIRST_VERSION "${LIB_CURRENT_VERSION} - ${LIB_AGE_VERSION}")
@@ -874,6 +894,17 @@ set(KERNEL_COMPILER_LIB_VERSION "${LIB_CURRENT_VERSION}.0.0")
 
 ##########################################################
 
+function(rename_if_different SRC DST)
+  if(EXISTS "${DST}")
+    file(MD5 "${SRC}" OLD_MD5)
+    file(MD5 "${DST}" NEW_MD5)
+    if(NOT OLD_MD5 STREQUAL NEW_MD5)
+      file(RENAME "${SRC}" "${DST}")
+    endif()
+  else()
+    file(RENAME "${SRC}" "${DST}")
+  endif()
+endfunction()
 
 #TODO
 # these vars are copies b/c tons of sources use BUILD_ICD etc
@@ -885,21 +916,25 @@ set(_CL_DISABLE_LONG ${CL_DISABLE_LONG})
 set(_CL_DISABLE_HALF ${CL_DISABLE_HALF})
 set(PACKAGE_VERSION "${POCL_VERSION}")
 
-configure_file("config.h.in.cmake" "config.h" ESCAPE_QUOTES)
+configure_file("config.h.in.cmake" "config.h.new" ESCAPE_QUOTES)
+rename_if_different("${CMAKE_BINARY_DIR}/config.h.new" "${CMAKE_BINARY_DIR}/config.h")
 include_directories("${CMAKE_BINARY_DIR}")
 
 # autotools compat
-file(WRITE "${CMAKE_BINARY_DIR}/install-paths.h" "#define PKGDATADIR \"${POCL_INSTALL_PRIVATE_DATADIR}\"")
+file(WRITE "${CMAKE_BINARY_DIR}/install-paths.h.new" "#define PKGDATADIR \"${POCL_INSTALL_PRIVATE_DATADIR}\"")
+rename_if_different("${CMAKE_BINARY_DIR}/install-paths.h.new" "${CMAKE_BINARY_DIR}/install-paths.h")
 
 ##########################################################
 
-file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/pocl.icd" CONTENT "${POCL_INSTALL_PUBLIC_LIBDIR}/$<TARGET_FILE_NAME:pocl>" CONDITION 1)
-install(FILES "${CMAKE_BINARY_DIR}/pocl.icd"
+if(ENABLE_ICD)
+  file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/pocl.icd" CONTENT "${POCL_INSTALL_PUBLIC_LIBDIR}/$<TARGET_FILE_NAME:pocl>" CONDITION 1)
+  install(FILES "${CMAKE_BINARY_DIR}/pocl.icd"
          DESTINATION "${POCL_INSTALL_ICD_VENDORDIR}")
 
-# write icd file for pocl testing
-file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ocl-vendors")
-file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/ocl-vendors/pocl-tests.icd" CONTENT "$<TARGET_FILE:pocl>" CONDITION 1)
+  # write icd file for pocl testing
+  file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ocl-vendors")
+  file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/ocl-vendors/pocl-tests.icd" CONTENT "$<TARGET_FILE:pocl>" CONDITION 1)
+endif()
 
 file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/CTestCustom.cmake" CONTENT "
   set(ENV{POCL_BUILDING} \"1\")
@@ -918,7 +953,7 @@ endif()
 
 #############################################################
 
-include_directories("fix-includes" "include")
+include_directories("fix-include" "include")
 
 add_subdirectory("include")
 
@@ -929,7 +964,7 @@ message(STATUS "OPENCL_LIBS: ${OPENCL_LIBS}")
 message(STATUS "OPENCL_CFLAGS: ${OPENCL_CFLAGS}")
 
 # for tests / examples
-set(POCLU_LINK_OPTIONS "-lm" ${OPENCL_LIBS} "poclu")
+set(POCLU_LINK_OPTIONS ${LIBMATH} ${OPENCL_LIBS} "poclu")
 message(STATUS "POCLU LINK OPTS: ${POCLU_LINK_OPTIONS}")
 
 # DONE - just pocl-standalone script
@@ -955,7 +990,7 @@ endif()
 add_subdirectory("tests")
 
 # TODO In progress
-set(ALL_TESTSUITES "AMD;AMDSDK2.9;opencl-book-samples;Parboil;piglit;Rodinia;VexCL;ViennaCL")
+set(ALL_TESTSUITES "AMD;AMDSDK2.9;opencl-book-samples;Parboil;Piglit;Rodinia;VexCL;ViennaCL;Halide;OpenCV;CloverLeaf;hsa")
 add_subdirectory("examples")
 
 add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
@@ -991,6 +1026,7 @@ MESSAGE(STATUS "ENABLE_ICD: ${ENABLE_ICD}")
 MESSAGE(STATUS "ENABLE_SPU (Cell SPU enabled): ${ENABLE_SPU}")
 MESSAGE(STATUS "ENABLE_TCE: ${ENABLE_TCE}")
 MESSAGE(STATUS "ENABLE_TCEMC: ${ENABLE_TCEMC}")
+MESSAGE(STATUS "ENABLE_HSA: ${ENABLE_HSA}")
 MESSAGE(STATUS "HAVE_CLOCK_GETTIME: ${HAVE_CLOCK_GETTIME}")
 MESSAGE(STATUS "HAVE_GLEW: ${HAVE_GLEW}")
 MESSAGE(STATUS "HAVE_OPENCL_HPP: ${HAVE_OPENCL_HPP}")
@@ -1032,6 +1068,9 @@ MESSAGE(STATUS "HOST_AS_FLAGS: ${HOST_AS_FLAGS}")
 MESSAGE(STATUS "HOST_CLANG_FLAGS: ${HOST_CLANG_FLAGS}")
 MESSAGE(STATUS "HOST_LD_FLAGS: ${HOST_LD_FLAGS}")
 MESSAGE(STATUS "HOST_LLC_FLAGS: ${HOST_LLC_FLAGS}")
+MESSAGE(STATUS "HSA_INCLUDES: ${HSA_INCLUDES}")
+MESSAGE(STATUS "HSALIB: ${HSALIB}")
+MESSAGE(STATUS "HSAIL_ASM: ${HSAIL_ASM}")
 MESSAGE(STATUS "ICD_LD_FLAGS: ${ICD_LD_FLAGS}")
 MESSAGE(STATUS "KERNEL_CLANGXX_FLAGS: ${KERNEL_CLANGXX_FLAGS}")
 MESSAGE(STATUS "KERNEL_CL_FLAGS: ${KERNEL_CL_FLAGS}")
@@ -1039,6 +1078,7 @@ MESSAGE(STATUS "LD_FLAGS_BIN: ${LD_FLAGS_BIN}")
 MESSAGE(STATUS "LIB_API_VERSION: ${LIB_API_VERSION}")
 MESSAGE(STATUS "LIB_BUILD_VERSION: ${LIB_BUILD_VERSION}")
 MESSAGE(STATUS "LLVM_VERSION: ${LLVM_VERSION}")
+MESSAGE(STATUS "LLVM_ASSERTS_BUILD ${LLVM_ASSERTS_BUILD}")
 MESSAGE(STATUS "LLVM_CFLAGS: ${LLVM_CFLAGS}")
 MESSAGE(STATUS "LLVM_CXXFLAGS: ${LLVM_CXXFLAGS}")
 MESSAGE(STATUS "LLVM_CPPFLAGS: ${LLVM_CPPFLAGS}")
diff --git a/CREDITS b/CREDITS
index cf434ec..5d2e905 100644
--- a/CREDITS
+++ b/CREDITS
@@ -39,3 +39,8 @@ Volkan Keleş
 Lassi Koskinen
 Hugo van der Wijst <hugwijst at gmail.com>
 Mateusz Szpakowski <matszpk at interia.pl>
+Lars Buitinck (larsmans)
+Chen Chou-chuan <ccchen at pllab.cs.nthu.edu.tw>
+Shao-chung Wang <scwang at pllab.cs.nthu.edu.tw>
+Pavan Yalamanchili <pavan at arrayfire.com>
+Romaric Jodin <rjodin at kalray.eu>
diff --git a/Makefile.am b/Makefile.am
index 7ec585d..6d753e7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -61,16 +61,20 @@ endif
 EXTRA_DIST = config/xclang tools/data/test_machine.adf tools/data/test_machine_fp16.adf \
   doc/build-envs.txt CHANGES fix-include pocl.icd.in README README.ARM README.Cell \
   README.Windows README.mips README.OSX README.powerpc README.packaging CREDITS LICENSE \
-  tools/uncrustify_cxx.cfg windows/setup_and_build_win64.sh
+  tools/uncrustify_cxx.cfg windows/setup_and_build_win64.sh README.mipsel
 
 # CMake
 EXTRA_DIST += CMakeLists.txt cmake/FindHwloc.cmake cmake/FindPthreadsWin32.cmake \
   cmake/LLVM.cmake cmake/Sphinx.cmake cmake/bitcode_rules.cmake cmake/run_test.cmake \
 	android/androideabi.cmake config.h.in.cmake pocl.icd.in.cmake pocl.pc.in.cmake \
-	scripts/pocl-standalone.in.cmake
+	scripts/pocl-standalone.in.cmake cmake/kernellib_hash.cmake
 
 # Sphinx dist:
-EXTRA_DIST += doc/sphinx/source/conf.py doc/sphinx/source/design.rst doc/sphinx/source/development.rst doc/sphinx/source/env_variables.rst doc/sphinx/source/faq.rst doc/sphinx/source/features.rst doc/sphinx/source/host_library.rst doc/sphinx/source/index.rst doc/sphinx/source/kernel_compiler.rst doc/sphinx/source/memory_management.rst doc/sphinx/source/releasing.rst doc/sphinx/source/using.rst doc/sphinx/Makefile
+EXTRA_DIST += doc/sphinx/source/conf.py doc/sphinx/source/design.rst doc/sphinx/source/development.rst doc/sphinx/source/env_variables.rst doc/sphinx/source/faq.rst doc/sphinx/source/features.rst doc/sphinx/source/host_library.rst doc/sphinx/source/hsa.rst doc/sphinx/source/index.rst doc/sphinx/source/kernel_compiler.rst doc/sphinx/source/memory_management.rst doc/sphinx/source/releasing.rst doc/sphinx/source/using.rst doc/sphinx/Makefile
+
+# Tools, patches etc
+EXTRA_DIST += tools/patches/khronos-icd-loader.patch tools/patches/clang-3.7-hsail-branch.patch tools/patches/llvm-3.7-hsail-branch.patch tools/scripts/devel-envs.sh tools/scripts/run_hsa_tests
+
 
 BUILT_SOURCES = install-paths.h
 
diff --git a/Makefile.in b/Makefile.in
index 897c118..95c1fa3 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -111,17 +121,6 @@ target_triplet = @target@
 @BUILD_ICD_TRUE at am__append_4 = pocl.icd
 @BUILD_ICD_TRUE at am__append_5 = pocl.icd
 subdir = .
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/configure $(am__configure_deps) \
-	$(srcdir)/config.h.in $(srcdir)/pocl.pc.in \
-	$(top_srcdir)/ocl-vendors/pocl-tests.icd.in COPYING INSTALL \
-	README TODO config/ar-lib config/compile config/config.guess \
-	config/config.sub depcomp config/install-sh config/missing \
-	config/ltmain.sh $(top_srcdir)/config/ar-lib \
-	$(top_srcdir)/config/compile $(top_srcdir)/config/config.guess \
-	$(top_srcdir)/config/config.sub \
-	$(top_srcdir)/config/install-sh $(top_srcdir)/config/ltmain.sh \
-	$(top_srcdir)/config/missing
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -130,6 +129,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
+	$(am__configure_deps) $(am__DIST_COMMON)
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
  configure.lineno config.status.lineno
 mkinstalldirs = $(install_sh) -d
@@ -222,6 +223,16 @@ ETAGS = etags
 CTAGS = ctags
 CSCOPE = cscope
 DIST_SUBDIRS = include lib scripts examples tests
+am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \
+	$(srcdir)/pocl.pc.in $(top_srcdir)/config/ar-lib \
+	$(top_srcdir)/config/compile $(top_srcdir)/config/config.guess \
+	$(top_srcdir)/config/config.sub \
+	$(top_srcdir)/config/install-sh $(top_srcdir)/config/ltmain.sh \
+	$(top_srcdir)/config/missing \
+	$(top_srcdir)/ocl-vendors/pocl-tests.icd.in COPYING INSTALL \
+	README TODO config/ar-lib config/compile config/config.guess \
+	config/config.sub config/install-sh config/ltmain.sh \
+	config/missing depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
 top_distdir = $(distdir)
@@ -314,6 +325,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -350,6 +364,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -478,25 +493,32 @@ PHONIES = install-paths.h $(am__append_5)
 # CMake
 
 # Sphinx dist:
+
+# Tools, patches etc
 EXTRA_DIST = config/xclang tools/data/test_machine.adf \
 	tools/data/test_machine_fp16.adf doc/build-envs.txt CHANGES \
 	fix-include pocl.icd.in README README.ARM README.Cell \
 	README.Windows README.mips README.OSX README.powerpc \
 	README.packaging CREDITS LICENSE tools/uncrustify_cxx.cfg \
-	windows/setup_and_build_win64.sh CMakeLists.txt \
+	windows/setup_and_build_win64.sh README.mipsel CMakeLists.txt \
 	cmake/FindHwloc.cmake cmake/FindPthreadsWin32.cmake \
 	cmake/LLVM.cmake cmake/Sphinx.cmake cmake/bitcode_rules.cmake \
 	cmake/run_test.cmake android/androideabi.cmake \
 	config.h.in.cmake pocl.icd.in.cmake pocl.pc.in.cmake \
-	scripts/pocl-standalone.in.cmake doc/sphinx/source/conf.py \
-	doc/sphinx/source/design.rst doc/sphinx/source/development.rst \
+	scripts/pocl-standalone.in.cmake cmake/kernellib_hash.cmake \
+	doc/sphinx/source/conf.py doc/sphinx/source/design.rst \
+	doc/sphinx/source/development.rst \
 	doc/sphinx/source/env_variables.rst doc/sphinx/source/faq.rst \
 	doc/sphinx/source/features.rst \
-	doc/sphinx/source/host_library.rst doc/sphinx/source/index.rst \
+	doc/sphinx/source/host_library.rst doc/sphinx/source/hsa.rst \
+	doc/sphinx/source/index.rst \
 	doc/sphinx/source/kernel_compiler.rst \
 	doc/sphinx/source/memory_management.rst \
 	doc/sphinx/source/releasing.rst doc/sphinx/source/using.rst \
-	doc/sphinx/Makefile
+	doc/sphinx/Makefile tools/patches/khronos-icd-loader.patch \
+	tools/patches/clang-3.7-hsail-branch.patch \
+	tools/patches/llvm-3.7-hsail-branch.patch \
+	tools/scripts/devel-envs.sh tools/scripts/run_hsa_tests
 BUILT_SOURCES = install-paths.h
 all: $(BUILT_SOURCES) config.h
 	$(MAKE) $(AM_MAKEFLAGS) all-recursive
@@ -517,7 +539,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -794,15 +815,15 @@ dist-xz: distdir
 	$(am__post_remove_distdir)
 
 dist-tarZ: distdir
-	@echo WARNING: "Support for shar distribution archives is" \
-	               "deprecated." >&2
+	@echo WARNING: "Support for distribution archives compressed with" \
+		       "legacy program 'compress' is deprecated." >&2
 	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
 	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
 	$(am__post_remove_distdir)
 
 dist-shar: distdir
-	@echo WARNING: "Support for distribution archives compressed with" \
-		       "legacy program 'compress' is deprecated." >&2
+	@echo WARNING: "Support for shar distribution archives is" \
+	               "deprecated." >&2
 	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
 	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
 	$(am__post_remove_distdir)
@@ -838,17 +859,17 @@ distcheck: dist
 	esac
 	chmod -R a-w $(distdir)
 	chmod u+w $(distdir)
-	mkdir $(distdir)/_build $(distdir)/_inst
+	mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
 	chmod a-w $(distdir)
 	test -d $(distdir)/_build || exit 0; \
 	dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
 	  && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
 	  && am__cwd=`pwd` \
-	  && $(am__cd) $(distdir)/_build \
-	  && ../configure \
+	  && $(am__cd) $(distdir)/_build/sub \
+	  && ../../configure \
 	    $(AM_DISTCHECK_CONFIGURE_FLAGS) \
 	    $(DISTCHECK_CONFIGURE_FLAGS) \
-	    --srcdir=.. --prefix="$$dc_install_base" \
+	    --srcdir=../.. --prefix="$$dc_install_base" \
 	  && $(MAKE) $(AM_MAKEFLAGS) \
 	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
 	  && $(MAKE) $(AM_MAKEFLAGS) check \
@@ -1034,6 +1055,8 @@ uninstall-am: uninstall-icdDATA uninstall-pkgconfigDATA
 	tags tags-am uninstall uninstall-am uninstall-icdDATA \
 	uninstall-pkgconfigDATA
 
+.PRECIOUS: Makefile
+
 
 @BUILD_ICD_TRUE at pocl.icd:
 @BUILD_ICD_TRUE@	$(do_subst) < $(srcdir)/pocl.icd.in > $(builddir)/pocl.icd
diff --git a/README.mips b/README.mips
index 8588ecf..b75beee 100644
--- a/README.mips
+++ b/README.mips
@@ -12,18 +12,13 @@ to two bugs:
 * Vectors whose size is not a multiple of 4 bytes (such as char3) trigger an
   optimisation bug in SROA. This is still being debugged.
 
-Little-endian MIPS32r2 systems pass most tests but currently fails SPIR tests
-and shuffle tests. The shuffle tests fail because they define 16-byte aligned
-vectors on the stack which turn out to only be 8-byte aligned since stack
-frames are 8-byte aligned and LLVM 3.5 does not implement dynamic stack
-realignment for MIPS yet. An experimental patch to detect this situation and
-report an error at compile-time has revealed that many of the tests that do
-pass are affected by this issue and seem to pass by luck.
+It's expected that most of this has been fixed in LLVM 3.7 but this
+has not yet been re-tested.
 
 Testing
 -------
 
-Tested on an EdgeRouter Pro running 32-bit big-endian Debian Jessie with the following
-configure command:
+Tested on an EdgeRouter Pro running 32-bit big-endian Debian Jessie with the
+following configure command:
 
     ./configure --host=mips-unknown-linux-gnu --build mips-unknown-linux-gnu
diff --git a/README.mipsel b/README.mipsel
new file mode 100644
index 0000000..66a1c5a
--- /dev/null
+++ b/README.mipsel
@@ -0,0 +1,14 @@
+MIPS Little Endian
+==================
+
+With LLVM 3.7.0 plus a couple minor patches, almost all Little-endian MIPS32r2
+tests from pocl's set pass.
+
+Testing
+-------
+
+Tested on a Creator CI20 running 32-bit little-endian Debian Jessie with
+the following cmake command:
+
+    PATH=/path/to/clang-3.7.0-patched/bin/:$PATH CC=clang CXX=clang++ \
+        cmake -GNinja ../pocl.src/ -DLLC_HOST_CPU=mips32r2
diff --git a/TODO b/TODO
index 51d6b14..ce5f266 100644
--- a/TODO
+++ b/TODO
@@ -13,6 +13,36 @@ Medium priority:
     * device supporting AMD GPU cards.
     * Check all the function pointers in the ICD dispatch struct.
 
+Known ambiguous OpenCL 1.2 features
+-----------------------------------
+
+The OpenCL 1.2 and later standards are very ambiguous when it
+comes to sub-devices. On the one hand, they claim that sub-devices
+can be used wherever their parent devices can be used, on the
+other hand various parts of the standard hint that they should be
+treated independently.
+
+In particular, it's not clear whether sub-devices can be used
+within a context that only holds their parent device, or not. This
+might even depend on whether the context was created "from type"
+or not.
+
+The experimental implementation in pocl currently assumes that
+sub-devices are to be treated independently from their parent
+device. This means, for example, that sub-devices cannot be used
+in a context that does not contain them (but contains their parent
+device). Note that this is different from the AMD behavior (which
+is tested in the DeviceFission AMD APP SDK example), but follows
+e.g. Intel's behavior. Clarification from the standard body is
+needed on which behavior is correct.
+
+There is room for optimizations in the current implementation,
+particularly for what concerns the program build system, since
+sub-devices share the bitcode with their parent device and
+building could be done only once. Such an optimization will
+actually become necessary if the other behavior (sub-devices as
+slaves of their parent device) is ever implemented in the future.
+
 Known missing OpenCL 1.2 features
 ---------------------------------
 
@@ -85,4 +115,4 @@ Optimization opportunities
   on the unfinished ones (should be legal per OpenCL 1.2 5.11).
 
   
-  
\ No newline at end of file
+  
diff --git a/aclocal.m4 b/aclocal.m4
index 236efd3..b4b67cd 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,6 +1,6 @@
-# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
+# generated automatically by aclocal 1.15 -*- Autoconf -*-
 
-# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -235,7 +235,7 @@ AS_VAR_COPY([$1], [pkg_cv_][$1])
 AS_VAR_IF([$1], [""], [$5], [$4])dnl
 ])# PKG_CHECK_VAR
 
-# Copyright (C) 2002-2013 Free Software Foundation, Inc.
+# Copyright (C) 2002-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -247,10 +247,10 @@ AS_VAR_IF([$1], [""], [$5], [$4])dnl
 # generated from the m4 files accompanying Automake X.Y.
 # (This private macro should not be called outside this file.)
 AC_DEFUN([AM_AUTOMAKE_VERSION],
-[am__api_version='1.14'
+[am__api_version='1.15'
 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
 dnl require some minimum version.  Point them to the right macro.
-m4_if([$1], [1.14.1], [],
+m4_if([$1], [1.15], [],
       [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
 ])
 
@@ -266,12 +266,12 @@ m4_define([_AM_AUTOCONF_VERSION], [])
 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
 # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.14.1])dnl
+[AM_AUTOMAKE_VERSION([1.15])dnl
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 
-# Copyright (C) 2011-2013 Free Software Foundation, Inc.
+# Copyright (C) 2011-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -333,7 +333,7 @@ AC_SUBST([AR])dnl
 
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -385,7 +385,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd`
 
 # AM_CONDITIONAL                                            -*- Autoconf -*-
 
-# Copyright (C) 1997-2013 Free Software Foundation, Inc.
+# Copyright (C) 1997-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -416,7 +416,7 @@ AC_CONFIG_COMMANDS_PRE(
 Usually this means the macro was only invoked conditionally.]])
 fi])])
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -607,7 +607,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
 
 # Generate code to set up dependency tracking.              -*- Autoconf -*-
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -683,7 +683,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 
 # Do all the work for Automake.                             -*- Autoconf -*-
 
-# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -773,8 +773,8 @@ AC_REQUIRE([AC_PROG_MKDIR_P])dnl
 # <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
 # <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
 AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
-# We need awk for the "check" target.  The system "awk" is bad on
-# some platforms.
+# We need awk for the "check" target (and possibly the TAP driver).  The
+# system "awk" is bad on some platforms.
 AC_REQUIRE([AC_PROG_AWK])dnl
 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
 AC_REQUIRE([AM_SET_LEADING_DOT])dnl
@@ -848,6 +848,9 @@ END
     AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
   fi
 fi
+dnl The trailing newline in this macro's definition is deliberate, for
+dnl backward compatibility and to allow trailing 'dnl'-style comments
+dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841.
 ])
 
 dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
@@ -877,7 +880,7 @@ for _am_header in $config_headers :; do
 done
 echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -888,7 +891,7 @@ echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_co
 # Define $install_sh.
 AC_DEFUN([AM_PROG_INSTALL_SH],
 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-if test x"${install_sh}" != xset; then
+if test x"${install_sh+set}" != xset; then
   case $am_aux_dir in
   *\ * | *\	*)
     install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
@@ -898,7 +901,7 @@ if test x"${install_sh}" != xset; then
 fi
 AC_SUBST([install_sh])])
 
-# Copyright (C) 2003-2013 Free Software Foundation, Inc.
+# Copyright (C) 2003-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -919,7 +922,7 @@ AC_SUBST([am__leading_dot])])
 
 # Check to see how 'make' treats includes.	            -*- Autoconf -*-
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -969,7 +972,7 @@ rm -f confinc confmf
 
 # Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 
-# Copyright (C) 1997-2013 Free Software Foundation, Inc.
+# Copyright (C) 1997-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1008,7 +1011,7 @@ fi
 
 # Helper functions for option handling.                     -*- Autoconf -*-
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1037,7 +1040,7 @@ AC_DEFUN([_AM_SET_OPTIONS],
 AC_DEFUN([_AM_IF_OPTION],
 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1084,7 +1087,7 @@ AC_LANG_POP([C])])
 # For backward compatibility.
 AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1103,7 +1106,7 @@ AC_DEFUN([AM_RUN_LOG],
 
 # Check to make sure that the build environment is sane.    -*- Autoconf -*-
 
-# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1184,7 +1187,7 @@ AC_CONFIG_COMMANDS_PRE(
 rm -f conftest.file
 ])
 
-# Copyright (C) 2009-2013 Free Software Foundation, Inc.
+# Copyright (C) 2009-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1244,7 +1247,7 @@ AC_SUBST([AM_BACKSLASH])dnl
 _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
 ])
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1272,7 +1275,7 @@ fi
 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
 AC_SUBST([INSTALL_STRIP_PROGRAM])])
 
-# Copyright (C) 2006-2013 Free Software Foundation, Inc.
+# Copyright (C) 2006-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1291,7 +1294,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
 
 # Check how to create a tarball.                            -*- Autoconf -*-
 
-# Copyright (C) 2004-2013 Free Software Foundation, Inc.
+# Copyright (C) 2004-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
diff --git a/cmake/LLVM.cmake b/cmake/LLVM.cmake
index 440f882..2785f43 100644
--- a/cmake/LLVM.cmake
+++ b/cmake/LLVM.cmake
@@ -36,6 +36,7 @@ else()
   # search for any version
   find_program(LLVM_CONFIG
     NAMES "llvm-config"
+      "llvm-config-mp-3.7" "llvm-config-3.7" "llvm-config37"
       "llvm-config-mp-3.6" "llvm-config-3.6" "llvm-config36"
       "llvm-config-mp-3.5" "llvm-config-3.5" "llvm-config35"
       "llvm-config-mp-3.4" "llvm-config-3.4" "llvm-config34"
@@ -49,6 +50,7 @@ set(WITH_LLVM_CONFIG "${WITH_LLVM_CONFIG}" CACHE PATH "Path to preferred llvm-co
 if(NOT LLVM_CONFIG)
   message(FATAL_ERROR "llvm-config not found !")
 else()
+  file(TO_CMAKE_PATH "${LLVM_CONFIG}" LLVM_CONFIG)
   message(STATUS "Using llvm-config: ${LLVM_CONFIG}")
   if(LLVM_CONFIG MATCHES "llvm-config${CMAKE_EXECUTABLE_SUFFIX}$")
     set(LLVM_BINARY_SUFFIX "")
@@ -80,26 +82,50 @@ macro(run_llvm_config VARIABLE_NAME)
 endmacro(run_llvm_config)
 
 run_llvm_config(LLVM_PREFIX --prefix)
-set(LLVM_PREFIX_BIN "${LLVM_PREFIX}/bin")
+# on windows, llvm-config returs "C:\llvm_prefix/bin" mixed style paths,
+# and cmake doesn't like the "\" - thinks its an escape char..
+file(TO_CMAKE_PATH "${LLVM_PREFIX}" LLVM_PREFIX_CMAKE)
+
+set(LLVM_PREFIX_BIN "${LLVM_PREFIX_CMAKE}/bin")
 run_llvm_config(LLVM_VERSION_FULL --version)
 # sigh, sanitize version... `llvm --version` on debian might return 3.4.1 but llvm command names are still <command>-3.4
 string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\1.\\2" LLVM_VERSION "${LLVM_VERSION_FULL}")
 message(STATUS "LLVM_VERSION: ${LLVM_VERSION}")
 
 run_llvm_config(LLVM_CFLAGS --cflags)
+string(REPLACE "${LLVM_PREFIX}" "${LLVM_PREFIX_CMAKE}" LLVM_CFLAGS "${LLVM_CFLAGS}")
 run_llvm_config(LLVM_CXXFLAGS --cxxflags)
+string(REPLACE "${LLVM_PREFIX}" "${LLVM_PREFIX_CMAKE}" LLVM_CXXFLAGS "${LLVM_CXXFLAGS}")
 run_llvm_config(LLVM_CPPFLAGS --cppflags)
+string(REPLACE "${LLVM_PREFIX}" "${LLVM_PREFIX_CMAKE}" LLVM_CPPFLAGS "${LLVM_CPPFLAGS}")
 run_llvm_config(LLVM_LDFLAGS --ldflags)
+string(REPLACE "${LLVM_PREFIX}" "${LLVM_PREFIX_CMAKE}" LLVM_LDFLAGS "${LLVM_LDFLAGS}")
 run_llvm_config(LLVM_BINDIR --bindir)
+string(REPLACE "${LLVM_PREFIX}" "${LLVM_PREFIX_CMAKE}" LLVM_BINDIR "${LLVM_BINDIR}")
 run_llvm_config(LLVM_LIBDIR --libdir)
+string(REPLACE "${LLVM_PREFIX}" "${LLVM_PREFIX_CMAKE}" LLVM_LIBDIR "${LLVM_LIBDIR}")
 run_llvm_config(LLVM_INCLUDEDIR --includedir)
+string(REPLACE "${LLVM_PREFIX}" "${LLVM_PREFIX_CMAKE}" LLVM_INCLUDEDIR "${LLVM_INCLUDEDIR}")
 run_llvm_config(LLVM_LIBS --libs)
 # Convert LLVM_LIBS from string -> list format to make handling them easier
 separate_arguments(LLVM_LIBS)
+# workaround for a bug in current HSAIL LLVM
+# it forgets to report one HSAIL library in llvm-config
+if(ENABLE_HSA)
+  list(APPEND LLVM_LIBS "-lLLVMHSAILUtil")
+endif()
 run_llvm_config(LLVM_SRC_ROOT --src-root)
 run_llvm_config(LLVM_OBJ_ROOT --obj-root)
+string(REPLACE "${LLVM_PREFIX}" "${LLVM_PREFIX_CMAKE}" LLVM_OBJ_ROOT "${LLVM_OBJ_ROOT}")
 run_llvm_config(LLVM_ALL_TARGETS --targets-built)
 run_llvm_config(LLVM_HOST_TARGET --host-target)
+# TODO can be changed to --assertion-mode once we drop LLVM < 3.5 support
+run_llvm_config(LLVM_BUILD_MODE --build-mode)
+if(LLVM_BUILD_MODE MATCHES "Asserts")
+  set(LLVM_ASSERTS_BUILD 1)
+else()
+  set(LLVM_ASSERTS_BUILD 0)
+endif()
 # Ubuntu's llvm reports "arm-unknown-linux-gnueabihf" triple, then if one tries
 # `clang --target=arm-unknown-linux-gnueabihf ...` it will produce armv6 code,
 # even if one's running armv7;
@@ -132,6 +158,8 @@ if(LLVM_VERSION MATCHES "3[.]([0-9]+)")
     set(LLVM_3_5 1)
   elseif(LLVM_MINOR STREQUAL "6")
     set(LLVM_3_6 1)
+  elseif(LLVM_MINOR STREQUAL "7")
+    set(LLVM_3_7 1)
   else()
     message(FATAL_ERROR "Unknown/unsupported minor llvm version: ${LLVM_MINOR}")
   endif()
@@ -148,9 +176,10 @@ if("${LLVM_CXXFLAGS}" MATCHES "-fno-rtti")
        See the INSTALL file for more information.")
 endif()
 
-# Ubuntu's LLVM 3.5 is broken
-message(STATUS "Testing for Ubuntu's broken LLVM 3.5+")
+# Ubuntu's LLVM 3.5 is broken (is really 3.4svn with
+# some patches, neither 3.4 nor 3.5 in the end..
 if((LLVM_MINOR GREATER 4) AND (CMAKE_SYSTEM_NAME MATCHES "Linux"))
+  message(STATUS "Testing for Ubuntu's broken LLVM 3.5+")
   if(NOT EXISTS "${LLVM_INCLUDEDIR}/llvm/IR/CFG.h")
     message(FATAL_ERROR "Your llvm installation is broken. This is known to be the case on Ubuntu and clones with llvm 3.5; official llvm 3.5 downloads should work though.")
   endif()
@@ -163,13 +192,15 @@ endif()
 string(REPLACE " -pedantic" "" LLVM_CXXFLAGS "${LLVM_CXXFLAGS}")
 
 # - '-fno-rtti' is a work-around for llvm bug 14200
-#LLVM_CXX_FLAGS="$LLVM_CXX_FLAGS -fno-rtti"
-if(NOT MSVC)
+# Which according to bug report has been fixed in llvm 3.7
+# sadly, that bugreport is mistaken, it's not fixed in 3.7
+if (NOT MSVC)
   set(LLVM_CXXFLAGS "${LLVM_CXXFLAGS} -fno-rtti")
 endif()
 
 if(NOT LLVM_VERSION VERSION_LESS "3.5")
   run_llvm_config(LLVM_SYSLIBS --system-libs)
+  string(STRIP "${LLVM_SYSLIBS}" LLVM_SYSLIBS)
 endif()
 
 # Llvm-config may be installed or it might be used from build directory, in which case
@@ -185,7 +216,7 @@ set(CLANG_LIBNAMES clangFrontendTool clangFrontend clangDriver clangSerializatio
 if(LLVM_MINOR GREATER 4)
   list(APPEND CLANG_LIBNAMES clangRewrite)
 endif()
-list(APPEND CLANG_LIBNAMES clangRewriteFrontend clangStaticAnalyzerFrontend clangStaticAnalyzerCheckers clangStaticAnalyzerCore clangARCMigrate clangAnalysis clangEdit clangAST clangLex clangBasic)
+list(APPEND CLANG_LIBNAMES clangRewriteFrontend clangStaticAnalyzerFrontend clangStaticAnalyzerCheckers clangStaticAnalyzerCore clangAnalysis clangEdit clangAST clangLex clangBasic)
 
 foreach(LIBNAME ${CLANG_LIBNAMES})
   find_library(C_LIBFILE_${LIBNAME} NAMES "${LIBNAME}" HINTS "${LLVM_LIBDIR}")
@@ -244,8 +275,8 @@ macro(custom_try_compile_any COMPILER SUFFIX SOURCE RES_VAR)
   execute_process(COMMAND "${COMPILER}" ${ARGN} "${RANDOM_FILENAME}" RESULT_VARIABLE ${RES_VAR} OUTPUT_VARIABLE OV ERROR_VARIABLE EV)
   if(${${RES_VAR}})
     message(STATUS " ########## The command: ")
-    message(STATUS "${COMPILER} ${ARGN} ${RANDOM_FILENAME}")
-    message(STATUS " ########## ARGN size: ${LSIZE}")
+    string(REPLACE ";" " " ARGN_STR "${ARGN}")
+    message(STATUS "${COMPILER} ${ARGN_STR} ${RANDOM_FILENAME}")
     message(STATUS " ########## Exited with nonzero status: ${${RES_VAR}}")
     if(OV)
       message(STATUS "STDOUT: ${OV}")
@@ -482,11 +513,11 @@ endif()
 
 if(NOT LLVM_CXXFLAGS MATCHES "-DNDEBUG")
 
-  message(STATUS "Checking if LLVM is built with assertions")
+  message(STATUS "Checking if LLVM is a DEBUG build")
   separate_arguments(_FLAGS UNIX_COMMAND "${LLVM_CXXFLAGS}")
 
-  SET (_TEST_SOURCE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/llvmbuiltwithassertions.cc")
-  FILE (WRITE "${_TEST_SOURCE}"
+  set(_TEST_SOURCE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/llvmNDEBUG.cc")
+  file(WRITE "${_TEST_SOURCE}"
     "
       #include <llvm/Support/Debug.h>
       int main(int argc, char** argv) {
@@ -496,7 +527,7 @@ if(NOT LLVM_CXXFLAGS MATCHES "-DNDEBUG")
 
   set(TRY_COMPILE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LLVM_CXXFLAGS} -UNDEBUG")
 
-  TRY_COMPILE(_TRY_SUCCESS ${CMAKE_BINARY_DIR} "${_TEST_SOURCE}"
+  try_compile(_TRY_SUCCESS ${CMAKE_BINARY_DIR} "${_TEST_SOURCE}"
     CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${LLVM_INCLUDE_DIRS}"
     CMAKE_FLAGS "-DLINK_DIRECTORIES:STRING=${LLVM_LIBDIR}"
     LINK_LIBRARIES "${LLVM_LIBS} ${LLVM_SYSLIBS} ${LLVM_LDFLAGS}"
@@ -504,13 +535,13 @@ if(NOT LLVM_CXXFLAGS MATCHES "-DNDEBUG")
     OUTPUT_VARIABLE _TRY_COMPILE_OUTPUT
   )
 
-  FILE(APPEND "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log"
+  file(APPEND "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log"
     "Test -NDEBUG flag: ${_TRY_COMPILE_OUTPUT}\n")
 
   if(_TRY_SUCCESS)
-    message(STATUS "assertions present")
+    message(STATUS "DEBUG build")
   else()
-    message(STATUS "no assertions.. adding -DNDEBUG")
+    message(STATUS "Not a DEBUG build, adding -DNDEBUG explicitly")
     set(LLVM_CXXFLAGS "${LLVM_CXXFLAGS} -DNDEBUG")
   endif()
 
@@ -538,8 +569,8 @@ setup_cache_var_name(LLC_TRIPLE "LLC_TRIPLE-${LLVM_HOST_TARGET}-${CLANG}")
 
 if(NOT DEFINED ${CACHE_VAR_NAME})
   message(STATUS "Find out LLC target triple (for host ${LLVM_HOST_TARGET})")
-  SET (_EMPTY_C_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/tripletfind.c")
-  FILE (WRITE "${_EMPTY_C_FILE}" "")
+  set(_EMPTY_C_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/tripletfind.c")
+  file(WRITE "${_EMPTY_C_FILE}" "")
 
   execute_process(COMMAND ${CLANG} "${CLANG_TARGET_OPTION}${LLVM_HOST_TARGET}" -x c ${_EMPTY_C_FILE} -S -emit-llvm -o - RESULT_VARIABLE RES_VAR OUTPUT_VARIABLE OUTPUT_VAR)
   if(RES_VAR)
@@ -558,11 +589,7 @@ endif()
 
 set_cache_var(LLC_TRIPLE "LLC_TRIPLE")
 
-
-
-setup_cache_var_name(LLC_HOST_CPU "LLC_HOST_CPU-${LLVM_HOST_TARGET}-${LLC}")
-
-if(NOT DEFINED ${CACHE_VAR_NAME} AND NOT CMAKE_CROSSCOMPILING)
+if(NOT DEFINED LLC_HOST_CPU AND NOT CMAKE_CROSSCOMPILING)
   message(STATUS "Find out LLC host CPU with ${LLC}")
   execute_process(COMMAND ${LLC} "--version" RESULT_VARIABLE RES_VAR OUTPUT_VARIABLE OUTPUT_VAR)
   # WTF, ^^ has return value 1
@@ -581,10 +608,9 @@ if(NOT DEFINED ${CACHE_VAR_NAME} AND NOT CMAKE_CROSSCOMPILING)
   if(CMAKE_LIBRARY_ARCHITECTURE MATCHES "gnueabihf" AND LLC_HOST_CPU MATCHES "arm1176jz-s")
     set(LLC_HOST_CPU "arm1176jzf-s")
   endif()
-
 endif()
 
-set_cache_var(LLC_HOST_CPU "LLC_HOST_CPU")
+set(LLC_HOST_CPU "${LLC_HOST_CPU}" CACHE STRING "The Host CPU to use with llc")
 
 ####################################################################
 #X86 has -march and -mcpu reversed, for clang
@@ -635,9 +661,7 @@ set_cache_var(CL_DISABLE_LONG "Disable cl_khr_int64 because of buggy llvm")
 
 ####################################################################
 
-setup_cache_var_name(CL_DISABLE_HALF "CL_DISABLE_HALF-${LLVM_HOST_TARGET}-${CLANG}")
-
-if(NOT DEFINED ${CACHE_VAR_NAME})
+if(NOT DEFINED ${CL_DISABLE_HALF})
   set(CL_DISABLE_HALF 0)
   # TODO -march=CPU flags !
   custom_try_compile_c_cxx("${CLANG}" "c" "__fp16 callfp16(__fp16 a) { return a * (__fp16)1.8; };" "__fp16 x=callfp16((__fp16)argc);" RESV -c ${CLANG_TARGET_OPTION}${LLC_TRIPLE} ${CLANG_MARCH_FLAG}${LLC_HOST_CPU})
@@ -646,4 +670,59 @@ if(NOT DEFINED ${CACHE_VAR_NAME})
   endif()
 endif()
 
-set_cache_var(CL_DISABLE_HALF "Disable cl_khr_fp16 because fp16 is not supported")
+set(CL_DISABLE_HALF "${CL_DISABLE_HALF}" CACHE BOOL "Disable cl_khr_fp16 because fp16 is not supported")
+
+####################################################################
+
+if(ENABLE_HSA)
+
+  message(STATUS "Trying HSA support in LLVM")
+  # test that Clang supports the amdgcn--amdhsa target
+  custom_try_compile_clangxx("" "return 0;" RESULT "-target" "amdgcn--amdhsa" "-emit-llvm" "-S")
+  if(RESULT)
+    message(FATAL_ERROR "LLVM support for amdgcn--amdhsa target is required")
+  endif()
+
+  # find the headers & the library
+  if(DEFINED WITH_HSA_RUNTIME_DIR AND WITH_HSA_RUNTIME_DIR)
+    set(HSA_RUNTIME_DIR "${WITH_HSA_RUNTIME_DIR}")
+  else()
+    message(STATUS "WITH_HSA_RUNTIME_DIR not given, trying default path")
+    set(HSA_RUNTIME_DIR "/opt/hsa")
+  endif()
+
+  if((IS_ABSOLUTE "${WITH_HSA_RUNTIME_DIR}") AND (EXISTS "${WITH_HSA_RUNTIME_DIR}"))
+    set(HSA_INCLUDEDIR "${HSA_RUNTIME_DIR}/include")
+    set(HSA_LIBDIR "${HSA_RUNTIME_DIR}/lib")
+  else()
+    message(WARNING "${HSA_RUNTIME_DIR} is not a directory (using default system paths for search)")
+    set(HSA_INCLUDEDIR "")
+    set(HSA_LIBDIR "")
+  endif()
+
+  find_path(HSA_INCLUDES "hsa.h" PATHS "${HSA_INCLUDEDIR}")
+  if(NOT HSA_INCLUDES)
+    message(FATAL_ERROR "hsa.h header not found (use -DHSA_RUNTIME_DIR=... to specify path to HSA runtime)")
+  endif()
+
+  find_library(HSALIB NAMES "hsa-runtime64" "hsa-runtime" PATHS "${HSA_LIBDIR}")
+  if(NOT HSALIB)
+    message(FATAL_ERROR "libhsa-runtime not found (use -DHSA_RUNTIME_DIR=... to specify path to HSA runtime)")
+  endif()
+
+  if(DEFINED WITH_HSAILASM_PATH)
+    set(HSAILASM_SEARCH_PATH "${WITH_HSAILASM_PATH}")
+  else()
+    set(HSAILASM_SEARCH_PATH "${HSA_RUNTIME_DIR}/bin")
+  endif()
+
+  find_program(HSAIL_ASM "HSAILasm${CMAKE_EXECUTABLE_SUFFIX}" PATHS "${HSAILASM_SEARCH_PATH}")
+  if(NOT HSAIL_ASM)
+    message(FATAL_ERROR "HSAILasm executable not found (use -DWITH_HSAILASM_PATH=... to specify)")
+  endif()
+
+
+  message(STATUS "OK, building HSA")
+endif()
+
+#####################################################################
diff --git a/cmake/bitcode_rules.cmake b/cmake/bitcode_rules.cmake
index 28ffbeb..1d3c64f 100644
--- a/cmake/bitcode_rules.cmake
+++ b/cmake/bitcode_rules.cmake
@@ -31,8 +31,8 @@ separate_arguments(KERNEL_CLANGXX_FLAGS)
 #/usr/bin/clang --target=x86_64-pc-linux-gnu -march=bdver1 -Xclang -ffake-address-space-map -emit-llvm -ffp-contract=off -D__OPENCL_VERSION__=120 -DPOCL_VECMATHLIB_BUILTIN -D__CBUILD__ -o get_local_id.bc -c ${CMAKE_SOURCE_DIR}/lib/kernel/get_local_id.c -include ${CMAKE_SOURCE_DIR}/include/_kernel_c.h
 #	  @CLANG@ ${CLANG_FLAGS} ${KERNEL_CL_FLAGS} -D__CBUILD__ -c -o $@ -include ${abs_top_srcdir}/include/_kernel_c.h $< 
 function(compile_c_to_bc FILENAME BC_FILE_LIST)
-    set(BC_FILE "${FILENAME}.bc")
-    string(REPLACE "vecmathlib-pocl/" "" BC_FILE "${CMAKE_CURRENT_BINARY_DIR}/${BC_FILE}")
+    get_filename_component(FNAME "${FILENAME}" NAME)
+    set(BC_FILE "${CMAKE_CURRENT_BINARY_DIR}/${FNAME}.bc")
     set(${BC_FILE_LIST} ${${BC_FILE_LIST}} ${BC_FILE} PARENT_SCOPE)
     set(FULL_F_PATH "${CMAKE_SOURCE_DIR}/lib/kernel/${FILENAME}")
 
@@ -50,8 +50,8 @@ endfunction()
 # /usr/bin/clang++ --target=x86_64-pc-linux-gnu -march=bdver1 -Xclang -ffake-address-space-map -emit-llvm -ffp-contract=off -DVML_NO_IOSTREAM -DPOCL_VECMATHLIB_BUILTIN -o trunc.bc -c ${CMAKE_SOURCE_DIR}/lib/kernel/vecmathlib-pocl/trunc.cc -include ${CMAKE_SOURCE_DIR}/include/pocl_features.h
 # 	@CLANGXX@ ${CLANG_FLAGS} ${KERNEL_CLANGXX_FLAGS} -c -o $@ $< -include ${abs_top_srcdir}/include/pocl_features.h
 function(compile_cc_to_bc FILENAME BC_FILE_LIST)
-    set(BC_FILE "${FILENAME}.bc")
-    string(REPLACE "vecmathlib-pocl/" "" BC_FILE "${CMAKE_CURRENT_BINARY_DIR}/${BC_FILE}")
+    get_filename_component(FNAME "${FILENAME}" NAME)
+    set(BC_FILE "${CMAKE_CURRENT_BINARY_DIR}/${FNAME}.bc")
     set(${BC_FILE_LIST} ${${BC_FILE_LIST}} ${BC_FILE} PARENT_SCOPE)
     set(FULL_F_PATH "${CMAKE_SOURCE_DIR}/lib/kernel/${FILENAME}")
 
@@ -68,8 +68,8 @@ endfunction()
 
 # /usr/bin/clang --target=x86_64-pc-linux-gnu -march=bdver1 -Xclang -ffake-address-space-map -emit-llvm -ffp-contract=off -x cl -D__OPENCL_VERSION__=120 -DPOCL_VECMATHLIB_BUILTIN -fsigned-char -o atan2pi.bc -c ${CMAKE_SOURCE_DIR}/lib/kernel/vecmathlib-pocl/atan2pi.cl -include ${CMAKE_SOURCE_DIR}/include/_kernel.h
 function(compile_cl_to_bc FILENAME BC_FILE_LIST)
-    set(BC_FILE "${FILENAME}.bc")
-    string(REPLACE "vecmathlib-pocl/" "" BC_FILE "${CMAKE_CURRENT_BINARY_DIR}/${BC_FILE}")
+    get_filename_component(FNAME "${FILENAME}" NAME)
+    set(BC_FILE "${CMAKE_CURRENT_BINARY_DIR}/${FNAME}.bc")
     set(${BC_FILE_LIST} ${${BC_FILE_LIST}} ${BC_FILE} PARENT_SCOPE)
     set(FULL_F_PATH "${CMAKE_SOURCE_DIR}/lib/kernel/${FILENAME}")
 
@@ -89,8 +89,8 @@ endfunction()
 
 
 function(compile_ll_to_bc FILENAME BC_FILE_LIST)
-    set(BC_FILE "${FILENAME}.bc")
-    string(REPLACE "vecmathlib-pocl/" "" BC_FILE "${CMAKE_CURRENT_BINARY_DIR}/${BC_FILE}")
+    get_filename_component(FNAME "${FILENAME}" NAME)
+    set(BC_FILE "${CMAKE_CURRENT_BINARY_DIR}/${FNAME}.bc")
     set(${BC_FILE_LIST} ${${BC_FILE_LIST}} ${BC_FILE} PARENT_SCOPE)
     set(FULL_F_PATH "${CMAKE_SOURCE_DIR}/lib/kernel/${FILENAME}")
 
@@ -122,7 +122,7 @@ endmacro()
 
 
 function(make_kernel_bc OUTPUT_VAR NAME)
-  set(KERNEL_BC "kernel-${NAME}.bc")
+  set(KERNEL_BC "${CMAKE_CURRENT_BINARY_DIR}/kernel-${NAME}.bc")
   set(${OUTPUT_VAR} "${KERNEL_BC}" PARENT_SCOPE)
 
   compile_to_bc(BC_LIST ${ARGN})
@@ -133,7 +133,7 @@ function(make_kernel_bc OUTPUT_VAR NAME)
     # straight parsing semicolon separated list with xargs -d didn't work on windows.. no such switch available
     SET(BC_LIST_FILE_TXT "${BC_LIST_FILE_TXT} \"${FILENAME}\"")
   endforeach()
-  SET (BC_LIST_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/kernel_linklist.txt")
+  SET (BC_LIST_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/kernel_${NAME}_linklist.txt")
   FILE (WRITE "${BC_LIST_FILE}" "${BC_LIST_FILE_TXT}")
 
   add_custom_command( OUTPUT "${KERNEL_BC}"
@@ -145,5 +145,17 @@ function(make_kernel_bc OUTPUT_VAR NAME)
         COMMENT "Linking Kernel bitcode ${KERNEL_BC}" 
         VERBATIM)
 
+  add_custom_command( OUTPUT "${CMAKE_BINARY_DIR}/kernellib_hash.h"
+    COMMAND "${CMAKE_COMMAND}" -DKERNELBC='${KERNEL_BC}'
+        -DINCLUDEDIR='${CMAKE_SOURCE_DIR}/include'
+        -DOUTPUT='${CMAKE_BINARY_DIR}/kernellib_hash.h'
+        -P "${CMAKE_SOURCE_DIR}/cmake/kernellib_hash.cmake"
+    DEPENDS "${KERNEL_BC}" "${CMAKE_SOURCE_DIR}/include/_kernel.h"
+        "${CMAKE_SOURCE_DIR}/include/_kernel_c.h"
+        "${CMAKE_SOURCE_DIR}/include/pocl_types.h"
+        "${CMAKE_SOURCE_DIR}/include/pocl_features.h"
+    COMMENT "Generating SHA1 of kernel lib..."
+    VERBATIM)
+
 endfunction()
 
diff --git a/cmake/kernellib_hash.cmake b/cmake/kernellib_hash.cmake
new file mode 100644
index 0000000..7959a86
--- /dev/null
+++ b/cmake/kernellib_hash.cmake
@@ -0,0 +1,7 @@
+file(SHA1 "${KERNELBC}" S1)
+file(SHA1 "${INCLUDEDIR}/_kernel.h" S2)
+file(SHA1 "${INCLUDEDIR}/_kernel_c.h" S3)
+file(SHA1 "${INCLUDEDIR}/pocl_types.h" S4)
+file(SHA1 "${INCLUDEDIR}/pocl_features.h" S5)
+
+file(WRITE "${OUTPUT}" "#define POCL_KERNELLIB_SHA1 \"${S1}${S2}${S3}${S4}${S5}\"")
diff --git a/config.h.in b/config.h.in
index d01fe1c..5ef3011 100644
--- a/config.h.in
+++ b/config.h.in
@@ -12,6 +12,9 @@
 /* Absolute path of build directory. */
 #undef BUILDDIR
 
+/* Defined to 1 in case the HSA driver should be built. */
+#undef BUILD_HSA
+
 /* "Build with ICD" */
 #undef BUILD_ICD
 
@@ -54,9 +57,6 @@
 /* Defined if The OpenGL Extension Wrangler library is found */
 #undef HAVE_GLEW
 
-/* Define to 1 if you have the <GL/gl.h> header file. */
-#undef HAVE_GL_GL_H
-
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
@@ -69,9 +69,6 @@
 /* Defined if system cl.hpp found to be working */
 #undef HAVE_OPENCL_HPP
 
-/* Define to 1 if you have the <OpenGL/OpenGL.h> header file. */
-#undef HAVE_OPENGL_OPENGL_H
-
 /* Defined if posix_memalign is available. */
 #undef HAVE_POSIX_MEMALIGN
 
@@ -123,6 +120,9 @@
 /* Parameters to llc for code generation in the host. */
 #undef HOST_LLC_FLAGS
 
+/* Path to HSAILasm executable */
+#undef HSAIL_ASM
+
 /* Use the libkernel from lib/kernel/$KERNEL_DIR/ */
 #undef KERNEL_DIR
 
@@ -141,14 +141,19 @@
 /* "Using LLVM 3.5" */
 #undef LLVM_3_5
 
-/* "Using LLVM svn */
+/* "Using LLVM 3.6" */
 #undef LLVM_3_6
 
+/* "Using LLVM svn */
+#undef LLVM_3_7
+
+/* "LLVM was built with Assertions on." */
+#undef LLVM_BUILT_WITH_ASSERTS
+
 /* "LLVM version as a string." */
 #undef LLVM_VERSION
 
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
-   */
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
 #undef LT_OBJDIR
 
 /* Defined to greatest expected alignment for extended types, in bytes. */
diff --git a/config.h.in.cmake b/config.h.in.cmake
index 7999116..f5499d2 100644
--- a/config.h.in.cmake
+++ b/config.h.in.cmake
@@ -5,9 +5,12 @@
 /* The normal alignment of `float16', in bytes. */
 #define ALIGNOF_FLOAT16 @ALIGNOF_FLOAT16@
 
-
 #cmakedefine BUILD_SPU
 
+#cmakedefine BUILD_HSA
+
+#define POCL_BUILT_WITH_CMAKE
+
 #define BUILDDIR "@BUILDDIR@"
 
 /* "Build with ICD" */
@@ -20,6 +23,8 @@
 /* clang++ executable */
 #define CLANGXX "@CLANGXX@"
 
+#define HSAIL_ASM "@HSAIL_ASM@"
+
 /* clang++ compiler flags */
 /* TODO in sources */
 #define KERNEL_CLANGXX_FLAGS "@KERNEL_CLANGXX_FLAGS@"
@@ -87,6 +92,9 @@
 /* "Using LLVM 3.6" */
 #cmakedefine LLVM_3_6
 
+/* "Using LLVM 3.7" */
+#cmakedefine LLVM_3_7
+
 
 /* Defined to greatest expected alignment for extended types, in bytes. */
 #define MAX_EXTENDED_ALIGNMENT @MAX_EXTENDED_ALIGNMENT@
@@ -103,8 +111,6 @@
 
 #define POCL_BUILD_KERNEL_CACHE @POCL_BUILD_KERNEL_CACHE@
 
-#define POCL_BUILD_TIMESTAMP "@POCL_BUILD_TIMESTAMP@"
-
 #define POCL_DEVICE_ADDRESS_BITS @POCL_DEVICE_ADDRESS_BITS@
 
 #cmakedefine POCL_DEBUG_MESSAGES
diff --git a/config/ar-lib b/config/ar-lib
index fe2301e..463b9ec 100755
--- a/config/ar-lib
+++ b/config/ar-lib
@@ -4,7 +4,7 @@
 me=ar-lib
 scriptversion=2012-03-01.08; # UTC
 
-# Copyright (C) 2010-2013 Free Software Foundation, Inc.
+# Copyright (C) 2010-2014 Free Software Foundation, Inc.
 # Written by Peter Rosin <peda at lysator.liu.se>.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/config/compile b/config/compile
index 531136b..a85b723 100755
--- a/config/compile
+++ b/config/compile
@@ -3,7 +3,7 @@
 
 scriptversion=2012-10-14.11; # UTC
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 # Written by Tom Tromey <tromey at cygnus.com>.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/config/config.guess b/config/config.guess
index 1f5c50c..6c32c86 100755
--- a/config/config.guess
+++ b/config/config.guess
@@ -2,7 +2,7 @@
 # Attempt to guess a canonical system name.
 #   Copyright 1992-2014 Free Software Foundation, Inc.
 
-timestamp='2014-03-23'
+timestamp='2014-11-04'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -24,12 +24,12 @@ timestamp='2014-03-23'
 # program.  This Exception is an additional permission under section 7
 # of the GNU General Public License, version 3 ("GPLv3").
 #
-# Originally written by Per Bothner.
+# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
 #
 # You can get the latest version of this script from:
 # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
 #
-# Please send patches with a ChangeLog entry to config-patches at gnu.org.
+# Please send patches to <config-patches at gnu.org>.
 
 
 me=`echo "$0" | sed -e 's,.*/,,'`
@@ -579,8 +579,9 @@ EOF
 	else
 		IBM_ARCH=powerpc
 	fi
-	if [ -x /usr/bin/oslevel ] ; then
-		IBM_REV=`/usr/bin/oslevel`
+	if [ -x /usr/bin/lslpp ] ; then
+		IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
+			   awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
 	else
 		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
 	fi
diff --git a/config/config.sub b/config/config.sub
index bba4efb..7ffe373 100755
--- a/config/config.sub
+++ b/config/config.sub
@@ -2,7 +2,7 @@
 # Configuration validation subroutine script.
 #   Copyright 1992-2014 Free Software Foundation, Inc.
 
-timestamp='2014-09-11'
+timestamp='2014-12-03'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@ timestamp='2014-09-11'
 # of the GNU General Public License, version 3 ("GPLv3").
 
 
-# Please send patches with a ChangeLog entry to config-patches at gnu.org.
+# Please send patches to <config-patches at gnu.org>.
 #
 # Configuration subroutine to validate and canonicalize a configuration type.
 # Supply the specified configuration type as an argument.
@@ -313,6 +313,7 @@ case $basic_machine in
 	| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
 	| ubicom32 \
 	| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
+	| visium \
 	| we32k \
 	| x86 | xc16x | xstormy16 | xtensa \
 	| z8k | z80)
@@ -327,6 +328,9 @@ case $basic_machine in
 	c6x)
 		basic_machine=tic6x-unknown
 		;;
+	leon|leon[3-9])
+		basic_machine=sparc-$basic_machine
+		;;
 	m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
 		basic_machine=$basic_machine-unknown
 		os=-none
@@ -437,6 +441,7 @@ case $basic_machine in
 	| ubicom32-* \
 	| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
 	| vax-* \
+	| visium-* \
 	| we32k-* \
 	| x86-* | x86_64-* | xc16x-* | xps100-* \
 	| xstormy16-* | xtensa*-* \
@@ -774,6 +779,9 @@ case $basic_machine in
 		basic_machine=m68k-isi
 		os=-sysv
 		;;
+	leon-*|leon[3-9]-*)
+		basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'`
+		;;
 	m68knommu)
 		basic_machine=m68k-unknown
 		os=-linux
diff --git a/config/depcomp b/config/depcomp
index 4ebd5b3..fc98710 100755
--- a/config/depcomp
+++ b/config/depcomp
@@ -3,7 +3,7 @@
 
 scriptversion=2013-05-30.07; # UTC
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/config/install-sh b/config/install-sh
index 377bb86..0b0fdcb 100755
--- a/config/install-sh
+++ b/config/install-sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 # install - install a program, script, or datafile
 
-scriptversion=2011-11-20.07; # UTC
+scriptversion=2013-12-25.23; # UTC
 
 # This originates from X11R5 (mit/util/scripts/install.sh), which was
 # later released in X11R6 (xc/config/util/install.sh) with the
@@ -41,19 +41,15 @@ scriptversion=2011-11-20.07; # UTC
 # This script is compatible with the BSD install script, but was written
 # from scratch.
 
+tab='	'
 nl='
 '
-IFS=" ""	$nl"
+IFS=" $tab$nl"
 
-# set DOITPROG to echo to test this script
+# Set DOITPROG to "echo" to test this script.
 
-# Don't use :- since 4.3BSD and earlier shells don't like it.
 doit=${DOITPROG-}
-if test -z "$doit"; then
-  doit_exec=exec
-else
-  doit_exec=$doit
-fi
+doit_exec=${doit:-exec}
 
 # Put in absolute file names if you don't have them in your path;
 # or use environment vars.
@@ -68,17 +64,6 @@ mvprog=${MVPROG-mv}
 rmprog=${RMPROG-rm}
 stripprog=${STRIPPROG-strip}
 
-posix_glob='?'
-initialize_posix_glob='
-  test "$posix_glob" != "?" || {
-    if (set -f) 2>/dev/null; then
-      posix_glob=
-    else
-      posix_glob=:
-    fi
-  }
-'
-
 posix_mkdir=
 
 # Desired mode of installed file.
@@ -97,7 +82,7 @@ dir_arg=
 dst_arg=
 
 copy_on_change=false
-no_target_directory=
+is_target_a_directory=possibly
 
 usage="\
 Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
@@ -137,46 +122,57 @@ while test $# -ne 0; do
     -d) dir_arg=true;;
 
     -g) chgrpcmd="$chgrpprog $2"
-	shift;;
+        shift;;
 
     --help) echo "$usage"; exit $?;;
 
     -m) mode=$2
-	case $mode in
-	  *' '* | *'	'* | *'
-'*	  | *'*'* | *'?'* | *'['*)
-	    echo "$0: invalid mode: $mode" >&2
-	    exit 1;;
-	esac
-	shift;;
+        case $mode in
+          *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
+            echo "$0: invalid mode: $mode" >&2
+            exit 1;;
+        esac
+        shift;;
 
     -o) chowncmd="$chownprog $2"
-	shift;;
+        shift;;
 
     -s) stripcmd=$stripprog;;
 
-    -t) dst_arg=$2
-	# Protect names problematic for 'test' and other utilities.
-	case $dst_arg in
-	  -* | [=\(\)!]) dst_arg=./$dst_arg;;
-	esac
-	shift;;
+    -t)
+        is_target_a_directory=always
+        dst_arg=$2
+        # Protect names problematic for 'test' and other utilities.
+        case $dst_arg in
+          -* | [=\(\)!]) dst_arg=./$dst_arg;;
+        esac
+        shift;;
 
-    -T) no_target_directory=true;;
+    -T) is_target_a_directory=never;;
 
     --version) echo "$0 $scriptversion"; exit $?;;
 
-    --)	shift
-	break;;
+    --) shift
+        break;;
 
-    -*)	echo "$0: invalid option: $1" >&2
-	exit 1;;
+    -*) echo "$0: invalid option: $1" >&2
+        exit 1;;
 
     *)  break;;
   esac
   shift
 done
 
+# We allow the use of options -d and -T together, by making -d
+# take the precedence; this is for compatibility with GNU install.
+
+if test -n "$dir_arg"; then
+  if test -n "$dst_arg"; then
+    echo "$0: target directory not allowed when installing a directory." >&2
+    exit 1
+  fi
+fi
+
 if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
   # When -d is used, all remaining arguments are directories to create.
   # When -t is used, the destination is already specified.
@@ -208,6 +204,15 @@ if test $# -eq 0; then
 fi
 
 if test -z "$dir_arg"; then
+  if test $# -gt 1 || test "$is_target_a_directory" = always; then
+    if test ! -d "$dst_arg"; then
+      echo "$0: $dst_arg: Is not a directory." >&2
+      exit 1
+    fi
+  fi
+fi
+
+if test -z "$dir_arg"; then
   do_exit='(exit $ret); exit $ret'
   trap "ret=129; $do_exit" 1
   trap "ret=130; $do_exit" 2
@@ -223,16 +228,16 @@ if test -z "$dir_arg"; then
 
     *[0-7])
       if test -z "$stripcmd"; then
-	u_plus_rw=
+        u_plus_rw=
       else
-	u_plus_rw='% 200'
+        u_plus_rw='% 200'
       fi
       cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
     *)
       if test -z "$stripcmd"; then
-	u_plus_rw=
+        u_plus_rw=
       else
-	u_plus_rw=,u+rw
+        u_plus_rw=,u+rw
       fi
       cp_umask=$mode$u_plus_rw;;
   esac
@@ -269,41 +274,15 @@ do
     # If destination is a directory, append the input filename; won't work
     # if double slashes aren't ignored.
     if test -d "$dst"; then
-      if test -n "$no_target_directory"; then
-	echo "$0: $dst_arg: Is a directory" >&2
-	exit 1
+      if test "$is_target_a_directory" = never; then
+        echo "$0: $dst_arg: Is a directory" >&2
+        exit 1
       fi
       dstdir=$dst
       dst=$dstdir/`basename "$src"`
       dstdir_status=0
     else
-      # Prefer dirname, but fall back on a substitute if dirname fails.
-      dstdir=`
-	(dirname "$dst") 2>/dev/null ||
-	expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	     X"$dst" : 'X\(//\)[^/]' \| \
-	     X"$dst" : 'X\(//\)$' \| \
-	     X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
-	echo X"$dst" |
-	    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-		   s//\1/
-		   q
-		 }
-		 /^X\(\/\/\)[^/].*/{
-		   s//\1/
-		   q
-		 }
-		 /^X\(\/\/\)$/{
-		   s//\1/
-		   q
-		 }
-		 /^X\(\/\).*/{
-		   s//\1/
-		   q
-		 }
-		 s/.*/./; q'
-      `
-
+      dstdir=`dirname "$dst"`
       test -d "$dstdir"
       dstdir_status=$?
     fi
@@ -314,74 +293,74 @@ do
   if test $dstdir_status != 0; then
     case $posix_mkdir in
       '')
-	# Create intermediate dirs using mode 755 as modified by the umask.
-	# This is like FreeBSD 'install' as of 1997-10-28.
-	umask=`umask`
-	case $stripcmd.$umask in
-	  # Optimize common cases.
-	  *[2367][2367]) mkdir_umask=$umask;;
-	  .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
-
-	  *[0-7])
-	    mkdir_umask=`expr $umask + 22 \
-	      - $umask % 100 % 40 + $umask % 20 \
-	      - $umask % 10 % 4 + $umask % 2
-	    `;;
-	  *) mkdir_umask=$umask,go-w;;
-	esac
-
-	# With -d, create the new directory with the user-specified mode.
-	# Otherwise, rely on $mkdir_umask.
-	if test -n "$dir_arg"; then
-	  mkdir_mode=-m$mode
-	else
-	  mkdir_mode=
-	fi
-
-	posix_mkdir=false
-	case $umask in
-	  *[123567][0-7][0-7])
-	    # POSIX mkdir -p sets u+wx bits regardless of umask, which
-	    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
-	    ;;
-	  *)
-	    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
-	    trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
-
-	    if (umask $mkdir_umask &&
-		exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
-	    then
-	      if test -z "$dir_arg" || {
-		   # Check for POSIX incompatibilities with -m.
-		   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
-		   # other-writable bit of parent directory when it shouldn't.
-		   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
-		   ls_ld_tmpdir=`ls -ld "$tmpdir"`
-		   case $ls_ld_tmpdir in
-		     d????-?r-*) different_mode=700;;
-		     d????-?--*) different_mode=755;;
-		     *) false;;
-		   esac &&
-		   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
-		     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
-		     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
-		   }
-		 }
-	      then posix_mkdir=:
-	      fi
-	      rmdir "$tmpdir/d" "$tmpdir"
-	    else
-	      # Remove any dirs left behind by ancient mkdir implementations.
-	      rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
-	    fi
-	    trap '' 0;;
-	esac;;
+        # Create intermediate dirs using mode 755 as modified by the umask.
+        # This is like FreeBSD 'install' as of 1997-10-28.
+        umask=`umask`
+        case $stripcmd.$umask in
+          # Optimize common cases.
+          *[2367][2367]) mkdir_umask=$umask;;
+          .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+          *[0-7])
+            mkdir_umask=`expr $umask + 22 \
+              - $umask % 100 % 40 + $umask % 20 \
+              - $umask % 10 % 4 + $umask % 2
+            `;;
+          *) mkdir_umask=$umask,go-w;;
+        esac
+
+        # With -d, create the new directory with the user-specified mode.
+        # Otherwise, rely on $mkdir_umask.
+        if test -n "$dir_arg"; then
+          mkdir_mode=-m$mode
+        else
+          mkdir_mode=
+        fi
+
+        posix_mkdir=false
+        case $umask in
+          *[123567][0-7][0-7])
+            # POSIX mkdir -p sets u+wx bits regardless of umask, which
+            # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+            ;;
+          *)
+            tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+            trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+            if (umask $mkdir_umask &&
+                exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+            then
+              if test -z "$dir_arg" || {
+                   # Check for POSIX incompatibilities with -m.
+                   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+                   # other-writable bit of parent directory when it shouldn't.
+                   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+                   ls_ld_tmpdir=`ls -ld "$tmpdir"`
+                   case $ls_ld_tmpdir in
+                     d????-?r-*) different_mode=700;;
+                     d????-?--*) different_mode=755;;
+                     *) false;;
+                   esac &&
+                   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+                     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+                     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+                   }
+                 }
+              then posix_mkdir=:
+              fi
+              rmdir "$tmpdir/d" "$tmpdir"
+            else
+              # Remove any dirs left behind by ancient mkdir implementations.
+              rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+            fi
+            trap '' 0;;
+        esac;;
     esac
 
     if
       $posix_mkdir && (
-	umask $mkdir_umask &&
-	$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+        umask $mkdir_umask &&
+        $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
       )
     then :
     else
@@ -391,53 +370,51 @@ do
       # directory the slow way, step by step, checking for races as we go.
 
       case $dstdir in
-	/*) prefix='/';;
-	[-=\(\)!]*) prefix='./';;
-	*)  prefix='';;
+        /*) prefix='/';;
+        [-=\(\)!]*) prefix='./';;
+        *)  prefix='';;
       esac
 
-      eval "$initialize_posix_glob"
-
       oIFS=$IFS
       IFS=/
-      $posix_glob set -f
+      set -f
       set fnord $dstdir
       shift
-      $posix_glob set +f
+      set +f
       IFS=$oIFS
 
       prefixes=
 
       for d
       do
-	test X"$d" = X && continue
-
-	prefix=$prefix$d
-	if test -d "$prefix"; then
-	  prefixes=
-	else
-	  if $posix_mkdir; then
-	    (umask=$mkdir_umask &&
-	     $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
-	    # Don't fail if two instances are running concurrently.
-	    test -d "$prefix" || exit 1
-	  else
-	    case $prefix in
-	      *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
-	      *) qprefix=$prefix;;
-	    esac
-	    prefixes="$prefixes '$qprefix'"
-	  fi
-	fi
-	prefix=$prefix/
+        test X"$d" = X && continue
+
+        prefix=$prefix$d
+        if test -d "$prefix"; then
+          prefixes=
+        else
+          if $posix_mkdir; then
+            (umask=$mkdir_umask &&
+             $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+            # Don't fail if two instances are running concurrently.
+            test -d "$prefix" || exit 1
+          else
+            case $prefix in
+              *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+              *) qprefix=$prefix;;
+            esac
+            prefixes="$prefixes '$qprefix'"
+          fi
+        fi
+        prefix=$prefix/
       done
 
       if test -n "$prefixes"; then
-	# Don't fail if two instances are running concurrently.
-	(umask $mkdir_umask &&
-	 eval "\$doit_exec \$mkdirprog $prefixes") ||
-	  test -d "$dstdir" || exit 1
-	obsolete_mkdir_used=true
+        # Don't fail if two instances are running concurrently.
+        (umask $mkdir_umask &&
+         eval "\$doit_exec \$mkdirprog $prefixes") ||
+          test -d "$dstdir" || exit 1
+        obsolete_mkdir_used=true
       fi
     fi
   fi
@@ -472,15 +449,12 @@ do
 
     # If -C, don't bother to copy if it wouldn't change the file.
     if $copy_on_change &&
-       old=`LC_ALL=C ls -dlL "$dst"	2>/dev/null` &&
-       new=`LC_ALL=C ls -dlL "$dsttmp"	2>/dev/null` &&
-
-       eval "$initialize_posix_glob" &&
-       $posix_glob set -f &&
+       old=`LC_ALL=C ls -dlL "$dst"     2>/dev/null` &&
+       new=`LC_ALL=C ls -dlL "$dsttmp"  2>/dev/null` &&
+       set -f &&
        set X $old && old=:$2:$4:$5:$6 &&
        set X $new && new=:$2:$4:$5:$6 &&
-       $posix_glob set +f &&
-
+       set +f &&
        test "$old" = "$new" &&
        $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
     then
@@ -493,24 +467,24 @@ do
       # to itself, or perhaps because mv is so ancient that it does not
       # support -f.
       {
-	# Now remove or move aside any old file at destination location.
-	# We try this two ways since rm can't unlink itself on some
-	# systems and the destination file might be busy for other
-	# reasons.  In this case, the final cleanup might fail but the new
-	# file should still install successfully.
-	{
-	  test ! -f "$dst" ||
-	  $doit $rmcmd -f "$dst" 2>/dev/null ||
-	  { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
-	    { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
-	  } ||
-	  { echo "$0: cannot unlink or rename $dst" >&2
-	    (exit 1); exit 1
-	  }
-	} &&
-
-	# Now rename the file to the real destination.
-	$doit $mvcmd "$dsttmp" "$dst"
+        # Now remove or move aside any old file at destination location.
+        # We try this two ways since rm can't unlink itself on some
+        # systems and the destination file might be busy for other
+        # reasons.  In this case, the final cleanup might fail but the new
+        # file should still install successfully.
+        {
+          test ! -f "$dst" ||
+          $doit $rmcmd -f "$dst" 2>/dev/null ||
+          { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+            { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+          } ||
+          { echo "$0: cannot unlink or rename $dst" >&2
+            (exit 1); exit 1
+          }
+        } &&
+
+        # Now rename the file to the real destination.
+        $doit $mvcmd "$dsttmp" "$dst"
       }
     fi || exit 1
 
diff --git a/config/ltmain.sh b/config/ltmain.sh
index bffda54..0f0a2da 100644
--- a/config/ltmain.sh
+++ b/config/ltmain.sh
@@ -1,9 +1,12 @@
+#! /bin/sh
+## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
+##               by inline-source v2014-01-03.01
 
-# libtool (GNU libtool) 2.4.2
+# libtool (GNU libtool) 2.4.6
+# Provide generalized library-building support services.
 # Written by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
 
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
-# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+# Copyright (C) 1996-2015 Free Software Foundation, Inc.
 # This is free software; see the source for copying conditions.  There is NO
 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
@@ -23,881 +26,2112 @@
 # General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with GNU Libtool; see the file COPYING.  If not, a copy
-# can be downloaded from http://www.gnu.org/licenses/gpl.html,
-# or obtained by writing to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Usage: $progname [OPTION]... [MODE-ARG]...
-#
-# Provide generalized library-building support services.
-#
-#       --config             show all configuration variables
-#       --debug              enable verbose shell tracing
-#   -n, --dry-run            display commands without modifying any files
-#       --features           display basic configuration information and exit
-#       --mode=MODE          use operation mode MODE
-#       --preserve-dup-deps  don't remove duplicate dependency libraries
-#       --quiet, --silent    don't print informational messages
-#       --no-quiet, --no-silent
-#                            print informational messages (default)
-#       --no-warn            don't display warning messages
-#       --tag=TAG            use configuration variables from tag TAG
-#   -v, --verbose            print more informational messages than default
-#       --no-verbose         don't print the extra informational messages
-#       --version            print version information
-#   -h, --help, --help-all   print short, long, or detailed help message
-#
-# MODE must be one of the following:
-#
-#         clean              remove files from the build directory
-#         compile            compile a source file into a libtool object
-#         execute            automatically set library path, then run a program
-#         finish             complete the installation of libtool libraries
-#         install            install libraries or executables
-#         link               create a library or an executable
-#         uninstall          remove libraries from an installed directory
-#
-# MODE-ARGS vary depending on the MODE.  When passed as first option,
-# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
-# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
-#
-# When reporting a bug, please describe a test case to reproduce it and
-# include the following information:
-#
-#         host-triplet:	$host
-#         shell:		$SHELL
-#         compiler:		$LTCC
-#         compiler flags:		$LTCFLAGS
-#         linker:		$LD (gnu? $with_gnu_ld)
-#         $progname:	(GNU libtool) 2.4.2 Debian-2.4.2-1.11
-#         automake:	$automake_version
-#         autoconf:	$autoconf_version
-#
-# Report bugs to <bug-libtool at gnu.org>.
-# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
-# General help using GNU software: <http://www.gnu.org/gethelp/>.
 
 PROGRAM=libtool
 PACKAGE=libtool
-VERSION="2.4.2 Debian-2.4.2-1.11"
-TIMESTAMP=""
-package_revision=1.3337
+VERSION=2.4.6
+package_revision=2.4.6
 
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+
+## ------ ##
+## Usage. ##
+## ------ ##
+
+# Run './libtool --help' for help with using this script from the
+# command line.
+
+
+## ------------------------------- ##
+## User overridable command paths. ##
+## ------------------------------- ##
+
+# After configure completes, it has a better idea of some of the
+# shell tools we need than the defaults used by the functions shared
+# with bootstrap, so set those here where they can still be over-
+# ridden by the user, but otherwise take precedence.
+
+: ${AUTOCONF="autoconf"}
+: ${AUTOMAKE="automake"}
+
+
+## -------------------------- ##
+## Source external libraries. ##
+## -------------------------- ##
+
+# Much of our low-level functionality needs to be sourced from external
+# libraries, which are installed to $pkgauxdir.
+
+# Set a version string for this script.
+scriptversion=2015-01-20.17; # UTC
+
+# General shell script boiler plate, and helper functions.
+# Written by Gary V. Vaughan, 2004
+
+# Copyright (C) 2004-2015 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# As a special exception to the GNU General Public License, if you distribute
+# this file as part of a program or library that is built using GNU Libtool,
+# you may include this file under the same distribution terms that you use
+# for the rest of that program.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Please report bugs or propose patches to gary at gnu.org.
+
+
+## ------ ##
+## Usage. ##
+## ------ ##
+
+# Evaluate this file near the top of your script to gain access to
+# the functions and variables defined here:
+#
+#   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
+#
+# If you need to override any of the default environment variable
+# settings, do that before evaluating this file.
+
+
+## -------------------- ##
+## Shell normalisation. ##
+## -------------------- ##
+
+# Some shells need a little help to be as Bourne compatible as possible.
+# Before doing anything else, make sure all that help has been provided!
+
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
   emulate sh
   NULLCMD=:
-  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
   # is contrary to our usage.  Disable this feature.
   alias -g '${1+"$@"}'='"$@"'
   setopt NO_GLOB_SUBST
 else
-  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+  case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
 fi
-BIN_SH=xpg4; export BIN_SH # for Tru64
-DUALCASE=1; export DUALCASE # for MKS sh
-
-# A function that is used when there is no print builtin or printf.
-func_fallback_echo ()
-{
-  eval 'cat <<_LTECHO_EOF
-$1
-_LTECHO_EOF'
-}
 
-# NLS nuisances: We save the old values to restore during execute mode.
-lt_user_locale=
-lt_safe_locale=
-for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+# NLS nuisances: We save the old values in case they are required later.
+_G_user_locale=
+_G_safe_locale=
+for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
 do
-  eval "if test \"\${$lt_var+set}\" = set; then
-          save_$lt_var=\$$lt_var
-          $lt_var=C
-	  export $lt_var
-	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
-	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
+  eval "if test set = \"\${$_G_var+set}\"; then
+          save_$_G_var=\$$_G_var
+          $_G_var=C
+	  export $_G_var
+	  _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
+	  _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
 	fi"
 done
-LC_ALL=C
-LANGUAGE=C
-export LANGUAGE LC_ALL
 
-$lt_unset CDPATH
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
+# Make sure IFS has a sensible default
+sp=' '
+nl='
+'
+IFS="$sp	$nl"
+
+# There are apparently some retarded systems that use ';' as a PATH separator!
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
 
-# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
-# is ksh but when the shell is invoked as "sh" and the current value of
-# the _XPG environment variable is not equal to 1 (one), the special
-# positional parameter $0, within a function call, is the name of the
-# function.
-progpath="$0"
 
 
+## ------------------------- ##
+## Locate command utilities. ##
+## ------------------------- ##
+
+
+# func_executable_p FILE
+# ----------------------
+# Check that FILE is an executable regular file.
+func_executable_p ()
+{
+    test -f "$1" && test -x "$1"
+}
+
+
+# func_path_progs PROGS_LIST CHECK_FUNC [PATH]
+# --------------------------------------------
+# Search for either a program that responds to --version with output
+# containing "GNU", or else returned by CHECK_FUNC otherwise, by
+# trying all the directories in PATH with each of the elements of
+# PROGS_LIST.
+#
+# CHECK_FUNC should accept the path to a candidate program, and
+# set $func_check_prog_result if it truncates its output less than
+# $_G_path_prog_max characters.
+func_path_progs ()
+{
+    _G_progs_list=$1
+    _G_check_func=$2
+    _G_PATH=${3-"$PATH"}
+
+    _G_path_prog_max=0
+    _G_path_prog_found=false
+    _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
+    for _G_dir in $_G_PATH; do
+      IFS=$_G_save_IFS
+      test -z "$_G_dir" && _G_dir=.
+      for _G_prog_name in $_G_progs_list; do
+        for _exeext in '' .EXE; do
+          _G_path_prog=$_G_dir/$_G_prog_name$_exeext
+          func_executable_p "$_G_path_prog" || continue
+          case `"$_G_path_prog" --version 2>&1` in
+            *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
+            *)     $_G_check_func $_G_path_prog
+		   func_path_progs_result=$func_check_prog_result
+		   ;;
+          esac
+          $_G_path_prog_found && break 3
+        done
+      done
+    done
+    IFS=$_G_save_IFS
+    test -z "$func_path_progs_result" && {
+      echo "no acceptable sed could be found in \$PATH" >&2
+      exit 1
+    }
+}
+
+
+# We want to be able to use the functions in this file before configure
+# has figured out where the best binaries are kept, which means we have
+# to search for them ourselves - except when the results are already set
+# where we skip the searches.
+
+# Unless the user overrides by setting SED, search the path for either GNU
+# sed, or the sed that truncates its output the least.
+test -z "$SED" && {
+  _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
+  for _G_i in 1 2 3 4 5 6 7; do
+    _G_sed_script=$_G_sed_script$nl$_G_sed_script
+  done
+  echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
+  _G_sed_script=
+
+  func_check_prog_sed ()
+  {
+    _G_path_prog=$1
+
+    _G_count=0
+    printf 0123456789 >conftest.in
+    while :
+    do
+      cat conftest.in conftest.in >conftest.tmp
+      mv conftest.tmp conftest.in
+      cp conftest.in conftest.nl
+      echo '' >> conftest.nl
+      "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
+      diff conftest.out conftest.nl >/dev/null 2>&1 || break
+      _G_count=`expr $_G_count + 1`
+      if test "$_G_count" -gt "$_G_path_prog_max"; then
+        # Best one so far, save it but keep looking for a better one
+        func_check_prog_result=$_G_path_prog
+        _G_path_prog_max=$_G_count
+      fi
+      # 10*(2^10) chars as input seems more than enough
+      test 10 -lt "$_G_count" && break
+    done
+    rm -f conftest.in conftest.tmp conftest.nl conftest.out
+  }
+
+  func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
+  rm -f conftest.sed
+  SED=$func_path_progs_result
+}
+
+
+# Unless the user overrides by setting GREP, search the path for either GNU
+# grep, or the grep that truncates its output the least.
+test -z "$GREP" && {
+  func_check_prog_grep ()
+  {
+    _G_path_prog=$1
+
+    _G_count=0
+    _G_path_prog_max=0
+    printf 0123456789 >conftest.in
+    while :
+    do
+      cat conftest.in conftest.in >conftest.tmp
+      mv conftest.tmp conftest.in
+      cp conftest.in conftest.nl
+      echo 'GREP' >> conftest.nl
+      "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
+      diff conftest.out conftest.nl >/dev/null 2>&1 || break
+      _G_count=`expr $_G_count + 1`
+      if test "$_G_count" -gt "$_G_path_prog_max"; then
+        # Best one so far, save it but keep looking for a better one
+        func_check_prog_result=$_G_path_prog
+        _G_path_prog_max=$_G_count
+      fi
+      # 10*(2^10) chars as input seems more than enough
+      test 10 -lt "$_G_count" && break
+    done
+    rm -f conftest.in conftest.tmp conftest.nl conftest.out
+  }
+
+  func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
+  GREP=$func_path_progs_result
+}
+
+
+## ------------------------------- ##
+## User overridable command paths. ##
+## ------------------------------- ##
+
+# All uppercase variable names are used for environment variables.  These
+# variables can be overridden by the user before calling a script that
+# uses them if a suitable command of that name is not already available
+# in the command search PATH.
 
 : ${CP="cp -f"}
-test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
+: ${ECHO="printf %s\n"}
+: ${EGREP="$GREP -E"}
+: ${FGREP="$GREP -F"}
+: ${LN_S="ln -s"}
 : ${MAKE="make"}
 : ${MKDIR="mkdir"}
 : ${MV="mv -f"}
 : ${RM="rm -f"}
 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
-: ${Xsed="$SED -e 1s/^X//"}
-
-# Global variables:
-EXIT_SUCCESS=0
-EXIT_FAILURE=1
-EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
-EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
-
-exit_status=$EXIT_SUCCESS
-
-# Make sure IFS has a sensible default
-lt_nl='
-'
-IFS=" 	$lt_nl"
 
-dirname="s,/[^/]*$,,"
-basename="s,^.*/,,"
 
-# func_dirname file append nondir_replacement
-# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
-# otherwise set result to NONDIR_REPLACEMENT.
-func_dirname ()
-{
-    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
-    if test "X$func_dirname_result" = "X${1}"; then
-      func_dirname_result="${3}"
-    else
-      func_dirname_result="$func_dirname_result${2}"
-    fi
-} # func_dirname may be replaced by extended shell implementation
+## -------------------- ##
+## Useful sed snippets. ##
+## -------------------- ##
 
+sed_dirname='s|/[^/]*$||'
+sed_basename='s|^.*/||'
 
-# func_basename file
-func_basename ()
-{
-    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
-} # func_basename may be replaced by extended shell implementation
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
 
+# Same as above, but do not quote variable references.
+sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
 
-# func_dirname_and_basename file append nondir_replacement
-# perform func_basename and func_dirname in a single function
-# call:
-#   dirname:  Compute the dirname of FILE.  If nonempty,
-#             add APPEND to the result, otherwise set result
-#             to NONDIR_REPLACEMENT.
-#             value returned in "$func_dirname_result"
-#   basename: Compute filename of FILE.
-#             value retuned in "$func_basename_result"
-# Implementation must be kept synchronized with func_dirname
-# and func_basename. For efficiency, we do not delegate to
-# those functions but instead duplicate the functionality here.
-func_dirname_and_basename ()
-{
-    # Extract subdirectory from the argument.
-    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
-    if test "X$func_dirname_result" = "X${1}"; then
-      func_dirname_result="${3}"
-    else
-      func_dirname_result="$func_dirname_result${2}"
-    fi
-    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
-} # func_dirname_and_basename may be replaced by extended shell implementation
+# Sed substitution that turns a string into a regex matching for the
+# string literally.
+sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
 
+# Sed substitution that converts a w32 file name or path
+# that contains forward slashes, into one that contains
+# (escaped) backslashes.  A very naive implementation.
+sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
+
+# Re-'\' parameter expansions in output of sed_double_quote_subst that
+# were '\'-ed in input to the same.  If an odd number of '\' preceded a
+# '$' in input to sed_double_quote_subst, that '$' was protected from
+# expansion.  Since each input '\' is now two '\'s, look for any number
+# of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
+_G_bs='\\'
+_G_bs2='\\\\'
+_G_bs4='\\\\\\\\'
+_G_dollar='\$'
+sed_double_backslash="\
+  s/$_G_bs4/&\\
+/g
+  s/^$_G_bs2$_G_dollar/$_G_bs&/
+  s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
+  s/\n//g"
 
-# func_stripname prefix suffix name
-# strip PREFIX and SUFFIX off of NAME.
-# PREFIX and SUFFIX must not contain globbing or regex special
-# characters, hashes, percent signs, but SUFFIX may contain a leading
-# dot (in which case that matches only a dot).
-# func_strip_suffix prefix name
-func_stripname ()
-{
-    case ${2} in
-      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
-      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
-    esac
-} # func_stripname may be replaced by extended shell implementation
 
+## ----------------- ##
+## Global variables. ##
+## ----------------- ##
 
-# These SED scripts presuppose an absolute path with a trailing slash.
-pathcar='s,^/\([^/]*\).*$,\1,'
-pathcdr='s,^/[^/]*,,'
-removedotparts=':dotsl
-		s@/\./@/@g
-		t dotsl
-		s,/\.$,/,'
-collapseslashes='s@/\{1,\}@/@g'
-finalslash='s,/*$,/,'
+# Except for the global variables explicitly listed below, the following
+# functions in the '^func_' namespace, and the '^require_' namespace
+# variables initialised in the 'Resource management' section, sourcing
+# this file will not pollute your global namespace with anything
+# else. There's no portable way to scope variables in Bourne shell
+# though, so actually running these functions will sometimes place
+# results into a variable named after the function, and often use
+# temporary variables in the '^_G_' namespace. If you are careful to
+# avoid using those namespaces casually in your sourcing script, things
+# should continue to work as you expect. And, of course, you can freely
+# overwrite any of the functions or variables defined here before
+# calling anything to customize them.
 
-# func_normal_abspath PATH
-# Remove doubled-up and trailing slashes, "." path components,
-# and cancel out any ".." path components in PATH after making
-# it an absolute path.
-#             value returned in "$func_normal_abspath_result"
-func_normal_abspath ()
-{
-  # Start from root dir and reassemble the path.
-  func_normal_abspath_result=
-  func_normal_abspath_tpath=$1
-  func_normal_abspath_altnamespace=
-  case $func_normal_abspath_tpath in
-    "")
-      # Empty path, that just means $cwd.
-      func_stripname '' '/' "`pwd`"
-      func_normal_abspath_result=$func_stripname_result
-      return
-    ;;
-    # The next three entries are used to spot a run of precisely
-    # two leading slashes without using negated character classes;
-    # we take advantage of case's first-match behaviour.
-    ///*)
-      # Unusual form of absolute path, do nothing.
-    ;;
-    //*)
-      # Not necessarily an ordinary path; POSIX reserves leading '//'
-      # and for example Cygwin uses it to access remote file shares
-      # over CIFS/SMB, so we conserve a leading double slash if found.
-      func_normal_abspath_altnamespace=/
-    ;;
-    /*)
-      # Absolute path, do nothing.
-    ;;
-    *)
-      # Relative path, prepend $cwd.
-      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
-    ;;
-  esac
-  # Cancel out all the simple stuff to save iterations.  We also want
-  # the path to end with a slash for ease of parsing, so make sure
-  # there is one (and only one) here.
-  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
-        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
-  while :; do
-    # Processed it all yet?
-    if test "$func_normal_abspath_tpath" = / ; then
-      # If we ascended to the root using ".." the result may be empty now.
-      if test -z "$func_normal_abspath_result" ; then
-        func_normal_abspath_result=/
-      fi
-      break
-    fi
-    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
-        -e "$pathcar"`
-    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
-        -e "$pathcdr"`
-    # Figure out what to do with it
-    case $func_normal_abspath_tcomponent in
-      "")
-        # Trailing empty path component, ignore it.
-      ;;
-      ..)
-        # Parent dir; strip last assembled component from result.
-        func_dirname "$func_normal_abspath_result"
-        func_normal_abspath_result=$func_dirname_result
-      ;;
-      *)
-        # Actual path component, append it.
-        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
-      ;;
-    esac
-  done
-  # Restore leading double-slash if one was found on entry.
-  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
-}
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
+EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
 
-# func_relative_path SRCDIR DSTDIR
-# generates a relative path from SRCDIR to DSTDIR, with a trailing
-# slash if non-empty, suitable for immediately appending a filename
-# without needing to append a separator.
-#             value returned in "$func_relative_path_result"
-func_relative_path ()
-{
-  func_relative_path_result=
-  func_normal_abspath "$1"
-  func_relative_path_tlibdir=$func_normal_abspath_result
-  func_normal_abspath "$2"
-  func_relative_path_tbindir=$func_normal_abspath_result
-
-  # Ascend the tree starting from libdir
-  while :; do
-    # check if we have found a prefix of bindir
-    case $func_relative_path_tbindir in
-      $func_relative_path_tlibdir)
-        # found an exact match
-        func_relative_path_tcancelled=
-        break
-        ;;
-      $func_relative_path_tlibdir*)
-        # found a matching prefix
-        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
-        func_relative_path_tcancelled=$func_stripname_result
-        if test -z "$func_relative_path_result"; then
-          func_relative_path_result=.
-        fi
-        break
-        ;;
-      *)
-        func_dirname $func_relative_path_tlibdir
-        func_relative_path_tlibdir=${func_dirname_result}
-        if test "x$func_relative_path_tlibdir" = x ; then
-          # Have to descend all the way to the root!
-          func_relative_path_result=../$func_relative_path_result
-          func_relative_path_tcancelled=$func_relative_path_tbindir
-          break
-        fi
-        func_relative_path_result=../$func_relative_path_result
-        ;;
-    esac
-  done
+# Allow overriding, eg assuming that you follow the convention of
+# putting '$debug_cmd' at the start of all your functions, you can get
+# bash to show function call trace with:
+#
+#    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
+debug_cmd=${debug_cmd-":"}
+exit_cmd=:
 
-  # Now calculate path; take care to avoid doubling-up slashes.
-  func_stripname '' '/' "$func_relative_path_result"
-  func_relative_path_result=$func_stripname_result
-  func_stripname '/' '/' "$func_relative_path_tcancelled"
-  if test "x$func_stripname_result" != x ; then
-    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
-  fi
+# By convention, finish your script with:
+#
+#    exit $exit_status
+#
+# so that you can set exit_status to non-zero if you want to indicate
+# something went wrong during execution without actually bailing out at
+# the point of failure.
+exit_status=$EXIT_SUCCESS
 
-  # Normalisation. If bindir is libdir, return empty string,
-  # else relative path ending with a slash; either way, target
-  # file name can be directly appended.
-  if test ! -z "$func_relative_path_result"; then
-    func_stripname './' '' "$func_relative_path_result/"
-    func_relative_path_result=$func_stripname_result
-  fi
-}
+# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
+# is ksh but when the shell is invoked as "sh" and the current value of
+# the _XPG environment variable is not equal to 1 (one), the special
+# positional parameter $0, within a function call, is the name of the
+# function.
+progpath=$0
 
-# The name of this program:
-func_dirname_and_basename "$progpath"
-progname=$func_basename_result
+# The name of this program.
+progname=`$ECHO "$progpath" |$SED "$sed_basename"`
 
-# Make sure we have an absolute path for reexecution:
+# Make sure we have an absolute progpath for reexecution:
 case $progpath in
   [\\/]*|[A-Za-z]:\\*) ;;
   *[\\/]*)
-     progdir=$func_dirname_result
+     progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
      progdir=`cd "$progdir" && pwd`
-     progpath="$progdir/$progname"
+     progpath=$progdir/$progname
      ;;
   *)
-     save_IFS="$IFS"
+     _G_IFS=$IFS
      IFS=${PATH_SEPARATOR-:}
      for progdir in $PATH; do
-       IFS="$save_IFS"
+       IFS=$_G_IFS
        test -x "$progdir/$progname" && break
      done
-     IFS="$save_IFS"
+     IFS=$_G_IFS
      test -n "$progdir" || progdir=`pwd`
-     progpath="$progdir/$progname"
+     progpath=$progdir/$progname
      ;;
 esac
 
-# Sed substitution that helps us do robust quoting.  It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed="${SED}"' -e 1s/^X//'
-sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
-
-# Same as above, but do not quote variable references.
-double_quote_subst='s/\(["`\\]\)/\\\1/g'
 
-# Sed substitution that turns a string into a regex matching for the
-# string literally.
-sed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
+## ----------------- ##
+## Standard options. ##
+## ----------------- ##
 
-# Sed substitution that converts a w32 file name or path
-# which contains forward slashes, into one that contains
-# (escaped) backslashes.  A very naive implementation.
-lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
-
-# Re-`\' parameter expansions in output of double_quote_subst that were
-# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
-# in input to double_quote_subst, that '$' was protected from expansion.
-# Since each input `\' is now two `\'s, look for any number of runs of
-# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
-bs='\\'
-bs2='\\\\'
-bs4='\\\\\\\\'
-dollar='\$'
-sed_double_backslash="\
-  s/$bs4/&\\
-/g
-  s/^$bs2$dollar/$bs&/
-  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
-  s/\n//g"
+# The following options affect the operation of the functions defined
+# below, and should be set appropriately depending on run-time para-
+# meters passed on the command line.
 
-# Standard options:
 opt_dry_run=false
-opt_help=false
 opt_quiet=false
 opt_verbose=false
-opt_warning=:
 
-# func_echo arg...
-# Echo program name prefixed message, along with the current mode
-# name if it has been set yet.
-func_echo ()
-{
-    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
-}
+# Categories 'all' and 'none' are always available.  Append any others
+# you will pass as the first argument to func_warning from your own
+# code.
+warning_categories=
 
-# func_verbose arg...
-# Echo program name prefixed message in verbose mode only.
-func_verbose ()
-{
-    $opt_verbose && func_echo ${1+"$@"}
+# By default, display warnings according to 'opt_warning_types'.  Set
+# 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
+# treat the next displayed warning as a fatal error.
+warning_func=func_warn_and_continue
 
-    # A bug in bash halts the script if the last line of a function
-    # fails when set -e is in force, so we need another command to
-    # work around that:
-    :
-}
+# Set to 'all' to display all warnings, 'none' to suppress all
+# warnings, or a space delimited list of some subset of
+# 'warning_categories' to display only the listed warnings.
+opt_warning_types=all
 
-# func_echo_all arg...
-# Invoke $ECHO with all args, space-separated.
-func_echo_all ()
-{
-    $ECHO "$*"
-}
 
-# func_error arg...
-# Echo program name prefixed message to standard error.
-func_error ()
-{
-    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
-}
+## -------------------- ##
+## Resource management. ##
+## -------------------- ##
 
-# func_warning arg...
-# Echo program name prefixed warning message to standard error.
-func_warning ()
-{
-    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
+# This section contains definitions for functions that each ensure a
+# particular resource (a file, or a non-empty configuration variable for
+# example) is available, and if appropriate to extract default values
+# from pertinent package files. Call them using their associated
+# 'require_*' variable to ensure that they are executed, at most, once.
+#
+# It's entirely deliberate that calling these functions can set
+# variables that don't obey the namespace limitations obeyed by the rest
+# of this file, in order that that they be as useful as possible to
+# callers.
 
-    # bash bug again:
-    :
-}
 
-# func_fatal_error arg...
-# Echo program name prefixed message to standard error, and exit.
-func_fatal_error ()
+# require_term_colors
+# -------------------
+# Allow display of bold text on terminals that support it.
+require_term_colors=func_require_term_colors
+func_require_term_colors ()
 {
-    func_error ${1+"$@"}
-    exit $EXIT_FAILURE
-}
+    $debug_cmd
+
+    test -t 1 && {
+      # COLORTERM and USE_ANSI_COLORS environment variables take
+      # precedence, because most terminfo databases neglect to describe
+      # whether color sequences are supported.
+      test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
+
+      if test 1 = "$USE_ANSI_COLORS"; then
+        # Standard ANSI escape sequences
+        tc_reset=''
+        tc_bold='';   tc_standout=''
+        tc_red='';   tc_green=''
+        tc_blue='';  tc_cyan=''
+      else
+        # Otherwise trust the terminfo database after all.
+        test -n "`tput sgr0 2>/dev/null`" && {
+          tc_reset=`tput sgr0`
+          test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
+          tc_standout=$tc_bold
+          test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
+          test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
+          test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
+          test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
+          test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
+        }
+      fi
+    }
 
-# func_fatal_help arg...
-# Echo program name prefixed message to standard error, followed by
-# a help hint, and exit.
-func_fatal_help ()
-{
-    func_error ${1+"$@"}
-    func_fatal_error "$help"
+    require_term_colors=:
 }
-help="Try \`$progname --help' for more information."  ## default
 
 
-# func_grep expression filename
+## ----------------- ##
+## Function library. ##
+## ----------------- ##
+
+# This section contains a variety of useful functions to call in your
+# scripts. Take note of the portable wrappers for features provided by
+# some modern shells, which will fall back to slower equivalents on
+# less featureful shells.
+
+
+# func_append VAR VALUE
+# ---------------------
+# Append VALUE onto the existing contents of VAR.
+
+  # We should try to minimise forks, especially on Windows where they are
+  # unreasonably slow, so skip the feature probes when bash or zsh are
+  # being used:
+  if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
+    : ${_G_HAVE_ARITH_OP="yes"}
+    : ${_G_HAVE_XSI_OPS="yes"}
+    # The += operator was introduced in bash 3.1
+    case $BASH_VERSION in
+      [12].* | 3.0 | 3.0*) ;;
+      *)
+        : ${_G_HAVE_PLUSEQ_OP="yes"}
+        ;;
+    esac
+  fi
+
+  # _G_HAVE_PLUSEQ_OP
+  # Can be empty, in which case the shell is probed, "yes" if += is
+  # useable or anything else if it does not work.
+  test -z "$_G_HAVE_PLUSEQ_OP" \
+    && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
+    && _G_HAVE_PLUSEQ_OP=yes
+
+if test yes = "$_G_HAVE_PLUSEQ_OP"
+then
+  # This is an XSI compatible shell, allowing a faster implementation...
+  eval 'func_append ()
+  {
+    $debug_cmd
+
+    eval "$1+=\$2"
+  }'
+else
+  # ...otherwise fall back to using expr, which is often a shell builtin.
+  func_append ()
+  {
+    $debug_cmd
+
+    eval "$1=\$$1\$2"
+  }
+fi
+
+
+# func_append_quoted VAR VALUE
+# ----------------------------
+# Quote VALUE and append to the end of shell variable VAR, separated
+# by a space.
+if test yes = "$_G_HAVE_PLUSEQ_OP"; then
+  eval 'func_append_quoted ()
+  {
+    $debug_cmd
+
+    func_quote_for_eval "$2"
+    eval "$1+=\\ \$func_quote_for_eval_result"
+  }'
+else
+  func_append_quoted ()
+  {
+    $debug_cmd
+
+    func_quote_for_eval "$2"
+    eval "$1=\$$1\\ \$func_quote_for_eval_result"
+  }
+fi
+
+
+# func_append_uniq VAR VALUE
+# --------------------------
+# Append unique VALUE onto the existing contents of VAR, assuming
+# entries are delimited by the first character of VALUE.  For example:
+#
+#   func_append_uniq options " --another-option option-argument"
+#
+# will only append to $options if " --another-option option-argument "
+# is not already present somewhere in $options already (note spaces at
+# each end implied by leading space in second argument).
+func_append_uniq ()
+{
+    $debug_cmd
+
+    eval _G_current_value='`$ECHO $'$1'`'
+    _G_delim=`expr "$2" : '\(.\)'`
+
+    case $_G_delim$_G_current_value$_G_delim in
+      *"$2$_G_delim"*) ;;
+      *) func_append "$@" ;;
+    esac
+}
+
+
+# func_arith TERM...
+# ------------------
+# Set func_arith_result to the result of evaluating TERMs.
+  test -z "$_G_HAVE_ARITH_OP" \
+    && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
+    && _G_HAVE_ARITH_OP=yes
+
+if test yes = "$_G_HAVE_ARITH_OP"; then
+  eval 'func_arith ()
+  {
+    $debug_cmd
+
+    func_arith_result=$(( $* ))
+  }'
+else
+  func_arith ()
+  {
+    $debug_cmd
+
+    func_arith_result=`expr "$@"`
+  }
+fi
+
+
+# func_basename FILE
+# ------------------
+# Set func_basename_result to FILE with everything up to and including
+# the last / stripped.
+if test yes = "$_G_HAVE_XSI_OPS"; then
+  # If this shell supports suffix pattern removal, then use it to avoid
+  # forking. Hide the definitions single quotes in case the shell chokes
+  # on unsupported syntax...
+  _b='func_basename_result=${1##*/}'
+  _d='case $1 in
+        */*) func_dirname_result=${1%/*}$2 ;;
+        *  ) func_dirname_result=$3        ;;
+      esac'
+
+else
+  # ...otherwise fall back to using sed.
+  _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
+  _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
+      if test "X$func_dirname_result" = "X$1"; then
+        func_dirname_result=$3
+      else
+        func_append func_dirname_result "$2"
+      fi'
+fi
+
+eval 'func_basename ()
+{
+    $debug_cmd
+
+    '"$_b"'
+}'
+
+
+# func_dirname FILE APPEND NONDIR_REPLACEMENT
+# -------------------------------------------
+# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+eval 'func_dirname ()
+{
+    $debug_cmd
+
+    '"$_d"'
+}'
+
+
+# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
+# --------------------------------------------------------
+# Perform func_basename and func_dirname in a single function
+# call:
+#   dirname:  Compute the dirname of FILE.  If nonempty,
+#             add APPEND to the result, otherwise set result
+#             to NONDIR_REPLACEMENT.
+#             value returned in "$func_dirname_result"
+#   basename: Compute filename of FILE.
+#             value retuned in "$func_basename_result"
+# For efficiency, we do not delegate to the functions above but instead
+# duplicate the functionality here.
+eval 'func_dirname_and_basename ()
+{
+    $debug_cmd
+
+    '"$_b"'
+    '"$_d"'
+}'
+
+
+# func_echo ARG...
+# ----------------
+# Echo program name prefixed message.
+func_echo ()
+{
+    $debug_cmd
+
+    _G_message=$*
+
+    func_echo_IFS=$IFS
+    IFS=$nl
+    for _G_line in $_G_message; do
+      IFS=$func_echo_IFS
+      $ECHO "$progname: $_G_line"
+    done
+    IFS=$func_echo_IFS
+}
+
+
+# func_echo_all ARG...
+# --------------------
+# Invoke $ECHO with all args, space-separated.
+func_echo_all ()
+{
+    $ECHO "$*"
+}
+
+
+# func_echo_infix_1 INFIX ARG...
+# ------------------------------
+# Echo program name, followed by INFIX on the first line, with any
+# additional lines not showing INFIX.
+func_echo_infix_1 ()
+{
+    $debug_cmd
+
+    $require_term_colors
+
+    _G_infix=$1; shift
+    _G_indent=$_G_infix
+    _G_prefix="$progname: $_G_infix: "
+    _G_message=$*
+
+    # Strip color escape sequences before counting printable length
+    for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
+    do
+      test -n "$_G_tc" && {
+        _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
+        _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
+      }
+    done
+    _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
+
+    func_echo_infix_1_IFS=$IFS
+    IFS=$nl
+    for _G_line in $_G_message; do
+      IFS=$func_echo_infix_1_IFS
+      $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
+      _G_prefix=$_G_indent
+    done
+    IFS=$func_echo_infix_1_IFS
+}
+
+
+# func_error ARG...
+# -----------------
+# Echo program name prefixed message to standard error.
+func_error ()
+{
+    $debug_cmd
+
+    $require_term_colors
+
+    func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
+}
+
+
+# func_fatal_error ARG...
+# -----------------------
+# Echo program name prefixed message to standard error, and exit.
+func_fatal_error ()
+{
+    $debug_cmd
+
+    func_error "$*"
+    exit $EXIT_FAILURE
+}
+
+
+# func_grep EXPRESSION FILENAME
+# -----------------------------
 # Check whether EXPRESSION matches any line of FILENAME, without output.
 func_grep ()
 {
+    $debug_cmd
+
     $GREP "$1" "$2" >/dev/null 2>&1
 }
 
 
-# func_mkdir_p directory-path
+# func_len STRING
+# ---------------
+# Set func_len_result to the length of STRING. STRING may not
+# start with a hyphen.
+  test -z "$_G_HAVE_XSI_OPS" \
+    && (eval 'x=a/b/c;
+      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
+    && _G_HAVE_XSI_OPS=yes
+
+if test yes = "$_G_HAVE_XSI_OPS"; then
+  eval 'func_len ()
+  {
+    $debug_cmd
+
+    func_len_result=${#1}
+  }'
+else
+  func_len ()
+  {
+    $debug_cmd
+
+    func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
+  }
+fi
+
+
+# func_mkdir_p DIRECTORY-PATH
+# ---------------------------
 # Make sure the entire path to DIRECTORY-PATH is available.
 func_mkdir_p ()
 {
-    my_directory_path="$1"
-    my_dir_list=
+    $debug_cmd
+
+    _G_directory_path=$1
+    _G_dir_list=
 
-    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
+    if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
 
-      # Protect directory names starting with `-'
-      case $my_directory_path in
-        -*) my_directory_path="./$my_directory_path" ;;
+      # Protect directory names starting with '-'
+      case $_G_directory_path in
+        -*) _G_directory_path=./$_G_directory_path ;;
       esac
 
       # While some portion of DIR does not yet exist...
-      while test ! -d "$my_directory_path"; do
+      while test ! -d "$_G_directory_path"; do
         # ...make a list in topmost first order.  Use a colon delimited
 	# list incase some portion of path contains whitespace.
-        my_dir_list="$my_directory_path:$my_dir_list"
+        _G_dir_list=$_G_directory_path:$_G_dir_list
 
         # If the last portion added has no slash in it, the list is done
-        case $my_directory_path in */*) ;; *) break ;; esac
+        case $_G_directory_path in */*) ;; *) break ;; esac
 
         # ...otherwise throw away the child directory and loop
-        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
+        _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
       done
-      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
+      _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
 
-      save_mkdir_p_IFS="$IFS"; IFS=':'
-      for my_dir in $my_dir_list; do
-	IFS="$save_mkdir_p_IFS"
-        # mkdir can fail with a `File exist' error if two processes
+      func_mkdir_p_IFS=$IFS; IFS=:
+      for _G_dir in $_G_dir_list; do
+	IFS=$func_mkdir_p_IFS
+        # mkdir can fail with a 'File exist' error if two processes
         # try to create one of the directories concurrently.  Don't
         # stop in that case!
-        $MKDIR "$my_dir" 2>/dev/null || :
+        $MKDIR "$_G_dir" 2>/dev/null || :
       done
-      IFS="$save_mkdir_p_IFS"
+      IFS=$func_mkdir_p_IFS
 
       # Bail out if we (or some other process) failed to create a directory.
-      test -d "$my_directory_path" || \
-        func_fatal_error "Failed to create \`$1'"
+      test -d "$_G_directory_path" || \
+        func_fatal_error "Failed to create '$1'"
     fi
 }
 
 
-# func_mktempdir [string]
+# func_mktempdir [BASENAME]
+# -------------------------
 # Make a temporary directory that won't clash with other running
 # libtool processes, and avoids race conditions if possible.  If
-# given, STRING is the basename for that directory.
+# given, BASENAME is the basename for that directory.
 func_mktempdir ()
 {
-    my_template="${TMPDIR-/tmp}/${1-$progname}"
+    $debug_cmd
+
+    _G_template=${TMPDIR-/tmp}/${1-$progname}
 
-    if test "$opt_dry_run" = ":"; then
+    if test : = "$opt_dry_run"; then
       # Return a directory name, but don't create it in dry-run mode
-      my_tmpdir="${my_template}-$$"
+      _G_tmpdir=$_G_template-$$
     else
 
       # If mktemp works, use that first and foremost
-      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
+      _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
 
-      if test ! -d "$my_tmpdir"; then
+      if test ! -d "$_G_tmpdir"; then
         # Failing that, at least try and use $RANDOM to avoid a race
-        my_tmpdir="${my_template}-${RANDOM-0}$$"
+        _G_tmpdir=$_G_template-${RANDOM-0}$$
 
-        save_mktempdir_umask=`umask`
+        func_mktempdir_umask=`umask`
         umask 0077
-        $MKDIR "$my_tmpdir"
-        umask $save_mktempdir_umask
+        $MKDIR "$_G_tmpdir"
+        umask $func_mktempdir_umask
       fi
 
       # If we're not in dry-run mode, bomb out on failure
-      test -d "$my_tmpdir" || \
-        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
+      test -d "$_G_tmpdir" || \
+        func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
     fi
 
-    $ECHO "$my_tmpdir"
+    $ECHO "$_G_tmpdir"
 }
 
 
-# func_quote_for_eval arg
-# Aesthetically quote ARG to be evaled later.
-# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
-# is double-quoted, suitable for a subsequent eval, whereas
-# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
-# which are still active within double quotes backslashified.
-func_quote_for_eval ()
+# func_normal_abspath PATH
+# ------------------------
+# Remove doubled-up and trailing slashes, "." path components,
+# and cancel out any ".." path components in PATH after making
+# it an absolute path.
+func_normal_abspath ()
 {
-    case $1 in
-      *[\\\`\"\$]*)
-	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
-      *)
-        func_quote_for_eval_unquoted_result="$1" ;;
-    esac
+    $debug_cmd
 
-    case $func_quote_for_eval_unquoted_result in
-      # Double-quote args containing shell metacharacters to delay
-      # word splitting, command substitution and and variable
-      # expansion for a subsequent eval.
-      # Many Bourne shells cannot handle close brackets correctly
-      # in scan sets, so we specify it separately.
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
+    # These SED scripts presuppose an absolute path with a trailing slash.
+    _G_pathcar='s|^/\([^/]*\).*$|\1|'
+    _G_pathcdr='s|^/[^/]*||'
+    _G_removedotparts=':dotsl
+		s|/\./|/|g
+		t dotsl
+		s|/\.$|/|'
+    _G_collapseslashes='s|/\{1,\}|/|g'
+    _G_finalslash='s|/*$|/|'
+
+    # Start from root dir and reassemble the path.
+    func_normal_abspath_result=
+    func_normal_abspath_tpath=$1
+    func_normal_abspath_altnamespace=
+    case $func_normal_abspath_tpath in
+      "")
+        # Empty path, that just means $cwd.
+        func_stripname '' '/' "`pwd`"
+        func_normal_abspath_result=$func_stripname_result
+        return
+        ;;
+      # The next three entries are used to spot a run of precisely
+      # two leading slashes without using negated character classes;
+      # we take advantage of case's first-match behaviour.
+      ///*)
+        # Unusual form of absolute path, do nothing.
+        ;;
+      //*)
+        # Not necessarily an ordinary path; POSIX reserves leading '//'
+        # and for example Cygwin uses it to access remote file shares
+        # over CIFS/SMB, so we conserve a leading double slash if found.
+        func_normal_abspath_altnamespace=/
+        ;;
+      /*)
+        # Absolute path, do nothing.
         ;;
       *)
-        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
+        # Relative path, prepend $cwd.
+        func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
+        ;;
     esac
+
+    # Cancel out all the simple stuff to save iterations.  We also want
+    # the path to end with a slash for ease of parsing, so make sure
+    # there is one (and only one) here.
+    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
+          -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
+    while :; do
+      # Processed it all yet?
+      if test / = "$func_normal_abspath_tpath"; then
+        # If we ascended to the root using ".." the result may be empty now.
+        if test -z "$func_normal_abspath_result"; then
+          func_normal_abspath_result=/
+        fi
+        break
+      fi
+      func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
+          -e "$_G_pathcar"`
+      func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
+          -e "$_G_pathcdr"`
+      # Figure out what to do with it
+      case $func_normal_abspath_tcomponent in
+        "")
+          # Trailing empty path component, ignore it.
+          ;;
+        ..)
+          # Parent dir; strip last assembled component from result.
+          func_dirname "$func_normal_abspath_result"
+          func_normal_abspath_result=$func_dirname_result
+          ;;
+        *)
+          # Actual path component, append it.
+          func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
+          ;;
+      esac
+    done
+    # Restore leading double-slash if one was found on entry.
+    func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
+}
+
+
+# func_notquiet ARG...
+# --------------------
+# Echo program name prefixed message only when not in quiet mode.
+func_notquiet ()
+{
+    $debug_cmd
+
+    $opt_quiet || func_echo ${1+"$@"}
+
+    # A bug in bash halts the script if the last line of a function
+    # fails when set -e is in force, so we need another command to
+    # work around that:
+    :
+}
+
+
+# func_relative_path SRCDIR DSTDIR
+# --------------------------------
+# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
+func_relative_path ()
+{
+    $debug_cmd
+
+    func_relative_path_result=
+    func_normal_abspath "$1"
+    func_relative_path_tlibdir=$func_normal_abspath_result
+    func_normal_abspath "$2"
+    func_relative_path_tbindir=$func_normal_abspath_result
+
+    # Ascend the tree starting from libdir
+    while :; do
+      # check if we have found a prefix of bindir
+      case $func_relative_path_tbindir in
+        $func_relative_path_tlibdir)
+          # found an exact match
+          func_relative_path_tcancelled=
+          break
+          ;;
+        $func_relative_path_tlibdir*)
+          # found a matching prefix
+          func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
+          func_relative_path_tcancelled=$func_stripname_result
+          if test -z "$func_relative_path_result"; then
+            func_relative_path_result=.
+          fi
+          break
+          ;;
+        *)
+          func_dirname $func_relative_path_tlibdir
+          func_relative_path_tlibdir=$func_dirname_result
+          if test -z "$func_relative_path_tlibdir"; then
+            # Have to descend all the way to the root!
+            func_relative_path_result=../$func_relative_path_result
+            func_relative_path_tcancelled=$func_relative_path_tbindir
+            break
+          fi
+          func_relative_path_result=../$func_relative_path_result
+          ;;
+      esac
+    done
+
+    # Now calculate path; take care to avoid doubling-up slashes.
+    func_stripname '' '/' "$func_relative_path_result"
+    func_relative_path_result=$func_stripname_result
+    func_stripname '/' '/' "$func_relative_path_tcancelled"
+    if test -n "$func_stripname_result"; then
+      func_append func_relative_path_result "/$func_stripname_result"
+    fi
+
+    # Normalisation. If bindir is libdir, return '.' else relative path.
+    if test -n "$func_relative_path_result"; then
+      func_stripname './' '' "$func_relative_path_result"
+      func_relative_path_result=$func_stripname_result
+    fi
+
+    test -n "$func_relative_path_result" || func_relative_path_result=.
+
+    :
 }
 
 
-# func_quote_for_expand arg
+# func_quote_for_eval ARG...
+# --------------------------
+# Aesthetically quote ARGs to be evaled later.
+# This function returns two values:
+#   i) func_quote_for_eval_result
+#      double-quoted, suitable for a subsequent eval
+#  ii) func_quote_for_eval_unquoted_result
+#      has all characters that are still active within double
+#      quotes backslashified.
+func_quote_for_eval ()
+{
+    $debug_cmd
+
+    func_quote_for_eval_unquoted_result=
+    func_quote_for_eval_result=
+    while test 0 -lt $#; do
+      case $1 in
+        *[\\\`\"\$]*)
+	  _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
+        *)
+          _G_unquoted_arg=$1 ;;
+      esac
+      if test -n "$func_quote_for_eval_unquoted_result"; then
+	func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
+      else
+        func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
+      fi
+
+      case $_G_unquoted_arg in
+        # Double-quote args containing shell metacharacters to delay
+        # word splitting, command substitution and variable expansion
+        # for a subsequent eval.
+        # Many Bourne shells cannot handle close brackets correctly
+        # in scan sets, so we specify it separately.
+        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+          _G_quoted_arg=\"$_G_unquoted_arg\"
+          ;;
+        *)
+          _G_quoted_arg=$_G_unquoted_arg
+	  ;;
+      esac
+
+      if test -n "$func_quote_for_eval_result"; then
+	func_append func_quote_for_eval_result " $_G_quoted_arg"
+      else
+        func_append func_quote_for_eval_result "$_G_quoted_arg"
+      fi
+      shift
+    done
+}
+
+
+# func_quote_for_expand ARG
+# -------------------------
 # Aesthetically quote ARG to be evaled later; same as above,
 # but do not quote variable references.
 func_quote_for_expand ()
 {
+    $debug_cmd
+
     case $1 in
       *[\\\`\"]*)
-	my_arg=`$ECHO "$1" | $SED \
-	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
+	_G_arg=`$ECHO "$1" | $SED \
+	    -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
       *)
-        my_arg="$1" ;;
+        _G_arg=$1 ;;
     esac
 
-    case $my_arg in
+    case $_G_arg in
       # Double-quote args containing shell metacharacters to delay
       # word splitting and command substitution for a subsequent eval.
       # Many Bourne shells cannot handle close brackets correctly
       # in scan sets, so we specify it separately.
       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-        my_arg="\"$my_arg\""
+        _G_arg=\"$_G_arg\"
         ;;
     esac
 
-    func_quote_for_expand_result="$my_arg"
+    func_quote_for_expand_result=$_G_arg
+}
+
+
+# func_stripname PREFIX SUFFIX NAME
+# ---------------------------------
+# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+if test yes = "$_G_HAVE_XSI_OPS"; then
+  eval 'func_stripname ()
+  {
+    $debug_cmd
+
+    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
+    # positional parameters, so assign one to ordinary variable first.
+    func_stripname_result=$3
+    func_stripname_result=${func_stripname_result#"$1"}
+    func_stripname_result=${func_stripname_result%"$2"}
+  }'
+else
+  func_stripname ()
+  {
+    $debug_cmd
+
+    case $2 in
+      .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
+      *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
+    esac
+  }
+fi
+
+
+# func_show_eval CMD [FAIL_EXP]
+# -----------------------------
+# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
+# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.
+func_show_eval ()
+{
+    $debug_cmd
+
+    _G_cmd=$1
+    _G_fail_exp=${2-':'}
+
+    func_quote_for_expand "$_G_cmd"
+    eval "func_notquiet $func_quote_for_expand_result"
+
+    $opt_dry_run || {
+      eval "$_G_cmd"
+      _G_status=$?
+      if test 0 -ne "$_G_status"; then
+	eval "(exit $_G_status); $_G_fail_exp"
+      fi
+    }
+}
+
+
+# func_show_eval_locale CMD [FAIL_EXP]
+# ------------------------------------
+# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
+# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.  Use the saved locale for evaluation.
+func_show_eval_locale ()
+{
+    $debug_cmd
+
+    _G_cmd=$1
+    _G_fail_exp=${2-':'}
+
+    $opt_quiet || {
+      func_quote_for_expand "$_G_cmd"
+      eval "func_echo $func_quote_for_expand_result"
+    }
+
+    $opt_dry_run || {
+      eval "$_G_user_locale
+	    $_G_cmd"
+      _G_status=$?
+      eval "$_G_safe_locale"
+      if test 0 -ne "$_G_status"; then
+	eval "(exit $_G_status); $_G_fail_exp"
+      fi
+    }
+}
+
+
+# func_tr_sh
+# ----------
+# Turn $1 into a string suitable for a shell variable name.
+# Result is stored in $func_tr_sh_result.  All characters
+# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
+# if $1 begins with a digit, a '_' is prepended as well.
+func_tr_sh ()
+{
+    $debug_cmd
+
+    case $1 in
+    [0-9]* | *[!a-zA-Z0-9_]*)
+      func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
+      ;;
+    * )
+      func_tr_sh_result=$1
+      ;;
+    esac
+}
+
+
+# func_verbose ARG...
+# -------------------
+# Echo program name prefixed message in verbose mode only.
+func_verbose ()
+{
+    $debug_cmd
+
+    $opt_verbose && func_echo "$*"
+
+    :
+}
+
+
+# func_warn_and_continue ARG...
+# -----------------------------
+# Echo program name prefixed warning message to standard error.
+func_warn_and_continue ()
+{
+    $debug_cmd
+
+    $require_term_colors
+
+    func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
+}
+
+
+# func_warning CATEGORY ARG...
+# ----------------------------
+# Echo program name prefixed warning message to standard error. Warning
+# messages can be filtered according to CATEGORY, where this function
+# elides messages where CATEGORY is not listed in the global variable
+# 'opt_warning_types'.
+func_warning ()
+{
+    $debug_cmd
+
+    # CATEGORY must be in the warning_categories list!
+    case " $warning_categories " in
+      *" $1 "*) ;;
+      *) func_internal_error "invalid warning category '$1'" ;;
+    esac
+
+    _G_category=$1
+    shift
+
+    case " $opt_warning_types " in
+      *" $_G_category "*) $warning_func ${1+"$@"} ;;
+    esac
 }
 
 
-# func_show_eval cmd [fail_exp]
-# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
-# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
-# is given, then evaluate it.
-func_show_eval ()
+# func_sort_ver VER1 VER2
+# -----------------------
+# 'sort -V' is not generally available.
+# Note this deviates from the version comparison in automake
+# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
+# but this should suffice as we won't be specifying old
+# version formats or redundant trailing .0 in bootstrap.conf.
+# If we did want full compatibility then we should probably
+# use m4_version_compare from autoconf.
+func_sort_ver ()
+{
+    $debug_cmd
+
+    printf '%s\n%s\n' "$1" "$2" \
+      | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n
+}
+
+# func_lt_ver PREV CURR
+# ---------------------
+# Return true if PREV and CURR are in the correct order according to
+# func_sort_ver, otherwise false.  Use it like this:
+#
+#  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
+func_lt_ver ()
+{
+    $debug_cmd
+
+    test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
+}
+
+
+# Local variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'before-save-hook 'time-stamp)
+# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
+# time-stamp-time-zone: "UTC"
+# End:
+#! /bin/sh
+
+# Set a version string for this script.
+scriptversion=2014-01-07.03; # UTC
+
+# A portable, pluggable option parser for Bourne shell.
+# Written by Gary V. Vaughan, 2010
+
+# Copyright (C) 2010-2015 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Please report bugs or propose patches to gary at gnu.org.
+
+
+## ------ ##
+## Usage. ##
+## ------ ##
+
+# This file is a library for parsing options in your shell scripts along
+# with assorted other useful supporting features that you can make use
+# of too.
+#
+# For the simplest scripts you might need only:
+#
+#   #!/bin/sh
+#   . relative/path/to/funclib.sh
+#   . relative/path/to/options-parser
+#   scriptversion=1.0
+#   func_options ${1+"$@"}
+#   eval set dummy "$func_options_result"; shift
+#   ...rest of your script...
+#
+# In order for the '--version' option to work, you will need to have a
+# suitably formatted comment like the one at the top of this file
+# starting with '# Written by ' and ending with '# warranty; '.
+#
+# For '-h' and '--help' to work, you will also need a one line
+# description of your script's purpose in a comment directly above the
+# '# Written by ' line, like the one at the top of this file.
+#
+# The default options also support '--debug', which will turn on shell
+# execution tracing (see the comment above debug_cmd below for another
+# use), and '--verbose' and the func_verbose function to allow your script
+# to display verbose messages only when your user has specified
+# '--verbose'.
+#
+# After sourcing this file, you can plug processing for additional
+# options by amending the variables from the 'Configuration' section
+# below, and following the instructions in the 'Option parsing'
+# section further down.
+
+## -------------- ##
+## Configuration. ##
+## -------------- ##
+
+# You should override these variables in your script after sourcing this
+# file so that they reflect the customisations you have added to the
+# option parser.
+
+# The usage line for option parsing errors and the start of '-h' and
+# '--help' output messages. You can embed shell variables for delayed
+# expansion at the time the message is displayed, but you will need to
+# quote other shell meta-characters carefully to prevent them being
+# expanded when the contents are evaled.
+usage='$progpath [OPTION]...'
+
+# Short help message in response to '-h' and '--help'.  Add to this or
+# override it after sourcing this library to reflect the full set of
+# options your script accepts.
+usage_message="\
+       --debug        enable verbose shell tracing
+   -W, --warnings=CATEGORY
+                      report the warnings falling in CATEGORY [all]
+   -v, --verbose      verbosely report processing
+       --version      print version information and exit
+   -h, --help         print short or long help message and exit
+"
+
+# Additional text appended to 'usage_message' in response to '--help'.
+long_help_message="
+Warning categories include:
+       'all'          show all warnings
+       'none'         turn off all the warnings
+       'error'        warnings are treated as fatal errors"
+
+# Help message printed before fatal option parsing errors.
+fatal_help="Try '\$progname --help' for more information."
+
+
+
+## ------------------------- ##
+## Hook function management. ##
+## ------------------------- ##
+
+# This section contains functions for adding, removing, and running hooks
+# to the main code.  A hook is just a named list of of function, that can
+# be run in order later on.
+
+# func_hookable FUNC_NAME
+# -----------------------
+# Declare that FUNC_NAME will run hooks added with
+# 'func_add_hook FUNC_NAME ...'.
+func_hookable ()
+{
+    $debug_cmd
+
+    func_append hookable_fns " $1"
+}
+
+
+# func_add_hook FUNC_NAME HOOK_FUNC
+# ---------------------------------
+# Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
+# first have been declared "hookable" by a call to 'func_hookable'.
+func_add_hook ()
+{
+    $debug_cmd
+
+    case " $hookable_fns " in
+      *" $1 "*) ;;
+      *) func_fatal_error "'$1' does not accept hook functions." ;;
+    esac
+
+    eval func_append ${1}_hooks '" $2"'
+}
+
+
+# func_remove_hook FUNC_NAME HOOK_FUNC
+# ------------------------------------
+# Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
+func_remove_hook ()
+{
+    $debug_cmd
+
+    eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
+}
+
+
+# func_run_hooks FUNC_NAME [ARG]...
+# ---------------------------------
+# Run all hook functions registered to FUNC_NAME.
+# It is assumed that the list of hook functions contains nothing more
+# than a whitespace-delimited list of legal shell function names, and
+# no effort is wasted trying to catch shell meta-characters or preserve
+# whitespace.
+func_run_hooks ()
+{
+    $debug_cmd
+
+    case " $hookable_fns " in
+      *" $1 "*) ;;
+      *) func_fatal_error "'$1' does not support hook funcions.n" ;;
+    esac
+
+    eval _G_hook_fns=\$$1_hooks; shift
+
+    for _G_hook in $_G_hook_fns; do
+      eval $_G_hook '"$@"'
+
+      # store returned options list back into positional
+      # parameters for next 'cmd' execution.
+      eval _G_hook_result=\$${_G_hook}_result
+      eval set dummy "$_G_hook_result"; shift
+    done
+
+    func_quote_for_eval ${1+"$@"}
+    func_run_hooks_result=$func_quote_for_eval_result
+}
+
+
+
+## --------------- ##
+## Option parsing. ##
+## --------------- ##
+
+# In order to add your own option parsing hooks, you must accept the
+# full positional parameter list in your hook function, remove any
+# options that you action, and then pass back the remaining unprocessed
+# options in '<hooked_function_name>_result', escaped suitably for
+# 'eval'.  Like this:
+#
+#    my_options_prep ()
+#    {
+#        $debug_cmd
+#
+#        # Extend the existing usage message.
+#        usage_message=$usage_message'
+#      -s, --silent       don'\''t print informational messages
+#    '
+#
+#        func_quote_for_eval ${1+"$@"}
+#        my_options_prep_result=$func_quote_for_eval_result
+#    }
+#    func_add_hook func_options_prep my_options_prep
+#
+#
+#    my_silent_option ()
+#    {
+#        $debug_cmd
+#
+#        # Note that for efficiency, we parse as many options as we can
+#        # recognise in a loop before passing the remainder back to the
+#        # caller on the first unrecognised argument we encounter.
+#        while test $# -gt 0; do
+#          opt=$1; shift
+#          case $opt in
+#            --silent|-s) opt_silent=: ;;
+#            # Separate non-argument short options:
+#            -s*)         func_split_short_opt "$_G_opt"
+#                         set dummy "$func_split_short_opt_name" \
+#                             "-$func_split_short_opt_arg" ${1+"$@"}
+#                         shift
+#                         ;;
+#            *)            set dummy "$_G_opt" "$*"; shift; break ;;
+#          esac
+#        done
+#
+#        func_quote_for_eval ${1+"$@"}
+#        my_silent_option_result=$func_quote_for_eval_result
+#    }
+#    func_add_hook func_parse_options my_silent_option
+#
+#
+#    my_option_validation ()
+#    {
+#        $debug_cmd
+#
+#        $opt_silent && $opt_verbose && func_fatal_help "\
+#    '--silent' and '--verbose' options are mutually exclusive."
+#
+#        func_quote_for_eval ${1+"$@"}
+#        my_option_validation_result=$func_quote_for_eval_result
+#    }
+#    func_add_hook func_validate_options my_option_validation
+#
+# You'll alse need to manually amend $usage_message to reflect the extra
+# options you parse.  It's preferable to append if you can, so that
+# multiple option parsing hooks can be added safely.
+
+
+# func_options [ARG]...
+# ---------------------
+# All the functions called inside func_options are hookable. See the
+# individual implementations for details.
+func_hookable func_options
+func_options ()
 {
-    my_cmd="$1"
-    my_fail_exp="${2-:}"
+    $debug_cmd
 
-    ${opt_silent-false} || {
-      func_quote_for_expand "$my_cmd"
-      eval "func_echo $func_quote_for_expand_result"
-    }
+    func_options_prep ${1+"$@"}
+    eval func_parse_options \
+        ${func_options_prep_result+"$func_options_prep_result"}
+    eval func_validate_options \
+        ${func_parse_options_result+"$func_parse_options_result"}
 
-    if ${opt_dry_run-false}; then :; else
-      eval "$my_cmd"
-      my_status=$?
-      if test "$my_status" -eq 0; then :; else
-	eval "(exit $my_status); $my_fail_exp"
-      fi
-    fi
+    eval func_run_hooks func_options \
+        ${func_validate_options_result+"$func_validate_options_result"}
+
+    # save modified positional parameters for caller
+    func_options_result=$func_run_hooks_result
 }
 
 
-# func_show_eval_locale cmd [fail_exp]
-# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
-# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
-# is given, then evaluate it.  Use the saved locale for evaluation.
-func_show_eval_locale ()
+# func_options_prep [ARG]...
+# --------------------------
+# All initialisations required before starting the option parse loop.
+# Note that when calling hook functions, we pass through the list of
+# positional parameters.  If a hook function modifies that list, and
+# needs to propogate that back to rest of this script, then the complete
+# modified list must be put in 'func_run_hooks_result' before
+# returning.
+func_hookable func_options_prep
+func_options_prep ()
 {
-    my_cmd="$1"
-    my_fail_exp="${2-:}"
+    $debug_cmd
 
-    ${opt_silent-false} || {
-      func_quote_for_expand "$my_cmd"
-      eval "func_echo $func_quote_for_expand_result"
-    }
+    # Option defaults:
+    opt_verbose=false
+    opt_warning_types=
 
-    if ${opt_dry_run-false}; then :; else
-      eval "$lt_user_locale
-	    $my_cmd"
-      my_status=$?
-      eval "$lt_safe_locale"
-      if test "$my_status" -eq 0; then :; else
-	eval "(exit $my_status); $my_fail_exp"
-      fi
-    fi
+    func_run_hooks func_options_prep ${1+"$@"}
+
+    # save modified positional parameters for caller
+    func_options_prep_result=$func_run_hooks_result
 }
 
-# func_tr_sh
-# Turn $1 into a string suitable for a shell variable name.
-# Result is stored in $func_tr_sh_result.  All characters
-# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
-# if $1 begins with a digit, a '_' is prepended as well.
-func_tr_sh ()
+
+# func_parse_options [ARG]...
+# ---------------------------
+# The main option parsing loop.
+func_hookable func_parse_options
+func_parse_options ()
 {
-  case $1 in
-  [0-9]* | *[!a-zA-Z0-9_]*)
-    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
-    ;;
-  * )
-    func_tr_sh_result=$1
-    ;;
-  esac
+    $debug_cmd
+
+    func_parse_options_result=
+
+    # this just eases exit handling
+    while test $# -gt 0; do
+      # Defer to hook functions for initial option parsing, so they
+      # get priority in the event of reusing an option name.
+      func_run_hooks func_parse_options ${1+"$@"}
+
+      # Adjust func_parse_options positional parameters to match
+      eval set dummy "$func_run_hooks_result"; shift
+
+      # Break out of the loop if we already parsed every option.
+      test $# -gt 0 || break
+
+      _G_opt=$1
+      shift
+      case $_G_opt in
+        --debug|-x)   debug_cmd='set -x'
+                      func_echo "enabling shell trace mode"
+                      $debug_cmd
+                      ;;
+
+        --no-warnings|--no-warning|--no-warn)
+                      set dummy --warnings none ${1+"$@"}
+                      shift
+		      ;;
+
+        --warnings|--warning|-W)
+                      test $# = 0 && func_missing_arg $_G_opt && break
+                      case " $warning_categories $1" in
+                        *" $1 "*)
+                          # trailing space prevents matching last $1 above
+                          func_append_uniq opt_warning_types " $1"
+                          ;;
+                        *all)
+                          opt_warning_types=$warning_categories
+                          ;;
+                        *none)
+                          opt_warning_types=none
+                          warning_func=:
+                          ;;
+                        *error)
+                          opt_warning_types=$warning_categories
+                          warning_func=func_fatal_error
+                          ;;
+                        *)
+                          func_fatal_error \
+                             "unsupported warning category: '$1'"
+                          ;;
+                      esac
+                      shift
+                      ;;
+
+        --verbose|-v) opt_verbose=: ;;
+        --version)    func_version ;;
+        -\?|-h)       func_usage ;;
+        --help)       func_help ;;
+
+	# Separate optargs to long options (plugins may need this):
+	--*=*)        func_split_equals "$_G_opt"
+	              set dummy "$func_split_equals_lhs" \
+                          "$func_split_equals_rhs" ${1+"$@"}
+                      shift
+                      ;;
+
+       # Separate optargs to short options:
+        -W*)
+                      func_split_short_opt "$_G_opt"
+                      set dummy "$func_split_short_opt_name" \
+                          "$func_split_short_opt_arg" ${1+"$@"}
+                      shift
+                      ;;
+
+        # Separate non-argument short options:
+        -\?*|-h*|-v*|-x*)
+                      func_split_short_opt "$_G_opt"
+                      set dummy "$func_split_short_opt_name" \
+                          "-$func_split_short_opt_arg" ${1+"$@"}
+                      shift
+                      ;;
+
+        --)           break ;;
+        -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
+        *)            set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
+      esac
+    done
+
+    # save modified positional parameters for caller
+    func_quote_for_eval ${1+"$@"}
+    func_parse_options_result=$func_quote_for_eval_result
 }
 
 
-# func_version
-# Echo version message to standard output and exit.
-func_version ()
+# func_validate_options [ARG]...
+# ------------------------------
+# Perform any sanity checks on option settings and/or unconsumed
+# arguments.
+func_hookable func_validate_options
+func_validate_options ()
 {
-    $opt_debug
+    $debug_cmd
 
-    $SED -n '/(C)/!b go
-	:more
-	/\./!{
-	  N
-	  s/\n# / /
-	  b more
-	}
-	:go
-	/^# '$PROGRAM' (GNU /,/# warranty; / {
-        s/^# //
-	s/^# *$//
-        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
-        p
-     }' < "$progpath"
-     exit $?
+    # Display all warnings if -W was not given.
+    test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
+
+    func_run_hooks func_validate_options ${1+"$@"}
+
+    # Bail if the options were screwed!
+    $exit_cmd $EXIT_FAILURE
+
+    # save modified positional parameters for caller
+    func_validate_options_result=$func_run_hooks_result
 }
 
-# func_usage
-# Echo short help message to standard output and exit.
-func_usage ()
+
+
+## ----------------- ##
+## Helper functions. ##
+## ----------------- ##
+
+# This section contains the helper functions used by the rest of the
+# hookable option parser framework in ascii-betical order.
+
+
+# func_fatal_help ARG...
+# ----------------------
+# Echo program name prefixed message to standard error, followed by
+# a help hint, and exit.
+func_fatal_help ()
 {
-    $opt_debug
+    $debug_cmd
 
-    $SED -n '/^# Usage:/,/^#  *.*--help/ {
-        s/^# //
-	s/^# *$//
-	s/\$progname/'$progname'/
-	p
-    }' < "$progpath"
-    echo
-    $ECHO "run \`$progname --help | more' for full usage"
-    exit $?
+    eval \$ECHO \""Usage: $usage"\"
+    eval \$ECHO \""$fatal_help"\"
+    func_error ${1+"$@"}
+    exit $EXIT_FAILURE
 }
 
-# func_help [NOEXIT]
-# Echo long help message to standard output and exit,
-# unless 'noexit' is passed as argument.
+
+# func_help
+# ---------
+# Echo long help message to standard output and exit.
 func_help ()
 {
-    $opt_debug
-
-    $SED -n '/^# Usage:/,/# Report bugs to/ {
-	:print
-        s/^# //
-	s/^# *$//
-	s*\$progname*'$progname'*
-	s*\$host*'"$host"'*
-	s*\$SHELL*'"$SHELL"'*
-	s*\$LTCC*'"$LTCC"'*
-	s*\$LTCFLAGS*'"$LTCFLAGS"'*
-	s*\$LD*'"$LD"'*
-	s/\$with_gnu_ld/'"$with_gnu_ld"'/
-	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
-	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
-	p
-	d
-     }
-     /^# .* home page:/b print
-     /^# General help using/b print
-     ' < "$progpath"
-    ret=$?
-    if test -z "$1"; then
-      exit $ret
-    fi
+    $debug_cmd
+
+    func_usage_message
+    $ECHO "$long_help_message"
+    exit 0
 }
 
-# func_missing_arg argname
+
+# func_missing_arg ARGNAME
+# ------------------------
 # Echo program name prefixed message to standard error and set global
 # exit_cmd.
 func_missing_arg ()
 {
-    $opt_debug
+    $debug_cmd
 
-    func_error "missing argument for $1."
+    func_error "Missing argument for '$1'."
     exit_cmd=exit
 }
 
 
-# func_split_short_opt shortopt
+# func_split_equals STRING
+# ------------------------
+# Set func_split_equals_lhs and func_split_equals_rhs shell variables after
+# splitting STRING at the '=' sign.
+test -z "$_G_HAVE_XSI_OPS" \
+    && (eval 'x=a/b/c;
+      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
+    && _G_HAVE_XSI_OPS=yes
+
+if test yes = "$_G_HAVE_XSI_OPS"
+then
+  # This is an XSI compatible shell, allowing a faster implementation...
+  eval 'func_split_equals ()
+  {
+      $debug_cmd
+
+      func_split_equals_lhs=${1%%=*}
+      func_split_equals_rhs=${1#*=}
+      test "x$func_split_equals_lhs" = "x$1" \
+        && func_split_equals_rhs=
+  }'
+else
+  # ...otherwise fall back to using expr, which is often a shell builtin.
+  func_split_equals ()
+  {
+      $debug_cmd
+
+      func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
+      func_split_equals_rhs=
+      test "x$func_split_equals_lhs" = "x$1" \
+        || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
+  }
+fi #func_split_equals
+
+
+# func_split_short_opt SHORTOPT
+# -----------------------------
 # Set func_split_short_opt_name and func_split_short_opt_arg shell
 # variables after splitting SHORTOPT after the 2nd character.
-func_split_short_opt ()
+if test yes = "$_G_HAVE_XSI_OPS"
+then
+  # This is an XSI compatible shell, allowing a faster implementation...
+  eval 'func_split_short_opt ()
+  {
+      $debug_cmd
+
+      func_split_short_opt_arg=${1#??}
+      func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
+  }'
+else
+  # ...otherwise fall back to using expr, which is often a shell builtin.
+  func_split_short_opt ()
+  {
+      $debug_cmd
+
+      func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
+      func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
+  }
+fi #func_split_short_opt
+
+
+# func_usage
+# ----------
+# Echo short help message to standard output and exit.
+func_usage ()
 {
-    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
-    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
+    $debug_cmd
 
-    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
-    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
-} # func_split_short_opt may be replaced by extended shell implementation
+    func_usage_message
+    $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
+    exit 0
+}
 
 
-# func_split_long_opt longopt
-# Set func_split_long_opt_name and func_split_long_opt_arg shell
-# variables after splitting LONGOPT at the `=' sign.
-func_split_long_opt ()
+# func_usage_message
+# ------------------
+# Echo short help message to standard output.
+func_usage_message ()
 {
-    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
-    my_sed_long_arg='1s/^--[^=]*=//'
+    $debug_cmd
 
-    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
-    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
-} # func_split_long_opt may be replaced by extended shell implementation
+    eval \$ECHO \""Usage: $usage"\"
+    echo
+    $SED -n 's|^# ||
+        /^Written by/{
+          x;p;x
+        }
+	h
+	/^Written by/q' < "$progpath"
+    echo
+    eval \$ECHO \""$usage_message"\"
+}
 
-exit_cmd=:
 
+# func_version
+# ------------
+# Echo version message to standard output and exit.
+func_version ()
+{
+    $debug_cmd
 
+    printf '%s\n' "$progname $scriptversion"
+    $SED -n '
+        /(C)/!b go
+        :more
+        /\./!{
+          N
+          s|\n# | |
+          b more
+        }
+        :go
+        /^# Written by /,/# warranty; / {
+          s|^# ||
+          s|^# *$||
+          s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
+          p
+        }
+        /^# Written by / {
+          s|^# ||
+          p
+        }
+        /^warranty; /q' < "$progpath"
 
+    exit $?
+}
 
 
-magic="%%%MAGIC variable%%%"
-magic_exe="%%%MAGIC EXE variable%%%"
+# Local variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'before-save-hook 'time-stamp)
+# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
+# time-stamp-time-zone: "UTC"
+# End:
 
-# Global variables.
-nonopt=
-preserve_args=
-lo2o="s/\\.lo\$/.${objext}/"
-o2lo="s/\\.${objext}\$/.lo/"
-extracted_archives=
-extracted_serial=0
+# Set a version string.
+scriptversion='(GNU libtool) 2.4.6'
 
-# If this variable is set in any of the actions, the command in it
-# will be execed at the end.  This prevents here-documents from being
-# left over by shells.
-exec_cmd=
 
-# func_append var value
-# Append VALUE to the end of shell variable VAR.
-func_append ()
+# func_echo ARG...
+# ----------------
+# Libtool also displays the current mode in messages, so override
+# funclib.sh func_echo with this custom definition.
+func_echo ()
 {
-    eval "${1}=\$${1}\${2}"
-} # func_append may be replaced by extended shell implementation
+    $debug_cmd
 
-# func_append_quoted var value
-# Quote VALUE and append to the end of shell variable VAR, separated
-# by a space.
-func_append_quoted ()
-{
-    func_quote_for_eval "${2}"
-    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
-} # func_append_quoted may be replaced by extended shell implementation
+    _G_message=$*
+
+    func_echo_IFS=$IFS
+    IFS=$nl
+    for _G_line in $_G_message; do
+      IFS=$func_echo_IFS
+      $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
+    done
+    IFS=$func_echo_IFS
+}
 
 
-# func_arith arithmetic-term...
-func_arith ()
+# func_warning ARG...
+# -------------------
+# Libtool warnings are not categorized, so override funclib.sh
+# func_warning with this simpler definition.
+func_warning ()
 {
-    func_arith_result=`expr "${@}"`
-} # func_arith may be replaced by extended shell implementation
+    $debug_cmd
+
+    $warning_func ${1+"$@"}
+}
+
 
+## ---------------- ##
+## Options parsing. ##
+## ---------------- ##
+
+# Hook in the functions to make sure our own options are parsed during
+# the option parsing loop.
+
+usage='$progpath [OPTION]... [MODE-ARG]...'
+
+# Short help message in response to '-h'.
+usage_message="Options:
+       --config             show all configuration variables
+       --debug              enable verbose shell tracing
+   -n, --dry-run            display commands without modifying any files
+       --features           display basic configuration information and exit
+       --mode=MODE          use operation mode MODE
+       --no-warnings        equivalent to '-Wnone'
+       --preserve-dup-deps  don't remove duplicate dependency libraries
+       --quiet, --silent    don't print informational messages
+       --tag=TAG            use configuration variables from tag TAG
+   -v, --verbose            print more informational messages than default
+       --version            print version information
+   -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [all]
+   -h, --help, --help-all   print short, long, or detailed help message
+"
 
-# func_len string
-# STRING may not start with a hyphen.
-func_len ()
+# Additional text appended to 'usage_message' in response to '--help'.
+func_help ()
 {
-    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
-} # func_len may be replaced by extended shell implementation
+    $debug_cmd
+
+    func_usage_message
+    $ECHO "$long_help_message
+
+MODE must be one of the following:
+
+       clean           remove files from the build directory
+       compile         compile a source file into a libtool object
+       execute         automatically set library path, then run a program
+       finish          complete the installation of libtool libraries
+       install         install libraries or executables
+       link            create a library or an executable
+       uninstall       remove libraries from an installed directory
+
+MODE-ARGS vary depending on the MODE.  When passed as first option,
+'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
+Try '$progname --help --mode=MODE' for a more detailed description of MODE.
+
+When reporting a bug, please describe a test case to reproduce it and
+include the following information:
+
+       host-triplet:   $host
+       shell:          $SHELL
+       compiler:       $LTCC
+       compiler flags: $LTCFLAGS
+       linker:         $LD (gnu? $with_gnu_ld)
+       version:        $progname (GNU libtool) 2.4.6
+       automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
+       autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
+
+Report bugs to <bug-libtool at gnu.org>.
+GNU libtool home page: <http://www.gnu.org/software/libtool/>.
+General help using GNU software: <http://www.gnu.org/gethelp/>."
+    exit 0
+}
 
 
-# func_lo2o object
-func_lo2o ()
-{
-    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
-} # func_lo2o may be replaced by extended shell implementation
+# func_lo2o OBJECT-NAME
+# ---------------------
+# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
+# object suffix.
 
+lo2o=s/\\.lo\$/.$objext/
+o2lo=s/\\.$objext\$/.lo/
 
-# func_xform libobj-or-source
-func_xform ()
-{
-    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
-} # func_xform may be replaced by extended shell implementation
+if test yes = "$_G_HAVE_XSI_OPS"; then
+  eval 'func_lo2o ()
+  {
+    case $1 in
+      *.lo) func_lo2o_result=${1%.lo}.$objext ;;
+      *   ) func_lo2o_result=$1               ;;
+    esac
+  }'
+
+  # func_xform LIBOBJ-OR-SOURCE
+  # ---------------------------
+  # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
+  # suffix to a '.lo' libtool-object suffix.
+  eval 'func_xform ()
+  {
+    func_xform_result=${1%.*}.lo
+  }'
+else
+  # ...otherwise fall back to using sed.
+  func_lo2o ()
+  {
+    func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
+  }
+
+  func_xform ()
+  {
+    func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
+  }
+fi
 
 
-# func_fatal_configuration arg...
+# func_fatal_configuration ARG...
+# -------------------------------
 # Echo program name prefixed message to standard error, followed by
 # a configuration failure hint, and exit.
 func_fatal_configuration ()
 {
-    func_error ${1+"$@"}
-    func_error "See the $PACKAGE documentation for more information."
-    func_fatal_error "Fatal configuration error."
+    func__fatal_error ${1+"$@"} \
+      "See the $PACKAGE documentation for more information." \
+      "Fatal configuration error."
 }
 
 
 # func_config
+# -----------
 # Display the configuration for all the tags in this script.
 func_config ()
 {
@@ -915,17 +2149,19 @@ func_config ()
     exit $?
 }
 
+
 # func_features
+# -------------
 # Display the features supported by this script.
 func_features ()
 {
     echo "host: $host"
-    if test "$build_libtool_libs" = yes; then
+    if test yes = "$build_libtool_libs"; then
       echo "enable shared libraries"
     else
       echo "disable shared libraries"
     fi
-    if test "$build_old_libs" = yes; then
+    if test yes = "$build_old_libs"; then
       echo "enable static libraries"
     else
       echo "disable static libraries"
@@ -934,289 +2170,297 @@ func_features ()
     exit $?
 }
 
-# func_enable_tag tagname
+
+# func_enable_tag TAGNAME
+# -----------------------
 # Verify that TAGNAME is valid, and either flag an error and exit, or
 # enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
 # variable here.
 func_enable_tag ()
 {
-  # Global variable:
-  tagname="$1"
+    # Global variable:
+    tagname=$1
 
-  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
-  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
-  sed_extractcf="/$re_begincf/,/$re_endcf/p"
+    re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
+    re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
+    sed_extractcf=/$re_begincf/,/$re_endcf/p
 
-  # Validate tagname.
-  case $tagname in
-    *[!-_A-Za-z0-9,/]*)
-      func_fatal_error "invalid tag name: $tagname"
-      ;;
-  esac
+    # Validate tagname.
+    case $tagname in
+      *[!-_A-Za-z0-9,/]*)
+        func_fatal_error "invalid tag name: $tagname"
+        ;;
+    esac
 
-  # Don't test for the "default" C tag, as we know it's
-  # there but not specially marked.
-  case $tagname in
-    CC) ;;
+    # Don't test for the "default" C tag, as we know it's
+    # there but not specially marked.
+    case $tagname in
+        CC) ;;
     *)
-      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
-	taglist="$taglist $tagname"
-
-	# Evaluate the configuration.  Be careful to quote the path
-	# and the sed script, to avoid splitting on whitespace, but
-	# also don't use non-portable quotes within backquotes within
-	# quotes we have to do it in 2 steps:
-	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
-	eval "$extractedcf"
-      else
-	func_error "ignoring unknown tag $tagname"
-      fi
-      ;;
-  esac
+        if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
+	  taglist="$taglist $tagname"
+
+	  # Evaluate the configuration.  Be careful to quote the path
+	  # and the sed script, to avoid splitting on whitespace, but
+	  # also don't use non-portable quotes within backquotes within
+	  # quotes we have to do it in 2 steps:
+	  extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
+	  eval "$extractedcf"
+        else
+	  func_error "ignoring unknown tag $tagname"
+        fi
+        ;;
+    esac
 }
 
+
 # func_check_version_match
+# ------------------------
 # Ensure that we are using m4 macros, and libtool script from the same
 # release of libtool.
 func_check_version_match ()
 {
-  if test "$package_revision" != "$macro_revision"; then
-    if test "$VERSION" != "$macro_version"; then
-      if test -z "$macro_version"; then
-        cat >&2 <<_LT_EOF
+    if test "$package_revision" != "$macro_revision"; then
+      if test "$VERSION" != "$macro_version"; then
+        if test -z "$macro_version"; then
+          cat >&2 <<_LT_EOF
 $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
 $progname: definition of this LT_INIT comes from an older release.
 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
 $progname: and run autoconf again.
 _LT_EOF
-      else
-        cat >&2 <<_LT_EOF
+        else
+          cat >&2 <<_LT_EOF
 $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
 $progname: and run autoconf again.
 _LT_EOF
-      fi
-    else
-      cat >&2 <<_LT_EOF
+        fi
+      else
+        cat >&2 <<_LT_EOF
 $progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
 $progname: of $PACKAGE $VERSION and run autoconf again.
 _LT_EOF
-    fi
+      fi
 
-    exit $EXIT_MISMATCH
-  fi
+      exit $EXIT_MISMATCH
+    fi
 }
 
 
-# Shorthand for --mode=foo, only valid as the first argument
-case $1 in
-clean|clea|cle|cl)
-  shift; set dummy --mode clean ${1+"$@"}; shift
-  ;;
-compile|compil|compi|comp|com|co|c)
-  shift; set dummy --mode compile ${1+"$@"}; shift
-  ;;
-execute|execut|execu|exec|exe|ex|e)
-  shift; set dummy --mode execute ${1+"$@"}; shift
-  ;;
-finish|finis|fini|fin|fi|f)
-  shift; set dummy --mode finish ${1+"$@"}; shift
-  ;;
-install|instal|insta|inst|ins|in|i)
-  shift; set dummy --mode install ${1+"$@"}; shift
-  ;;
-link|lin|li|l)
-  shift; set dummy --mode link ${1+"$@"}; shift
-  ;;
-uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
-  shift; set dummy --mode uninstall ${1+"$@"}; shift
-  ;;
-esac
+# libtool_options_prep [ARG]...
+# -----------------------------
+# Preparation for options parsed by libtool.
+libtool_options_prep ()
+{
+    $debug_mode
 
+    # Option defaults:
+    opt_config=false
+    opt_dlopen=
+    opt_dry_run=false
+    opt_help=false
+    opt_mode=
+    opt_preserve_dup_deps=false
+    opt_quiet=false
 
+    nonopt=
+    preserve_args=
 
-# Option defaults:
-opt_debug=:
-opt_dry_run=false
-opt_config=false
-opt_preserve_dup_deps=false
-opt_features=false
-opt_finish=false
-opt_help=false
-opt_help_all=false
-opt_silent=:
-opt_warning=:
-opt_verbose=:
-opt_silent=false
-opt_verbose=false
+    # Shorthand for --mode=foo, only valid as the first argument
+    case $1 in
+    clean|clea|cle|cl)
+      shift; set dummy --mode clean ${1+"$@"}; shift
+      ;;
+    compile|compil|compi|comp|com|co|c)
+      shift; set dummy --mode compile ${1+"$@"}; shift
+      ;;
+    execute|execut|execu|exec|exe|ex|e)
+      shift; set dummy --mode execute ${1+"$@"}; shift
+      ;;
+    finish|finis|fini|fin|fi|f)
+      shift; set dummy --mode finish ${1+"$@"}; shift
+      ;;
+    install|instal|insta|inst|ins|in|i)
+      shift; set dummy --mode install ${1+"$@"}; shift
+      ;;
+    link|lin|li|l)
+      shift; set dummy --mode link ${1+"$@"}; shift
+      ;;
+    uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
+      shift; set dummy --mode uninstall ${1+"$@"}; shift
+      ;;
+    esac
+
+    # Pass back the list of options.
+    func_quote_for_eval ${1+"$@"}
+    libtool_options_prep_result=$func_quote_for_eval_result
+}
+func_add_hook func_options_prep libtool_options_prep
 
 
-# Parse options once, thoroughly.  This comes as soon as possible in the
-# script to make things like `--version' happen as quickly as we can.
+# libtool_parse_options [ARG]...
+# ---------------------------------
+# Provide handling for libtool specific options.
+libtool_parse_options ()
 {
-  # this just eases exit handling
-  while test $# -gt 0; do
-    opt="$1"
-    shift
-    case $opt in
-      --debug|-x)	opt_debug='set -x'
-			func_echo "enabling shell trace mode"
-			$opt_debug
-			;;
-      --dry-run|--dryrun|-n)
-			opt_dry_run=:
-			;;
-      --config)
-			opt_config=:
-func_config
-			;;
-      --dlopen|-dlopen)
-			optarg="$1"
-			opt_dlopen="${opt_dlopen+$opt_dlopen
-}$optarg"
-			shift
-			;;
-      --preserve-dup-deps)
-			opt_preserve_dup_deps=:
-			;;
-      --features)
-			opt_features=:
-func_features
-			;;
-      --finish)
-			opt_finish=:
-set dummy --mode finish ${1+"$@"}; shift
-			;;
-      --help)
-			opt_help=:
-			;;
-      --help-all)
-			opt_help_all=:
-opt_help=': help-all'
-			;;
-      --mode)
-			test $# = 0 && func_missing_arg $opt && break
-			optarg="$1"
-			opt_mode="$optarg"
-case $optarg in
-  # Valid mode arguments:
-  clean|compile|execute|finish|install|link|relink|uninstall) ;;
-
-  # Catch anything else as an error
-  *) func_error "invalid argument for $opt"
-     exit_cmd=exit
-     break
-     ;;
-esac
-			shift
-			;;
-      --no-silent|--no-quiet)
-			opt_silent=false
-func_append preserve_args " $opt"
-			;;
-      --no-warning|--no-warn)
-			opt_warning=false
-func_append preserve_args " $opt"
-			;;
-      --no-verbose)
-			opt_verbose=false
-func_append preserve_args " $opt"
-			;;
-      --silent|--quiet)
-			opt_silent=:
-func_append preserve_args " $opt"
-        opt_verbose=false
-			;;
-      --verbose|-v)
-			opt_verbose=:
-func_append preserve_args " $opt"
-opt_silent=false
-			;;
-      --tag)
-			test $# = 0 && func_missing_arg $opt && break
-			optarg="$1"
-			opt_tag="$optarg"
-func_append preserve_args " $opt $optarg"
-func_enable_tag "$optarg"
-			shift
-			;;
-
-      -\?|-h)		func_usage				;;
-      --help)		func_help				;;
-      --version)	func_version				;;
-
-      # Separate optargs to long options:
-      --*=*)
-			func_split_long_opt "$opt"
-			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
-			shift
-			;;
-
-      # Separate non-argument short options:
-      -\?*|-h*|-n*|-v*)
-			func_split_short_opt "$opt"
-			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
-			shift
-			;;
-
-      --)		break					;;
-      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
-      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
-    esac
-  done
+    $debug_cmd
 
-  # Validate options:
+    # Perform our own loop to consume as many options as possible in
+    # each iteration.
+    while test $# -gt 0; do
+      _G_opt=$1
+      shift
+      case $_G_opt in
+        --dry-run|--dryrun|-n)
+                        opt_dry_run=:
+                        ;;
+
+        --config)       func_config ;;
+
+        --dlopen|-dlopen)
+                        opt_dlopen="${opt_dlopen+$opt_dlopen
+}$1"
+                        shift
+                        ;;
+
+        --preserve-dup-deps)
+                        opt_preserve_dup_deps=: ;;
+
+        --features)     func_features ;;
+
+        --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
+
+        --help)         opt_help=: ;;
+
+        --help-all)     opt_help=': help-all' ;;
+
+        --mode)         test $# = 0 && func_missing_arg $_G_opt && break
+                        opt_mode=$1
+                        case $1 in
+                          # Valid mode arguments:
+                          clean|compile|execute|finish|install|link|relink|uninstall) ;;
+
+                          # Catch anything else as an error
+                          *) func_error "invalid argument for $_G_opt"
+                             exit_cmd=exit
+                             break
+                             ;;
+                        esac
+                        shift
+                        ;;
+
+        --no-silent|--no-quiet)
+                        opt_quiet=false
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+        --no-warnings|--no-warning|--no-warn)
+                        opt_warning=false
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+        --no-verbose)
+                        opt_verbose=false
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+        --silent|--quiet)
+                        opt_quiet=:
+                        opt_verbose=false
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+        --tag)          test $# = 0 && func_missing_arg $_G_opt && break
+                        opt_tag=$1
+                        func_append preserve_args " $_G_opt $1"
+                        func_enable_tag "$1"
+                        shift
+                        ;;
+
+        --verbose|-v)   opt_quiet=false
+                        opt_verbose=:
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+	# An option not handled by this hook function:
+        *)		set dummy "$_G_opt" ${1+"$@"};	shift; break  ;;
+      esac
+    done
 
-  # save first non-option argument
-  if test "$#" -gt 0; then
-    nonopt="$opt"
-    shift
-  fi
 
-  # preserve --debug
-  test "$opt_debug" = : || func_append preserve_args " --debug"
+    # save modified positional parameters for caller
+    func_quote_for_eval ${1+"$@"}
+    libtool_parse_options_result=$func_quote_for_eval_result
+}
+func_add_hook func_parse_options libtool_parse_options
 
-  case $host in
-    *cygwin* | *mingw* | *pw32* | *cegcc*)
-      # don't eliminate duplications in $postdeps and $predeps
-      opt_duplicate_compiler_generated_deps=:
-      ;;
-    *)
-      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
-      ;;
-  esac
 
-  $opt_help || {
-    # Sanity checks first:
-    func_check_version_match
 
-    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
-      func_fatal_configuration "not configured to build any kind of library"
+# libtool_validate_options [ARG]...
+# ---------------------------------
+# Perform any sanity checks on option settings and/or unconsumed
+# arguments.
+libtool_validate_options ()
+{
+    # save first non-option argument
+    if test 0 -lt $#; then
+      nonopt=$1
+      shift
     fi
 
-    # Darwin sucks
-    eval std_shrext=\"$shrext_cmds\"
+    # preserve --debug
+    test : = "$debug_cmd" || func_append preserve_args " --debug"
 
-    # Only execute mode is allowed to have -dlopen flags.
-    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
-      func_error "unrecognized option \`-dlopen'"
-      $ECHO "$help" 1>&2
-      exit $EXIT_FAILURE
-    fi
+    case $host in
+      # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
+      # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
+      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
+        # don't eliminate duplications in $postdeps and $predeps
+        opt_duplicate_compiler_generated_deps=:
+        ;;
+      *)
+        opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
+        ;;
+    esac
 
-    # Change the help message to a mode-specific one.
-    generic_help="$help"
-    help="Try \`$progname --help --mode=$opt_mode' for more information."
-  }
+    $opt_help || {
+      # Sanity checks first:
+      func_check_version_match
 
+      test yes != "$build_libtool_libs" \
+        && test yes != "$build_old_libs" \
+        && func_fatal_configuration "not configured to build any kind of library"
 
-  # Bail if the options were screwed
-  $exit_cmd $EXIT_FAILURE
+      # Darwin sucks
+      eval std_shrext=\"$shrext_cmds\"
+
+      # Only execute mode is allowed to have -dlopen flags.
+      if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
+        func_error "unrecognized option '-dlopen'"
+        $ECHO "$help" 1>&2
+        exit $EXIT_FAILURE
+      fi
+
+      # Change the help message to a mode-specific one.
+      generic_help=$help
+      help="Try '$progname --help --mode=$opt_mode' for more information."
+    }
+
+    # Pass back the unparsed argument list
+    func_quote_for_eval ${1+"$@"}
+    libtool_validate_options_result=$func_quote_for_eval_result
 }
+func_add_hook func_validate_options libtool_validate_options
+
 
+# Process options as early as possible so that --help and --version
+# can return quickly.
+func_options ${1+"$@"}
+eval set dummy "$func_options_result"; shift
 
 
 
@@ -1224,24 +2468,52 @@ func_enable_tag "$optarg"
 ##    Main.    ##
 ## ----------- ##
 
+magic='%%%MAGIC variable%%%'
+magic_exe='%%%MAGIC EXE variable%%%'
+
+# Global variables.
+extracted_archives=
+extracted_serial=0
+
+# If this variable is set in any of the actions, the command in it
+# will be execed at the end.  This prevents here-documents from being
+# left over by shells.
+exec_cmd=
+
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+  eval 'cat <<_LTECHO_EOF
+$1
+_LTECHO_EOF'
+}
+
+# func_generated_by_libtool
+# True iff stdin has been generated by Libtool. This function is only
+# a basic sanity check; it will hardly flush out determined imposters.
+func_generated_by_libtool_p ()
+{
+  $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
+}
+
 # func_lalib_p file
-# True iff FILE is a libtool `.la' library or `.lo' object file.
+# True iff FILE is a libtool '.la' library or '.lo' object file.
 # This function is only a basic sanity check; it will hardly flush out
 # determined imposters.
 func_lalib_p ()
 {
     test -f "$1" &&
-      $SED -e 4q "$1" 2>/dev/null \
-        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
+      $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
 }
 
 # func_lalib_unsafe_p file
-# True iff FILE is a libtool `.la' library or `.lo' object file.
+# True iff FILE is a libtool '.la' library or '.lo' object file.
 # This function implements the same check as func_lalib_p without
 # resorting to external programs.  To this end, it redirects stdin and
 # closes it afterwards, without saving the original file descriptor.
 # As a safety measure, use it only where a negative result would be
-# fatal anyway.  Works if `file' does not exist.
+# fatal anyway.  Works if 'file' does not exist.
 func_lalib_unsafe_p ()
 {
     lalib_p=no
@@ -1249,13 +2521,13 @@ func_lalib_unsafe_p ()
 	for lalib_p_l in 1 2 3 4
 	do
 	    read lalib_p_line
-	    case "$lalib_p_line" in
+	    case $lalib_p_line in
 		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
 	    esac
 	done
 	exec 0<&5 5<&-
     fi
-    test "$lalib_p" = yes
+    test yes = "$lalib_p"
 }
 
 # func_ltwrapper_script_p file
@@ -1264,7 +2536,8 @@ func_lalib_unsafe_p ()
 # determined imposters.
 func_ltwrapper_script_p ()
 {
-    func_lalib_p "$1"
+    test -f "$1" &&
+      $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
 }
 
 # func_ltwrapper_executable_p file
@@ -1289,7 +2562,7 @@ func_ltwrapper_scriptname ()
 {
     func_dirname_and_basename "$1" "" "."
     func_stripname '' '.exe' "$func_basename_result"
-    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
+    func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
 }
 
 # func_ltwrapper_p file
@@ -1308,11 +2581,13 @@ func_ltwrapper_p ()
 # FAIL_CMD may read-access the current command in variable CMD!
 func_execute_cmds ()
 {
-    $opt_debug
+    $debug_cmd
+
     save_ifs=$IFS; IFS='~'
     for cmd in $1; do
-      IFS=$save_ifs
+      IFS=$sp$nl
       eval cmd=\"$cmd\"
+      IFS=$save_ifs
       func_show_eval "$cmd" "${2-:}"
     done
     IFS=$save_ifs
@@ -1324,10 +2599,11 @@ func_execute_cmds ()
 # Note that it is not necessary on cygwin/mingw to append a dot to
 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
 # behavior happens only for exec(3), not for open(2)!  Also, sourcing
-# `FILE.' does not work on cygwin managed mounts.
+# 'FILE.' does not work on cygwin managed mounts.
 func_source ()
 {
-    $opt_debug
+    $debug_cmd
+
     case $1 in
     */* | *\\*)	. "$1" ;;
     *)		. "./$1" ;;
@@ -1354,10 +2630,10 @@ func_resolve_sysroot ()
 # store the result into func_replace_sysroot_result.
 func_replace_sysroot ()
 {
-  case "$lt_sysroot:$1" in
+  case $lt_sysroot:$1 in
   ?*:"$lt_sysroot"*)
     func_stripname "$lt_sysroot" '' "$1"
-    func_replace_sysroot_result="=$func_stripname_result"
+    func_replace_sysroot_result='='$func_stripname_result
     ;;
   *)
     # Including no sysroot.
@@ -1374,7 +2650,8 @@ func_replace_sysroot ()
 # arg is usually of the form 'gcc ...'
 func_infer_tag ()
 {
-    $opt_debug
+    $debug_cmd
+
     if test -n "$available_tags" && test -z "$tagname"; then
       CC_quoted=
       for arg in $CC; do
@@ -1393,7 +2670,7 @@ func_infer_tag ()
 	for z in $available_tags; do
 	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
 	    # Evaluate the configuration.
-	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
+	    eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
 	    CC_quoted=
 	    for arg in $CC; do
 	      # Double-quote args containing other shell metacharacters.
@@ -1418,7 +2695,7 @@ func_infer_tag ()
 	# line option must be used.
 	if test -z "$tagname"; then
 	  func_echo "unable to infer tagged configuration"
-	  func_fatal_error "specify a tag with \`--tag'"
+	  func_fatal_error "specify a tag with '--tag'"
 #	else
 #	  func_verbose "using $tagname tagged configuration"
 	fi
@@ -1434,15 +2711,15 @@ func_infer_tag ()
 # but don't create it if we're doing a dry run.
 func_write_libtool_object ()
 {
-    write_libobj=${1}
-    if test "$build_libtool_libs" = yes; then
-      write_lobj=\'${2}\'
+    write_libobj=$1
+    if test yes = "$build_libtool_libs"; then
+      write_lobj=\'$2\'
     else
       write_lobj=none
     fi
 
-    if test "$build_old_libs" = yes; then
-      write_oldobj=\'${3}\'
+    if test yes = "$build_old_libs"; then
+      write_oldobj=\'$3\'
     else
       write_oldobj=none
     fi
@@ -1450,7 +2727,7 @@ func_write_libtool_object ()
     $opt_dry_run || {
       cat >${write_libobj}T <<EOF
 # $write_libobj - a libtool object file
-# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
 #
 # Please DO NOT delete this file!
 # It is necessary for linking the library.
@@ -1462,7 +2739,7 @@ pic_object=$write_lobj
 non_pic_object=$write_oldobj
 
 EOF
-      $MV "${write_libobj}T" "${write_libobj}"
+      $MV "${write_libobj}T" "$write_libobj"
     }
 }
 
@@ -1482,8 +2759,9 @@ EOF
 # be empty on error (or when ARG is empty)
 func_convert_core_file_wine_to_w32 ()
 {
-  $opt_debug
-  func_convert_core_file_wine_to_w32_result="$1"
+  $debug_cmd
+
+  func_convert_core_file_wine_to_w32_result=$1
   if test -n "$1"; then
     # Unfortunately, winepath does not exit with a non-zero error code, so we
     # are forced to check the contents of stdout. On the other hand, if the
@@ -1491,9 +2769,9 @@ func_convert_core_file_wine_to_w32 ()
     # *an error message* to stdout. So we must check for both error code of
     # zero AND non-empty stdout, which explains the odd construction:
     func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
-    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
+    if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
       func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
-        $SED -e "$lt_sed_naive_backslashify"`
+        $SED -e "$sed_naive_backslashify"`
     else
       func_convert_core_file_wine_to_w32_result=
     fi
@@ -1514,18 +2792,19 @@ func_convert_core_file_wine_to_w32 ()
 # are convertible, then the result may be empty.
 func_convert_core_path_wine_to_w32 ()
 {
-  $opt_debug
+  $debug_cmd
+
   # unfortunately, winepath doesn't convert paths, only file names
-  func_convert_core_path_wine_to_w32_result=""
+  func_convert_core_path_wine_to_w32_result=
   if test -n "$1"; then
     oldIFS=$IFS
     IFS=:
     for func_convert_core_path_wine_to_w32_f in $1; do
       IFS=$oldIFS
       func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
-      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
+      if test -n "$func_convert_core_file_wine_to_w32_result"; then
         if test -z "$func_convert_core_path_wine_to_w32_result"; then
-          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
+          func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
         else
           func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
         fi
@@ -1554,7 +2833,8 @@ func_convert_core_path_wine_to_w32 ()
 # environment variable; do not put it in $PATH.
 func_cygpath ()
 {
-  $opt_debug
+  $debug_cmd
+
   if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
     func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
     if test "$?" -ne 0; then
@@ -1563,7 +2843,7 @@ func_cygpath ()
     fi
   else
     func_cygpath_result=
-    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
+    func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
   fi
 }
 #end: func_cygpath
@@ -1574,10 +2854,11 @@ func_cygpath ()
 # result in func_convert_core_msys_to_w32_result.
 func_convert_core_msys_to_w32 ()
 {
-  $opt_debug
+  $debug_cmd
+
   # awkward: cmd appends spaces to result
   func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
-    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
+    $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
 }
 #end: func_convert_core_msys_to_w32
 
@@ -1588,13 +2869,14 @@ func_convert_core_msys_to_w32 ()
 # func_to_host_file_result to ARG1).
 func_convert_file_check ()
 {
-  $opt_debug
-  if test -z "$2" && test -n "$1" ; then
+  $debug_cmd
+
+  if test -z "$2" && test -n "$1"; then
     func_error "Could not determine host file name corresponding to"
-    func_error "  \`$1'"
+    func_error "  '$1'"
     func_error "Continuing, but uninstalled executables may not work."
     # Fallback:
-    func_to_host_file_result="$1"
+    func_to_host_file_result=$1
   fi
 }
 # end func_convert_file_check
@@ -1606,10 +2888,11 @@ func_convert_file_check ()
 # func_to_host_file_result to a simplistic fallback value (see below).
 func_convert_path_check ()
 {
-  $opt_debug
+  $debug_cmd
+
   if test -z "$4" && test -n "$3"; then
     func_error "Could not determine the host path corresponding to"
-    func_error "  \`$3'"
+    func_error "  '$3'"
     func_error "Continuing, but uninstalled executables may not work."
     # Fallback.  This is a deliberately simplistic "conversion" and
     # should not be "improved".  See libtool.info.
@@ -1618,7 +2901,7 @@ func_convert_path_check ()
       func_to_host_path_result=`echo "$3" |
         $SED -e "$lt_replace_pathsep_chars"`
     else
-      func_to_host_path_result="$3"
+      func_to_host_path_result=$3
     fi
   fi
 }
@@ -1630,9 +2913,10 @@ func_convert_path_check ()
 # and appending REPL if ORIG matches BACKPAT.
 func_convert_path_front_back_pathsep ()
 {
-  $opt_debug
+  $debug_cmd
+
   case $4 in
-  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
+  $1 ) func_to_host_path_result=$3$func_to_host_path_result
     ;;
   esac
   case $4 in
@@ -1646,7 +2930,7 @@ func_convert_path_front_back_pathsep ()
 ##################################################
 # $build to $host FILE NAME CONVERSION FUNCTIONS #
 ##################################################
-# invoked via `$to_host_file_cmd ARG'
+# invoked via '$to_host_file_cmd ARG'
 #
 # In each case, ARG is the path to be converted from $build to $host format.
 # Result will be available in $func_to_host_file_result.
@@ -1657,7 +2941,8 @@ func_convert_path_front_back_pathsep ()
 # in func_to_host_file_result.
 func_to_host_file ()
 {
-  $opt_debug
+  $debug_cmd
+
   $to_host_file_cmd "$1"
 }
 # end func_to_host_file
@@ -1669,7 +2954,8 @@ func_to_host_file ()
 # in (the comma separated) LAZY, no conversion takes place.
 func_to_tool_file ()
 {
-  $opt_debug
+  $debug_cmd
+
   case ,$2, in
     *,"$to_tool_file_cmd",*)
       func_to_tool_file_result=$1
@@ -1687,7 +2973,7 @@ func_to_tool_file ()
 # Copy ARG to func_to_host_file_result.
 func_convert_file_noop ()
 {
-  func_to_host_file_result="$1"
+  func_to_host_file_result=$1
 }
 # end func_convert_file_noop
 
@@ -1698,11 +2984,12 @@ func_convert_file_noop ()
 # func_to_host_file_result.
 func_convert_file_msys_to_w32 ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     func_convert_core_msys_to_w32 "$1"
-    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
+    func_to_host_file_result=$func_convert_core_msys_to_w32_result
   fi
   func_convert_file_check "$1" "$func_to_host_file_result"
 }
@@ -1714,8 +3001,9 @@ func_convert_file_msys_to_w32 ()
 # func_to_host_file_result.
 func_convert_file_cygwin_to_w32 ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
     # LT_CYGPATH in this case.
@@ -1731,11 +3019,12 @@ func_convert_file_cygwin_to_w32 ()
 # and a working winepath. Returns result in func_to_host_file_result.
 func_convert_file_nix_to_w32 ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     func_convert_core_file_wine_to_w32 "$1"
-    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
+    func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
   fi
   func_convert_file_check "$1" "$func_to_host_file_result"
 }
@@ -1747,12 +3036,13 @@ func_convert_file_nix_to_w32 ()
 # Returns result in func_to_host_file_result.
 func_convert_file_msys_to_cygwin ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     func_convert_core_msys_to_w32 "$1"
     func_cygpath -u "$func_convert_core_msys_to_w32_result"
-    func_to_host_file_result="$func_cygpath_result"
+    func_to_host_file_result=$func_cygpath_result
   fi
   func_convert_file_check "$1" "$func_to_host_file_result"
 }
@@ -1765,13 +3055,14 @@ func_convert_file_msys_to_cygwin ()
 # in func_to_host_file_result.
 func_convert_file_nix_to_cygwin ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
     func_convert_core_file_wine_to_w32 "$1"
     func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
-    func_to_host_file_result="$func_cygpath_result"
+    func_to_host_file_result=$func_cygpath_result
   fi
   func_convert_file_check "$1" "$func_to_host_file_result"
 }
@@ -1781,7 +3072,7 @@ func_convert_file_nix_to_cygwin ()
 #############################################
 # $build to $host PATH CONVERSION FUNCTIONS #
 #############################################
-# invoked via `$to_host_path_cmd ARG'
+# invoked via '$to_host_path_cmd ARG'
 #
 # In each case, ARG is the path to be converted from $build to $host format.
 # The result will be available in $func_to_host_path_result.
@@ -1805,10 +3096,11 @@ func_convert_file_nix_to_cygwin ()
 to_host_path_cmd=
 func_init_to_host_path_cmd ()
 {
-  $opt_debug
+  $debug_cmd
+
   if test -z "$to_host_path_cmd"; then
     func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
-    to_host_path_cmd="func_convert_path_${func_stripname_result}"
+    to_host_path_cmd=func_convert_path_$func_stripname_result
   fi
 }
 
@@ -1818,7 +3110,8 @@ func_init_to_host_path_cmd ()
 # in func_to_host_path_result.
 func_to_host_path ()
 {
-  $opt_debug
+  $debug_cmd
+
   func_init_to_host_path_cmd
   $to_host_path_cmd "$1"
 }
@@ -1829,7 +3122,7 @@ func_to_host_path ()
 # Copy ARG to func_to_host_path_result.
 func_convert_path_noop ()
 {
-  func_to_host_path_result="$1"
+  func_to_host_path_result=$1
 }
 # end func_convert_path_noop
 
@@ -1840,8 +3133,9 @@ func_convert_path_noop ()
 # func_to_host_path_result.
 func_convert_path_msys_to_w32 ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # Remove leading and trailing path separator characters from ARG.  MSYS
     # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
@@ -1849,7 +3143,7 @@ func_convert_path_msys_to_w32 ()
     func_stripname : : "$1"
     func_to_host_path_tmp1=$func_stripname_result
     func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
-    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
+    func_to_host_path_result=$func_convert_core_msys_to_w32_result
     func_convert_path_check : ";" \
       "$func_to_host_path_tmp1" "$func_to_host_path_result"
     func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
@@ -1863,8 +3157,9 @@ func_convert_path_msys_to_w32 ()
 # func_to_host_file_result.
 func_convert_path_cygwin_to_w32 ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # See func_convert_path_msys_to_w32:
     func_stripname : : "$1"
@@ -1883,14 +3178,15 @@ func_convert_path_cygwin_to_w32 ()
 # a working winepath.  Returns result in func_to_host_file_result.
 func_convert_path_nix_to_w32 ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # See func_convert_path_msys_to_w32:
     func_stripname : : "$1"
     func_to_host_path_tmp1=$func_stripname_result
     func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
-    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
+    func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
     func_convert_path_check : ";" \
       "$func_to_host_path_tmp1" "$func_to_host_path_result"
     func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
@@ -1904,15 +3200,16 @@ func_convert_path_nix_to_w32 ()
 # Returns result in func_to_host_file_result.
 func_convert_path_msys_to_cygwin ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # See func_convert_path_msys_to_w32:
     func_stripname : : "$1"
     func_to_host_path_tmp1=$func_stripname_result
     func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
     func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
-    func_to_host_path_result="$func_cygpath_result"
+    func_to_host_path_result=$func_cygpath_result
     func_convert_path_check : : \
       "$func_to_host_path_tmp1" "$func_to_host_path_result"
     func_convert_path_front_back_pathsep ":*" "*:" : "$1"
@@ -1927,8 +3224,9 @@ func_convert_path_msys_to_cygwin ()
 # func_to_host_file_result.
 func_convert_path_nix_to_cygwin ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # Remove leading and trailing path separator characters from
     # ARG. msys behavior is inconsistent here, cygpath turns them
@@ -1937,7 +3235,7 @@ func_convert_path_nix_to_cygwin ()
     func_to_host_path_tmp1=$func_stripname_result
     func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
     func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
-    func_to_host_path_result="$func_cygpath_result"
+    func_to_host_path_result=$func_cygpath_result
     func_convert_path_check : : \
       "$func_to_host_path_tmp1" "$func_to_host_path_result"
     func_convert_path_front_back_pathsep ":*" "*:" : "$1"
@@ -1946,13 +3244,31 @@ func_convert_path_nix_to_cygwin ()
 # end func_convert_path_nix_to_cygwin
 
 
+# func_dll_def_p FILE
+# True iff FILE is a Windows DLL '.def' file.
+# Keep in sync with _LT_DLL_DEF_P in libtool.m4
+func_dll_def_p ()
+{
+  $debug_cmd
+
+  func_dll_def_p_tmp=`$SED -n \
+    -e 's/^[	 ]*//' \
+    -e '/^\(;.*\)*$/d' \
+    -e 's/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p' \
+    -e q \
+    "$1"`
+  test DEF = "$func_dll_def_p_tmp"
+}
+
+
 # func_mode_compile arg...
 func_mode_compile ()
 {
-    $opt_debug
+    $debug_cmd
+
     # Get the compilation command and the source file.
     base_compile=
-    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
+    srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
     suppress_opt=yes
     suppress_output=
     arg_mode=normal
@@ -1965,12 +3281,12 @@ func_mode_compile ()
       case $arg_mode in
       arg  )
 	# do not "continue".  Instead, add this to base_compile
-	lastarg="$arg"
+	lastarg=$arg
 	arg_mode=normal
 	;;
 
       target )
-	libobj="$arg"
+	libobj=$arg
 	arg_mode=normal
 	continue
 	;;
@@ -1980,7 +3296,7 @@ func_mode_compile ()
 	case $arg in
 	-o)
 	  test -n "$libobj" && \
-	    func_fatal_error "you cannot specify \`-o' more than once"
+	    func_fatal_error "you cannot specify '-o' more than once"
 	  arg_mode=target
 	  continue
 	  ;;
@@ -2009,12 +3325,12 @@ func_mode_compile ()
 	  func_stripname '-Wc,' '' "$arg"
 	  args=$func_stripname_result
 	  lastarg=
-	  save_ifs="$IFS"; IFS=','
+	  save_ifs=$IFS; IFS=,
 	  for arg in $args; do
-	    IFS="$save_ifs"
+	    IFS=$save_ifs
 	    func_append_quoted lastarg "$arg"
 	  done
-	  IFS="$save_ifs"
+	  IFS=$save_ifs
 	  func_stripname ' ' '' "$lastarg"
 	  lastarg=$func_stripname_result
 
@@ -2027,8 +3343,8 @@ func_mode_compile ()
 	  # Accept the current argument as the source file.
 	  # The previous "srcfile" becomes the current argument.
 	  #
-	  lastarg="$srcfile"
-	  srcfile="$arg"
+	  lastarg=$srcfile
+	  srcfile=$arg
 	  ;;
 	esac  #  case $arg
 	;;
@@ -2043,13 +3359,13 @@ func_mode_compile ()
       func_fatal_error "you must specify an argument for -Xcompile"
       ;;
     target)
-      func_fatal_error "you must specify a target with \`-o'"
+      func_fatal_error "you must specify a target with '-o'"
       ;;
     *)
       # Get the name of the library object.
       test -z "$libobj" && {
 	func_basename "$srcfile"
-	libobj="$func_basename_result"
+	libobj=$func_basename_result
       }
       ;;
     esac
@@ -2069,7 +3385,7 @@ func_mode_compile ()
     case $libobj in
     *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
     *)
-      func_fatal_error "cannot determine name of library object from \`$libobj'"
+      func_fatal_error "cannot determine name of library object from '$libobj'"
       ;;
     esac
 
@@ -2078,8 +3394,8 @@ func_mode_compile ()
     for arg in $later; do
       case $arg in
       -shared)
-	test "$build_libtool_libs" != yes && \
-	  func_fatal_configuration "can not build a shared library"
+	test yes = "$build_libtool_libs" \
+	  || func_fatal_configuration "cannot build a shared library"
 	build_old_libs=no
 	continue
 	;;
@@ -2105,17 +3421,17 @@ func_mode_compile ()
     func_quote_for_eval "$libobj"
     test "X$libobj" != "X$func_quote_for_eval_result" \
       && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
-      && func_warning "libobj name \`$libobj' may not contain shell special characters."
+      && func_warning "libobj name '$libobj' may not contain shell special characters."
     func_dirname_and_basename "$obj" "/" ""
-    objname="$func_basename_result"
-    xdir="$func_dirname_result"
-    lobj=${xdir}$objdir/$objname
+    objname=$func_basename_result
+    xdir=$func_dirname_result
+    lobj=$xdir$objdir/$objname
 
     test -z "$base_compile" && \
       func_fatal_help "you must specify a compilation command"
 
     # Delete any leftover library objects.
-    if test "$build_old_libs" = yes; then
+    if test yes = "$build_old_libs"; then
       removelist="$obj $lobj $libobj ${libobj}T"
     else
       removelist="$lobj $libobj ${libobj}T"
@@ -2127,16 +3443,16 @@ func_mode_compile ()
       pic_mode=default
       ;;
     esac
-    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
+    if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
       # non-PIC code in shared libraries is not supported
       pic_mode=default
     fi
 
     # Calculate the filename of the output object if compiler does
     # not support -o with -c
-    if test "$compiler_c_o" = no; then
-      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
-      lockfile="$output_obj.lock"
+    if test no = "$compiler_c_o"; then
+      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
+      lockfile=$output_obj.lock
     else
       output_obj=
       need_locks=no
@@ -2145,12 +3461,12 @@ func_mode_compile ()
 
     # Lock this critical section if it is needed
     # We use this script file to make the link, it avoids creating a new file
-    if test "$need_locks" = yes; then
+    if test yes = "$need_locks"; then
       until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
 	func_echo "Waiting for $lockfile to be removed"
 	sleep 2
       done
-    elif test "$need_locks" = warn; then
+    elif test warn = "$need_locks"; then
       if test -f "$lockfile"; then
 	$ECHO "\
 *** ERROR, $lockfile exists and contains:
@@ -2158,7 +3474,7 @@ func_mode_compile ()
 
 This indicates that another process is trying to use the same
 temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together.  If you
+your compiler does not support '-c' and '-o' together.  If you
 repeat this compilation, it may succeed, by chance, but you had better
 avoid parallel builds (make -j) in this platform, or get a better
 compiler."
@@ -2180,11 +3496,11 @@ compiler."
     qsrcfile=$func_quote_for_eval_result
 
     # Only build a PIC object if we are building libtool libraries.
-    if test "$build_libtool_libs" = yes; then
+    if test yes = "$build_libtool_libs"; then
       # Without this assignment, base_compile gets emptied.
       fbsd_hideous_sh_bug=$base_compile
 
-      if test "$pic_mode" != no; then
+      if test no != "$pic_mode"; then
 	command="$base_compile $qsrcfile $pic_flag"
       else
 	# Don't build PIC code
@@ -2201,7 +3517,7 @@ compiler."
       func_show_eval_locale "$command"	\
           'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
 
-      if test "$need_locks" = warn &&
+      if test warn = "$need_locks" &&
 	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
 	$ECHO "\
 *** ERROR, $lockfile contains:
@@ -2212,7 +3528,7 @@ $srcfile
 
 This indicates that another process is trying to use the same
 temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together.  If you
+your compiler does not support '-c' and '-o' together.  If you
 repeat this compilation, it may succeed, by chance, but you had better
 avoid parallel builds (make -j) in this platform, or get a better
 compiler."
@@ -2228,20 +3544,20 @@ compiler."
       fi
 
       # Allow error messages only from the first compilation.
-      if test "$suppress_opt" = yes; then
+      if test yes = "$suppress_opt"; then
 	suppress_output=' >/dev/null 2>&1'
       fi
     fi
 
     # Only build a position-dependent object if we build old libraries.
-    if test "$build_old_libs" = yes; then
-      if test "$pic_mode" != yes; then
+    if test yes = "$build_old_libs"; then
+      if test yes != "$pic_mode"; then
 	# Don't build PIC code
 	command="$base_compile $qsrcfile$pie_flag"
       else
 	command="$base_compile $qsrcfile $pic_flag"
       fi
-      if test "$compiler_c_o" = yes; then
+      if test yes = "$compiler_c_o"; then
 	func_append command " -o $obj"
       fi
 
@@ -2250,7 +3566,7 @@ compiler."
       func_show_eval_locale "$command" \
         '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
 
-      if test "$need_locks" = warn &&
+      if test warn = "$need_locks" &&
 	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
 	$ECHO "\
 *** ERROR, $lockfile contains:
@@ -2261,7 +3577,7 @@ $srcfile
 
 This indicates that another process is trying to use the same
 temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together.  If you
+your compiler does not support '-c' and '-o' together.  If you
 repeat this compilation, it may succeed, by chance, but you had better
 avoid parallel builds (make -j) in this platform, or get a better
 compiler."
@@ -2281,7 +3597,7 @@ compiler."
       func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
 
       # Unlock the critical section if it was locked
-      if test "$need_locks" != no; then
+      if test no != "$need_locks"; then
 	removelist=$lockfile
         $RM "$lockfile"
       fi
@@ -2291,7 +3607,7 @@ compiler."
 }
 
 $opt_help || {
-  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
+  test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
 }
 
 func_mode_help ()
@@ -2311,7 +3627,7 @@ func_mode_help ()
 Remove files from the build directory.
 
 RM is the name of the program to use to delete files associated with each FILE
-(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
 to RM.
 
 If FILE is a libtool library, object or program, all the files associated
@@ -2330,16 +3646,16 @@ This mode accepts the following additional options:
   -no-suppress      do not suppress compiler output for multiple passes
   -prefer-pic       try to build PIC objects only
   -prefer-non-pic   try to build non-PIC objects only
-  -shared           do not build a \`.o' file suitable for static linking
-  -static           only build a \`.o' file suitable for static linking
+  -shared           do not build a '.o' file suitable for static linking
+  -static           only build a '.o' file suitable for static linking
   -Wc,FLAG          pass FLAG directly to the compiler
 
-COMPILE-COMMAND is a command to be used in creating a \`standard' object file
+COMPILE-COMMAND is a command to be used in creating a 'standard' object file
 from the given SOURCEFILE.
 
 The output file name is determined by removing the directory component from
-SOURCEFILE, then substituting the C source code suffix \`.c' with the
-library object suffix, \`.lo'."
+SOURCEFILE, then substituting the C source code suffix '.c' with the
+library object suffix, '.lo'."
         ;;
 
       execute)
@@ -2352,7 +3668,7 @@ This mode accepts the following additional options:
 
   -dlopen FILE      add the directory containing FILE to the library path
 
-This mode sets the library path environment variable according to \`-dlopen'
+This mode sets the library path environment variable according to '-dlopen'
 flags.
 
 If any of the ARGS are libtool executable wrappers, then they are translated
@@ -2371,7 +3687,7 @@ Complete the installation of libtool libraries.
 Each LIBDIR is a directory that contains libtool libraries.
 
 The commands that this mode executes may require superuser privileges.  Use
-the \`--dry-run' option if you just want to see what would be executed."
+the '--dry-run' option if you just want to see what would be executed."
         ;;
 
       install)
@@ -2381,7 +3697,7 @@ the \`--dry-run' option if you just want to see what would be executed."
 Install executables or libraries.
 
 INSTALL-COMMAND is the installation command.  The first component should be
-either the \`install' or \`cp' program.
+either the 'install' or 'cp' program.
 
 The following components of INSTALL-COMMAND are treated specially:
 
@@ -2407,7 +3723,7 @@ The following components of LINK-COMMAND are treated specially:
   -avoid-version    do not add a version suffix if possible
   -bindir BINDIR    specify path to binaries directory (for systems where
                     libraries must be found in the PATH setting at runtime)
-  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
+  -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
   -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
   -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
   -export-symbols SYMFILE
@@ -2421,7 +3737,8 @@ The following components of LINK-COMMAND are treated specially:
   -no-install       link a not-installable executable
   -no-undefined     declare that a library does not refer to external symbols
   -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
-  -objectlist FILE  Use a list of object files found in FILE to specify objects
+  -objectlist FILE  use a list of object files found in FILE to specify objects
+  -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
   -precious-files-regex REGEX
                     don't remove output files matching REGEX
   -release RELEASE  specify package release information
@@ -2441,20 +3758,20 @@ The following components of LINK-COMMAND are treated specially:
   -Xlinker FLAG     pass linker-specific FLAG directly to the linker
   -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
 
-All other options (arguments beginning with \`-') are ignored.
+All other options (arguments beginning with '-') are ignored.
 
-Every other argument is treated as a filename.  Files ending in \`.la' are
+Every other argument is treated as a filename.  Files ending in '.la' are
 treated as uninstalled libtool libraries, other files are standard or library
 object files.
 
-If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
-only library objects (\`.lo' files) may be specified, and \`-rpath' is
+If the OUTPUT-FILE ends in '.la', then a libtool library is created,
+only library objects ('.lo' files) may be specified, and '-rpath' is
 required, except when creating a convenience library.
 
-If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
-using \`ar' and \`ranlib', or on Windows using \`lib'.
+If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
+using 'ar' and 'ranlib', or on Windows using 'lib'.
 
-If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
+If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
 is created, otherwise an executable program is created."
         ;;
 
@@ -2465,7 +3782,7 @@ is created, otherwise an executable program is created."
 Remove libraries from an installation directory.
 
 RM is the name of the program to use to delete files associated with each FILE
-(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
 to RM.
 
 If FILE is a libtool library, all the files associated with it are deleted.
@@ -2473,17 +3790,17 @@ Otherwise, only FILE itself is deleted using RM."
         ;;
 
       *)
-        func_fatal_help "invalid operation mode \`$opt_mode'"
+        func_fatal_help "invalid operation mode '$opt_mode'"
         ;;
     esac
 
     echo
-    $ECHO "Try \`$progname --help' for more information about other modes."
+    $ECHO "Try '$progname --help' for more information about other modes."
 }
 
 # Now that we've collected a possible --mode arg, show help if necessary
 if $opt_help; then
-  if test "$opt_help" = :; then
+  if test : = "$opt_help"; then
     func_mode_help
   else
     {
@@ -2491,7 +3808,7 @@ if $opt_help; then
       for opt_mode in compile link execute install finish uninstall clean; do
 	func_mode_help
       done
-    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
+    } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
     {
       func_help noexit
       for opt_mode in compile link execute install finish uninstall clean; do
@@ -2499,7 +3816,7 @@ if $opt_help; then
 	func_mode_help
       done
     } |
-    sed '1d
+    $SED '1d
       /^When reporting/,/^Report/{
 	H
 	d
@@ -2516,16 +3833,17 @@ fi
 # func_mode_execute arg...
 func_mode_execute ()
 {
-    $opt_debug
+    $debug_cmd
+
     # The first argument is the command name.
-    cmd="$nonopt"
+    cmd=$nonopt
     test -z "$cmd" && \
       func_fatal_help "you must specify a COMMAND"
 
     # Handle -dlopen flags immediately.
     for file in $opt_dlopen; do
       test -f "$file" \
-	|| func_fatal_help "\`$file' is not a file"
+	|| func_fatal_help "'$file' is not a file"
 
       dir=
       case $file in
@@ -2535,7 +3853,7 @@ func_mode_execute ()
 
 	# Check to see that this really is a libtool archive.
 	func_lalib_unsafe_p "$file" \
-	  || func_fatal_help "\`$lib' is not a valid libtool archive"
+	  || func_fatal_help "'$lib' is not a valid libtool archive"
 
 	# Read the libtool library.
 	dlname=
@@ -2546,18 +3864,18 @@ func_mode_execute ()
 	if test -z "$dlname"; then
 	  # Warn if it was a shared library.
 	  test -n "$library_names" && \
-	    func_warning "\`$file' was not linked with \`-export-dynamic'"
+	    func_warning "'$file' was not linked with '-export-dynamic'"
 	  continue
 	fi
 
 	func_dirname "$file" "" "."
-	dir="$func_dirname_result"
+	dir=$func_dirname_result
 
 	if test -f "$dir/$objdir/$dlname"; then
 	  func_append dir "/$objdir"
 	else
 	  if test ! -f "$dir/$dlname"; then
-	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
+	    func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
 	  fi
 	fi
 	;;
@@ -2565,18 +3883,18 @@ func_mode_execute ()
       *.lo)
 	# Just add the directory containing the .lo file.
 	func_dirname "$file" "" "."
-	dir="$func_dirname_result"
+	dir=$func_dirname_result
 	;;
 
       *)
-	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
+	func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
 	continue
 	;;
       esac
 
       # Get the absolute pathname.
       absdir=`cd "$dir" && pwd`
-      test -n "$absdir" && dir="$absdir"
+      test -n "$absdir" && dir=$absdir
 
       # Now add the directory to shlibpath_var.
       if eval "test -z \"\$$shlibpath_var\""; then
@@ -2588,7 +3906,7 @@ func_mode_execute ()
 
     # This variable tells wrapper scripts just to set shlibpath_var
     # rather than running their programs.
-    libtool_execute_magic="$magic"
+    libtool_execute_magic=$magic
 
     # Check if any of the arguments is a wrapper script.
     args=
@@ -2601,12 +3919,12 @@ func_mode_execute ()
 	if func_ltwrapper_script_p "$file"; then
 	  func_source "$file"
 	  # Transform arg to wrapped name.
-	  file="$progdir/$program"
+	  file=$progdir/$program
 	elif func_ltwrapper_executable_p "$file"; then
 	  func_ltwrapper_scriptname "$file"
 	  func_source "$func_ltwrapper_scriptname_result"
 	  # Transform arg to wrapped name.
-	  file="$progdir/$program"
+	  file=$progdir/$program
 	fi
 	;;
       esac
@@ -2614,7 +3932,15 @@ func_mode_execute ()
       func_append_quoted args "$file"
     done
 
-    if test "X$opt_dry_run" = Xfalse; then
+    if $opt_dry_run; then
+      # Display what would be done.
+      if test -n "$shlibpath_var"; then
+	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
+	echo "export $shlibpath_var"
+      fi
+      $ECHO "$cmd$args"
+      exit $EXIT_SUCCESS
+    else
       if test -n "$shlibpath_var"; then
 	# Export the shlibpath_var.
 	eval "export $shlibpath_var"
@@ -2631,25 +3957,18 @@ func_mode_execute ()
       done
 
       # Now prepare to actually exec the command.
-      exec_cmd="\$cmd$args"
-    else
-      # Display what would be done.
-      if test -n "$shlibpath_var"; then
-	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
-	echo "export $shlibpath_var"
-      fi
-      $ECHO "$cmd$args"
-      exit $EXIT_SUCCESS
+      exec_cmd=\$cmd$args
     fi
 }
 
-test "$opt_mode" = execute && func_mode_execute ${1+"$@"}
+test execute = "$opt_mode" && func_mode_execute ${1+"$@"}
 
 
 # func_mode_finish arg...
 func_mode_finish ()
 {
-    $opt_debug
+    $debug_cmd
+
     libs=
     libdirs=
     admincmds=
@@ -2663,11 +3982,11 @@ func_mode_finish ()
 	if func_lalib_unsafe_p "$opt"; then
 	  func_append libs " $opt"
 	else
-	  func_warning "\`$opt' is not a valid libtool archive"
+	  func_warning "'$opt' is not a valid libtool archive"
 	fi
 
       else
-	func_fatal_error "invalid argument \`$opt'"
+	func_fatal_error "invalid argument '$opt'"
       fi
     done
 
@@ -2682,12 +4001,12 @@ func_mode_finish ()
       # Remove sysroot references
       if $opt_dry_run; then
         for lib in $libs; do
-          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
+          echo "removing references to $lt_sysroot and '=' prefixes from $lib"
         done
       else
         tmpdir=`func_mktempdir`
         for lib in $libs; do
-	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
+	  $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
 	    > $tmpdir/tmp-la
 	  mv -f $tmpdir/tmp-la $lib
 	done
@@ -2712,7 +4031,7 @@ func_mode_finish ()
     fi
 
     # Exit here if they wanted silent mode.
-    $opt_silent && exit $EXIT_SUCCESS
+    $opt_quiet && exit $EXIT_SUCCESS
 
     if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
       echo "----------------------------------------------------------------------"
@@ -2723,27 +4042,27 @@ func_mode_finish ()
       echo
       echo "If you ever happen to want to link against installed libraries"
       echo "in a given directory, LIBDIR, you must either use libtool, and"
-      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
+      echo "specify the full pathname of the library, or use the '-LLIBDIR'"
       echo "flag during linking and do at least one of the following:"
       if test -n "$shlibpath_var"; then
-	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
+	echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
 	echo "     during execution"
       fi
       if test -n "$runpath_var"; then
-	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
+	echo "   - add LIBDIR to the '$runpath_var' environment variable"
 	echo "     during linking"
       fi
       if test -n "$hardcode_libdir_flag_spec"; then
 	libdir=LIBDIR
 	eval flag=\"$hardcode_libdir_flag_spec\"
 
-	$ECHO "   - use the \`$flag' linker flag"
+	$ECHO "   - use the '$flag' linker flag"
       fi
       if test -n "$admincmds"; then
 	$ECHO "   - have your system administrator run these commands:$admincmds"
       fi
       if test -f /etc/ld.so.conf; then
-	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
+	echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
       fi
       echo
 
@@ -2762,18 +4081,20 @@ func_mode_finish ()
     exit $EXIT_SUCCESS
 }
 
-test "$opt_mode" = finish && func_mode_finish ${1+"$@"}
+test finish = "$opt_mode" && func_mode_finish ${1+"$@"}
 
 
 # func_mode_install arg...
 func_mode_install ()
 {
-    $opt_debug
+    $debug_cmd
+
     # There may be an optional sh(1) argument at the beginning of
     # install_prog (especially on Windows NT).
-    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
+    if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
        # Allow the use of GNU shtool's install command.
-       case $nonopt in *shtool*) :;; *) false;; esac; then
+       case $nonopt in *shtool*) :;; *) false;; esac
+    then
       # Aesthetically quote it.
       func_quote_for_eval "$nonopt"
       install_prog="$func_quote_for_eval_result "
@@ -2800,7 +4121,7 @@ func_mode_install ()
     opts=
     prev=
     install_type=
-    isdir=no
+    isdir=false
     stripme=
     no_mode=:
     for arg
@@ -2813,7 +4134,7 @@ func_mode_install ()
       fi
 
       case $arg in
-      -d) isdir=yes ;;
+      -d) isdir=: ;;
       -f)
 	if $install_cp; then :; else
 	  prev=$arg
@@ -2831,7 +4152,7 @@ func_mode_install ()
       *)
 	# If the previous option needed an argument, then skip it.
 	if test -n "$prev"; then
-	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
+	  if test X-m = "X$prev" && test -n "$install_override_mode"; then
 	    arg2=$install_override_mode
 	    no_mode=false
 	  fi
@@ -2856,7 +4177,7 @@ func_mode_install ()
       func_fatal_help "you must specify an install program"
 
     test -n "$prev" && \
-      func_fatal_help "the \`$prev' option requires an argument"
+      func_fatal_help "the '$prev' option requires an argument"
 
     if test -n "$install_override_mode" && $no_mode; then
       if $install_cp; then :; else
@@ -2878,19 +4199,19 @@ func_mode_install ()
     dest=$func_stripname_result
 
     # Check to see that the destination is a directory.
-    test -d "$dest" && isdir=yes
-    if test "$isdir" = yes; then
-      destdir="$dest"
+    test -d "$dest" && isdir=:
+    if $isdir; then
+      destdir=$dest
       destname=
     else
       func_dirname_and_basename "$dest" "" "."
-      destdir="$func_dirname_result"
-      destname="$func_basename_result"
+      destdir=$func_dirname_result
+      destname=$func_basename_result
 
       # Not a directory, so check to see that there is only one file specified.
       set dummy $files; shift
       test "$#" -gt 1 && \
-	func_fatal_help "\`$dest' is not a directory"
+	func_fatal_help "'$dest' is not a directory"
     fi
     case $destdir in
     [\\/]* | [A-Za-z]:[\\/]*) ;;
@@ -2899,7 +4220,7 @@ func_mode_install ()
 	case $file in
 	*.lo) ;;
 	*)
-	  func_fatal_help "\`$destdir' must be an absolute directory name"
+	  func_fatal_help "'$destdir' must be an absolute directory name"
 	  ;;
 	esac
       done
@@ -2908,7 +4229,7 @@ func_mode_install ()
 
     # This variable tells wrapper scripts just to set variables rather
     # than running their programs.
-    libtool_install_magic="$magic"
+    libtool_install_magic=$magic
 
     staticlibs=
     future_libdirs=
@@ -2928,7 +4249,7 @@ func_mode_install ()
 
 	# Check to see that this really is a libtool archive.
 	func_lalib_unsafe_p "$file" \
-	  || func_fatal_help "\`$file' is not a valid libtool archive"
+	  || func_fatal_help "'$file' is not a valid libtool archive"
 
 	library_names=
 	old_library=
@@ -2950,7 +4271,7 @@ func_mode_install ()
 	fi
 
 	func_dirname "$file" "/" ""
-	dir="$func_dirname_result"
+	dir=$func_dirname_result
 	func_append dir "$objdir"
 
 	if test -n "$relink_command"; then
@@ -2964,7 +4285,7 @@ func_mode_install ()
 	  # are installed into $libdir/../bin (currently, that works fine)
 	  # but it's something to keep an eye on.
 	  test "$inst_prefix_dir" = "$destdir" && \
-	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
+	    func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
 
 	  if test -n "$inst_prefix_dir"; then
 	    # Stick the inst_prefix_dir data into the link command.
@@ -2973,29 +4294,36 @@ func_mode_install ()
 	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
 	  fi
 
-	  func_warning "relinking \`$file'"
+	  func_warning "relinking '$file'"
 	  func_show_eval "$relink_command" \
-	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
+	    'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
 	fi
 
 	# See the names of the shared library.
 	set dummy $library_names; shift
 	if test -n "$1"; then
-	  realname="$1"
+	  realname=$1
 	  shift
 
-	  srcname="$realname"
-	  test -n "$relink_command" && srcname="$realname"T
+	  srcname=$realname
+	  test -n "$relink_command" && srcname=${realname}T
 
 	  # Install the shared library and build the symlinks.
 	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
 	      'exit $?'
-	  tstripme="$stripme"
+	  tstripme=$stripme
 	  case $host_os in
 	  cygwin* | mingw* | pw32* | cegcc*)
 	    case $realname in
 	    *.dll.a)
-	      tstripme=""
+	      tstripme=
+	      ;;
+	    esac
+	    ;;
+	  os2*)
+	    case $realname in
+	    *_dll.a)
+	      tstripme=
 	      ;;
 	    esac
 	    ;;
@@ -3006,7 +4334,7 @@ func_mode_install ()
 
 	  if test "$#" -gt 0; then
 	    # Delete the old symlinks, and create new ones.
-	    # Try `ln -sf' first, because the `ln' binary might depend on
+	    # Try 'ln -sf' first, because the 'ln' binary might depend on
 	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
 	    # so we also need to try rm && ln -s.
 	    for linkname
@@ -3017,14 +4345,14 @@ func_mode_install ()
 	  fi
 
 	  # Do each command in the postinstall commands.
-	  lib="$destdir/$realname"
+	  lib=$destdir/$realname
 	  func_execute_cmds "$postinstall_cmds" 'exit $?'
 	fi
 
 	# Install the pseudo-library for information purposes.
 	func_basename "$file"
-	name="$func_basename_result"
-	instname="$dir/$name"i
+	name=$func_basename_result
+	instname=$dir/${name}i
 	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
 
 	# Maybe install the static library, too.
@@ -3036,11 +4364,11 @@ func_mode_install ()
 
 	# Figure out destination file name, if it wasn't already specified.
 	if test -n "$destname"; then
-	  destfile="$destdir/$destname"
+	  destfile=$destdir/$destname
 	else
 	  func_basename "$file"
-	  destfile="$func_basename_result"
-	  destfile="$destdir/$destfile"
+	  destfile=$func_basename_result
+	  destfile=$destdir/$destfile
 	fi
 
 	# Deduce the name of the destination old-style object file.
@@ -3050,11 +4378,11 @@ func_mode_install ()
 	  staticdest=$func_lo2o_result
 	  ;;
 	*.$objext)
-	  staticdest="$destfile"
+	  staticdest=$destfile
 	  destfile=
 	  ;;
 	*)
-	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
+	  func_fatal_help "cannot copy a libtool object to '$destfile'"
 	  ;;
 	esac
 
@@ -3063,7 +4391,7 @@ func_mode_install ()
 	  func_show_eval "$install_prog $file $destfile" 'exit $?'
 
 	# Install the old object if enabled.
-	if test "$build_old_libs" = yes; then
+	if test yes = "$build_old_libs"; then
 	  # Deduce the name of the old-style object file.
 	  func_lo2o "$file"
 	  staticobj=$func_lo2o_result
@@ -3075,23 +4403,23 @@ func_mode_install ()
       *)
 	# Figure out destination file name, if it wasn't already specified.
 	if test -n "$destname"; then
-	  destfile="$destdir/$destname"
+	  destfile=$destdir/$destname
 	else
 	  func_basename "$file"
-	  destfile="$func_basename_result"
-	  destfile="$destdir/$destfile"
+	  destfile=$func_basename_result
+	  destfile=$destdir/$destfile
 	fi
 
 	# If the file is missing, and there is a .exe on the end, strip it
 	# because it is most likely a libtool script we actually want to
 	# install
-	stripped_ext=""
+	stripped_ext=
 	case $file in
 	  *.exe)
 	    if test ! -f "$file"; then
 	      func_stripname '' '.exe' "$file"
 	      file=$func_stripname_result
-	      stripped_ext=".exe"
+	      stripped_ext=.exe
 	    fi
 	    ;;
 	esac
@@ -3119,19 +4447,19 @@ func_mode_install ()
 
 	  # Check the variables that should have been set.
 	  test -z "$generated_by_libtool_version" && \
-	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
+	    func_fatal_error "invalid libtool wrapper script '$wrapper'"
 
-	  finalize=yes
+	  finalize=:
 	  for lib in $notinst_deplibs; do
 	    # Check to see that each library is installed.
 	    libdir=
 	    if test -f "$lib"; then
 	      func_source "$lib"
 	    fi
-	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
+	    libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
 	    if test -n "$libdir" && test ! -f "$libfile"; then
-	      func_warning "\`$lib' has not been installed in \`$libdir'"
-	      finalize=no
+	      func_warning "'$lib' has not been installed in '$libdir'"
+	      finalize=false
 	    fi
 	  done
 
@@ -3139,29 +4467,29 @@ func_mode_install ()
 	  func_source "$wrapper"
 
 	  outputname=
-	  if test "$fast_install" = no && test -n "$relink_command"; then
+	  if test no = "$fast_install" && test -n "$relink_command"; then
 	    $opt_dry_run || {
-	      if test "$finalize" = yes; then
+	      if $finalize; then
 	        tmpdir=`func_mktempdir`
 		func_basename "$file$stripped_ext"
-		file="$func_basename_result"
-	        outputname="$tmpdir/$file"
+		file=$func_basename_result
+	        outputname=$tmpdir/$file
 	        # Replace the output file specification.
 	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
 
-	        $opt_silent || {
+	        $opt_quiet || {
 	          func_quote_for_expand "$relink_command"
 		  eval "func_echo $func_quote_for_expand_result"
 	        }
 	        if eval "$relink_command"; then :
 	          else
-		  func_error "error: relink \`$file' with the above command before installing it"
+		  func_error "error: relink '$file' with the above command before installing it"
 		  $opt_dry_run || ${RM}r "$tmpdir"
 		  continue
 	        fi
-	        file="$outputname"
+	        file=$outputname
 	      else
-	        func_warning "cannot relink \`$file'"
+	        func_warning "cannot relink '$file'"
 	      fi
 	    }
 	  else
@@ -3198,10 +4526,10 @@ func_mode_install ()
 
     for file in $staticlibs; do
       func_basename "$file"
-      name="$func_basename_result"
+      name=$func_basename_result
 
       # Set up the ranlib parameters.
-      oldlib="$destdir/$name"
+      oldlib=$destdir/$name
       func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
       tool_oldlib=$func_to_tool_file_result
 
@@ -3216,18 +4544,18 @@ func_mode_install ()
     done
 
     test -n "$future_libdirs" && \
-      func_warning "remember to run \`$progname --finish$future_libdirs'"
+      func_warning "remember to run '$progname --finish$future_libdirs'"
 
     if test -n "$current_libdirs"; then
       # Maybe just do a dry run.
       $opt_dry_run && current_libdirs=" -n$current_libdirs"
-      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
+      exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
     else
       exit $EXIT_SUCCESS
     fi
 }
 
-test "$opt_mode" = install && func_mode_install ${1+"$@"}
+test install = "$opt_mode" && func_mode_install ${1+"$@"}
 
 
 # func_generate_dlsyms outputname originator pic_p
@@ -3235,16 +4563,17 @@ test "$opt_mode" = install && func_mode_install ${1+"$@"}
 # a dlpreopen symbol table.
 func_generate_dlsyms ()
 {
-    $opt_debug
-    my_outputname="$1"
-    my_originator="$2"
-    my_pic_p="${3-no}"
-    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
+    $debug_cmd
+
+    my_outputname=$1
+    my_originator=$2
+    my_pic_p=${3-false}
+    my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
     my_dlsyms=
 
-    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+    if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
       if test -n "$NM" && test -n "$global_symbol_pipe"; then
-	my_dlsyms="${my_outputname}S.c"
+	my_dlsyms=${my_outputname}S.c
       else
 	func_error "not configured to extract global symbols from dlpreopened files"
       fi
@@ -3255,7 +4584,7 @@ func_generate_dlsyms ()
       "") ;;
       *.c)
 	# Discover the nlist of each of the dlfiles.
-	nlist="$output_objdir/${my_outputname}.nm"
+	nlist=$output_objdir/$my_outputname.nm
 
 	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
 
@@ -3263,34 +4592,36 @@ func_generate_dlsyms ()
 	func_verbose "creating $output_objdir/$my_dlsyms"
 
 	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
-/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
-/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
+/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
+/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
 
 #ifdef __cplusplus
 extern \"C\" {
 #endif
 
-#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
+#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
 #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
 #endif
 
 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
-#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
-/* DATA imports from DLLs on WIN32 con't be const, because runtime
+#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
+/* DATA imports from DLLs on WIN32 can't be const, because runtime
    relocations are performed -- see ld's documentation on pseudo-relocs.  */
 # define LT_DLSYM_CONST
-#elif defined(__osf__)
+#elif defined __osf__
 /* This system does not cope well with relocations in const data.  */
 # define LT_DLSYM_CONST
 #else
 # define LT_DLSYM_CONST const
 #endif
 
+#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
+
 /* External symbol declarations for the compiler. */\
 "
 
-	if test "$dlself" = yes; then
-	  func_verbose "generating symbol list for \`$output'"
+	if test yes = "$dlself"; then
+	  func_verbose "generating symbol list for '$output'"
 
 	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
 
@@ -3298,7 +4629,7 @@ extern \"C\" {
 	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
 	  for progfile in $progfiles; do
 	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
-	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
+	    func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
 	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
 	  done
 
@@ -3318,10 +4649,10 @@ extern \"C\" {
 
 	  # Prepare the list of exported symbols
 	  if test -z "$export_symbols"; then
-	    export_symbols="$output_objdir/$outputname.exp"
+	    export_symbols=$output_objdir/$outputname.exp
 	    $opt_dry_run || {
 	      $RM $export_symbols
-	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+	      eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
 	      case $host in
 	      *cygwin* | *mingw* | *cegcc* )
                 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
@@ -3331,7 +4662,7 @@ extern \"C\" {
 	    }
 	  else
 	    $opt_dry_run || {
-	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
+	      eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
 	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
 	      eval '$MV "$nlist"T "$nlist"'
 	      case $host in
@@ -3345,22 +4676,22 @@ extern \"C\" {
 	fi
 
 	for dlprefile in $dlprefiles; do
-	  func_verbose "extracting global C symbols from \`$dlprefile'"
+	  func_verbose "extracting global C symbols from '$dlprefile'"
 	  func_basename "$dlprefile"
-	  name="$func_basename_result"
+	  name=$func_basename_result
           case $host in
 	    *cygwin* | *mingw* | *cegcc* )
 	      # if an import library, we need to obtain dlname
 	      if func_win32_import_lib_p "$dlprefile"; then
 	        func_tr_sh "$dlprefile"
 	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
-	        dlprefile_dlbasename=""
+	        dlprefile_dlbasename=
 	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
 	          # Use subshell, to avoid clobbering current variable values
 	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
-	          if test -n "$dlprefile_dlname" ; then
+	          if test -n "$dlprefile_dlname"; then
 	            func_basename "$dlprefile_dlname"
-	            dlprefile_dlbasename="$func_basename_result"
+	            dlprefile_dlbasename=$func_basename_result
 	          else
 	            # no lafile. user explicitly requested -dlpreopen <import library>.
 	            $sharedlib_from_linklib_cmd "$dlprefile"
@@ -3368,7 +4699,7 @@ extern \"C\" {
 	          fi
 	        fi
 	        $opt_dry_run || {
-	          if test -n "$dlprefile_dlbasename" ; then
+	          if test -n "$dlprefile_dlbasename"; then
 	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
 	          else
 	            func_warning "Could not compute DLL name from $name"
@@ -3424,6 +4755,11 @@ extern \"C\" {
 	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
 	  fi
 
+	  func_show_eval '$RM "${nlist}I"'
+	  if test -n "$global_symbol_to_import"; then
+	    eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
+	  fi
+
 	  echo >> "$output_objdir/$my_dlsyms" "\
 
 /* The mapping between symbol names and symbols.  */
@@ -3432,11 +4768,30 @@ typedef struct {
   void *address;
 } lt_dlsymlist;
 extern LT_DLSYM_CONST lt_dlsymlist
-lt_${my_prefix}_LTX_preloaded_symbols[];
+lt_${my_prefix}_LTX_preloaded_symbols[];\
+"
+
+	  if test -s "$nlist"I; then
+	    echo >> "$output_objdir/$my_dlsyms" "\
+static void lt_syminit(void)
+{
+  LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
+  for (; symbol->name; ++symbol)
+    {"
+	    $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
+	    echo >> "$output_objdir/$my_dlsyms" "\
+    }
+}"
+	  fi
+	  echo >> "$output_objdir/$my_dlsyms" "\
 LT_DLSYM_CONST lt_dlsymlist
 lt_${my_prefix}_LTX_preloaded_symbols[] =
-{\
-  { \"$my_originator\", (void *) 0 },"
+{ {\"$my_originator\", (void *) 0},"
+
+	  if test -s "$nlist"I; then
+	    echo >> "$output_objdir/$my_dlsyms" "\
+  {\"@INIT@\", (void *) &lt_syminit},"
+	  fi
 
 	  case $need_lib_prefix in
 	  no)
@@ -3478,9 +4833,7 @@ static const void *lt_preloaded_setup() {
 	  *-*-hpux*)
 	    pic_flag_for_symtable=" $pic_flag"  ;;
 	  *)
-	    if test "X$my_pic_p" != Xno; then
-	      pic_flag_for_symtable=" $pic_flag"
-	    fi
+	    $my_pic_p && pic_flag_for_symtable=" $pic_flag"
 	    ;;
 	  esac
 	  ;;
@@ -3497,10 +4850,10 @@ static const void *lt_preloaded_setup() {
 	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
 
 	# Clean up the generated files.
-	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
+	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
 
 	# Transform the symbol file into the correct name.
-	symfileobj="$output_objdir/${my_outputname}S.$objext"
+	symfileobj=$output_objdir/${my_outputname}S.$objext
 	case $host in
 	*cygwin* | *mingw* | *cegcc* )
 	  if test -f "$output_objdir/$my_outputname.def"; then
@@ -3518,7 +4871,7 @@ static const void *lt_preloaded_setup() {
 	esac
 	;;
       *)
-	func_fatal_error "unknown suffix for \`$my_dlsyms'"
+	func_fatal_error "unknown suffix for '$my_dlsyms'"
 	;;
       esac
     else
@@ -3532,6 +4885,32 @@ static const void *lt_preloaded_setup() {
     fi
 }
 
+# func_cygming_gnu_implib_p ARG
+# This predicate returns with zero status (TRUE) if
+# ARG is a GNU/binutils-style import library. Returns
+# with nonzero status (FALSE) otherwise.
+func_cygming_gnu_implib_p ()
+{
+  $debug_cmd
+
+  func_to_tool_file "$1" func_convert_file_msys_to_w32
+  func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
+  test -n "$func_cygming_gnu_implib_tmp"
+}
+
+# func_cygming_ms_implib_p ARG
+# This predicate returns with zero status (TRUE) if
+# ARG is an MS-style import library. Returns
+# with nonzero status (FALSE) otherwise.
+func_cygming_ms_implib_p ()
+{
+  $debug_cmd
+
+  func_to_tool_file "$1" func_convert_file_msys_to_w32
+  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
+  test -n "$func_cygming_ms_implib_tmp"
+}
+
 # func_win32_libid arg
 # return the library type of file 'arg'
 #
@@ -3541,8 +4920,9 @@ static const void *lt_preloaded_setup() {
 # Despite the name, also deal with 64 bit binaries.
 func_win32_libid ()
 {
-  $opt_debug
-  win32_libid_type="unknown"
+  $debug_cmd
+
+  win32_libid_type=unknown
   win32_fileres=`file -L $1 2>/dev/null`
   case $win32_fileres in
   *ar\ archive\ import\ library*) # definitely import
@@ -3552,16 +4932,29 @@ func_win32_libid ()
     # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
     if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
        $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
-      func_to_tool_file "$1" func_convert_file_msys_to_w32
-      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
-	$SED -n -e '
+      case $nm_interface in
+      "MS dumpbin")
+	if func_cygming_ms_implib_p "$1" ||
+	   func_cygming_gnu_implib_p "$1"
+	then
+	  win32_nmres=import
+	else
+	  win32_nmres=
+	fi
+	;;
+      *)
+	func_to_tool_file "$1" func_convert_file_msys_to_w32
+	win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
+	  $SED -n -e '
 	    1,100{
 		/ I /{
-		    s,.*,import,
+		    s|.*|import|
 		    p
 		    q
 		}
 	    }'`
+	;;
+      esac
       case $win32_nmres in
       import*)  win32_libid_type="x86 archive import";;
       *)        win32_libid_type="x86 archive static";;
@@ -3593,7 +4986,8 @@ func_win32_libid ()
 #    $sharedlib_from_linklib_result
 func_cygming_dll_for_implib ()
 {
-  $opt_debug
+  $debug_cmd
+
   sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
 }
 
@@ -3610,7 +5004,8 @@ func_cygming_dll_for_implib ()
 # specified import library.
 func_cygming_dll_for_implib_fallback_core ()
 {
-  $opt_debug
+  $debug_cmd
+
   match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
   $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
     $SED '/^Contents of section '"$match_literal"':/{
@@ -3646,8 +5041,8 @@ func_cygming_dll_for_implib_fallback_core ()
       /./p' |
     # we now have a list, one entry per line, of the stringified
     # contents of the appropriate section of all members of the
-    # archive which possess that section. Heuristic: eliminate
-    # all those which have a first or second character that is
+    # archive that possess that section. Heuristic: eliminate
+    # all those that have a first or second character that is
     # a '.' (that is, objdump's representation of an unprintable
     # character.) This should work for all archives with less than
     # 0x302f exports -- but will fail for DLLs whose name actually
@@ -3658,30 +5053,6 @@ func_cygming_dll_for_implib_fallback_core ()
     $SED -e '/^\./d;/^.\./d;q'
 }
 
-# func_cygming_gnu_implib_p ARG
-# This predicate returns with zero status (TRUE) if
-# ARG is a GNU/binutils-style import library. Returns
-# with nonzero status (FALSE) otherwise.
-func_cygming_gnu_implib_p ()
-{
-  $opt_debug
-  func_to_tool_file "$1" func_convert_file_msys_to_w32
-  func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
-  test -n "$func_cygming_gnu_implib_tmp"
-}
-
-# func_cygming_ms_implib_p ARG
-# This predicate returns with zero status (TRUE) if
-# ARG is an MS-style import library. Returns
-# with nonzero status (FALSE) otherwise.
-func_cygming_ms_implib_p ()
-{
-  $opt_debug
-  func_to_tool_file "$1" func_convert_file_msys_to_w32
-  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
-  test -n "$func_cygming_ms_implib_tmp"
-}
-
 # func_cygming_dll_for_implib_fallback ARG
 # Platform-specific function to extract the
 # name of the DLL associated with the specified
@@ -3695,16 +5066,17 @@ func_cygming_ms_implib_p ()
 #    $sharedlib_from_linklib_result
 func_cygming_dll_for_implib_fallback ()
 {
-  $opt_debug
-  if func_cygming_gnu_implib_p "$1" ; then
+  $debug_cmd
+
+  if func_cygming_gnu_implib_p "$1"; then
     # binutils import library
     sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
-  elif func_cygming_ms_implib_p "$1" ; then
+  elif func_cygming_ms_implib_p "$1"; then
     # ms-generated import library
     sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
   else
     # unknown
-    sharedlib_from_linklib_result=""
+    sharedlib_from_linklib_result=
   fi
 }
 
@@ -3712,10 +5084,11 @@ func_cygming_dll_for_implib_fallback ()
 # func_extract_an_archive dir oldlib
 func_extract_an_archive ()
 {
-    $opt_debug
-    f_ex_an_ar_dir="$1"; shift
-    f_ex_an_ar_oldlib="$1"
-    if test "$lock_old_archive_extraction" = yes; then
+    $debug_cmd
+
+    f_ex_an_ar_dir=$1; shift
+    f_ex_an_ar_oldlib=$1
+    if test yes = "$lock_old_archive_extraction"; then
       lockfile=$f_ex_an_ar_oldlib.lock
       until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
 	func_echo "Waiting for $lockfile to be removed"
@@ -3724,7 +5097,7 @@ func_extract_an_archive ()
     fi
     func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
 		   'stat=$?; rm -f "$lockfile"; exit $stat'
-    if test "$lock_old_archive_extraction" = yes; then
+    if test yes = "$lock_old_archive_extraction"; then
       $opt_dry_run || rm -f "$lockfile"
     fi
     if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
@@ -3738,22 +5111,23 @@ func_extract_an_archive ()
 # func_extract_archives gentop oldlib ...
 func_extract_archives ()
 {
-    $opt_debug
-    my_gentop="$1"; shift
+    $debug_cmd
+
+    my_gentop=$1; shift
     my_oldlibs=${1+"$@"}
-    my_oldobjs=""
-    my_xlib=""
-    my_xabs=""
-    my_xdir=""
+    my_oldobjs=
+    my_xlib=
+    my_xabs=
+    my_xdir=
 
     for my_xlib in $my_oldlibs; do
       # Extract the objects.
       case $my_xlib in
-	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
+	[\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
 	*) my_xabs=`pwd`"/$my_xlib" ;;
       esac
       func_basename "$my_xlib"
-      my_xlib="$func_basename_result"
+      my_xlib=$func_basename_result
       my_xlib_u=$my_xlib
       while :; do
         case " $extracted_archives " in
@@ -3765,7 +5139,7 @@ func_extract_archives ()
 	esac
       done
       extracted_archives="$extracted_archives $my_xlib_u"
-      my_xdir="$my_gentop/$my_xlib_u"
+      my_xdir=$my_gentop/$my_xlib_u
 
       func_mkdir_p "$my_xdir"
 
@@ -3778,22 +5152,23 @@ func_extract_archives ()
 	  cd $my_xdir || exit $?
 	  darwin_archive=$my_xabs
 	  darwin_curdir=`pwd`
-	  darwin_base_archive=`basename "$darwin_archive"`
+	  func_basename "$darwin_archive"
+	  darwin_base_archive=$func_basename_result
 	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
 	  if test -n "$darwin_arches"; then
 	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
 	    darwin_arch=
 	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
-	    for darwin_arch in  $darwin_arches ; do
-	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
-	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
-	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
-	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
+	    for darwin_arch in  $darwin_arches; do
+	      func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
+	      $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
+	      cd "unfat-$$/$darwin_base_archive-$darwin_arch"
+	      func_extract_an_archive "`pwd`" "$darwin_base_archive"
 	      cd "$darwin_curdir"
-	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
+	      $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
 	    done # $darwin_arches
             ## Okay now we've a bunch of thin objects, gotta fatten them up :)
-	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
+	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
 	    darwin_file=
 	    darwin_files=
 	    for darwin_file in $darwin_filelist; do
@@ -3815,7 +5190,7 @@ func_extract_archives ()
       my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
     done
 
-    func_extract_archives_result="$my_oldobjs"
+    func_extract_archives_result=$my_oldobjs
 }
 
 
@@ -3830,7 +5205,7 @@ func_extract_archives ()
 #
 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
 # variable will take.  If 'yes', then the emitted script
-# will assume that the directory in which it is stored is
+# will assume that the directory where it is stored is
 # the $objdir directory.  This is a cygwin/mingw-specific
 # behavior.
 func_emit_wrapper ()
@@ -3841,7 +5216,7 @@ func_emit_wrapper ()
 #! $SHELL
 
 # $output - temporary wrapper script for $objdir/$outputname
-# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
 #
 # The $output program cannot be directly executed until all the libtool
 # libraries that it depends on are installed.
@@ -3898,9 +5273,9 @@ _LTECHO_EOF'
 
 # Very basic option parsing. These options are (a) specific to
 # the libtool wrapper, (b) are identical between the wrapper
-# /script/ and the wrapper /executable/ which is used only on
+# /script/ and the wrapper /executable/ that is used only on
 # windows platforms, and (c) all begin with the string "--lt-"
-# (application programs are unlikely to have options which match
+# (application programs are unlikely to have options that match
 # this pattern).
 #
 # There are only two supported options: --lt-debug and
@@ -3933,7 +5308,7 @@ func_parse_lt_options ()
 
   # Print the debug banner immediately:
   if test -n \"\$lt_option_debug\"; then
-    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
+    echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
   fi
 }
 
@@ -3944,7 +5319,7 @@ func_lt_dump_args ()
   lt_dump_args_N=1;
   for lt_arg
   do
-    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
+    \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
     lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
   done
 }
@@ -3958,7 +5333,7 @@ func_exec_program_core ()
   *-*-mingw | *-*-os2* | *-cegcc*)
     $ECHO "\
       if test -n \"\$lt_option_debug\"; then
-        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
+        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
         func_lt_dump_args \${1+\"\$@\"} 1>&2
       fi
       exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
@@ -3968,7 +5343,7 @@ func_exec_program_core ()
   *)
     $ECHO "\
       if test -n \"\$lt_option_debug\"; then
-        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
+        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
         func_lt_dump_args \${1+\"\$@\"} 1>&2
       fi
       exec \"\$progdir/\$program\" \${1+\"\$@\"}
@@ -4043,13 +5418,13 @@ func_exec_program ()
   test -n \"\$absdir\" && thisdir=\"\$absdir\"
 "
 
-	if test "$fast_install" = yes; then
+	if test yes = "$fast_install"; then
 	  $ECHO "\
   program=lt-'$outputname'$exeext
   progdir=\"\$thisdir/$objdir\"
 
   if test ! -f \"\$progdir/\$program\" ||
-     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
+     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
        test \"X\$file\" != \"X\$progdir/\$program\"; }; then
 
     file=\"\$\$-\$program\"
@@ -4066,7 +5441,7 @@ func_exec_program ()
     if test -n \"\$relink_command\"; then
       if relink_command_output=\`eval \$relink_command 2>&1\`; then :
       else
-	$ECHO \"\$relink_command_output\" >&2
+	\$ECHO \"\$relink_command_output\" >&2
 	$RM \"\$progdir/\$file\"
 	exit 1
       fi
@@ -4101,7 +5476,7 @@ func_exec_program ()
 	fi
 
 	# Export our shlibpath_var if we have one.
-	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+	if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
 	  $ECHO "\
     # Add our own library path to $shlibpath_var
     $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
@@ -4121,7 +5496,7 @@ func_exec_program ()
     fi
   else
     # The program doesn't exist.
-    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
+    \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
     \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
     \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
     exit 1
@@ -4140,7 +5515,7 @@ func_emit_cwrapperexe_src ()
 	cat <<EOF
 
 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
-   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+   Generated by $PROGRAM (GNU $PACKAGE) $VERSION
 
    The $output program cannot be directly executed until all the libtool
    libraries that it depends on are installed.
@@ -4175,47 +5550,45 @@ EOF
 #include <fcntl.h>
 #include <sys/stat.h>
 
+#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
+
 /* declarations of non-ANSI functions */
-#if defined(__MINGW32__)
+#if defined __MINGW32__
 # ifdef __STRICT_ANSI__
 int _putenv (const char *);
 # endif
-#elif defined(__CYGWIN__)
+#elif defined __CYGWIN__
 # ifdef __STRICT_ANSI__
 char *realpath (const char *, char *);
 int putenv (char *);
 int setenv (const char *, const char *, int);
 # endif
-/* #elif defined (other platforms) ... */
+/* #elif defined other_platform || defined ... */
 #endif
 
 /* portability defines, excluding path handling macros */
-#if defined(_MSC_VER)
+#if defined _MSC_VER
 # define setmode _setmode
 # define stat    _stat
 # define chmod   _chmod
 # define getcwd  _getcwd
 # define putenv  _putenv
 # define S_IXUSR _S_IEXEC
-# ifndef _INTPTR_T_DEFINED
-#  define _INTPTR_T_DEFINED
-#  define intptr_t int
-# endif
-#elif defined(__MINGW32__)
+#elif defined __MINGW32__
 # define setmode _setmode
 # define stat    _stat
 # define chmod   _chmod
 # define getcwd  _getcwd
 # define putenv  _putenv
-#elif defined(__CYGWIN__)
+#elif defined __CYGWIN__
 # define HAVE_SETENV
 # define FOPEN_WB "wb"
-/* #elif defined (other platforms) ... */
+/* #elif defined other platforms ... */
 #endif
 
-#if defined(PATH_MAX)
+#if defined PATH_MAX
 # define LT_PATHMAX PATH_MAX
-#elif defined(MAXPATHLEN)
+#elif defined MAXPATHLEN
 # define LT_PATHMAX MAXPATHLEN
 #else
 # define LT_PATHMAX 1024
@@ -4234,8 +5607,8 @@ int setenv (const char *, const char *, int);
 # define PATH_SEPARATOR ':'
 #endif
 
-#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
-  defined (__OS2__)
+#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
+  defined __OS2__
 # define HAVE_DOS_BASED_FILE_SYSTEM
 # define FOPEN_WB "wb"
 # ifndef DIR_SEPARATOR_2
@@ -4268,10 +5641,10 @@ int setenv (const char *, const char *, int);
 
 #define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
 #define XFREE(stale) do { \
-  if (stale) { free ((void *) stale); stale = 0; } \
+  if (stale) { free (stale); stale = 0; } \
 } while (0)
 
-#if defined(LT_DEBUGWRAPPER)
+#if defined LT_DEBUGWRAPPER
 static int lt_debug = 1;
 #else
 static int lt_debug = 0;
@@ -4300,11 +5673,16 @@ void lt_dump_script (FILE *f);
 EOF
 
 	    cat <<EOF
-volatile const char * MAGIC_EXE = "$magic_exe";
+#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
+# define externally_visible volatile
+#else
+# define externally_visible __attribute__((externally_visible)) volatile
+#endif
+externally_visible const char * MAGIC_EXE = "$magic_exe";
 const char * LIB_PATH_VARNAME = "$shlibpath_var";
 EOF
 
-	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+	    if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
               func_to_host_path "$temp_rpath"
 	      cat <<EOF
 const char * LIB_PATH_VALUE   = "$func_to_host_path_result";
@@ -4328,7 +5706,7 @@ const char * EXE_PATH_VALUE   = "";
 EOF
 	    fi
 
-	    if test "$fast_install" = yes; then
+	    if test yes = "$fast_install"; then
 	      cat <<EOF
 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
 EOF
@@ -4357,12 +5735,12 @@ main (int argc, char *argv[])
   char *actual_cwrapper_name;
   char *target_name;
   char *lt_argv_zero;
-  intptr_t rval = 127;
+  int rval = 127;
 
   int i;
 
   program_name = (char *) xstrdup (base_name (argv[0]));
-  newargz = XMALLOC (char *, argc + 1);
+  newargz = XMALLOC (char *, (size_t) argc + 1);
 
   /* very simple arg parsing; don't want to rely on getopt
    * also, copy all non cwrapper options to newargz, except
@@ -4371,10 +5749,10 @@ main (int argc, char *argv[])
   newargc=0;
   for (i = 1; i < argc; i++)
     {
-      if (strcmp (argv[i], dumpscript_opt) == 0)
+      if (STREQ (argv[i], dumpscript_opt))
 	{
 EOF
-	    case "$host" in
+	    case $host in
 	      *mingw* | *cygwin* )
 		# make stdout use "unix" line endings
 		echo "          setmode(1,_O_BINARY);"
@@ -4385,12 +5763,12 @@ EOF
 	  lt_dump_script (stdout);
 	  return 0;
 	}
-      if (strcmp (argv[i], debug_opt) == 0)
+      if (STREQ (argv[i], debug_opt))
 	{
           lt_debug = 1;
           continue;
 	}
-      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
+      if (STREQ (argv[i], ltwrapper_option_prefix))
         {
           /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
              namespace, but it is not one of the ones we know about and
@@ -4413,7 +5791,7 @@ EOF
 EOF
 	    cat <<EOF
   /* The GNU banner must be the first non-error debug message */
-  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
+  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
 EOF
 	    cat <<"EOF"
   lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
@@ -4524,7 +5902,7 @@ EOF
 		cat <<"EOF"
   /* execv doesn't actually work on mingw as expected on unix */
   newargz = prepare_spawn (newargz);
-  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
+  rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
   if (rval == -1)
     {
       /* failed to start process */
@@ -4569,7 +5947,7 @@ base_name (const char *name)
 {
   const char *base;
 
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+#if defined HAVE_DOS_BASED_FILE_SYSTEM
   /* Skip over the disk name in MSDOS pathnames. */
   if (isalpha ((unsigned char) name[0]) && name[1] == ':')
     name += 2;
@@ -4628,7 +6006,7 @@ find_executable (const char *wrapper)
   const char *p_next;
   /* static buffer for getcwd */
   char tmp[LT_PATHMAX + 1];
-  int tmp_len;
+  size_t tmp_len;
   char *concat_name;
 
   lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
@@ -4638,7 +6016,7 @@ find_executable (const char *wrapper)
     return NULL;
 
   /* Absolute path? */
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+#if defined HAVE_DOS_BASED_FILE_SYSTEM
   if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
     {
       concat_name = xstrdup (wrapper);
@@ -4656,7 +6034,7 @@ find_executable (const char *wrapper)
 	    return concat_name;
 	  XFREE (concat_name);
 	}
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+#if defined HAVE_DOS_BASED_FILE_SYSTEM
     }
 #endif
 
@@ -4679,7 +6057,7 @@ find_executable (const char *wrapper)
 	      for (q = p; *q; q++)
 		if (IS_PATH_SEPARATOR (*q))
 		  break;
-	      p_len = q - p;
+	      p_len = (size_t) (q - p);
 	      p_next = (*q == '\0' ? q : q + 1);
 	      if (p_len == 0)
 		{
@@ -4798,7 +6176,7 @@ strendzap (char *str, const char *pat)
   if (patlen <= len)
     {
       str += len - patlen;
-      if (strcmp (str, pat) == 0)
+      if (STREQ (str, pat))
 	*str = '\0';
     }
   return str;
@@ -4863,7 +6241,7 @@ lt_setenv (const char *name, const char *value)
     char *str = xstrdup (value);
     setenv (name, str, 1);
 #else
-    int len = strlen (name) + 1 + strlen (value) + 1;
+    size_t len = strlen (name) + 1 + strlen (value) + 1;
     char *str = XMALLOC (char, len);
     sprintf (str, "%s=%s", name, value);
     if (putenv (str) != EXIT_SUCCESS)
@@ -4880,8 +6258,8 @@ lt_extend_str (const char *orig_value, const char *add, int to_end)
   char *new_value;
   if (orig_value && *orig_value)
     {
-      int orig_value_len = strlen (orig_value);
-      int add_len = strlen (add);
+      size_t orig_value_len = strlen (orig_value);
+      size_t add_len = strlen (add);
       new_value = XMALLOC (char, add_len + orig_value_len + 1);
       if (to_end)
         {
@@ -4912,10 +6290,10 @@ lt_update_exe_path (const char *name, const char *value)
     {
       char *new_value = lt_extend_str (getenv (name), value, 0);
       /* some systems can't cope with a ':'-terminated path #' */
-      int len = strlen (new_value);
-      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
+      size_t len = strlen (new_value);
+      while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
         {
-          new_value[len-1] = '\0';
+          new_value[--len] = '\0';
         }
       lt_setenv (name, new_value);
       XFREE (new_value);
@@ -5082,27 +6460,47 @@ EOF
 # True if ARG is an import lib, as indicated by $file_magic_cmd
 func_win32_import_lib_p ()
 {
-    $opt_debug
+    $debug_cmd
+
     case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
     *import*) : ;;
     *) false ;;
     esac
 }
 
+# func_suncc_cstd_abi
+# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
+# Several compiler flags select an ABI that is incompatible with the
+# Cstd library. Avoid specifying it if any are in CXXFLAGS.
+func_suncc_cstd_abi ()
+{
+    $debug_cmd
+
+    case " $compile_command " in
+    *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
+      suncc_use_cstd_abi=no
+      ;;
+    *)
+      suncc_use_cstd_abi=yes
+      ;;
+    esac
+}
+
 # func_mode_link arg...
 func_mode_link ()
 {
-    $opt_debug
+    $debug_cmd
+
     case $host in
     *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
       # It is impossible to link a dll without this setting, and
       # we shouldn't force the makefile maintainer to figure out
-      # which system we are compiling for in order to pass an extra
+      # what system we are compiling for in order to pass an extra
       # flag for every libtool invocation.
       # allow_undefined=no
 
       # FIXME: Unfortunately, there are problems with the above when trying
-      # to make a dll which has undefined symbols, in which case not
+      # to make a dll that has undefined symbols, in which case not
       # even a static library is built.  For now, we need to specify
       # -no-undefined on the libtool link line when we can be certain
       # that all symbols are satisfied, otherwise we get a static library.
@@ -5146,10 +6544,11 @@ func_mode_link ()
     module=no
     no_install=no
     objs=
+    os2dllname=
     non_pic_objects=
     precious_files_regex=
     prefer_static_libs=no
-    preload=no
+    preload=false
     prev=
     prevarg=
     release=
@@ -5161,7 +6560,7 @@ func_mode_link ()
     vinfo=
     vinfo_number=no
     weak_libs=
-    single_module="${wl}-single_module"
+    single_module=$wl-single_module
     func_infer_tag $base_compile
 
     # We need to know -static, to get the right output filenames.
@@ -5169,15 +6568,15 @@ func_mode_link ()
     do
       case $arg in
       -shared)
-	test "$build_libtool_libs" != yes && \
-	  func_fatal_configuration "can not build a shared library"
+	test yes != "$build_libtool_libs" \
+	  && func_fatal_configuration "cannot build a shared library"
 	build_old_libs=no
 	break
 	;;
       -all-static | -static | -static-libtool-libs)
 	case $arg in
 	-all-static)
-	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
+	  if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
 	    func_warning "complete static linking is impossible in this configuration"
 	  fi
 	  if test -n "$link_static_flag"; then
@@ -5210,7 +6609,7 @@ func_mode_link ()
 
     # Go through the arguments, transforming them on the way.
     while test "$#" -gt 0; do
-      arg="$1"
+      arg=$1
       shift
       func_quote_for_eval "$arg"
       qarg=$func_quote_for_eval_unquoted_result
@@ -5227,21 +6626,21 @@ func_mode_link ()
 
 	case $prev in
 	bindir)
-	  bindir="$arg"
+	  bindir=$arg
 	  prev=
 	  continue
 	  ;;
 	dlfiles|dlprefiles)
-	  if test "$preload" = no; then
+	  $preload || {
 	    # Add the symbol object into the linking commands.
 	    func_append compile_command " @SYMFILE@"
 	    func_append finalize_command " @SYMFILE@"
-	    preload=yes
-	  fi
+	    preload=:
+	  }
 	  case $arg in
 	  *.la | *.lo) ;;  # We handle these cases below.
 	  force)
-	    if test "$dlself" = no; then
+	    if test no = "$dlself"; then
 	      dlself=needless
 	      export_dynamic=yes
 	    fi
@@ -5249,9 +6648,9 @@ func_mode_link ()
 	    continue
 	    ;;
 	  self)
-	    if test "$prev" = dlprefiles; then
+	    if test dlprefiles = "$prev"; then
 	      dlself=yes
-	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
+	    elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
 	      dlself=yes
 	    else
 	      dlself=needless
@@ -5261,7 +6660,7 @@ func_mode_link ()
 	    continue
 	    ;;
 	  *)
-	    if test "$prev" = dlfiles; then
+	    if test dlfiles = "$prev"; then
 	      func_append dlfiles " $arg"
 	    else
 	      func_append dlprefiles " $arg"
@@ -5272,14 +6671,14 @@ func_mode_link ()
 	  esac
 	  ;;
 	expsyms)
-	  export_symbols="$arg"
+	  export_symbols=$arg
 	  test -f "$arg" \
-	    || func_fatal_error "symbol file \`$arg' does not exist"
+	    || func_fatal_error "symbol file '$arg' does not exist"
 	  prev=
 	  continue
 	  ;;
 	expsyms_regex)
-	  export_symbols_regex="$arg"
+	  export_symbols_regex=$arg
 	  prev=
 	  continue
 	  ;;
@@ -5297,7 +6696,13 @@ func_mode_link ()
 	  continue
 	  ;;
 	inst_prefix)
-	  inst_prefix_dir="$arg"
+	  inst_prefix_dir=$arg
+	  prev=
+	  continue
+	  ;;
+	mllvm)
+	  # Clang does not use LLVM to link, so we can simply discard any
+	  # '-mllvm $arg' options when doing the link step.
 	  prev=
 	  continue
 	  ;;
@@ -5321,21 +6726,21 @@ func_mode_link ()
 
 		if test -z "$pic_object" ||
 		   test -z "$non_pic_object" ||
-		   test "$pic_object" = none &&
-		   test "$non_pic_object" = none; then
-		  func_fatal_error "cannot find name of object for \`$arg'"
+		   test none = "$pic_object" &&
+		   test none = "$non_pic_object"; then
+		  func_fatal_error "cannot find name of object for '$arg'"
 		fi
 
 		# Extract subdirectory from the argument.
 		func_dirname "$arg" "/" ""
-		xdir="$func_dirname_result"
+		xdir=$func_dirname_result
 
-		if test "$pic_object" != none; then
+		if test none != "$pic_object"; then
 		  # Prepend the subdirectory the object is found in.
-		  pic_object="$xdir$pic_object"
+		  pic_object=$xdir$pic_object
 
-		  if test "$prev" = dlfiles; then
-		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+		  if test dlfiles = "$prev"; then
+		    if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
 		      func_append dlfiles " $pic_object"
 		      prev=
 		      continue
@@ -5346,7 +6751,7 @@ func_mode_link ()
 		  fi
 
 		  # CHECK ME:  I think I busted this.  -Ossama
-		  if test "$prev" = dlprefiles; then
+		  if test dlprefiles = "$prev"; then
 		    # Preload the old-style object.
 		    func_append dlprefiles " $pic_object"
 		    prev=
@@ -5354,23 +6759,23 @@ func_mode_link ()
 
 		  # A PIC object.
 		  func_append libobjs " $pic_object"
-		  arg="$pic_object"
+		  arg=$pic_object
 		fi
 
 		# Non-PIC object.
-		if test "$non_pic_object" != none; then
+		if test none != "$non_pic_object"; then
 		  # Prepend the subdirectory the object is found in.
-		  non_pic_object="$xdir$non_pic_object"
+		  non_pic_object=$xdir$non_pic_object
 
 		  # A standard non-PIC object
 		  func_append non_pic_objects " $non_pic_object"
-		  if test -z "$pic_object" || test "$pic_object" = none ; then
-		    arg="$non_pic_object"
+		  if test -z "$pic_object" || test none = "$pic_object"; then
+		    arg=$non_pic_object
 		  fi
 		else
 		  # If the PIC object exists, use it instead.
 		  # $xdir was prepended to $pic_object above.
-		  non_pic_object="$pic_object"
+		  non_pic_object=$pic_object
 		  func_append non_pic_objects " $non_pic_object"
 		fi
 	      else
@@ -5378,7 +6783,7 @@ func_mode_link ()
 		if $opt_dry_run; then
 		  # Extract subdirectory from the argument.
 		  func_dirname "$arg" "/" ""
-		  xdir="$func_dirname_result"
+		  xdir=$func_dirname_result
 
 		  func_lo2o "$arg"
 		  pic_object=$xdir$objdir/$func_lo2o_result
@@ -5386,24 +6791,29 @@ func_mode_link ()
 		  func_append libobjs " $pic_object"
 		  func_append non_pic_objects " $non_pic_object"
 	        else
-		  func_fatal_error "\`$arg' is not a valid libtool object"
+		  func_fatal_error "'$arg' is not a valid libtool object"
 		fi
 	      fi
 	    done
 	  else
-	    func_fatal_error "link input file \`$arg' does not exist"
+	    func_fatal_error "link input file '$arg' does not exist"
 	  fi
 	  arg=$save_arg
 	  prev=
 	  continue
 	  ;;
+	os2dllname)
+	  os2dllname=$arg
+	  prev=
+	  continue
+	  ;;
 	precious_regex)
-	  precious_files_regex="$arg"
+	  precious_files_regex=$arg
 	  prev=
 	  continue
 	  ;;
 	release)
-	  release="-$arg"
+	  release=-$arg
 	  prev=
 	  continue
 	  ;;
@@ -5415,7 +6825,7 @@ func_mode_link ()
 	    func_fatal_error "only absolute run-paths are allowed"
 	    ;;
 	  esac
-	  if test "$prev" = rpath; then
+	  if test rpath = "$prev"; then
 	    case "$rpath " in
 	    *" $arg "*) ;;
 	    *) func_append rpath " $arg" ;;
@@ -5430,7 +6840,7 @@ func_mode_link ()
 	  continue
 	  ;;
 	shrext)
-	  shrext_cmds="$arg"
+	  shrext_cmds=$arg
 	  prev=
 	  continue
 	  ;;
@@ -5470,7 +6880,7 @@ func_mode_link ()
 	esac
       fi # test -n "$prev"
 
-      prevarg="$arg"
+      prevarg=$arg
 
       case $arg in
       -all-static)
@@ -5484,7 +6894,7 @@ func_mode_link ()
 
       -allow-undefined)
 	# FIXME: remove this flag sometime in the future.
-	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
+	func_fatal_error "'-allow-undefined' must not be used because it is the default"
 	;;
 
       -avoid-version)
@@ -5516,7 +6926,7 @@ func_mode_link ()
 	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
 	  func_fatal_error "more than one -exported-symbols argument is not allowed"
 	fi
-	if test "X$arg" = "X-export-symbols"; then
+	if test X-export-symbols = "X$arg"; then
 	  prev=expsyms
 	else
 	  prev=expsyms_regex
@@ -5550,9 +6960,9 @@ func_mode_link ()
 	func_stripname "-L" '' "$arg"
 	if test -z "$func_stripname_result"; then
 	  if test "$#" -gt 0; then
-	    func_fatal_error "require no space between \`-L' and \`$1'"
+	    func_fatal_error "require no space between '-L' and '$1'"
 	  else
-	    func_fatal_error "need path for \`-L' option"
+	    func_fatal_error "need path for '-L' option"
 	  fi
 	fi
 	func_resolve_sysroot "$func_stripname_result"
@@ -5563,8 +6973,8 @@ func_mode_link ()
 	*)
 	  absdir=`cd "$dir" && pwd`
 	  test -z "$absdir" && \
-	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
-	  dir="$absdir"
+	    func_fatal_error "cannot determine absolute directory name of '$dir'"
+	  dir=$absdir
 	  ;;
 	esac
 	case "$deplibs " in
@@ -5599,7 +7009,7 @@ func_mode_link ()
 	;;
 
       -l*)
-	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
+	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
 	  case $host in
 	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
 	    # These systems don't actually have a C or math library (as such)
@@ -5607,11 +7017,11 @@ func_mode_link ()
 	    ;;
 	  *-*-os2*)
 	    # These systems don't actually have a C library (as such)
-	    test "X$arg" = "X-lc" && continue
+	    test X-lc = "X$arg" && continue
 	    ;;
-	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
 	    # Do not include libc due to us having libc/libc_r.
-	    test "X$arg" = "X-lc" && continue
+	    test X-lc = "X$arg" && continue
 	    ;;
 	  *-*-rhapsody* | *-*-darwin1.[012])
 	    # Rhapsody C and math libraries are in the System framework
@@ -5620,16 +7030,16 @@ func_mode_link ()
 	    ;;
 	  *-*-sco3.2v5* | *-*-sco5v6*)
 	    # Causes problems with __ctype
-	    test "X$arg" = "X-lc" && continue
+	    test X-lc = "X$arg" && continue
 	    ;;
 	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
 	    # Compiler inserts libc in the correct place for threads to work
-	    test "X$arg" = "X-lc" && continue
+	    test X-lc = "X$arg" && continue
 	    ;;
 	  esac
-	elif test "X$arg" = "X-lc_r"; then
+	elif test X-lc_r = "X$arg"; then
 	 case $host in
-	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
 	   # Do not include libc_r directly, use -pthread flag.
 	   continue
 	   ;;
@@ -5639,6 +7049,11 @@ func_mode_link ()
 	continue
 	;;
 
+      -mllvm)
+	prev=mllvm
+	continue
+	;;
+
       -module)
 	module=yes
 	continue
@@ -5668,7 +7083,7 @@ func_mode_link ()
 	;;
 
       -multi_module)
-	single_module="${wl}-multi_module"
+	single_module=$wl-multi_module
 	continue
 	;;
 
@@ -5682,8 +7097,8 @@ func_mode_link ()
 	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
 	  # The PATH hackery in wrapper scripts is required on Windows
 	  # and Darwin in order for the loader to find any dlls it needs.
-	  func_warning "\`-no-install' is ignored for $host"
-	  func_warning "assuming \`-no-fast-install' instead"
+	  func_warning "'-no-install' is ignored for $host"
+	  func_warning "assuming '-no-fast-install' instead"
 	  fast_install=no
 	  ;;
 	*) no_install=yes ;;
@@ -5701,6 +7116,11 @@ func_mode_link ()
 	continue
 	;;
 
+      -os2dllname)
+	prev=os2dllname
+	continue
+	;;
+
       -o) prev=output ;;
 
       -precious-files-regex)
@@ -5788,14 +7208,14 @@ func_mode_link ()
 	func_stripname '-Wc,' '' "$arg"
 	args=$func_stripname_result
 	arg=
-	save_ifs="$IFS"; IFS=','
+	save_ifs=$IFS; IFS=,
 	for flag in $args; do
-	  IFS="$save_ifs"
+	  IFS=$save_ifs
           func_quote_for_eval "$flag"
 	  func_append arg " $func_quote_for_eval_result"
 	  func_append compiler_flags " $func_quote_for_eval_result"
 	done
-	IFS="$save_ifs"
+	IFS=$save_ifs
 	func_stripname ' ' '' "$arg"
 	arg=$func_stripname_result
 	;;
@@ -5804,15 +7224,15 @@ func_mode_link ()
 	func_stripname '-Wl,' '' "$arg"
 	args=$func_stripname_result
 	arg=
-	save_ifs="$IFS"; IFS=','
+	save_ifs=$IFS; IFS=,
 	for flag in $args; do
-	  IFS="$save_ifs"
+	  IFS=$save_ifs
           func_quote_for_eval "$flag"
 	  func_append arg " $wl$func_quote_for_eval_result"
 	  func_append compiler_flags " $wl$func_quote_for_eval_result"
 	  func_append linker_flags " $func_quote_for_eval_result"
 	done
-	IFS="$save_ifs"
+	IFS=$save_ifs
 	func_stripname ' ' '' "$arg"
 	arg=$func_stripname_result
 	;;
@@ -5835,7 +7255,7 @@ func_mode_link ()
       # -msg_* for osf cc
       -msg_*)
 	func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
+	arg=$func_quote_for_eval_result
 	;;
 
       # Flags to be passed through unchanged, with rationale:
@@ -5847,25 +7267,46 @@ func_mode_link ()
       # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
       # -F/path              path to uninstalled frameworks, gcc on darwin
       # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
+      # -fstack-protector*   stack protector flags for GCC
       # @file                GCC response files
       # -tp=*                Portland pgcc target processor selection
       # --sysroot=*          for sysroot support
-      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
+      # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
+      # -stdlib=*            select c++ std lib with clang
       -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
       -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
-      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
+      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*)
         func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
+	arg=$func_quote_for_eval_result
         func_append compile_command " $arg"
         func_append finalize_command " $arg"
         func_append compiler_flags " $arg"
         continue
         ;;
 
+      -Z*)
+        if test os2 = "`expr $host : '.*\(os2\)'`"; then
+          # OS/2 uses -Zxxx to specify OS/2-specific options
+	  compiler_flags="$compiler_flags $arg"
+	  func_append compile_command " $arg"
+	  func_append finalize_command " $arg"
+	  case $arg in
+	  -Zlinker | -Zstack)
+	    prev=xcompiler
+	    ;;
+	  esac
+	  continue
+        else
+	  # Otherwise treat like 'Some other compiler flag' below
+	  func_quote_for_eval "$arg"
+	  arg=$func_quote_for_eval_result
+        fi
+	;;
+
       # Some other compiler flag.
       -* | +*)
         func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
+	arg=$func_quote_for_eval_result
 	;;
 
       *.$objext)
@@ -5886,21 +7327,21 @@ func_mode_link ()
 
 	  if test -z "$pic_object" ||
 	     test -z "$non_pic_object" ||
-	     test "$pic_object" = none &&
-	     test "$non_pic_object" = none; then
-	    func_fatal_error "cannot find name of object for \`$arg'"
+	     test none = "$pic_object" &&
+	     test none = "$non_pic_object"; then
+	    func_fatal_error "cannot find name of object for '$arg'"
 	  fi
 
 	  # Extract subdirectory from the argument.
 	  func_dirname "$arg" "/" ""
-	  xdir="$func_dirname_result"
+	  xdir=$func_dirname_result
 
-	  if test "$pic_object" != none; then
+	  test none = "$pic_object" || {
 	    # Prepend the subdirectory the object is found in.
-	    pic_object="$xdir$pic_object"
+	    pic_object=$xdir$pic_object
 
-	    if test "$prev" = dlfiles; then
-	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+	    if test dlfiles = "$prev"; then
+	      if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
 		func_append dlfiles " $pic_object"
 		prev=
 		continue
@@ -5911,7 +7352,7 @@ func_mode_link ()
 	    fi
 
 	    # CHECK ME:  I think I busted this.  -Ossama
-	    if test "$prev" = dlprefiles; then
+	    if test dlprefiles = "$prev"; then
 	      # Preload the old-style object.
 	      func_append dlprefiles " $pic_object"
 	      prev=
@@ -5919,23 +7360,23 @@ func_mode_link ()
 
 	    # A PIC object.
 	    func_append libobjs " $pic_object"
-	    arg="$pic_object"
-	  fi
+	    arg=$pic_object
+	  }
 
 	  # Non-PIC object.
-	  if test "$non_pic_object" != none; then
+	  if test none != "$non_pic_object"; then
 	    # Prepend the subdirectory the object is found in.
-	    non_pic_object="$xdir$non_pic_object"
+	    non_pic_object=$xdir$non_pic_object
 
 	    # A standard non-PIC object
 	    func_append non_pic_objects " $non_pic_object"
-	    if test -z "$pic_object" || test "$pic_object" = none ; then
-	      arg="$non_pic_object"
+	    if test -z "$pic_object" || test none = "$pic_object"; then
+	      arg=$non_pic_object
 	    fi
 	  else
 	    # If the PIC object exists, use it instead.
 	    # $xdir was prepended to $pic_object above.
-	    non_pic_object="$pic_object"
+	    non_pic_object=$pic_object
 	    func_append non_pic_objects " $non_pic_object"
 	  fi
 	else
@@ -5943,7 +7384,7 @@ func_mode_link ()
 	  if $opt_dry_run; then
 	    # Extract subdirectory from the argument.
 	    func_dirname "$arg" "/" ""
-	    xdir="$func_dirname_result"
+	    xdir=$func_dirname_result
 
 	    func_lo2o "$arg"
 	    pic_object=$xdir$objdir/$func_lo2o_result
@@ -5951,7 +7392,7 @@ func_mode_link ()
 	    func_append libobjs " $pic_object"
 	    func_append non_pic_objects " $non_pic_object"
 	  else
-	    func_fatal_error "\`$arg' is not a valid libtool object"
+	    func_fatal_error "'$arg' is not a valid libtool object"
 	  fi
 	fi
 	;;
@@ -5967,11 +7408,11 @@ func_mode_link ()
 	# A libtool-controlled library.
 
 	func_resolve_sysroot "$arg"
-	if test "$prev" = dlfiles; then
+	if test dlfiles = "$prev"; then
 	  # This library was specified with -dlopen.
 	  func_append dlfiles " $func_resolve_sysroot_result"
 	  prev=
-	elif test "$prev" = dlprefiles; then
+	elif test dlprefiles = "$prev"; then
 	  # The library was specified with -dlpreopen.
 	  func_append dlprefiles " $func_resolve_sysroot_result"
 	  prev=
@@ -5986,7 +7427,7 @@ func_mode_link ()
 	# Unknown arguments in both finalize_command and compile_command need
 	# to be aesthetically quoted because they are evaled later.
 	func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
+	arg=$func_quote_for_eval_result
 	;;
       esac # arg
 
@@ -5998,9 +7439,9 @@ func_mode_link ()
     done # argument parsing loop
 
     test -n "$prev" && \
-      func_fatal_help "the \`$prevarg' option requires an argument"
+      func_fatal_help "the '$prevarg' option requires an argument"
 
-    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
+    if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
       eval arg=\"$export_dynamic_flag_spec\"
       func_append compile_command " $arg"
       func_append finalize_command " $arg"
@@ -6009,20 +7450,23 @@ func_mode_link ()
     oldlibs=
     # calculate the name of the file, without its directory
     func_basename "$output"
-    outputname="$func_basename_result"
-    libobjs_save="$libobjs"
+    outputname=$func_basename_result
+    libobjs_save=$libobjs
 
     if test -n "$shlibpath_var"; then
       # get the directories listed in $shlibpath_var
-      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
+      eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
     else
       shlib_search_path=
     fi
     eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
     eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
 
+    # Definition is injected by LT_CONFIG during libtool generation.
+    func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
+
     func_dirname "$output" "/" ""
-    output_objdir="$func_dirname_result$objdir"
+    output_objdir=$func_dirname_result$objdir
     func_to_tool_file "$output_objdir/"
     tool_output_objdir=$func_to_tool_file_result
     # Create the object directory.
@@ -6045,7 +7489,7 @@ func_mode_link ()
     # Find all interdependent deplibs by searching for libraries
     # that are linked more than once (e.g. -la -lb -la)
     for deplib in $deplibs; do
-      if $opt_preserve_dup_deps ; then
+      if $opt_preserve_dup_deps; then
 	case "$libs " in
 	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
 	esac
@@ -6053,7 +7497,7 @@ func_mode_link ()
       func_append libs " $deplib"
     done
 
-    if test "$linkmode" = lib; then
+    if test lib = "$linkmode"; then
       libs="$predeps $libs $compiler_lib_search_path $postdeps"
 
       # Compute libraries that are listed more than once in $predeps
@@ -6085,7 +7529,7 @@ func_mode_link ()
 	  case $file in
 	  *.la) ;;
 	  *)
-	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
+	    func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
 	    ;;
 	  esac
 	done
@@ -6093,7 +7537,7 @@ func_mode_link ()
     prog)
 	compile_deplibs=
 	finalize_deplibs=
-	alldeplibs=no
+	alldeplibs=false
 	newdlfiles=
 	newdlprefiles=
 	passes="conv scan dlopen dlpreopen link"
@@ -6105,32 +7549,29 @@ func_mode_link ()
     for pass in $passes; do
       # The preopen pass in lib mode reverses $deplibs; put it back here
       # so that -L comes before libs that need it for instance...
-      if test "$linkmode,$pass" = "lib,link"; then
+      if test lib,link = "$linkmode,$pass"; then
 	## FIXME: Find the place where the list is rebuilt in the wrong
 	##        order, and fix it there properly
         tmp_deplibs=
 	for deplib in $deplibs; do
 	  tmp_deplibs="$deplib $tmp_deplibs"
 	done
-	deplibs="$tmp_deplibs"
+	deplibs=$tmp_deplibs
       fi
 
-      if test "$linkmode,$pass" = "lib,link" ||
-	 test "$linkmode,$pass" = "prog,scan"; then
-	libs="$deplibs"
+      if test lib,link = "$linkmode,$pass" ||
+	 test prog,scan = "$linkmode,$pass"; then
+	libs=$deplibs
 	deplibs=
       fi
-      if test "$linkmode" = prog; then
+      if test prog = "$linkmode"; then
 	case $pass in
-	dlopen) libs="$dlfiles" ;;
-	dlpreopen) libs="$dlprefiles" ;;
-	link)
-	  libs="$deplibs %DEPLIBS%"
-	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
-	  ;;
+	dlopen) libs=$dlfiles ;;
+	dlpreopen) libs=$dlprefiles ;;
+	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
 	esac
       fi
-      if test "$linkmode,$pass" = "lib,dlpreopen"; then
+      if test lib,dlpreopen = "$linkmode,$pass"; then
 	# Collect and forward deplibs of preopened libtool libs
 	for lib in $dlprefiles; do
 	  # Ignore non-libtool-libs
@@ -6151,26 +7592,26 @@ func_mode_link ()
 	    esac
 	  done
 	done
-	libs="$dlprefiles"
+	libs=$dlprefiles
       fi
-      if test "$pass" = dlopen; then
+      if test dlopen = "$pass"; then
 	# Collect dlpreopened libraries
-	save_deplibs="$deplibs"
+	save_deplibs=$deplibs
 	deplibs=
       fi
 
       for deplib in $libs; do
 	lib=
-	found=no
+	found=false
 	case $deplib in
 	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
         |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
-	  if test "$linkmode,$pass" = "prog,link"; then
+	  if test prog,link = "$linkmode,$pass"; then
 	    compile_deplibs="$deplib $compile_deplibs"
 	    finalize_deplibs="$deplib $finalize_deplibs"
 	  else
 	    func_append compiler_flags " $deplib"
-	    if test "$linkmode" = lib ; then
+	    if test lib = "$linkmode"; then
 		case "$new_inherited_linker_flags " in
 		    *" $deplib "*) ;;
 		    * ) func_append new_inherited_linker_flags " $deplib" ;;
@@ -6180,13 +7621,13 @@ func_mode_link ()
 	  continue
 	  ;;
 	-l*)
-	  if test "$linkmode" != lib && test "$linkmode" != prog; then
-	    func_warning "\`-l' is ignored for archives/objects"
+	  if test lib != "$linkmode" && test prog != "$linkmode"; then
+	    func_warning "'-l' is ignored for archives/objects"
 	    continue
 	  fi
 	  func_stripname '-l' '' "$deplib"
 	  name=$func_stripname_result
-	  if test "$linkmode" = lib; then
+	  if test lib = "$linkmode"; then
 	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
 	  else
 	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
@@ -6194,31 +7635,22 @@ func_mode_link ()
 	  for searchdir in $searchdirs; do
 	    for search_ext in .la $std_shrext .so .a; do
 	      # Search the libtool library
-	      lib="$searchdir/lib${name}${search_ext}"
+	      lib=$searchdir/lib$name$search_ext
 	      if test -f "$lib"; then
-		if test "$search_ext" = ".la"; then
-		  found=yes
+		if test .la = "$search_ext"; then
+		  found=:
 		else
-		  found=no
+		  found=false
 		fi
 		break 2
 	      fi
 	    done
 	  done
-	  if test "$found" != yes; then
-	    # deplib doesn't seem to be a libtool library
-	    if test "$linkmode,$pass" = "prog,link"; then
-	      compile_deplibs="$deplib $compile_deplibs"
-	      finalize_deplibs="$deplib $finalize_deplibs"
-	    else
-	      deplibs="$deplib $deplibs"
-	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
-	    fi
-	    continue
-	  else # deplib is a libtool library
+	  if $found; then
+	    # deplib is a libtool library
 	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
 	    # We need to do some special things here, and not later.
-	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	    if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 	      case " $predeps $postdeps " in
 	      *" $deplib "*)
 		if func_lalib_p "$lib"; then
@@ -6226,19 +7658,19 @@ func_mode_link ()
 		  old_library=
 		  func_source "$lib"
 		  for l in $old_library $library_names; do
-		    ll="$l"
+		    ll=$l
 		  done
-		  if test "X$ll" = "X$old_library" ; then # only static version available
-		    found=no
+		  if test "X$ll" = "X$old_library"; then # only static version available
+		    found=false
 		    func_dirname "$lib" "" "."
-		    ladir="$func_dirname_result"
+		    ladir=$func_dirname_result
 		    lib=$ladir/$old_library
-		    if test "$linkmode,$pass" = "prog,link"; then
+		    if test prog,link = "$linkmode,$pass"; then
 		      compile_deplibs="$deplib $compile_deplibs"
 		      finalize_deplibs="$deplib $finalize_deplibs"
 		    else
 		      deplibs="$deplib $deplibs"
-		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+		      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
 		    fi
 		    continue
 		  fi
@@ -6247,15 +7679,25 @@ func_mode_link ()
 	      *) ;;
 	      esac
 	    fi
+	  else
+	    # deplib doesn't seem to be a libtool library
+	    if test prog,link = "$linkmode,$pass"; then
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    else
+	      deplibs="$deplib $deplibs"
+	      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
+	    fi
+	    continue
 	  fi
 	  ;; # -l
 	*.ltframework)
-	  if test "$linkmode,$pass" = "prog,link"; then
+	  if test prog,link = "$linkmode,$pass"; then
 	    compile_deplibs="$deplib $compile_deplibs"
 	    finalize_deplibs="$deplib $finalize_deplibs"
 	  else
 	    deplibs="$deplib $deplibs"
-	    if test "$linkmode" = lib ; then
+	    if test lib = "$linkmode"; then
 		case "$new_inherited_linker_flags " in
 		    *" $deplib "*) ;;
 		    * ) func_append new_inherited_linker_flags " $deplib" ;;
@@ -6268,18 +7710,18 @@ func_mode_link ()
 	  case $linkmode in
 	  lib)
 	    deplibs="$deplib $deplibs"
-	    test "$pass" = conv && continue
+	    test conv = "$pass" && continue
 	    newdependency_libs="$deplib $newdependency_libs"
 	    func_stripname '-L' '' "$deplib"
 	    func_resolve_sysroot "$func_stripname_result"
 	    func_append newlib_search_path " $func_resolve_sysroot_result"
 	    ;;
 	  prog)
-	    if test "$pass" = conv; then
+	    if test conv = "$pass"; then
 	      deplibs="$deplib $deplibs"
 	      continue
 	    fi
-	    if test "$pass" = scan; then
+	    if test scan = "$pass"; then
 	      deplibs="$deplib $deplibs"
 	    else
 	      compile_deplibs="$deplib $compile_deplibs"
@@ -6290,13 +7732,13 @@ func_mode_link ()
 	    func_append newlib_search_path " $func_resolve_sysroot_result"
 	    ;;
 	  *)
-	    func_warning "\`-L' is ignored for archives/objects"
+	    func_warning "'-L' is ignored for archives/objects"
 	    ;;
 	  esac # linkmode
 	  continue
 	  ;; # -L
 	-R*)
-	  if test "$pass" = link; then
+	  if test link = "$pass"; then
 	    func_stripname '-R' '' "$deplib"
 	    func_resolve_sysroot "$func_stripname_result"
 	    dir=$func_resolve_sysroot_result
@@ -6314,7 +7756,7 @@ func_mode_link ()
 	  lib=$func_resolve_sysroot_result
 	  ;;
 	*.$libext)
-	  if test "$pass" = conv; then
+	  if test conv = "$pass"; then
 	    deplibs="$deplib $deplibs"
 	    continue
 	  fi
@@ -6325,21 +7767,26 @@ func_mode_link ()
 	    case " $dlpreconveniencelibs " in
 	    *" $deplib "*) ;;
 	    *)
-	      valid_a_lib=no
+	      valid_a_lib=false
 	      case $deplibs_check_method in
 		match_pattern*)
 		  set dummy $deplibs_check_method; shift
 		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
 		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
 		    | $EGREP "$match_pattern_regex" > /dev/null; then
-		    valid_a_lib=yes
+		    valid_a_lib=:
 		  fi
 		;;
 		pass_all)
-		  valid_a_lib=yes
+		  valid_a_lib=:
 		;;
 	      esac
-	      if test "$valid_a_lib" != yes; then
+	      if $valid_a_lib; then
+		echo
+		$ECHO "*** Warning: Linking the shared library $output against the"
+		$ECHO "*** static library $deplib is not portable!"
+		deplibs="$deplib $deplibs"
+	      else
 		echo
 		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
 		echo "*** I have the capability to make that library automatically link in when"
@@ -6347,18 +7794,13 @@ func_mode_link ()
 		echo "*** shared version of the library, which you do not appear to have"
 		echo "*** because the file extensions .$libext of this argument makes me believe"
 		echo "*** that it is just a static archive that I should not use here."
-	      else
-		echo
-		$ECHO "*** Warning: Linking the shared library $output against the"
-		$ECHO "*** static library $deplib is not portable!"
-		deplibs="$deplib $deplibs"
 	      fi
 	      ;;
 	    esac
 	    continue
 	    ;;
 	  prog)
-	    if test "$pass" != link; then
+	    if test link != "$pass"; then
 	      deplibs="$deplib $deplibs"
 	    else
 	      compile_deplibs="$deplib $compile_deplibs"
@@ -6369,10 +7811,10 @@ func_mode_link ()
 	  esac # linkmode
 	  ;; # *.$libext
 	*.lo | *.$objext)
-	  if test "$pass" = conv; then
+	  if test conv = "$pass"; then
 	    deplibs="$deplib $deplibs"
-	  elif test "$linkmode" = prog; then
-	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+	  elif test prog = "$linkmode"; then
+	    if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
 	      # If there is no dlopen support or we're linking statically,
 	      # we need to preload.
 	      func_append newdlprefiles " $deplib"
@@ -6385,22 +7827,20 @@ func_mode_link ()
 	  continue
 	  ;;
 	%DEPLIBS%)
-	  alldeplibs=yes
+	  alldeplibs=:
 	  continue
 	  ;;
 	esac # case $deplib
 
-	if test "$found" = yes || test -f "$lib"; then :
-	else
-	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
-	fi
+	$found || test -f "$lib" \
+	  || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
 
 	# Check to see that this really is a libtool archive.
 	func_lalib_unsafe_p "$lib" \
-	  || func_fatal_error "\`$lib' is not a valid libtool archive"
+	  || func_fatal_error "'$lib' is not a valid libtool archive"
 
 	func_dirname "$lib" "" "."
-	ladir="$func_dirname_result"
+	ladir=$func_dirname_result
 
 	dlname=
 	dlopen=
@@ -6430,36 +7870,36 @@ func_mode_link ()
 	  done
 	fi
 	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
-	if test "$linkmode,$pass" = "lib,link" ||
-	   test "$linkmode,$pass" = "prog,scan" ||
-	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
+	if test lib,link = "$linkmode,$pass" ||
+	   test prog,scan = "$linkmode,$pass" ||
+	   { test prog != "$linkmode" && test lib != "$linkmode"; }; then
 	  test -n "$dlopen" && func_append dlfiles " $dlopen"
 	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
 	fi
 
-	if test "$pass" = conv; then
+	if test conv = "$pass"; then
 	  # Only check for convenience libraries
 	  deplibs="$lib $deplibs"
 	  if test -z "$libdir"; then
 	    if test -z "$old_library"; then
-	      func_fatal_error "cannot find name of link library for \`$lib'"
+	      func_fatal_error "cannot find name of link library for '$lib'"
 	    fi
 	    # It is a libtool convenience library, so add in its objects.
 	    func_append convenience " $ladir/$objdir/$old_library"
 	    func_append old_convenience " $ladir/$objdir/$old_library"
-	    tmp_libs=
-	    for deplib in $dependency_libs; do
-	      deplibs="$deplib $deplibs"
-	      if $opt_preserve_dup_deps ; then
-		case "$tmp_libs " in
-		*" $deplib "*) func_append specialdeplibs " $deplib" ;;
-		esac
-	      fi
-	      func_append tmp_libs " $deplib"
-	    done
-	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
-	    func_fatal_error "\`$lib' is not a convenience library"
+	  elif test prog != "$linkmode" && test lib != "$linkmode"; then
+	    func_fatal_error "'$lib' is not a convenience library"
 	  fi
+	  tmp_libs=
+	  for deplib in $dependency_libs; do
+	    deplibs="$deplib $deplibs"
+	    if $opt_preserve_dup_deps; then
+	      case "$tmp_libs " in
+	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
+	      esac
+	    fi
+	    func_append tmp_libs " $deplib"
+	  done
 	  continue
 	fi # $pass = conv
 
@@ -6467,26 +7907,26 @@ func_mode_link ()
 	# Get the name of the library we link against.
 	linklib=
 	if test -n "$old_library" &&
-	   { test "$prefer_static_libs" = yes ||
-	     test "$prefer_static_libs,$installed" = "built,no"; }; then
+	   { test yes = "$prefer_static_libs" ||
+	     test built,no = "$prefer_static_libs,$installed"; }; then
 	  linklib=$old_library
 	else
 	  for l in $old_library $library_names; do
-	    linklib="$l"
+	    linklib=$l
 	  done
 	fi
 	if test -z "$linklib"; then
-	  func_fatal_error "cannot find name of link library for \`$lib'"
+	  func_fatal_error "cannot find name of link library for '$lib'"
 	fi
 
 	# This library was specified with -dlopen.
-	if test "$pass" = dlopen; then
-	  if test -z "$libdir"; then
-	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
-	  fi
+	if test dlopen = "$pass"; then
+	  test -z "$libdir" \
+	    && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
 	  if test -z "$dlname" ||
-	     test "$dlopen_support" != yes ||
-	     test "$build_libtool_libs" = no; then
+	     test yes != "$dlopen_support" ||
+	     test no = "$build_libtool_libs"
+	  then
 	    # If there is no dlname, no dlopen support or we're linking
 	    # statically, we need to preload.  We also need to preload any
 	    # dependent libraries so libltdl's deplib preloader doesn't
@@ -6500,40 +7940,40 @@ func_mode_link ()
 
 	# We need an absolute path.
 	case $ladir in
-	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
+	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
 	*)
 	  abs_ladir=`cd "$ladir" && pwd`
 	  if test -z "$abs_ladir"; then
-	    func_warning "cannot determine absolute directory name of \`$ladir'"
+	    func_warning "cannot determine absolute directory name of '$ladir'"
 	    func_warning "passing it literally to the linker, although it might fail"
-	    abs_ladir="$ladir"
+	    abs_ladir=$ladir
 	  fi
 	  ;;
 	esac
 	func_basename "$lib"
-	laname="$func_basename_result"
+	laname=$func_basename_result
 
 	# Find the relevant object directory and library name.
-	if test "X$installed" = Xyes; then
+	if test yes = "$installed"; then
 	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
-	    func_warning "library \`$lib' was moved."
-	    dir="$ladir"
-	    absdir="$abs_ladir"
-	    libdir="$abs_ladir"
+	    func_warning "library '$lib' was moved."
+	    dir=$ladir
+	    absdir=$abs_ladir
+	    libdir=$abs_ladir
 	  else
-	    dir="$lt_sysroot$libdir"
-	    absdir="$lt_sysroot$libdir"
+	    dir=$lt_sysroot$libdir
+	    absdir=$lt_sysroot$libdir
 	  fi
-	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
+	  test yes = "$hardcode_automatic" && avoidtemprpath=yes
 	else
 	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
-	    dir="$ladir"
-	    absdir="$abs_ladir"
+	    dir=$ladir
+	    absdir=$abs_ladir
 	    # Remove this search path later
 	    func_append notinst_path " $abs_ladir"
 	  else
-	    dir="$ladir/$objdir"
-	    absdir="$abs_ladir/$objdir"
+	    dir=$ladir/$objdir
+	    absdir=$abs_ladir/$objdir
 	    # Remove this search path later
 	    func_append notinst_path " $abs_ladir"
 	  fi
@@ -6542,11 +7982,11 @@ func_mode_link ()
 	name=$func_stripname_result
 
 	# This library was specified with -dlpreopen.
-	if test "$pass" = dlpreopen; then
-	  if test -z "$libdir" && test "$linkmode" = prog; then
-	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
+	if test dlpreopen = "$pass"; then
+	  if test -z "$libdir" && test prog = "$linkmode"; then
+	    func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
 	  fi
-	  case "$host" in
+	  case $host in
 	    # special handling for platforms with PE-DLLs.
 	    *cygwin* | *mingw* | *cegcc* )
 	      # Linker will automatically link against shared library if both
@@ -6590,9 +8030,9 @@ func_mode_link ()
 
 	if test -z "$libdir"; then
 	  # Link the convenience library
-	  if test "$linkmode" = lib; then
+	  if test lib = "$linkmode"; then
 	    deplibs="$dir/$old_library $deplibs"
-	  elif test "$linkmode,$pass" = "prog,link"; then
+	  elif test prog,link = "$linkmode,$pass"; then
 	    compile_deplibs="$dir/$old_library $compile_deplibs"
 	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
 	  else
@@ -6602,14 +8042,14 @@ func_mode_link ()
 	fi
 
 
-	if test "$linkmode" = prog && test "$pass" != link; then
+	if test prog = "$linkmode" && test link != "$pass"; then
 	  func_append newlib_search_path " $ladir"
 	  deplibs="$lib $deplibs"
 
-	  linkalldeplibs=no
-	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
-	     test "$build_libtool_libs" = no; then
-	    linkalldeplibs=yes
+	  linkalldeplibs=false
+	  if test no != "$link_all_deplibs" || test -z "$library_names" ||
+	     test no = "$build_libtool_libs"; then
+	    linkalldeplibs=:
 	  fi
 
 	  tmp_libs=
@@ -6621,14 +8061,14 @@ func_mode_link ()
 		 ;;
 	    esac
 	    # Need to link against all dependency_libs?
-	    if test "$linkalldeplibs" = yes; then
+	    if $linkalldeplibs; then
 	      deplibs="$deplib $deplibs"
 	    else
 	      # Need to hardcode shared library paths
 	      # or/and link against static libraries
 	      newdependency_libs="$deplib $newdependency_libs"
 	    fi
-	    if $opt_preserve_dup_deps ; then
+	    if $opt_preserve_dup_deps; then
 	      case "$tmp_libs " in
 	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
 	      esac
@@ -6638,15 +8078,15 @@ func_mode_link ()
 	  continue
 	fi # $linkmode = prog...
 
-	if test "$linkmode,$pass" = "prog,link"; then
+	if test prog,link = "$linkmode,$pass"; then
 	  if test -n "$library_names" &&
-	     { { test "$prefer_static_libs" = no ||
-	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
+	     { { test no = "$prefer_static_libs" ||
+	         test built,yes = "$prefer_static_libs,$installed"; } ||
 	       test -z "$old_library"; }; then
 	    # We need to hardcode the library path
-	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
+	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
 	      # Make sure the rpath contains only unique directories.
-	      case "$temp_rpath:" in
+	      case $temp_rpath: in
 	      *"$absdir:"*) ;;
 	      *) func_append temp_rpath "$absdir:" ;;
 	      esac
@@ -6675,9 +8115,9 @@ func_mode_link ()
 	    esac
 	  fi # $linkmode,$pass = prog,link...
 
-	  if test "$alldeplibs" = yes &&
-	     { test "$deplibs_check_method" = pass_all ||
-	       { test "$build_libtool_libs" = yes &&
+	  if $alldeplibs &&
+	     { test pass_all = "$deplibs_check_method" ||
+	       { test yes = "$build_libtool_libs" &&
 		 test -n "$library_names"; }; }; then
 	    # We only need to search for static libraries
 	    continue
@@ -6686,19 +8126,19 @@ func_mode_link ()
 
 	link_static=no # Whether the deplib will be linked statically
 	use_static_libs=$prefer_static_libs
-	if test "$use_static_libs" = built && test "$installed" = yes; then
+	if test built = "$use_static_libs" && test yes = "$installed"; then
 	  use_static_libs=no
 	fi
 	if test -n "$library_names" &&
-	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
+	   { test no = "$use_static_libs" || test -z "$old_library"; }; then
 	  case $host in
-	  *cygwin* | *mingw* | *cegcc*)
+	  *cygwin* | *mingw* | *cegcc* | *os2*)
 	      # No point in relinking DLLs because paths are not encoded
 	      func_append notinst_deplibs " $lib"
 	      need_relink=no
 	    ;;
 	  *)
-	    if test "$installed" = no; then
+	    if test no = "$installed"; then
 	      func_append notinst_deplibs " $lib"
 	      need_relink=yes
 	    fi
@@ -6708,24 +8148,24 @@ func_mode_link ()
 
 	  # Warn about portability, can't link against -module's on some
 	  # systems (darwin).  Don't bleat about dlopened modules though!
-	  dlopenmodule=""
+	  dlopenmodule=
 	  for dlpremoduletest in $dlprefiles; do
 	    if test "X$dlpremoduletest" = "X$lib"; then
-	      dlopenmodule="$dlpremoduletest"
+	      dlopenmodule=$dlpremoduletest
 	      break
 	    fi
 	  done
-	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
+	  if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
 	    echo
-	    if test "$linkmode" = prog; then
+	    if test prog = "$linkmode"; then
 	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
 	    else
 	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
 	    fi
 	    $ECHO "*** $linklib is not portable!"
 	  fi
-	  if test "$linkmode" = lib &&
-	     test "$hardcode_into_libs" = yes; then
+	  if test lib = "$linkmode" &&
+	     test yes = "$hardcode_into_libs"; then
 	    # Hardcode the library path.
 	    # Skip directories that are in the system default run-time
 	    # search path.
@@ -6753,43 +8193,43 @@ func_mode_link ()
 	    # figure out the soname
 	    set dummy $library_names
 	    shift
-	    realname="$1"
+	    realname=$1
 	    shift
 	    libname=`eval "\\$ECHO \"$libname_spec\""`
 	    # use dlname if we got it. it's perfectly good, no?
 	    if test -n "$dlname"; then
-	      soname="$dlname"
+	      soname=$dlname
 	    elif test -n "$soname_spec"; then
 	      # bleh windows
 	      case $host in
-	      *cygwin* | mingw* | *cegcc*)
+	      *cygwin* | mingw* | *cegcc* | *os2*)
 	        func_arith $current - $age
 		major=$func_arith_result
-		versuffix="-$major"
+		versuffix=-$major
 		;;
 	      esac
 	      eval soname=\"$soname_spec\"
 	    else
-	      soname="$realname"
+	      soname=$realname
 	    fi
 
 	    # Make a new name for the extract_expsyms_cmds to use
-	    soroot="$soname"
+	    soroot=$soname
 	    func_basename "$soroot"
-	    soname="$func_basename_result"
+	    soname=$func_basename_result
 	    func_stripname 'lib' '.dll' "$soname"
 	    newlib=libimp-$func_stripname_result.a
 
 	    # If the library has no export list, then create one now
 	    if test -f "$output_objdir/$soname-def"; then :
 	    else
-	      func_verbose "extracting exported symbol list from \`$soname'"
+	      func_verbose "extracting exported symbol list from '$soname'"
 	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
 	    fi
 
 	    # Create $newlib
 	    if test -f "$output_objdir/$newlib"; then :; else
-	      func_verbose "generating import library for \`$soname'"
+	      func_verbose "generating import library for '$soname'"
 	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
 	    fi
 	    # make sure the library variables are pointing to the new library
@@ -6797,58 +8237,58 @@ func_mode_link ()
 	    linklib=$newlib
 	  fi # test -n "$old_archive_from_expsyms_cmds"
 
-	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
+	  if test prog = "$linkmode" || test relink != "$opt_mode"; then
 	    add_shlibpath=
 	    add_dir=
 	    add=
 	    lib_linked=yes
 	    case $hardcode_action in
 	    immediate | unsupported)
-	      if test "$hardcode_direct" = no; then
-		add="$dir/$linklib"
+	      if test no = "$hardcode_direct"; then
+		add=$dir/$linklib
 		case $host in
-		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
-		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
+		  *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
+		  *-*-sysv4*uw2*) add_dir=-L$dir ;;
 		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
-		    *-*-unixware7*) add_dir="-L$dir" ;;
+		    *-*-unixware7*) add_dir=-L$dir ;;
 		  *-*-darwin* )
-		    # if the lib is a (non-dlopened) module then we can not
+		    # if the lib is a (non-dlopened) module then we cannot
 		    # link against it, someone is ignoring the earlier warnings
 		    if /usr/bin/file -L $add 2> /dev/null |
-			 $GREP ": [^:]* bundle" >/dev/null ; then
+			 $GREP ": [^:]* bundle" >/dev/null; then
 		      if test "X$dlopenmodule" != "X$lib"; then
 			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
-			if test -z "$old_library" ; then
+			if test -z "$old_library"; then
 			  echo
 			  echo "*** And there doesn't seem to be a static archive available"
 			  echo "*** The link will probably fail, sorry"
 			else
-			  add="$dir/$old_library"
+			  add=$dir/$old_library
 			fi
 		      elif test -n "$old_library"; then
-			add="$dir/$old_library"
+			add=$dir/$old_library
 		      fi
 		    fi
 		esac
-	      elif test "$hardcode_minus_L" = no; then
+	      elif test no = "$hardcode_minus_L"; then
 		case $host in
-		*-*-sunos*) add_shlibpath="$dir" ;;
+		*-*-sunos*) add_shlibpath=$dir ;;
 		esac
-		add_dir="-L$dir"
-		add="-l$name"
-	      elif test "$hardcode_shlibpath_var" = no; then
-		add_shlibpath="$dir"
-		add="-l$name"
+		add_dir=-L$dir
+		add=-l$name
+	      elif test no = "$hardcode_shlibpath_var"; then
+		add_shlibpath=$dir
+		add=-l$name
 	      else
 		lib_linked=no
 	      fi
 	      ;;
 	    relink)
-	      if test "$hardcode_direct" = yes &&
-	         test "$hardcode_direct_absolute" = no; then
-		add="$dir/$linklib"
-	      elif test "$hardcode_minus_L" = yes; then
-		add_dir="-L$absdir"
+	      if test yes = "$hardcode_direct" &&
+	         test no = "$hardcode_direct_absolute"; then
+		add=$dir/$linklib
+	      elif test yes = "$hardcode_minus_L"; then
+		add_dir=-L$absdir
 		# Try looking first in the location we're being installed to.
 		if test -n "$inst_prefix_dir"; then
 		  case $libdir in
@@ -6857,10 +8297,10 @@ func_mode_link ()
 		      ;;
 		  esac
 		fi
-		add="-l$name"
-	      elif test "$hardcode_shlibpath_var" = yes; then
-		add_shlibpath="$dir"
-		add="-l$name"
+		add=-l$name
+	      elif test yes = "$hardcode_shlibpath_var"; then
+		add_shlibpath=$dir
+		add=-l$name
 	      else
 		lib_linked=no
 	      fi
@@ -6868,7 +8308,7 @@ func_mode_link ()
 	    *) lib_linked=no ;;
 	    esac
 
-	    if test "$lib_linked" != yes; then
+	    if test yes != "$lib_linked"; then
 	      func_fatal_configuration "unsupported hardcode properties"
 	    fi
 
@@ -6878,15 +8318,15 @@ func_mode_link ()
 	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
 	      esac
 	    fi
-	    if test "$linkmode" = prog; then
+	    if test prog = "$linkmode"; then
 	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
 	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
 	    else
 	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
 	      test -n "$add" && deplibs="$add $deplibs"
-	      if test "$hardcode_direct" != yes &&
-		 test "$hardcode_minus_L" != yes &&
-		 test "$hardcode_shlibpath_var" = yes; then
+	      if test yes != "$hardcode_direct" &&
+		 test yes != "$hardcode_minus_L" &&
+		 test yes = "$hardcode_shlibpath_var"; then
 		case :$finalize_shlibpath: in
 		*":$libdir:"*) ;;
 		*) func_append finalize_shlibpath "$libdir:" ;;
@@ -6895,33 +8335,33 @@ func_mode_link ()
 	    fi
 	  fi
 
-	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
+	  if test prog = "$linkmode" || test relink = "$opt_mode"; then
 	    add_shlibpath=
 	    add_dir=
 	    add=
 	    # Finalize command for both is simple: just hardcode it.
-	    if test "$hardcode_direct" = yes &&
-	       test "$hardcode_direct_absolute" = no; then
-	      add="$libdir/$linklib"
-	    elif test "$hardcode_minus_L" = yes; then
-	      add_dir="-L$libdir"
-	      add="-l$name"
-	    elif test "$hardcode_shlibpath_var" = yes; then
+	    if test yes = "$hardcode_direct" &&
+	       test no = "$hardcode_direct_absolute"; then
+	      add=$libdir/$linklib
+	    elif test yes = "$hardcode_minus_L"; then
+	      add_dir=-L$libdir
+	      add=-l$name
+	    elif test yes = "$hardcode_shlibpath_var"; then
 	      case :$finalize_shlibpath: in
 	      *":$libdir:"*) ;;
 	      *) func_append finalize_shlibpath "$libdir:" ;;
 	      esac
-	      add="-l$name"
-	    elif test "$hardcode_automatic" = yes; then
+	      add=-l$name
+	    elif test yes = "$hardcode_automatic"; then
 	      if test -n "$inst_prefix_dir" &&
-		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
-		add="$inst_prefix_dir$libdir/$linklib"
+		 test -f "$inst_prefix_dir$libdir/$linklib"; then
+		add=$inst_prefix_dir$libdir/$linklib
 	      else
-		add="$libdir/$linklib"
+		add=$libdir/$linklib
 	      fi
 	    else
 	      # We cannot seem to hardcode it, guess we'll fake it.
-	      add_dir="-L$libdir"
+	      add_dir=-L$libdir
 	      # Try looking first in the location we're being installed to.
 	      if test -n "$inst_prefix_dir"; then
 		case $libdir in
@@ -6930,10 +8370,10 @@ func_mode_link ()
 		    ;;
 		esac
 	      fi
-	      add="-l$name"
+	      add=-l$name
 	    fi
 
-	    if test "$linkmode" = prog; then
+	    if test prog = "$linkmode"; then
 	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
 	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
 	    else
@@ -6941,43 +8381,43 @@ func_mode_link ()
 	      test -n "$add" && deplibs="$add $deplibs"
 	    fi
 	  fi
-	elif test "$linkmode" = prog; then
+	elif test prog = "$linkmode"; then
 	  # Here we assume that one of hardcode_direct or hardcode_minus_L
 	  # is not unsupported.  This is valid on all known static and
 	  # shared platforms.
-	  if test "$hardcode_direct" != unsupported; then
-	    test -n "$old_library" && linklib="$old_library"
+	  if test unsupported != "$hardcode_direct"; then
+	    test -n "$old_library" && linklib=$old_library
 	    compile_deplibs="$dir/$linklib $compile_deplibs"
 	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
 	  else
 	    compile_deplibs="-l$name -L$dir $compile_deplibs"
 	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
 	  fi
-	elif test "$build_libtool_libs" = yes; then
+	elif test yes = "$build_libtool_libs"; then
 	  # Not a shared library
-	  if test "$deplibs_check_method" != pass_all; then
+	  if test pass_all != "$deplibs_check_method"; then
 	    # We're trying link a shared library against a static one
 	    # but the system doesn't support it.
 
 	    # Just print a warning and add the library to dependency_libs so
 	    # that the program can be linked against the static library.
 	    echo
-	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
+	    $ECHO "*** Warning: This system cannot link to static lib archive $lib."
 	    echo "*** I have the capability to make that library automatically link in when"
 	    echo "*** you link to this library.  But I can only do this if you have a"
 	    echo "*** shared version of the library, which you do not appear to have."
-	    if test "$module" = yes; then
+	    if test yes = "$module"; then
 	      echo "*** But as you try to build a module library, libtool will still create "
 	      echo "*** a static module, that should work as long as the dlopening application"
 	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
 	      if test -z "$global_symbol_pipe"; then
 		echo
 		echo "*** However, this would only work if libtool was able to extract symbol"
-		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+		echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
 		echo "*** not find such a program.  So, this module is probably useless."
-		echo "*** \`nm' from GNU binutils and a full rebuild may help."
+		echo "*** 'nm' from GNU binutils and a full rebuild may help."
 	      fi
-	      if test "$build_old_libs" = no; then
+	      if test no = "$build_old_libs"; then
 		build_libtool_libs=module
 		build_old_libs=yes
 	      else
@@ -6990,11 +8430,11 @@ func_mode_link ()
 	  fi
 	fi # link shared/static library?
 
-	if test "$linkmode" = lib; then
+	if test lib = "$linkmode"; then
 	  if test -n "$dependency_libs" &&
-	     { test "$hardcode_into_libs" != yes ||
-	       test "$build_old_libs" = yes ||
-	       test "$link_static" = yes; }; then
+	     { test yes != "$hardcode_into_libs" ||
+	       test yes = "$build_old_libs" ||
+	       test yes = "$link_static"; }; then
 	    # Extract -R from dependency_libs
 	    temp_deplibs=
 	    for libdir in $dependency_libs; do
@@ -7008,12 +8448,12 @@ func_mode_link ()
 	      *) func_append temp_deplibs " $libdir";;
 	      esac
 	    done
-	    dependency_libs="$temp_deplibs"
+	    dependency_libs=$temp_deplibs
 	  fi
 
 	  func_append newlib_search_path " $absdir"
 	  # Link against this library
-	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
+	  test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
 	  # ... and its dependency_libs
 	  tmp_libs=
 	  for deplib in $dependency_libs; do
@@ -7023,7 +8463,7 @@ func_mode_link ()
                    func_resolve_sysroot "$func_stripname_result";;
               *) func_resolve_sysroot "$deplib" ;;
             esac
-	    if $opt_preserve_dup_deps ; then
+	    if $opt_preserve_dup_deps; then
 	      case "$tmp_libs " in
 	      *" $func_resolve_sysroot_result "*)
                 func_append specialdeplibs " $func_resolve_sysroot_result" ;;
@@ -7032,12 +8472,12 @@ func_mode_link ()
 	    func_append tmp_libs " $func_resolve_sysroot_result"
 	  done
 
-	  if test "$link_all_deplibs" != no; then
+	  if test no != "$link_all_deplibs"; then
 	    # Add the search paths of all dependency libraries
 	    for deplib in $dependency_libs; do
 	      path=
 	      case $deplib in
-	      -L*) path="$deplib" ;;
+	      -L*) path=$deplib ;;
 	      *.la)
 	        func_resolve_sysroot "$deplib"
 	        deplib=$func_resolve_sysroot_result
@@ -7045,12 +8485,12 @@ func_mode_link ()
 		dir=$func_dirname_result
 		# We need an absolute path.
 		case $dir in
-		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
+		[\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
 		*)
 		  absdir=`cd "$dir" && pwd`
 		  if test -z "$absdir"; then
-		    func_warning "cannot determine absolute directory name of \`$dir'"
-		    absdir="$dir"
+		    func_warning "cannot determine absolute directory name of '$dir'"
+		    absdir=$dir
 		  fi
 		  ;;
 		esac
@@ -7058,35 +8498,35 @@ func_mode_link ()
 		case $host in
 		*-*-darwin*)
 		  depdepl=
-		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
-		  if test -n "$deplibrary_names" ; then
-		    for tmp in $deplibrary_names ; do
+		  eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
+		  if test -n "$deplibrary_names"; then
+		    for tmp in $deplibrary_names; do
 		      depdepl=$tmp
 		    done
-		    if test -f "$absdir/$objdir/$depdepl" ; then
-		      depdepl="$absdir/$objdir/$depdepl"
-		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
+		    if test -f "$absdir/$objdir/$depdepl"; then
+		      depdepl=$absdir/$objdir/$depdepl
+		      darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
                       if test -z "$darwin_install_name"; then
-                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
+                          darwin_install_name=`$OTOOL64 -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
                       fi
-		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
-		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
+		      func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
+		      func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
 		      path=
 		    fi
 		  fi
 		  ;;
 		*)
-		  path="-L$absdir/$objdir"
+		  path=-L$absdir/$objdir
 		  ;;
 		esac
 		else
-		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+		  eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
 		  test -z "$libdir" && \
-		    func_fatal_error "\`$deplib' is not a valid libtool archive"
+		    func_fatal_error "'$deplib' is not a valid libtool archive"
 		  test "$absdir" != "$libdir" && \
-		    func_warning "\`$deplib' seems to be moved"
+		    func_warning "'$deplib' seems to be moved"
 
-		  path="-L$absdir"
+		  path=-L$absdir
 		fi
 		;;
 	      esac
@@ -7098,23 +8538,23 @@ func_mode_link ()
 	  fi # link_all_deplibs != no
 	fi # linkmode = lib
       done # for deplib in $libs
-      if test "$pass" = link; then
-	if test "$linkmode" = "prog"; then
+      if test link = "$pass"; then
+	if test prog = "$linkmode"; then
 	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
 	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
 	else
 	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
 	fi
       fi
-      dependency_libs="$newdependency_libs"
-      if test "$pass" = dlpreopen; then
+      dependency_libs=$newdependency_libs
+      if test dlpreopen = "$pass"; then
 	# Link the dlpreopened libraries before other libraries
 	for deplib in $save_deplibs; do
 	  deplibs="$deplib $deplibs"
 	done
       fi
-      if test "$pass" != dlopen; then
-	if test "$pass" != conv; then
+      if test dlopen != "$pass"; then
+	test conv = "$pass" || {
 	  # Make sure lib_search_path contains only unique directories.
 	  lib_search_path=
 	  for dir in $newlib_search_path; do
@@ -7124,12 +8564,12 @@ func_mode_link ()
 	    esac
 	  done
 	  newlib_search_path=
-	fi
+	}
 
-	if test "$linkmode,$pass" != "prog,link"; then
-	  vars="deplibs"
-	else
+	if test prog,link = "$linkmode,$pass"; then
 	  vars="compile_deplibs finalize_deplibs"
+	else
+	  vars=deplibs
 	fi
 	for var in $vars dependency_libs; do
 	  # Add libraries to $var in reverse order
@@ -7187,62 +8627,93 @@ func_mode_link ()
 	  eval $var=\"$tmp_libs\"
 	done # for var
       fi
+
+      # Add Sun CC postdeps if required:
+      test CXX = "$tagname" && {
+        case $host_os in
+        linux*)
+          case `$CC -V 2>&1 | sed 5q` in
+          *Sun\ C*) # Sun C++ 5.9
+            func_suncc_cstd_abi
+
+            if test no != "$suncc_use_cstd_abi"; then
+              func_append postdeps ' -library=Cstd -library=Crun'
+            fi
+            ;;
+          esac
+          ;;
+
+        solaris*)
+          func_cc_basename "$CC"
+          case $func_cc_basename_result in
+          CC* | sunCC*)
+            func_suncc_cstd_abi
+
+            if test no != "$suncc_use_cstd_abi"; then
+              func_append postdeps ' -library=Cstd -library=Crun'
+            fi
+            ;;
+          esac
+          ;;
+        esac
+      }
+
       # Last step: remove runtime libs from dependency_libs
       # (they stay in deplibs)
       tmp_libs=
-      for i in $dependency_libs ; do
+      for i in $dependency_libs; do
 	case " $predeps $postdeps $compiler_lib_search_path " in
 	*" $i "*)
-	  i=""
+	  i=
 	  ;;
 	esac
-	if test -n "$i" ; then
+	if test -n "$i"; then
 	  func_append tmp_libs " $i"
 	fi
       done
       dependency_libs=$tmp_libs
     done # for pass
-    if test "$linkmode" = prog; then
-      dlfiles="$newdlfiles"
+    if test prog = "$linkmode"; then
+      dlfiles=$newdlfiles
     fi
-    if test "$linkmode" = prog || test "$linkmode" = lib; then
-      dlprefiles="$newdlprefiles"
+    if test prog = "$linkmode" || test lib = "$linkmode"; then
+      dlprefiles=$newdlprefiles
     fi
 
     case $linkmode in
     oldlib)
-      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
-	func_warning "\`-dlopen' is ignored for archives"
+      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
+	func_warning "'-dlopen' is ignored for archives"
       fi
 
       case " $deplibs" in
       *\ -l* | *\ -L*)
-	func_warning "\`-l' and \`-L' are ignored for archives" ;;
+	func_warning "'-l' and '-L' are ignored for archives" ;;
       esac
 
       test -n "$rpath" && \
-	func_warning "\`-rpath' is ignored for archives"
+	func_warning "'-rpath' is ignored for archives"
 
       test -n "$xrpath" && \
-	func_warning "\`-R' is ignored for archives"
+	func_warning "'-R' is ignored for archives"
 
       test -n "$vinfo" && \
-	func_warning "\`-version-info/-version-number' is ignored for archives"
+	func_warning "'-version-info/-version-number' is ignored for archives"
 
       test -n "$release" && \
-	func_warning "\`-release' is ignored for archives"
+	func_warning "'-release' is ignored for archives"
 
       test -n "$export_symbols$export_symbols_regex" && \
-	func_warning "\`-export-symbols' is ignored for archives"
+	func_warning "'-export-symbols' is ignored for archives"
 
       # Now set the variables for building old libraries.
       build_libtool_libs=no
-      oldlibs="$output"
+      oldlibs=$output
       func_append objs "$old_deplibs"
       ;;
 
     lib)
-      # Make sure we only generate libraries of the form `libNAME.la'.
+      # Make sure we only generate libraries of the form 'libNAME.la'.
       case $outputname in
       lib*)
 	func_stripname 'lib' '.la' "$outputname"
@@ -7251,10 +8722,10 @@ func_mode_link ()
 	eval libname=\"$libname_spec\"
 	;;
       *)
-	test "$module" = no && \
-	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
+	test no = "$module" \
+	  && func_fatal_help "libtool library '$output' must begin with 'lib'"
 
-	if test "$need_lib_prefix" != no; then
+	if test no != "$need_lib_prefix"; then
 	  # Add the "lib" prefix for modules if required
 	  func_stripname '' '.la' "$outputname"
 	  name=$func_stripname_result
@@ -7268,8 +8739,8 @@ func_mode_link ()
       esac
 
       if test -n "$objs"; then
-	if test "$deplibs_check_method" != pass_all; then
-	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
+	if test pass_all != "$deplibs_check_method"; then
+	  func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
 	else
 	  echo
 	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
@@ -7278,21 +8749,21 @@ func_mode_link ()
 	fi
       fi
 
-      test "$dlself" != no && \
-	func_warning "\`-dlopen self' is ignored for libtool libraries"
+      test no = "$dlself" \
+	|| func_warning "'-dlopen self' is ignored for libtool libraries"
 
       set dummy $rpath
       shift
-      test "$#" -gt 1 && \
-	func_warning "ignoring multiple \`-rpath's for a libtool library"
+      test 1 -lt "$#" \
+	&& func_warning "ignoring multiple '-rpath's for a libtool library"
 
-      install_libdir="$1"
+      install_libdir=$1
 
       oldlibs=
       if test -z "$rpath"; then
-	if test "$build_libtool_libs" = yes; then
+	if test yes = "$build_libtool_libs"; then
 	  # Building a libtool convenience library.
-	  # Some compilers have problems with a `.al' extension so
+	  # Some compilers have problems with a '.al' extension so
 	  # convenience libraries should have the same extension an
 	  # archive normally would.
 	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
@@ -7301,20 +8772,20 @@ func_mode_link ()
 	fi
 
 	test -n "$vinfo" && \
-	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
+	  func_warning "'-version-info/-version-number' is ignored for convenience libraries"
 
 	test -n "$release" && \
-	  func_warning "\`-release' is ignored for convenience libraries"
+	  func_warning "'-release' is ignored for convenience libraries"
       else
 
 	# Parse the version information argument.
-	save_ifs="$IFS"; IFS=':'
+	save_ifs=$IFS; IFS=:
 	set dummy $vinfo 0 0 0
 	shift
-	IFS="$save_ifs"
+	IFS=$save_ifs
 
 	test -n "$7" && \
-	  func_fatal_help "too many parameters to \`-version-info'"
+	  func_fatal_help "too many parameters to '-version-info'"
 
 	# convert absolute version numbers to libtool ages
 	# this retains compatibility with .la files and attempts
@@ -7322,45 +8793,42 @@ func_mode_link ()
 
 	case $vinfo_number in
 	yes)
-	  number_major="$1"
-	  number_minor="$2"
-	  number_revision="$3"
+	  number_major=$1
+	  number_minor=$2
+	  number_revision=$3
 	  #
 	  # There are really only two kinds -- those that
 	  # use the current revision as the major version
 	  # and those that subtract age and use age as
 	  # a minor version.  But, then there is irix
-	  # which has an extra 1 added just for fun
+	  # that has an extra 1 added just for fun
 	  #
 	  case $version_type in
 	  # correct linux to gnu/linux during the next big refactor
-	  darwin|linux|osf|windows|none)
+	  darwin|freebsd-elf|linux|osf|windows|none)
 	    func_arith $number_major + $number_minor
 	    current=$func_arith_result
-	    age="$number_minor"
-	    revision="$number_revision"
+	    age=$number_minor
+	    revision=$number_revision
 	    ;;
-	  freebsd-aout|freebsd-elf|qnx|sunos)
-	    current="$number_major"
-	    revision="$number_minor"
-	    age="0"
+	  freebsd-aout|qnx|sunos)
+	    current=$number_major
+	    revision=$number_minor
+	    age=0
 	    ;;
 	  irix|nonstopux)
 	    func_arith $number_major + $number_minor
 	    current=$func_arith_result
-	    age="$number_minor"
-	    revision="$number_minor"
+	    age=$number_minor
+	    revision=$number_minor
 	    lt_irix_increment=no
 	    ;;
-	  *)
-	    func_fatal_configuration "$modename: unknown library version type \`$version_type'"
-	    ;;
 	  esac
 	  ;;
 	no)
-	  current="$1"
-	  revision="$2"
-	  age="$3"
+	  current=$1
+	  revision=$2
+	  age=$3
 	  ;;
 	esac
 
@@ -7368,30 +8836,30 @@ func_mode_link ()
 	case $current in
 	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
 	*)
-	  func_error "CURRENT \`$current' must be a nonnegative integer"
-	  func_fatal_error "\`$vinfo' is not valid version information"
+	  func_error "CURRENT '$current' must be a nonnegative integer"
+	  func_fatal_error "'$vinfo' is not valid version information"
 	  ;;
 	esac
 
 	case $revision in
 	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
 	*)
-	  func_error "REVISION \`$revision' must be a nonnegative integer"
-	  func_fatal_error "\`$vinfo' is not valid version information"
+	  func_error "REVISION '$revision' must be a nonnegative integer"
+	  func_fatal_error "'$vinfo' is not valid version information"
 	  ;;
 	esac
 
 	case $age in
 	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
 	*)
-	  func_error "AGE \`$age' must be a nonnegative integer"
-	  func_fatal_error "\`$vinfo' is not valid version information"
+	  func_error "AGE '$age' must be a nonnegative integer"
+	  func_fatal_error "'$vinfo' is not valid version information"
 	  ;;
 	esac
 
 	if test "$age" -gt "$current"; then
-	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
-	  func_fatal_error "\`$vinfo' is not valid version information"
+	  func_error "AGE '$age' is greater than the current interface number '$current'"
+	  func_fatal_error "'$vinfo' is not valid version information"
 	fi
 
 	# Calculate the version variables.
@@ -7406,26 +8874,36 @@ func_mode_link ()
 	  # verstring for coding it into the library header
 	  func_arith $current - $age
 	  major=.$func_arith_result
-	  versuffix="$major.$age.$revision"
+	  versuffix=$major.$age.$revision
 	  # Darwin ld doesn't like 0 for these options...
 	  func_arith $current + 1
 	  minor_current=$func_arith_result
-	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
+	  xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
 	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+          # On Darwin other compilers
+          case $CC in
+              nagfor*)
+                  verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
+                  ;;
+              *)
+                  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+                  ;;
+          esac
 	  ;;
 
 	freebsd-aout)
-	  major=".$current"
-	  versuffix=".$current.$revision";
+	  major=.$current
+	  versuffix=.$current.$revision
 	  ;;
 
 	freebsd-elf)
-	  major=".$current"
-	  versuffix=".$current"
+	  func_arith $current - $age
+	  major=.$func_arith_result
+	  versuffix=$major.$age.$revision
 	  ;;
 
 	irix | nonstopux)
-	  if test "X$lt_irix_increment" = "Xno"; then
+	  if test no = "$lt_irix_increment"; then
 	    func_arith $current - $age
 	  else
 	    func_arith $current - $age + 1
@@ -7436,69 +8914,74 @@ func_mode_link ()
 	    nonstopux) verstring_prefix=nonstopux ;;
 	    *)         verstring_prefix=sgi ;;
 	  esac
-	  verstring="$verstring_prefix$major.$revision"
+	  verstring=$verstring_prefix$major.$revision
 
 	  # Add in all the interfaces that we are compatible with.
 	  loop=$revision
-	  while test "$loop" -ne 0; do
+	  while test 0 -ne "$loop"; do
 	    func_arith $revision - $loop
 	    iface=$func_arith_result
 	    func_arith $loop - 1
 	    loop=$func_arith_result
-	    verstring="$verstring_prefix$major.$iface:$verstring"
+	    verstring=$verstring_prefix$major.$iface:$verstring
 	  done
 
-	  # Before this point, $major must not contain `.'.
+	  # Before this point, $major must not contain '.'.
 	  major=.$major
-	  versuffix="$major.$revision"
+	  versuffix=$major.$revision
 	  ;;
 
 	linux) # correct to gnu/linux during the next big refactor
 	  func_arith $current - $age
 	  major=.$func_arith_result
-	  versuffix="$major.$age.$revision"
+	  versuffix=$major.$age.$revision
 	  ;;
 
 	osf)
 	  func_arith $current - $age
 	  major=.$func_arith_result
-	  versuffix=".$current.$age.$revision"
-	  verstring="$current.$age.$revision"
+	  versuffix=.$current.$age.$revision
+	  verstring=$current.$age.$revision
 
 	  # Add in all the interfaces that we are compatible with.
 	  loop=$age
-	  while test "$loop" -ne 0; do
+	  while test 0 -ne "$loop"; do
 	    func_arith $current - $loop
 	    iface=$func_arith_result
 	    func_arith $loop - 1
 	    loop=$func_arith_result
-	    verstring="$verstring:${iface}.0"
+	    verstring=$verstring:$iface.0
 	  done
 
 	  # Make executables depend on our current version.
-	  func_append verstring ":${current}.0"
+	  func_append verstring ":$current.0"
 	  ;;
 
 	qnx)
-	  major=".$current"
-	  versuffix=".$current"
+	  major=.$current
+	  versuffix=.$current
+	  ;;
+
+	sco)
+	  major=.$current
+	  versuffix=.$current
 	  ;;
 
 	sunos)
-	  major=".$current"
-	  versuffix=".$current.$revision"
+	  major=.$current
+	  versuffix=.$current.$revision
 	  ;;
 
 	windows)
 	  # Use '-' rather than '.', since we only want one
-	  # extension on DOS 8.3 filesystems.
+	  # extension on DOS 8.3 file systems.
 	  func_arith $current - $age
 	  major=$func_arith_result
-	  versuffix="-$major"
+	  versuffix=-$major
 	  ;;
 
 	*)
-	  func_fatal_configuration "unknown library version type \`$version_type'"
+	  func_fatal_configuration "unknown library version type '$version_type'"
 	  ;;
 	esac
 
@@ -7512,42 +8995,45 @@ func_mode_link ()
 	    verstring=
 	    ;;
 	  *)
-	    verstring="0.0"
+	    verstring=0.0
 	    ;;
 	  esac
-	  if test "$need_version" = no; then
+	  if test no = "$need_version"; then
 	    versuffix=
 	  else
-	    versuffix=".0.0"
+	    versuffix=.0.0
 	  fi
 	fi
 
 	# Remove version info from name if versioning should be avoided
-	if test "$avoid_version" = yes && test "$need_version" = no; then
+	if test yes,no = "$avoid_version,$need_version"; then
 	  major=
 	  versuffix=
-	  verstring=""
+	  verstring=
 	fi
 
 	# Check to see if the archive will have undefined symbols.
-	if test "$allow_undefined" = yes; then
-	  if test "$allow_undefined_flag" = unsupported; then
-	    func_warning "undefined symbols not allowed in $host shared libraries"
-	    build_libtool_libs=no
-	    build_old_libs=yes
+	if test yes = "$allow_undefined"; then
+	  if test unsupported = "$allow_undefined_flag"; then
+	    if test yes = "$build_old_libs"; then
+	      func_warning "undefined symbols not allowed in $host shared libraries; building static only"
+	      build_libtool_libs=no
+	    else
+	      func_fatal_error "can't build $host shared library unless -no-undefined is specified"
+	    fi
 	  fi
 	else
 	  # Don't allow undefined symbols.
-	  allow_undefined_flag="$no_undefined_flag"
+	  allow_undefined_flag=$no_undefined_flag
 	fi
 
       fi
 
-      func_generate_dlsyms "$libname" "$libname" "yes"
+      func_generate_dlsyms "$libname" "$libname" :
       func_append libobjs " $symfileobj"
-      test "X$libobjs" = "X " && libobjs=
+      test " " = "$libobjs" && libobjs=
 
-      if test "$opt_mode" != relink; then
+      if test relink != "$opt_mode"; then
 	# Remove our outputs, but don't remove object files since they
 	# may have been created when compiling PIC objects.
 	removelist=
@@ -7556,8 +9042,8 @@ func_mode_link ()
 	  case $p in
 	    *.$objext | *.gcno)
 	       ;;
-	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
-	       if test "X$precious_files_regex" != "X"; then
+	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
+	       if test -n "$precious_files_regex"; then
 		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
 		 then
 		   continue
@@ -7573,11 +9059,11 @@ func_mode_link ()
       fi
 
       # Now set the variables for building old libraries.
-      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
+      if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
 	func_append oldlibs " $output_objdir/$libname.$libext"
 
 	# Transform .lo files to .o files.
-	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
+	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
       fi
 
       # Eliminate all temporary directories.
@@ -7598,13 +9084,13 @@ func_mode_link ()
 	  *) func_append finalize_rpath " $libdir" ;;
 	  esac
 	done
-	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
+	if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
 	  dependency_libs="$temp_xrpath $dependency_libs"
 	fi
       fi
 
       # Make sure dlfiles contains only unique files that won't be dlpreopened
-      old_dlfiles="$dlfiles"
+      old_dlfiles=$dlfiles
       dlfiles=
       for lib in $old_dlfiles; do
 	case " $dlprefiles $dlfiles " in
@@ -7614,7 +9100,7 @@ func_mode_link ()
       done
 
       # Make sure dlprefiles contains only unique files
-      old_dlprefiles="$dlprefiles"
+      old_dlprefiles=$dlprefiles
       dlprefiles=
       for lib in $old_dlprefiles; do
 	case "$dlprefiles " in
@@ -7623,7 +9109,7 @@ func_mode_link ()
 	esac
       done
 
-      if test "$build_libtool_libs" = yes; then
+      if test yes = "$build_libtool_libs"; then
 	if test -n "$rpath"; then
 	  case $host in
 	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
@@ -7647,7 +9133,7 @@ func_mode_link ()
 	    ;;
 	  *)
 	    # Add libc to deplibs on all other systems if necessary.
-	    if test "$build_libtool_need_lc" = "yes"; then
+	    if test yes = "$build_libtool_need_lc"; then
 	      func_append deplibs " -lc"
 	    fi
 	    ;;
@@ -7663,9 +9149,9 @@ func_mode_link ()
 	# I'm not sure if I'm treating the release correctly.  I think
 	# release should show up in the -l (ie -lgmp5) so we don't want to
 	# add it in twice.  Is that correct?
-	release=""
-	versuffix=""
-	major=""
+	release=
+	versuffix=
+	major=
 	newdeplibs=
 	droppeddeps=no
 	case $deplibs_check_method in
@@ -7694,20 +9180,20 @@ EOF
 	      -l*)
 		func_stripname -l '' "$i"
 		name=$func_stripname_result
-		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 		  case " $predeps $postdeps " in
 		  *" $i "*)
 		    func_append newdeplibs " $i"
-		    i=""
+		    i=
 		    ;;
 		  esac
 		fi
-		if test -n "$i" ; then
+		if test -n "$i"; then
 		  libname=`eval "\\$ECHO \"$libname_spec\""`
 		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
 		  set dummy $deplib_matches; shift
 		  deplib_match=$1
-		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
 		    func_append newdeplibs " $i"
 		  else
 		    droppeddeps=yes
@@ -7737,20 +9223,20 @@ EOF
 		$opt_dry_run || $RM conftest
 		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
 		  ldd_output=`ldd conftest`
-		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 		    case " $predeps $postdeps " in
 		    *" $i "*)
 		      func_append newdeplibs " $i"
-		      i=""
+		      i=
 		      ;;
 		    esac
 		  fi
-		  if test -n "$i" ; then
+		  if test -n "$i"; then
 		    libname=`eval "\\$ECHO \"$libname_spec\""`
 		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
 		    set dummy $deplib_matches; shift
 		    deplib_match=$1
-		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
 		      func_append newdeplibs " $i"
 		    else
 		      droppeddeps=yes
@@ -7787,24 +9273,24 @@ EOF
 	    -l*)
 	      func_stripname -l '' "$a_deplib"
 	      name=$func_stripname_result
-	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 		case " $predeps $postdeps " in
 		*" $a_deplib "*)
 		  func_append newdeplibs " $a_deplib"
-		  a_deplib=""
+		  a_deplib=
 		  ;;
 		esac
 	      fi
-	      if test -n "$a_deplib" ; then
+	      if test -n "$a_deplib"; then
 		libname=`eval "\\$ECHO \"$libname_spec\""`
 		if test -n "$file_magic_glob"; then
 		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
 		else
 		  libnameglob=$libname
 		fi
-		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
+		test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
 		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
-		  if test "$want_nocaseglob" = yes; then
+		  if test yes = "$want_nocaseglob"; then
 		    shopt -s nocaseglob
 		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
 		    $nocaseglob
@@ -7822,25 +9308,25 @@ EOF
 		      # We might still enter an endless loop, since a link
 		      # loop can be closed while we follow links,
 		      # but so what?
-		      potlib="$potent_lib"
+		      potlib=$potent_lib
 		      while test -h "$potlib" 2>/dev/null; do
-			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
+			potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
 			case $potliblink in
-			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
-			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
+			[\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
+			*) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
 			esac
 		      done
 		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
 			 $SED -e 10q |
 			 $EGREP "$file_magic_regex" > /dev/null; then
 			func_append newdeplibs " $a_deplib"
-			a_deplib=""
+			a_deplib=
 			break 2
 		      fi
 		  done
 		done
 	      fi
-	      if test -n "$a_deplib" ; then
+	      if test -n "$a_deplib"; then
 		droppeddeps=yes
 		echo
 		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
@@ -7848,7 +9334,7 @@ EOF
 		echo "*** you link to this library.  But I can only do this if you have a"
 		echo "*** shared version of the library, which you do not appear to have"
 		echo "*** because I did check the linker path looking for a file starting"
-		if test -z "$potlib" ; then
+		if test -z "$potlib"; then
 		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
 		else
 		  $ECHO "*** with $libname and none of the candidates passed a file format test"
@@ -7871,30 +9357,30 @@ EOF
 	    -l*)
 	      func_stripname -l '' "$a_deplib"
 	      name=$func_stripname_result
-	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 		case " $predeps $postdeps " in
 		*" $a_deplib "*)
 		  func_append newdeplibs " $a_deplib"
-		  a_deplib=""
+		  a_deplib=
 		  ;;
 		esac
 	      fi
-	      if test -n "$a_deplib" ; then
+	      if test -n "$a_deplib"; then
 		libname=`eval "\\$ECHO \"$libname_spec\""`
 		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
 		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
 		  for potent_lib in $potential_libs; do
-		    potlib="$potent_lib" # see symlink-check above in file_magic test
+		    potlib=$potent_lib # see symlink-check above in file_magic test
 		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
 		       $EGREP "$match_pattern_regex" > /dev/null; then
 		      func_append newdeplibs " $a_deplib"
-		      a_deplib=""
+		      a_deplib=
 		      break 2
 		    fi
 		  done
 		done
 	      fi
-	      if test -n "$a_deplib" ; then
+	      if test -n "$a_deplib"; then
 		droppeddeps=yes
 		echo
 		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
@@ -7902,7 +9388,7 @@ EOF
 		echo "*** you link to this library.  But I can only do this if you have a"
 		echo "*** shared version of the library, which you do not appear to have"
 		echo "*** because I did check the linker path looking for a file starting"
-		if test -z "$potlib" ; then
+		if test -z "$potlib"; then
 		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
 		else
 		  $ECHO "*** with $libname and none of the candidates passed a file format test"
@@ -7918,18 +9404,18 @@ EOF
 	  done # Gone through all deplibs.
 	  ;;
 	none | unknown | *)
-	  newdeplibs=""
+	  newdeplibs=
 	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
-	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
-	    for i in $predeps $postdeps ; do
+	  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
+	    for i in $predeps $postdeps; do
 	      # can't use Xsed below, because $i might contain '/'
-	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
+	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
 	    done
 	  fi
 	  case $tmp_deplibs in
 	  *[!\	\ ]*)
 	    echo
-	    if test "X$deplibs_check_method" = "Xnone"; then
+	    if test none = "$deplibs_check_method"; then
 	      echo "*** Warning: inter-library dependencies are not supported in this platform."
 	    else
 	      echo "*** Warning: inter-library dependencies are not known to be supported."
@@ -7953,8 +9439,8 @@ EOF
 	  ;;
 	esac
 
-	if test "$droppeddeps" = yes; then
-	  if test "$module" = yes; then
+	if test yes = "$droppeddeps"; then
+	  if test yes = "$module"; then
 	    echo
 	    echo "*** Warning: libtool could not satisfy all declared inter-library"
 	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
@@ -7963,12 +9449,12 @@ EOF
 	    if test -z "$global_symbol_pipe"; then
 	      echo
 	      echo "*** However, this would only work if libtool was able to extract symbol"
-	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+	      echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
 	      echo "*** not find such a program.  So, this module is probably useless."
-	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
+	      echo "*** 'nm' from GNU binutils and a full rebuild may help."
 	    fi
-	    if test "$build_old_libs" = no; then
-	      oldlibs="$output_objdir/$libname.$libext"
+	    if test no = "$build_old_libs"; then
+	      oldlibs=$output_objdir/$libname.$libext
 	      build_libtool_libs=module
 	      build_old_libs=yes
 	    else
@@ -7979,14 +9465,14 @@ EOF
 	    echo "*** automatically added whenever a program is linked with this library"
 	    echo "*** or is declared to -dlopen it."
 
-	    if test "$allow_undefined" = no; then
+	    if test no = "$allow_undefined"; then
 	      echo
 	      echo "*** Since this library must not contain undefined symbols,"
 	      echo "*** because either the platform does not support them or"
 	      echo "*** it was explicitly requested with -no-undefined,"
 	      echo "*** libtool will only create a static version of it."
-	      if test "$build_old_libs" = no; then
-		oldlibs="$output_objdir/$libname.$libext"
+	      if test no = "$build_old_libs"; then
+		oldlibs=$output_objdir/$libname.$libext
 		build_libtool_libs=module
 		build_old_libs=yes
 	      else
@@ -8032,7 +9518,7 @@ EOF
 	*) func_append new_libs " $deplib" ;;
 	esac
       done
-      deplibs="$new_libs"
+      deplibs=$new_libs
 
       # All the library-specific variables (install_libdir is set above).
       library_names=
@@ -8040,25 +9526,25 @@ EOF
       dlname=
 
       # Test again, we may have decided not to build it any more
-      if test "$build_libtool_libs" = yes; then
-	# Remove ${wl} instances when linking with ld.
+      if test yes = "$build_libtool_libs"; then
+	# Remove $wl instances when linking with ld.
 	# FIXME: should test the right _cmds variable.
 	case $archive_cmds in
 	  *\$LD\ *) wl= ;;
         esac
-	if test "$hardcode_into_libs" = yes; then
+	if test yes = "$hardcode_into_libs"; then
 	  # Hardcode the library paths
 	  hardcode_libdirs=
 	  dep_rpath=
-	  rpath="$finalize_rpath"
-	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
+	  rpath=$finalize_rpath
+	  test relink = "$opt_mode" || rpath=$compile_rpath$rpath
 	  for libdir in $rpath; do
 	    if test -n "$hardcode_libdir_flag_spec"; then
 	      if test -n "$hardcode_libdir_separator"; then
 		func_replace_sysroot "$libdir"
 		libdir=$func_replace_sysroot_result
 		if test -z "$hardcode_libdirs"; then
-		  hardcode_libdirs="$libdir"
+		  hardcode_libdirs=$libdir
 		else
 		  # Just accumulate the unique libdirs.
 		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
@@ -8083,7 +9569,7 @@ EOF
 	  # Substitute the hardcoded libdirs into the rpath.
 	  if test -n "$hardcode_libdir_separator" &&
 	     test -n "$hardcode_libdirs"; then
-	    libdir="$hardcode_libdirs"
+	    libdir=$hardcode_libdirs
 	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
 	  fi
 	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
@@ -8097,8 +9583,8 @@ EOF
 	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
 	fi
 
-	shlibpath="$finalize_shlibpath"
-	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
+	shlibpath=$finalize_shlibpath
+	test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
 	if test -n "$shlibpath"; then
 	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
 	fi
@@ -8108,19 +9594,19 @@ EOF
 	eval library_names=\"$library_names_spec\"
 	set dummy $library_names
 	shift
-	realname="$1"
+	realname=$1
 	shift
 
 	if test -n "$soname_spec"; then
 	  eval soname=\"$soname_spec\"
 	else
-	  soname="$realname"
+	  soname=$realname
 	fi
 	if test -z "$dlname"; then
 	  dlname=$soname
 	fi
 
-	lib="$output_objdir/$realname"
+	lib=$output_objdir/$realname
 	linknames=
 	for link
 	do
@@ -8134,7 +9620,7 @@ EOF
 	delfiles=
 	if test -n "$export_symbols" && test -n "$include_expsyms"; then
 	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
-	  export_symbols="$output_objdir/$libname.uexp"
+	  export_symbols=$output_objdir/$libname.uexp
 	  func_append delfiles " $export_symbols"
 	fi
 
@@ -8143,31 +9629,31 @@ EOF
 	cygwin* | mingw* | cegcc*)
 	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
 	    # exporting using user supplied symfile
-	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
+	    func_dll_def_p "$export_symbols" || {
 	      # and it's NOT already a .def file. Must figure out
 	      # which of the given symbols are data symbols and tag
 	      # them as such. So, trigger use of export_symbols_cmds.
 	      # export_symbols gets reassigned inside the "prepare
 	      # the list of exported symbols" if statement, so the
 	      # include_expsyms logic still works.
-	      orig_export_symbols="$export_symbols"
+	      orig_export_symbols=$export_symbols
 	      export_symbols=
 	      always_export_symbols=yes
-	    fi
+	    }
 	  fi
 	  ;;
 	esac
 
 	# Prepare the list of exported symbols
 	if test -z "$export_symbols"; then
-	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
-	    func_verbose "generating symbol list for \`$libname.la'"
-	    export_symbols="$output_objdir/$libname.exp"
+	  if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
+	    func_verbose "generating symbol list for '$libname.la'"
+	    export_symbols=$output_objdir/$libname.exp
 	    $opt_dry_run || $RM $export_symbols
 	    cmds=$export_symbols_cmds
-	    save_ifs="$IFS"; IFS='~'
+	    save_ifs=$IFS; IFS='~'
 	    for cmd1 in $cmds; do
-	      IFS="$save_ifs"
+	      IFS=$save_ifs
 	      # Take the normal branch if the nm_file_list_spec branch
 	      # doesn't work or if tool conversion is not needed.
 	      case $nm_file_list_spec~$to_tool_file_cmd in
@@ -8181,7 +9667,7 @@ EOF
 		  try_normal_branch=no
 		  ;;
 	      esac
-	      if test "$try_normal_branch" = yes \
+	      if test yes = "$try_normal_branch" \
 		 && { test "$len" -lt "$max_cmd_len" \
 		      || test "$max_cmd_len" -le -1; }
 	      then
@@ -8192,7 +9678,7 @@ EOF
 		output_la=$func_basename_result
 		save_libobjs=$libobjs
 		save_output=$output
-		output=${output_objdir}/${output_la}.nm
+		output=$output_objdir/$output_la.nm
 		func_to_tool_file "$output"
 		libobjs=$nm_file_list_spec$func_to_tool_file_result
 		func_append delfiles " $output"
@@ -8215,8 +9701,8 @@ EOF
 		break
 	      fi
 	    done
-	    IFS="$save_ifs"
-	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
+	    IFS=$save_ifs
+	    if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
 	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
 	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
 	    fi
@@ -8224,16 +9710,16 @@ EOF
 	fi
 
 	if test -n "$export_symbols" && test -n "$include_expsyms"; then
-	  tmp_export_symbols="$export_symbols"
-	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+	  tmp_export_symbols=$export_symbols
+	  test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
 	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
 	fi
 
-	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
+	if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
 	  # The given exports_symbols file has to be filtered, so filter it.
-	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+	  func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
 	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
-	  # 's' commands which not all seds can handle. GNU sed should be fine
+	  # 's' commands, which not all seds can handle. GNU sed should be fine
 	  # though. Also, the filter scales superlinearly with the number of
 	  # global variables. join(1) would be nice here, but unfortunately
 	  # isn't a blessed tool.
@@ -8252,11 +9738,11 @@ EOF
 	    ;;
 	  esac
 	done
-	deplibs="$tmp_deplibs"
+	deplibs=$tmp_deplibs
 
 	if test -n "$convenience"; then
 	  if test -n "$whole_archive_flag_spec" &&
-	    test "$compiler_needs_object" = yes &&
+	    test yes = "$compiler_needs_object" &&
 	    test -z "$libobjs"; then
 	    # extract the archives, so we have objects to list.
 	    # TODO: could optimize this to just extract one archive.
@@ -8267,7 +9753,7 @@ EOF
 	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
 	    test "X$libobjs" = "X " && libobjs=
 	  else
-	    gentop="$output_objdir/${outputname}x"
+	    gentop=$output_objdir/${outputname}x
 	    func_append generated " $gentop"
 
 	    func_extract_archives $gentop $convenience
@@ -8276,18 +9762,18 @@ EOF
 	  fi
 	fi
 
-	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
+	if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
 	  eval flag=\"$thread_safe_flag_spec\"
 	  func_append linker_flags " $flag"
 	fi
 
 	# Make a backup of the uninstalled library when relinking
-	if test "$opt_mode" = relink; then
+	if test relink = "$opt_mode"; then
 	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
 	fi
 
 	# Do each of the archive commands.
-	if test "$module" = yes && test -n "$module_cmds" ; then
+	if test yes = "$module" && test -n "$module_cmds"; then
 	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
 	    eval test_cmds=\"$module_expsym_cmds\"
 	    cmds=$module_expsym_cmds
@@ -8305,7 +9791,7 @@ EOF
 	  fi
 	fi
 
-	if test "X$skipped_export" != "X:" &&
+	if test : != "$skipped_export" &&
 	   func_len " $test_cmds" &&
 	   len=$func_len_result &&
 	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
@@ -8338,8 +9824,8 @@ EOF
 	  last_robj=
 	  k=1
 
-	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
-	    output=${output_objdir}/${output_la}.lnkscript
+	  if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
+	    output=$output_objdir/$output_la.lnkscript
 	    func_verbose "creating GNU ld script: $output"
 	    echo 'INPUT (' > $output
 	    for obj in $save_libobjs
@@ -8351,14 +9837,14 @@ EOF
 	    func_append delfiles " $output"
 	    func_to_tool_file "$output"
 	    output=$func_to_tool_file_result
-	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
-	    output=${output_objdir}/${output_la}.lnk
+	  elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
+	    output=$output_objdir/$output_la.lnk
 	    func_verbose "creating linker input file list: $output"
 	    : > $output
 	    set x $save_libobjs
 	    shift
 	    firstobj=
-	    if test "$compiler_needs_object" = yes; then
+	    if test yes = "$compiler_needs_object"; then
 	      firstobj="$1 "
 	      shift
 	    fi
@@ -8373,7 +9859,7 @@ EOF
 	  else
 	    if test -n "$save_libobjs"; then
 	      func_verbose "creating reloadable object files..."
-	      output=$output_objdir/$output_la-${k}.$objext
+	      output=$output_objdir/$output_la-$k.$objext
 	      eval test_cmds=\"$reload_cmds\"
 	      func_len " $test_cmds"
 	      len0=$func_len_result
@@ -8385,13 +9871,13 @@ EOF
 		func_len " $obj"
 		func_arith $len + $func_len_result
 		len=$func_arith_result
-		if test "X$objlist" = X ||
+		if test -z "$objlist" ||
 		   test "$len" -lt "$max_cmd_len"; then
 		  func_append objlist " $obj"
 		else
 		  # The command $test_cmds is almost too long, add a
 		  # command to the queue.
-		  if test "$k" -eq 1 ; then
+		  if test 1 -eq "$k"; then
 		    # The first file doesn't have a previous command to add.
 		    reload_objs=$objlist
 		    eval concat_cmds=\"$reload_cmds\"
@@ -8401,10 +9887,10 @@ EOF
 		    reload_objs="$objlist $last_robj"
 		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
 		  fi
-		  last_robj=$output_objdir/$output_la-${k}.$objext
+		  last_robj=$output_objdir/$output_la-$k.$objext
 		  func_arith $k + 1
 		  k=$func_arith_result
-		  output=$output_objdir/$output_la-${k}.$objext
+		  output=$output_objdir/$output_la-$k.$objext
 		  objlist=" $obj"
 		  func_len " $last_robj"
 		  func_arith $len0 + $func_len_result
@@ -8416,9 +9902,9 @@ EOF
 	      # files will link in the last one created.
 	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
 	      reload_objs="$objlist $last_robj"
-	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
+	      eval concat_cmds=\"\$concat_cmds$reload_cmds\"
 	      if test -n "$last_robj"; then
-	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
+	        eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
 	      fi
 	      func_append delfiles " $output"
 
@@ -8426,9 +9912,9 @@ EOF
 	      output=
 	    fi
 
-	    if ${skipped_export-false}; then
-	      func_verbose "generating symbol list for \`$libname.la'"
-	      export_symbols="$output_objdir/$libname.exp"
+	    ${skipped_export-false} && {
+	      func_verbose "generating symbol list for '$libname.la'"
+	      export_symbols=$output_objdir/$libname.exp
 	      $opt_dry_run || $RM $export_symbols
 	      libobjs=$output
 	      # Append the command to create the export file.
@@ -8437,16 +9923,16 @@ EOF
 	      if test -n "$last_robj"; then
 		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
 	      fi
-	    fi
+	    }
 
 	    test -n "$save_libobjs" &&
 	      func_verbose "creating a temporary reloadable object file: $output"
 
 	    # Loop through the commands generated above and execute them.
-	    save_ifs="$IFS"; IFS='~'
+	    save_ifs=$IFS; IFS='~'
 	    for cmd in $concat_cmds; do
-	      IFS="$save_ifs"
-	      $opt_silent || {
+	      IFS=$save_ifs
+	      $opt_quiet || {
 		  func_quote_for_expand "$cmd"
 		  eval "func_echo $func_quote_for_expand_result"
 	      }
@@ -8454,7 +9940,7 @@ EOF
 		lt_exit=$?
 
 		# Restore the uninstalled library and exit
-		if test "$opt_mode" = relink; then
+		if test relink = "$opt_mode"; then
 		  ( cd "$output_objdir" && \
 		    $RM "${realname}T" && \
 		    $MV "${realname}U" "$realname" )
@@ -8463,7 +9949,7 @@ EOF
 		exit $lt_exit
 	      }
 	    done
-	    IFS="$save_ifs"
+	    IFS=$save_ifs
 
 	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
 	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
@@ -8471,18 +9957,18 @@ EOF
 	    fi
 	  fi
 
-          if ${skipped_export-false}; then
+          ${skipped_export-false} && {
 	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
-	      tmp_export_symbols="$export_symbols"
-	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+	      tmp_export_symbols=$export_symbols
+	      test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
 	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
 	    fi
 
 	    if test -n "$orig_export_symbols"; then
 	      # The given exports_symbols file has to be filtered, so filter it.
-	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+	      func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
 	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
-	      # 's' commands which not all seds can handle. GNU sed should be fine
+	      # 's' commands, which not all seds can handle. GNU sed should be fine
 	      # though. Also, the filter scales superlinearly with the number of
 	      # global variables. join(1) would be nice here, but unfortunately
 	      # isn't a blessed tool.
@@ -8491,7 +9977,7 @@ EOF
 	      export_symbols=$output_objdir/$libname.def
 	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
 	    fi
-	  fi
+	  }
 
 	  libobjs=$output
 	  # Restore the value of output.
@@ -8505,7 +9991,7 @@ EOF
 	  # value of $libobjs for piecewise linking.
 
 	  # Do each of the archive commands.
-	  if test "$module" = yes && test -n "$module_cmds" ; then
+	  if test yes = "$module" && test -n "$module_cmds"; then
 	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
 	      cmds=$module_expsym_cmds
 	    else
@@ -8527,7 +10013,7 @@ EOF
 
 	# Add any objects from preloaded convenience libraries
 	if test -n "$dlprefiles"; then
-	  gentop="$output_objdir/${outputname}x"
+	  gentop=$output_objdir/${outputname}x
 	  func_append generated " $gentop"
 
 	  func_extract_archives $gentop $dlprefiles
@@ -8535,11 +10021,12 @@ EOF
 	  test "X$libobjs" = "X " && libobjs=
 	fi
 
-	save_ifs="$IFS"; IFS='~'
+	save_ifs=$IFS; IFS='~'
 	for cmd in $cmds; do
-	  IFS="$save_ifs"
+	  IFS=$sp$nl
 	  eval cmd=\"$cmd\"
-	  $opt_silent || {
+	  IFS=$save_ifs
+	  $opt_quiet || {
 	    func_quote_for_expand "$cmd"
 	    eval "func_echo $func_quote_for_expand_result"
 	  }
@@ -8547,7 +10034,7 @@ EOF
 	    lt_exit=$?
 
 	    # Restore the uninstalled library and exit
-	    if test "$opt_mode" = relink; then
+	    if test relink = "$opt_mode"; then
 	      ( cd "$output_objdir" && \
 	        $RM "${realname}T" && \
 		$MV "${realname}U" "$realname" )
@@ -8556,10 +10043,10 @@ EOF
 	    exit $lt_exit
 	  }
 	done
-	IFS="$save_ifs"
+	IFS=$save_ifs
 
 	# Restore the uninstalled library and exit
-	if test "$opt_mode" = relink; then
+	if test relink = "$opt_mode"; then
 	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
 
 	  if test -n "$convenience"; then
@@ -8579,39 +10066,39 @@ EOF
 	done
 
 	# If -module or -export-dynamic was specified, set the dlname.
-	if test "$module" = yes || test "$export_dynamic" = yes; then
+	if test yes = "$module" || test yes = "$export_dynamic"; then
 	  # On all known operating systems, these are identical.
-	  dlname="$soname"
+	  dlname=$soname
 	fi
       fi
       ;;
 
     obj)
-      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
-	func_warning "\`-dlopen' is ignored for objects"
+      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
+	func_warning "'-dlopen' is ignored for objects"
       fi
 
       case " $deplibs" in
       *\ -l* | *\ -L*)
-	func_warning "\`-l' and \`-L' are ignored for objects" ;;
+	func_warning "'-l' and '-L' are ignored for objects" ;;
       esac
 
       test -n "$rpath" && \
-	func_warning "\`-rpath' is ignored for objects"
+	func_warning "'-rpath' is ignored for objects"
 
       test -n "$xrpath" && \
-	func_warning "\`-R' is ignored for objects"
+	func_warning "'-R' is ignored for objects"
 
       test -n "$vinfo" && \
-	func_warning "\`-version-info' is ignored for objects"
+	func_warning "'-version-info' is ignored for objects"
 
       test -n "$release" && \
-	func_warning "\`-release' is ignored for objects"
+	func_warning "'-release' is ignored for objects"
 
       case $output in
       *.lo)
 	test -n "$objs$old_deplibs" && \
-	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
+	  func_fatal_error "cannot build library object '$output' from non-libtool objects"
 
 	libobj=$output
 	func_lo2o "$libobj"
@@ -8619,7 +10106,7 @@ EOF
 	;;
       *)
 	libobj=
-	obj="$output"
+	obj=$output
 	;;
       esac
 
@@ -8632,17 +10119,19 @@ EOF
       # the extraction.
       reload_conv_objs=
       gentop=
-      # reload_cmds runs $LD directly, so let us get rid of
-      # -Wl from whole_archive_flag_spec and hope we can get by with
-      # turning comma into space..
-      wl=
-
+      # if reload_cmds runs $LD directly, get rid of -Wl from
+      # whole_archive_flag_spec and hope we can get by with turning comma
+      # into space.
+      case $reload_cmds in
+        *\$LD[\ \$]*) wl= ;;
+      esac
       if test -n "$convenience"; then
 	if test -n "$whole_archive_flag_spec"; then
 	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
-	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
+	  test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
+	  reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
 	else
-	  gentop="$output_objdir/${obj}x"
+	  gentop=$output_objdir/${obj}x
 	  func_append generated " $gentop"
 
 	  func_extract_archives $gentop $convenience
@@ -8651,12 +10140,12 @@ EOF
       fi
 
       # If we're not building shared, we need to use non_pic_objs
-      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
+      test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
 
       # Create the old-style object.
-      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
+      reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
 
-      output="$obj"
+      output=$obj
       func_execute_cmds "$reload_cmds" 'exit $?'
 
       # Exit if we aren't doing a library object file.
@@ -8668,7 +10157,7 @@ EOF
 	exit $EXIT_SUCCESS
       fi
 
-      if test "$build_libtool_libs" != yes; then
+      test yes = "$build_libtool_libs" || {
 	if test -n "$gentop"; then
 	  func_show_eval '${RM}r "$gentop"'
 	fi
@@ -8678,12 +10167,12 @@ EOF
 	# $show "echo timestamp > $libobj"
 	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
 	exit $EXIT_SUCCESS
-      fi
+      }
 
-      if test -n "$pic_flag" || test "$pic_mode" != default; then
+      if test -n "$pic_flag" || test default != "$pic_mode"; then
 	# Only do commands if we really have different PIC objects.
 	reload_objs="$libobjs $reload_conv_objs"
-	output="$libobj"
+	output=$libobj
 	func_execute_cmds "$reload_cmds" 'exit $?'
       fi
 
@@ -8700,16 +10189,14 @@ EOF
 	          output=$func_stripname_result.exe;;
       esac
       test -n "$vinfo" && \
-	func_warning "\`-version-info' is ignored for programs"
+	func_warning "'-version-info' is ignored for programs"
 
       test -n "$release" && \
-	func_warning "\`-release' is ignored for programs"
+	func_warning "'-release' is ignored for programs"
 
-      test "$preload" = yes \
-        && test "$dlopen_support" = unknown \
-	&& test "$dlopen_self" = unknown \
-	&& test "$dlopen_self_static" = unknown && \
-	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
+      $preload \
+	&& test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
+	&& func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
 
       case $host in
       *-*-rhapsody* | *-*-darwin1.[012])
@@ -8723,11 +10210,11 @@ EOF
       *-*-darwin*)
 	# Don't allow lazy linking, it breaks C++ global constructors
 	# But is supposedly fixed on 10.4 or later (yay!).
-	if test "$tagname" = CXX ; then
+	if test CXX = "$tagname"; then
 	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
 	    10.[0123])
-	      func_append compile_command " ${wl}-bind_at_load"
-	      func_append finalize_command " ${wl}-bind_at_load"
+	      func_append compile_command " $wl-bind_at_load"
+	      func_append finalize_command " $wl-bind_at_load"
 	    ;;
 	  esac
 	fi
@@ -8763,7 +10250,7 @@ EOF
 	*) func_append new_libs " $deplib" ;;
 	esac
       done
-      compile_deplibs="$new_libs"
+      compile_deplibs=$new_libs
 
 
       func_append compile_command " $compile_deplibs"
@@ -8787,7 +10274,7 @@ EOF
 	if test -n "$hardcode_libdir_flag_spec"; then
 	  if test -n "$hardcode_libdir_separator"; then
 	    if test -z "$hardcode_libdirs"; then
-	      hardcode_libdirs="$libdir"
+	      hardcode_libdirs=$libdir
 	    else
 	      # Just accumulate the unique libdirs.
 	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
@@ -8810,7 +10297,7 @@ EOF
 	fi
 	case $host in
 	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
-	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
+	  testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
 	  case :$dllsearchpath: in
 	  *":$libdir:"*) ;;
 	  ::) dllsearchpath=$libdir;;
@@ -8827,10 +10314,10 @@ EOF
       # Substitute the hardcoded libdirs into the rpath.
       if test -n "$hardcode_libdir_separator" &&
 	 test -n "$hardcode_libdirs"; then
-	libdir="$hardcode_libdirs"
+	libdir=$hardcode_libdirs
 	eval rpath=\" $hardcode_libdir_flag_spec\"
       fi
-      compile_rpath="$rpath"
+      compile_rpath=$rpath
 
       rpath=
       hardcode_libdirs=
@@ -8838,7 +10325,7 @@ EOF
 	if test -n "$hardcode_libdir_flag_spec"; then
 	  if test -n "$hardcode_libdir_separator"; then
 	    if test -z "$hardcode_libdirs"; then
-	      hardcode_libdirs="$libdir"
+	      hardcode_libdirs=$libdir
 	    else
 	      # Just accumulate the unique libdirs.
 	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
@@ -8863,45 +10350,43 @@ EOF
       # Substitute the hardcoded libdirs into the rpath.
       if test -n "$hardcode_libdir_separator" &&
 	 test -n "$hardcode_libdirs"; then
-	libdir="$hardcode_libdirs"
+	libdir=$hardcode_libdirs
 	eval rpath=\" $hardcode_libdir_flag_spec\"
       fi
-      finalize_rpath="$rpath"
+      finalize_rpath=$rpath
 
-      if test -n "$libobjs" && test "$build_old_libs" = yes; then
+      if test -n "$libobjs" && test yes = "$build_old_libs"; then
 	# Transform all the library objects into standard objects.
 	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
 	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
       fi
 
-      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
+      func_generate_dlsyms "$outputname" "@PROGRAM@" false
 
       # template prelinking step
       if test -n "$prelink_cmds"; then
 	func_execute_cmds "$prelink_cmds" 'exit $?'
       fi
 
-      wrappers_required=yes
+      wrappers_required=:
       case $host in
       *cegcc* | *mingw32ce*)
         # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
-        wrappers_required=no
+        wrappers_required=false
         ;;
       *cygwin* | *mingw* )
-        if test "$build_libtool_libs" != yes; then
-          wrappers_required=no
-        fi
+        test yes = "$build_libtool_libs" || wrappers_required=false
         ;;
       *)
-        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
-          wrappers_required=no
+        if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
+          wrappers_required=false
         fi
         ;;
       esac
-      if test "$wrappers_required" = no; then
+      $wrappers_required || {
 	# Replace the output file specification.
 	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
-	link_command="$compile_command$compile_rpath"
+	link_command=$compile_command$compile_rpath
 
 	# We have no uninstalled library dependencies, so finalize right now.
 	exit_status=0
@@ -8914,12 +10399,12 @@ EOF
 	fi
 
 	# Delete the generated files.
-	if test -f "$output_objdir/${outputname}S.${objext}"; then
-	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
+	if test -f "$output_objdir/${outputname}S.$objext"; then
+	  func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
 	fi
 
 	exit $exit_status
-      fi
+      }
 
       if test -n "$compile_shlibpath$finalize_shlibpath"; then
 	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
@@ -8949,9 +10434,9 @@ EOF
 	fi
       fi
 
-      if test "$no_install" = yes; then
+      if test yes = "$no_install"; then
 	# We don't need to create a wrapper script.
-	link_command="$compile_var$compile_command$compile_rpath"
+	link_command=$compile_var$compile_command$compile_rpath
 	# Replace the output file specification.
 	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
 	# Delete the old output file.
@@ -8968,27 +10453,28 @@ EOF
 	exit $EXIT_SUCCESS
       fi
 
-      if test "$hardcode_action" = relink; then
-	# Fast installation is not supported
-	link_command="$compile_var$compile_command$compile_rpath"
-	relink_command="$finalize_var$finalize_command$finalize_rpath"
+      case $hardcode_action,$fast_install in
+        relink,*)
+	  # Fast installation is not supported
+	  link_command=$compile_var$compile_command$compile_rpath
+	  relink_command=$finalize_var$finalize_command$finalize_rpath
 
-	func_warning "this platform does not like uninstalled shared libraries"
-	func_warning "\`$output' will be relinked during installation"
-      else
-	if test "$fast_install" != no; then
-	  link_command="$finalize_var$compile_command$finalize_rpath"
-	  if test "$fast_install" = yes; then
-	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
-	  else
-	    # fast_install is set to needless
-	    relink_command=
-	  fi
-	else
-	  link_command="$compile_var$compile_command$compile_rpath"
-	  relink_command="$finalize_var$finalize_command$finalize_rpath"
-	fi
-      fi
+	  func_warning "this platform does not like uninstalled shared libraries"
+	  func_warning "'$output' will be relinked during installation"
+	  ;;
+        *,yes)
+	  link_command=$finalize_var$compile_command$finalize_rpath
+	  relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
+          ;;
+	*,no)
+	  link_command=$compile_var$compile_command$compile_rpath
+	  relink_command=$finalize_var$finalize_command$finalize_rpath
+          ;;
+	*,needless)
+	  link_command=$finalize_var$compile_command$finalize_rpath
+	  relink_command=
+          ;;
+      esac
 
       # Replace the output file specification.
       link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
@@ -9045,8 +10531,8 @@ EOF
 	    func_dirname_and_basename "$output" "" "."
 	    output_name=$func_basename_result
 	    output_path=$func_dirname_result
-	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
-	    cwrapper="$output_path/$output_name.exe"
+	    cwrappersource=$output_path/$objdir/lt-$output_name.c
+	    cwrapper=$output_path/$output_name.exe
 	    $RM $cwrappersource $cwrapper
 	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
 
@@ -9067,7 +10553,7 @@ EOF
 	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
 	    $opt_dry_run || {
 	      # note: this script will not be executed, so do not chmod.
-	      if test "x$build" = "x$host" ; then
+	      if test "x$build" = "x$host"; then
 		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
 	      else
 		func_emit_wrapper no > $func_ltwrapper_scriptname_result
@@ -9090,25 +10576,27 @@ EOF
     # See if we need to build an old-fashioned archive.
     for oldlib in $oldlibs; do
 
-      if test "$build_libtool_libs" = convenience; then
-	oldobjs="$libobjs_save $symfileobj"
-	addlibs="$convenience"
-	build_libtool_libs=no
-      else
-	if test "$build_libtool_libs" = module; then
-	  oldobjs="$libobjs_save"
+      case $build_libtool_libs in
+        convenience)
+	  oldobjs="$libobjs_save $symfileobj"
+	  addlibs=$convenience
 	  build_libtool_libs=no
-	else
+	  ;;
+	module)
+	  oldobjs=$libobjs_save
+	  addlibs=$old_convenience
+	  build_libtool_libs=no
+          ;;
+	*)
 	  oldobjs="$old_deplibs $non_pic_objects"
-	  if test "$preload" = yes && test -f "$symfileobj"; then
-	    func_append oldobjs " $symfileobj"
-	  fi
-	fi
-	addlibs="$old_convenience"
-      fi
+	  $preload && test -f "$symfileobj" \
+	    && func_append oldobjs " $symfileobj"
+	  addlibs=$old_convenience
+	  ;;
+      esac
 
       if test -n "$addlibs"; then
-	gentop="$output_objdir/${outputname}x"
+	gentop=$output_objdir/${outputname}x
 	func_append generated " $gentop"
 
 	func_extract_archives $gentop $addlibs
@@ -9116,13 +10604,13 @@ EOF
       fi
 
       # Do each command in the archive commands.
-      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+      if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
 	cmds=$old_archive_from_new_cmds
       else
 
 	# Add any objects from preloaded convenience libraries
 	if test -n "$dlprefiles"; then
-	  gentop="$output_objdir/${outputname}x"
+	  gentop=$output_objdir/${outputname}x
 	  func_append generated " $gentop"
 
 	  func_extract_archives $gentop $dlprefiles
@@ -9143,7 +10631,7 @@ EOF
 	  :
 	else
 	  echo "copying selected object files to avoid basename conflicts..."
-	  gentop="$output_objdir/${outputname}x"
+	  gentop=$output_objdir/${outputname}x
 	  func_append generated " $gentop"
 	  func_mkdir_p "$gentop"
 	  save_oldobjs=$oldobjs
@@ -9152,7 +10640,7 @@ EOF
 	  for obj in $save_oldobjs
 	  do
 	    func_basename "$obj"
-	    objbase="$func_basename_result"
+	    objbase=$func_basename_result
 	    case " $oldobjs " in
 	    " ") oldobjs=$obj ;;
 	    *[\ /]"$objbase "*)
@@ -9221,18 +10709,18 @@ EOF
 	    else
 	      # the above command should be used before it gets too long
 	      oldobjs=$objlist
-	      if test "$obj" = "$last_oldobj" ; then
+	      if test "$obj" = "$last_oldobj"; then
 		RANLIB=$save_RANLIB
 	      fi
 	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
-	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
+	      eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
 	      objlist=
 	      len=$len0
 	    fi
 	  done
 	  RANLIB=$save_RANLIB
 	  oldobjs=$objlist
-	  if test "X$oldobjs" = "X" ; then
+	  if test -z "$oldobjs"; then
 	    eval cmds=\"\$concat_cmds\"
 	  else
 	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
@@ -9249,7 +10737,7 @@ EOF
     case $output in
     *.la)
       old_library=
-      test "$build_old_libs" = yes && old_library="$libname.$libext"
+      test yes = "$build_old_libs" && old_library=$libname.$libext
       func_verbose "creating $output"
 
       # Preserve any variables that may affect compiler behavior
@@ -9264,31 +10752,31 @@ EOF
 	fi
       done
       # Quote the link command for shipping.
-      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
+      relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
       relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
-      if test "$hardcode_automatic" = yes ; then
+      if test yes = "$hardcode_automatic"; then
 	relink_command=
       fi
 
       # Only create the output if not a dry run.
       $opt_dry_run || {
 	for installed in no yes; do
-	  if test "$installed" = yes; then
+	  if test yes = "$installed"; then
 	    if test -z "$install_libdir"; then
 	      break
 	    fi
-	    output="$output_objdir/$outputname"i
+	    output=$output_objdir/${outputname}i
 	    # Replace all uninstalled libtool libraries with the installed ones
 	    newdependency_libs=
 	    for deplib in $dependency_libs; do
 	      case $deplib in
 	      *.la)
 		func_basename "$deplib"
-		name="$func_basename_result"
+		name=$func_basename_result
 		func_resolve_sysroot "$deplib"
-		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
+		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
 		test -z "$libdir" && \
-		  func_fatal_error "\`$deplib' is not a valid libtool archive"
+		  func_fatal_error "'$deplib' is not a valid libtool archive"
 		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
 		;;
 	      -L*)
@@ -9304,23 +10792,23 @@ EOF
 	      *) func_append newdependency_libs " $deplib" ;;
 	      esac
 	    done
-	    dependency_libs="$newdependency_libs"
+	    dependency_libs=$newdependency_libs
 	    newdlfiles=
 
 	    for lib in $dlfiles; do
 	      case $lib in
 	      *.la)
 	        func_basename "$lib"
-		name="$func_basename_result"
-		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+		name=$func_basename_result
+		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
 		test -z "$libdir" && \
-		  func_fatal_error "\`$lib' is not a valid libtool archive"
+		  func_fatal_error "'$lib' is not a valid libtool archive"
 		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
 		;;
 	      *) func_append newdlfiles " $lib" ;;
 	      esac
 	    done
-	    dlfiles="$newdlfiles"
+	    dlfiles=$newdlfiles
 	    newdlprefiles=
 	    for lib in $dlprefiles; do
 	      case $lib in
@@ -9330,34 +10818,34 @@ EOF
 		# didn't already link the preopened objects directly into
 		# the library:
 		func_basename "$lib"
-		name="$func_basename_result"
-		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+		name=$func_basename_result
+		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
 		test -z "$libdir" && \
-		  func_fatal_error "\`$lib' is not a valid libtool archive"
+		  func_fatal_error "'$lib' is not a valid libtool archive"
 		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
 		;;
 	      esac
 	    done
-	    dlprefiles="$newdlprefiles"
+	    dlprefiles=$newdlprefiles
 	  else
 	    newdlfiles=
 	    for lib in $dlfiles; do
 	      case $lib in
-		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
 		*) abs=`pwd`"/$lib" ;;
 	      esac
 	      func_append newdlfiles " $abs"
 	    done
-	    dlfiles="$newdlfiles"
+	    dlfiles=$newdlfiles
 	    newdlprefiles=
 	    for lib in $dlprefiles; do
 	      case $lib in
-		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
 		*) abs=`pwd`"/$lib" ;;
 	      esac
 	      func_append newdlprefiles " $abs"
 	    done
-	    dlprefiles="$newdlprefiles"
+	    dlprefiles=$newdlprefiles
 	  fi
 	  $RM $output
 	  # place dlname in correct position for cygwin
@@ -9373,10 +10861,9 @@ EOF
 	  case $host,$output,$installed,$module,$dlname in
 	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
 	      # If a -bindir argument was supplied, place the dll there.
-	      if test "x$bindir" != x ;
-	      then
+	      if test -n "$bindir"; then
 		func_relative_path "$install_libdir" "$bindir"
-		tdlname=$func_relative_path_result$dlname
+		tdlname=$func_relative_path_result/$dlname
 	      else
 		# Otherwise fall back on heuristic.
 		tdlname=../bin/$dlname
@@ -9385,7 +10872,7 @@ EOF
 	  esac
 	  $ECHO > $output "\
 # $outputname - a libtool library file
-# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
 #
 # Please DO NOT delete this file!
 # It is necessary for linking the library.
@@ -9399,7 +10886,7 @@ library_names='$library_names'
 # The name of the static archive.
 old_library='$old_library'
 
-# Linker flags that can not go in dependency_libs.
+# Linker flags that cannot go in dependency_libs.
 inherited_linker_flags='$new_inherited_linker_flags'
 
 # Libraries that this one depends upon.
@@ -9425,7 +10912,7 @@ dlpreopen='$dlprefiles'
 
 # Directory that this library needs to be installed in:
 libdir='$install_libdir'"
-	  if test "$installed" = no && test "$need_relink" = yes; then
+	  if test no,yes = "$installed,$need_relink"; then
 	    $ECHO >> $output "\
 relink_command=\"$relink_command\""
 	  fi
@@ -9440,27 +10927,29 @@ relink_command=\"$relink_command\""
     exit $EXIT_SUCCESS
 }
 
-{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
-    func_mode_link ${1+"$@"}
+if test link = "$opt_mode" || test relink = "$opt_mode"; then
+  func_mode_link ${1+"$@"}
+fi
 
 
 # func_mode_uninstall arg...
 func_mode_uninstall ()
 {
-    $opt_debug
-    RM="$nonopt"
+    $debug_cmd
+
+    RM=$nonopt
     files=
-    rmforce=
+    rmforce=false
     exit_status=0
 
     # This variable tells wrapper scripts just to set variables rather
     # than running their programs.
-    libtool_install_magic="$magic"
+    libtool_install_magic=$magic
 
     for arg
     do
       case $arg in
-      -f) func_append RM " $arg"; rmforce=yes ;;
+      -f) func_append RM " $arg"; rmforce=: ;;
       -*) func_append RM " $arg" ;;
       *) func_append files " $arg" ;;
       esac
@@ -9473,18 +10962,18 @@ func_mode_uninstall ()
 
     for file in $files; do
       func_dirname "$file" "" "."
-      dir="$func_dirname_result"
-      if test "X$dir" = X.; then
-	odir="$objdir"
+      dir=$func_dirname_result
+      if test . = "$dir"; then
+	odir=$objdir
       else
-	odir="$dir/$objdir"
+	odir=$dir/$objdir
       fi
       func_basename "$file"
-      name="$func_basename_result"
-      test "$opt_mode" = uninstall && odir="$dir"
+      name=$func_basename_result
+      test uninstall = "$opt_mode" && odir=$dir
 
       # Remember odir for removal later, being careful to avoid duplicates
-      if test "$opt_mode" = clean; then
+      if test clean = "$opt_mode"; then
 	case " $rmdirs " in
 	  *" $odir "*) ;;
 	  *) func_append rmdirs " $odir" ;;
@@ -9499,11 +10988,11 @@ func_mode_uninstall ()
       elif test -d "$file"; then
 	exit_status=1
 	continue
-      elif test "$rmforce" = yes; then
+      elif $rmforce; then
 	continue
       fi
 
-      rmfiles="$file"
+      rmfiles=$file
 
       case $name in
       *.la)
@@ -9517,7 +11006,7 @@ func_mode_uninstall ()
 	  done
 	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
 
-	  case "$opt_mode" in
+	  case $opt_mode in
 	  clean)
 	    case " $library_names " in
 	    *" $dlname "*) ;;
@@ -9528,12 +11017,12 @@ func_mode_uninstall ()
 	  uninstall)
 	    if test -n "$library_names"; then
 	      # Do each command in the postuninstall commands.
-	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+	      func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
 	    fi
 
 	    if test -n "$old_library"; then
 	      # Do each command in the old_postuninstall commands.
-	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+	      func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
 	    fi
 	    # FIXME: should reinstall the best remaining shared library.
 	    ;;
@@ -9549,21 +11038,19 @@ func_mode_uninstall ()
 	  func_source $dir/$name
 
 	  # Add PIC object to the list of files to remove.
-	  if test -n "$pic_object" &&
-	     test "$pic_object" != none; then
+	  if test -n "$pic_object" && test none != "$pic_object"; then
 	    func_append rmfiles " $dir/$pic_object"
 	  fi
 
 	  # Add non-PIC object to the list of files to remove.
-	  if test -n "$non_pic_object" &&
-	     test "$non_pic_object" != none; then
+	  if test -n "$non_pic_object" && test none != "$non_pic_object"; then
 	    func_append rmfiles " $dir/$non_pic_object"
 	  fi
 	fi
 	;;
 
       *)
-	if test "$opt_mode" = clean ; then
+	if test clean = "$opt_mode"; then
 	  noexename=$name
 	  case $file in
 	  *.exe)
@@ -9590,12 +11077,12 @@ func_mode_uninstall ()
 
 	    # note $name still contains .exe if it was in $file originally
 	    # as does the version of $file that was added into $rmfiles
-	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
-	    if test "$fast_install" = yes && test -n "$relink_command"; then
+	    func_append rmfiles " $odir/$name $odir/${name}S.$objext"
+	    if test yes = "$fast_install" && test -n "$relink_command"; then
 	      func_append rmfiles " $odir/lt-$name"
 	    fi
-	    if test "X$noexename" != "X$name" ; then
-	      func_append rmfiles " $odir/lt-${noexename}.c"
+	    if test "X$noexename" != "X$name"; then
+	      func_append rmfiles " $odir/lt-$noexename.c"
 	    fi
 	  fi
 	fi
@@ -9604,7 +11091,7 @@ func_mode_uninstall ()
       func_show_eval "$RM $rmfiles" 'exit_status=1'
     done
 
-    # Try to remove the ${objdir}s in the directories where we deleted files
+    # Try to remove the $objdir's in the directories where we deleted files
     for dir in $rmdirs; do
       if test -d "$dir"; then
 	func_show_eval "rmdir $dir >/dev/null 2>&1"
@@ -9614,16 +11101,17 @@ func_mode_uninstall ()
     exit $exit_status
 }
 
-{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
-    func_mode_uninstall ${1+"$@"}
+if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
+  func_mode_uninstall ${1+"$@"}
+fi
 
 test -z "$opt_mode" && {
-  help="$generic_help"
+  help=$generic_help
   func_fatal_help "you must specify a MODE"
 }
 
 test -z "$exec_cmd" && \
-  func_fatal_help "invalid operation mode \`$opt_mode'"
+  func_fatal_help "invalid operation mode '$opt_mode'"
 
 if test -n "$exec_cmd"; then
   eval exec "$exec_cmd"
@@ -9634,7 +11122,7 @@ exit $exit_status
 
 
 # The TAGs below are defined such that we never get into a situation
-# in which we disable both kinds of libraries.  Given conflicting
+# where we disable both kinds of libraries.  Given conflicting
 # choices, we go for a static library, that is the most portable,
 # since we can't tell whether shared libraries were disabled because
 # the user asked for that or because the platform doesn't support
@@ -9657,5 +11145,3 @@ build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
 # mode:shell-script
 # sh-indentation:2
 # End:
-# vi:sw=2
-
diff --git a/config/missing b/config/missing
index db98974..f62bbae 100755
--- a/config/missing
+++ b/config/missing
@@ -3,7 +3,7 @@
 
 scriptversion=2013-10-28.13; # UTC
 
-# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 # Originally written by Fran,cois Pinard <pinard at iro.umontreal.ca>, 1996.
 
 # This program is free software; you can redistribute it and/or modify
diff --git a/configure b/configure
index 27cd2cc..8cd69ae 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for pocl 0.11.
+# Generated by GNU Autoconf 2.69 for pocl 0.12.
 #
 # Report bugs to <pocl-devel at lists.sourceforge.net>.
 #
@@ -590,8 +590,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='pocl'
 PACKAGE_TARNAME='pocl'
-PACKAGE_VERSION='0.11'
-PACKAGE_STRING='pocl 0.11'
+PACKAGE_VERSION='0.12'
+PACKAGE_STRING='pocl 0.12'
 PACKAGE_BUGREPORT='pocl-devel at lists.sourceforge.net'
 PACKAGE_URL=''
 
@@ -653,6 +653,16 @@ TARGET_SIZEOF_DOUBLE
 TARGET_SIZEOF_HALF
 TARGET_SIZEOF_LONG
 OCL_TARGETS
+BUILD_HSA_FALSE
+BUILD_HSA_TRUE
+BUILD_AMDGCN_FALSE
+BUILD_AMDGCN_TRUE
+POAT_TESTSUITES
+TEST_SUITE_HSA_FALSE
+TEST_SUITE_HSA_TRUE
+HSAILASM
+HSA_LIBS
+HSA_INCLUDES
 BUILD_SPU_FALSE
 BUILD_SPU_TRUE
 LIBSPE_LIBS
@@ -720,9 +730,10 @@ PTHREAD_CFLAGS
 PTHREAD_LIBS
 PTHREAD_CC
 acx_pthread_config
-POAT_TESTSUITES
 TEST_SUITE_CLOVERLEAF_FALSE
 TEST_SUITE_CLOVERLEAF_TRUE
+TEST_SUITE_OPENCV_FALSE
+TEST_SUITE_OPENCV_TRUE
 TEST_SUITE_HALIDE_FALSE
 TEST_SUITE_HALIDE_TRUE
 TEST_SUITE_PIGLIT_FALSE
@@ -755,6 +766,7 @@ LLVM_VERSION
 LLVM_CONFIG
 CXXCPP
 CPP
+LT_SYS_LIBRARY_PATH
 OTOOL64
 OTOOL
 LIPO
@@ -895,6 +907,7 @@ enable_shared
 enable_static
 with_pic
 enable_fast_install
+with_aix_soname
 with_gnu_ld
 with_sysroot
 enable_libtool_lock
@@ -912,6 +925,8 @@ enable_pedantic
 enable_kernel_cache
 enable_vecmathlib_builtins
 enable_tce
+enable_hsa_amdgcn
+with_hsa_runtime_dir
 '
       ac_precious_vars='build_alias
 host_alias
@@ -929,6 +944,7 @@ CPPFLAGS
 CXX
 CXXFLAGS
 CCC
+LT_SYS_LIBRARY_PATH
 CPP
 CXXCPP
 LLVM_CONFIG
@@ -954,7 +970,8 @@ HOST_CLANG_FLAGS
 HOST_LLC_FLAGS
 HOST_AS_FLAGS
 LIBSPE_CFLAGS
-LIBSPE_LIBS'
+LIBSPE_LIBS
+HSAILASM'
 
 
 # Initialize some variables set by options.
@@ -1495,7 +1512,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures pocl 0.11 to adapt to many kinds of systems.
+\`configure' configures pocl 0.12 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1566,7 +1583,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of pocl 0.11:";;
+     short | recursive ) echo "Configuration of pocl 0.12:";;
    esac
   cat <<\_ACEOF
 
@@ -1593,7 +1610,7 @@ Optional Features:
                           known issues!).
   --enable-testsuites=suite1,suite2,...
                           choose enabled external project testsuites
-                          (all,opencl-book-samples,ViennaCL,Rodinia,Parboil,amd,amdsdk2_9,VexCL,Piglit,Halide,CloverLeaf
+                          (all,opencl-book-samples,ViennaCL,Rodinia,Parboil,amd,amdsdk2_9,VexCL,Piglit,Halide,OpenCV,CloverLeaf,hsa
   --enable-icd            Build pocl with the ICD extensions (default yes)
   --enable-direct-linkage Allow OpenCL programs to be linked directly against
                           the pocl library instead of using a ICD Loader
@@ -1610,15 +1627,19 @@ Optional Features:
                           Use only __builtin_* functions in the kernel
                           library.
   --disable-tce           Do not build TCE driver, even if TCE is found.
+  --disable-hsa-amdgcn    Disable the HSA device driver for AMD GCN devices.
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-pic[=PKGS]       try to use only PIC/non-PIC objects [default=use
                           both]
+  --with-aix-soname=aix|svr4|both
+                          shared library versioning (aka "SONAME") variant to
+                          provide on AIX, [default=aix].
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
-  --with-sysroot=DIR Search for dependent libraries within DIR
-                        (or the compiler's sysroot if not specified).
+  --with-sysroot[=DIR]    Search for dependent libraries within DIR (or the
+                          compiler's sysroot if not specified).
   --with-boost[=ARG]      use Boost library from a standard location
                           (ARG=yes), from the specified location (ARG=<path>),
                           or disable it (ARG=no) [ARG=yes]
@@ -1628,6 +1649,8 @@ Optional Packages:
                           this parameter only if default library detection
                           fails and you know exactly where your boost
                           libraries are located.
+  --with-hsa-runtime-dir  absolute path where HSA runtime files (include,libs)
+                          are found, defaults to /opt/hsa
 
 Some influential environment variables:
   PKG_CONFIG  path to pkg-config utility
@@ -1647,6 +1670,8 @@ Some influential environment variables:
               you have headers in a nonstandard directory <include dir>
   CXX         C++ compiler command
   CXXFLAGS    C++ compiler flags
+  LT_SYS_LIBRARY_PATH
+              User-defined run-time library search path.
   CPP         C preprocessor
   CXXCPP      C++ preprocessor
   LLVM_CONFIG Program used to retrieve LLVM options and binaries
@@ -1682,6 +1707,7 @@ Some influential environment variables:
   LIBSPE_CFLAGS
               C compiler flags for LIBSPE, overriding pkg-config
   LIBSPE_LIBS linker flags for LIBSPE, overriding pkg-config
+  HSAILASM    Path to HSAILasm executable
 
 Use these variables to override the choices made by `configure' or to help
 it to find libraries and programs with nonstandard names/locations.
@@ -1749,7 +1775,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-pocl configure 0.11
+pocl configure 0.12
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2422,7 +2448,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by pocl $as_me 0.11, which was
+It was created by pocl $as_me 0.12, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2916,7 +2942,7 @@ test -n "$target_alias" &&
     NONENONEs,x,x, &&
   program_prefix=${target_alias}-
 
-am__api_version='1.14'
+am__api_version='1.15'
 
 # Find a good install program.  We prefer a C program (faster),
 # so one script is as good as another.  But avoid the broken or
@@ -3108,7 +3134,7 @@ else
 $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;}
 fi
 
-if test x"${install_sh}" != xset; then
+if test x"${install_sh+set}" != xset; then
   case $am_aux_dir in
   *\ * | *\	*)
     install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
@@ -3402,7 +3428,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='pocl'
- VERSION='0.11'
+ VERSION='0.12'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -3436,8 +3462,8 @@ MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
 # <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
 mkdir_p='$(MKDIR_P)'
 
-# We need awk for the "check" target.  The system "awk" is bad on
-# some platforms.
+# We need awk for the "check" target (and possibly the TAP driver).  The
+# system "awk" is bad on some platforms.
 # Always define AMTAR for backward compatibility.  Yes, it's still used
 # in the wild :-(  We should find a proper way to deprecate it ...
 AMTAR='$${TAR-tar}'
@@ -5413,8 +5439,8 @@ esac
 
 
 
-macro_version='2.4.2'
-macro_revision='1.3337'
+macro_version='2.4.6'
+macro_revision='2.4.6'
 
 
 
@@ -5428,7 +5454,7 @@ macro_revision='1.3337'
 
 
 
-ltmain="$ac_aux_dir/ltmain.sh"
+ltmain=$ac_aux_dir/ltmain.sh
 
 # Backslashify metacharacters that are still active within
 # double-quoted strings.
@@ -5477,7 +5503,7 @@ func_echo_all ()
     $ECHO ""
 }
 
-case "$ECHO" in
+case $ECHO in
   printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5
 $as_echo "printf" >&6; } ;;
   print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5
@@ -5800,19 +5826,19 @@ test -z "$GREP" && GREP=grep
 
 # Check whether --with-gnu-ld was given.
 if test "${with_gnu_ld+set}" = set; then :
-  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+  withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes
 else
   with_gnu_ld=no
 fi
 
 ac_prog=ld
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   # Check if gcc -print-prog-name=ld gives a path.
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
 $as_echo_n "checking for ld used by $CC... " >&6; }
   case $host in
   *-*-mingw*)
-    # gcc leaves a trailing carriage return which upsets mingw
+    # gcc leaves a trailing carriage return, which upsets mingw
     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
   *)
     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
@@ -5826,7 +5852,7 @@ $as_echo_n "checking for ld used by $CC... " >&6; }
       while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
 	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
       done
-      test -z "$LD" && LD="$ac_prog"
+      test -z "$LD" && LD=$ac_prog
       ;;
   "")
     # If it fails, then pretend we aren't using GCC.
@@ -5837,7 +5863,7 @@ $as_echo_n "checking for ld used by $CC... " >&6; }
     with_gnu_ld=unknown
     ;;
   esac
-elif test "$with_gnu_ld" = yes; then
+elif test yes = "$with_gnu_ld"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
 $as_echo_n "checking for GNU ld... " >&6; }
 else
@@ -5848,32 +5874,32 @@ if ${lt_cv_path_LD+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -z "$LD"; then
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   for ac_dir in $PATH; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-      lt_cv_path_LD="$ac_dir/$ac_prog"
+      lt_cv_path_LD=$ac_dir/$ac_prog
       # Check to see if the program is GNU ld.  I'd rather use --version,
       # but apparently some variants of GNU ld only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
       *GNU* | *'with BFD'*)
-	test "$with_gnu_ld" != no && break
+	test no != "$with_gnu_ld" && break
 	;;
       *)
-	test "$with_gnu_ld" != yes && break
+	test yes != "$with_gnu_ld" && break
 	;;
       esac
     fi
   done
-  IFS="$lt_save_ifs"
+  IFS=$lt_save_ifs
 else
-  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+  lt_cv_path_LD=$LD # Let the user override the test with a path.
 fi
 fi
 
-LD="$lt_cv_path_LD"
+LD=$lt_cv_path_LD
 if test -n "$LD"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
 $as_echo "$LD" >&6; }
@@ -5916,33 +5942,38 @@ if ${lt_cv_path_NM+:} false; then :
 else
   if test -n "$NM"; then
   # Let the user override the test.
-  lt_cv_path_NM="$NM"
+  lt_cv_path_NM=$NM
 else
-  lt_nm_to_check="${ac_tool_prefix}nm"
+  lt_nm_to_check=${ac_tool_prefix}nm
   if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
     lt_nm_to_check="$lt_nm_to_check nm"
   fi
   for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
     for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+      tmp_nm=$ac_dir/$lt_tmp_nm
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then
 	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
+	# Adding the 'sed 1q' prevents false positives on HP-UX, which says:
 	#   nm: unknown option "B" ignored
 	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
+	# MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty
+	case $build_os in
+	mingw*) lt_bad_file=conftest.nm/nofile ;;
+	*) lt_bad_file=/dev/null ;;
+	esac
+	case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in
+	*$lt_bad_file* | *'Invalid file or object type'*)
 	  lt_cv_path_NM="$tmp_nm -B"
-	  break
+	  break 2
 	  ;;
 	*)
 	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
 	  */dev/null*)
 	    lt_cv_path_NM="$tmp_nm -p"
-	    break
+	    break 2
 	    ;;
 	  *)
 	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
@@ -5953,15 +5984,15 @@ else
 	esac
       fi
     done
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
   done
   : ${lt_cv_path_NM=no}
 fi
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
 $as_echo "$lt_cv_path_NM" >&6; }
-if test "$lt_cv_path_NM" != "no"; then
-  NM="$lt_cv_path_NM"
+if test no != "$lt_cv_path_NM"; then
+  NM=$lt_cv_path_NM
 else
   # Didn't find any BSD compatible name lister, look for dumpbin.
   if test -n "$DUMPBIN"; then :
@@ -6067,9 +6098,9 @@ esac
   fi
 fi
 
-    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
+    case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in
     *COFF*)
-      DUMPBIN="$DUMPBIN -symbols"
+      DUMPBIN="$DUMPBIN -symbols -headers"
       ;;
     *)
       DUMPBIN=:
@@ -6077,8 +6108,8 @@ fi
     esac
   fi
 
-  if test "$DUMPBIN" != ":"; then
-    NM="$DUMPBIN"
+  if test : != "$DUMPBIN"; then
+    NM=$DUMPBIN
   fi
 fi
 test -z "$NM" && NM=nm
@@ -6118,7 +6149,7 @@ if ${lt_cv_sys_max_cmd_len+:} false; then :
   $as_echo_n "(cached) " >&6
 else
     i=0
-  teststring="ABCD"
+  teststring=ABCD
 
   case $build_os in
   msdosdjgpp*)
@@ -6158,7 +6189,7 @@ else
     lt_cv_sys_max_cmd_len=8192;
     ;;
 
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+  bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*)
     # This has been around since 386BSD, at least.  Likely further.
     if test -x /sbin/sysctl; then
       lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
@@ -6209,22 +6240,22 @@ else
   *)
     lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
     if test -n "$lt_cv_sys_max_cmd_len" && \
-	test undefined != "$lt_cv_sys_max_cmd_len"; then
+       test undefined != "$lt_cv_sys_max_cmd_len"; then
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
     else
       # Make teststring a little bigger before we do anything with it.
       # a 1K string should be a reasonable start.
-      for i in 1 2 3 4 5 6 7 8 ; do
+      for i in 1 2 3 4 5 6 7 8; do
         teststring=$teststring$teststring
       done
       SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
       # If test is not a shell built-in, we'll probably end up computing a
       # maximum length that is only half of the actual maximum length, but
       # we can't tell.
-      while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
+      while { test X`env echo "$teststring$teststring" 2>/dev/null` \
 	         = "X$teststring$teststring"; } >/dev/null 2>&1 &&
-	      test $i != 17 # 1/2 MB should be enough
+	      test 17 != "$i" # 1/2 MB should be enough
       do
         i=`expr $i + 1`
         teststring=$teststring$teststring
@@ -6242,7 +6273,7 @@ else
 
 fi
 
-if test -n $lt_cv_sys_max_cmd_len ; then
+if test -n "$lt_cv_sys_max_cmd_len"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
 $as_echo "$lt_cv_sys_max_cmd_len" >&6; }
 else
@@ -6260,30 +6291,6 @@ max_cmd_len=$lt_cv_sys_max_cmd_len
 : ${MV="mv -f"}
 : ${RM="rm -f"}
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5
-$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; }
-# Try some XSI features
-xsi_shell=no
-( _lt_dummy="a/b/c"
-  test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
-      = c,a/b,b/c, \
-    && eval 'test $(( 1 + 1 )) -eq 2 \
-    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
-  && xsi_shell=yes
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5
-$as_echo "$xsi_shell" >&6; }
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5
-$as_echo_n "checking whether the shell understands \"+=\"... " >&6; }
-lt_shell_append=no
-( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \
-    >/dev/null 2>&1 \
-  && lt_shell_append=yes
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5
-$as_echo "$lt_shell_append" >&6; }
-
-
 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
   lt_unset=unset
 else
@@ -6406,13 +6413,13 @@ esac
 reload_cmds='$LD$reload_flag -o $output$reload_objs'
 case $host_os in
   cygwin* | mingw* | pw32* | cegcc*)
-    if test "$GCC" != yes; then
+    if test yes != "$GCC"; then
       reload_cmds=false
     fi
     ;;
   darwin*)
-    if test "$GCC" = yes; then
-      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    if test yes = "$GCC"; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs'
     else
       reload_cmds='$LD$reload_flag -o $output$reload_objs'
     fi
@@ -6540,13 +6547,13 @@ lt_cv_deplibs_check_method='unknown'
 # Need to set the preceding variable on all platforms that support
 # interlibrary dependencies.
 # 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
+# 'unknown' -- same as none, but documents that we really don't know.
 # 'pass_all' -- all dependencies passed with no checks.
 # 'test_compile' -- check by making test program.
 # 'file_magic [[regex]]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given extended regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
+# that responds to the $file_magic_cmd with a given extended regex.
+# If you have 'file' or equivalent on your system and you're not sure
+# whether 'pass_all' will *always* work, you probably want this one.
 
 case $host_os in
 aix[4-9]*)
@@ -6573,8 +6580,7 @@ mingw* | pw32*)
   # Base MSYS/MinGW do not provide the 'file' command needed by
   # func_win32_libid shell function, so use a weaker test based on 'objdump',
   # unless we find 'file', for example because we are cross-compiling.
-  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
-  if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
+  if ( file / ) >/dev/null 2>&1; then
     lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
     lt_cv_file_magic_cmd='func_win32_libid'
   else
@@ -6652,7 +6658,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-netbsd* | netbsdelf*-gnu)
+netbsd*)
   if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
     lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
   else
@@ -6670,8 +6676,8 @@ newos6*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-openbsd*)
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+openbsd* | bitrig*)
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
     lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
   else
     lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
@@ -6724,6 +6730,9 @@ sysv4 | sysv4.3*)
 tpf*)
   lt_cv_deplibs_check_method=pass_all
   ;;
+os2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 esac
 
 fi
@@ -6881,8 +6890,8 @@ else
 
 case $host_os in
 cygwin* | mingw* | pw32* | cegcc*)
-  # two different shell functions defined in ltmain.sh
-  # decide which to use based on capabilities of $DLLTOOL
+  # two different shell functions defined in ltmain.sh;
+  # decide which one to use based on capabilities of $DLLTOOL
   case `$DLLTOOL --help 2>&1` in
   *--identify-strict*)
     lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
@@ -6894,7 +6903,7 @@ cygwin* | mingw* | pw32* | cegcc*)
   ;;
 *)
   # fallback: assume linklib IS sharedlib
-  lt_cv_sharedlib_from_linklib_cmd="$ECHO"
+  lt_cv_sharedlib_from_linklib_cmd=$ECHO
   ;;
 esac
 
@@ -7048,7 +7057,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
-      if test "$ac_status" -eq 0; then
+      if test 0 -eq "$ac_status"; then
 	# Ensure the archiver fails upon bogus file names.
 	rm -f conftest.$ac_objext libconftest.a
 	{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
@@ -7056,7 +7065,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
-	if test "$ac_status" -ne 0; then
+	if test 0 -ne "$ac_status"; then
           lt_cv_ar_at_file=@
         fi
       fi
@@ -7069,7 +7078,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5
 $as_echo "$lt_cv_ar_at_file" >&6; }
 
-if test "x$lt_cv_ar_at_file" = xno; then
+if test no = "$lt_cv_ar_at_file"; then
   archiver_list_spec=
 else
   archiver_list_spec=$lt_cv_ar_at_file
@@ -7286,7 +7295,7 @@ old_postuninstall_cmds=
 
 if test -n "$RANLIB"; then
   case $host_os in
-  openbsd*)
+  bitrig* | openbsd*)
     old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
     ;;
   *)
@@ -7376,7 +7385,7 @@ cygwin* | mingw* | pw32* | cegcc*)
   symcode='[ABCDGISTW]'
   ;;
 hpux*)
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     symcode='[ABCDEGRST]'
   fi
   ;;
@@ -7409,14 +7418,44 @@ case `$NM -V 2>&1` in
   symcode='[ABCDGIRSTW]' ;;
 esac
 
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+  # Gets list of data symbols to import.
+  lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'"
+  # Adjust the below global symbol transforms to fixup imported variables.
+  lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'"
+  lt_c_name_hook=" -e 's/^I .* \(.*\)$/  {\"\1\", (void *) 0},/p'"
+  lt_c_name_lib_hook="\
+  -e 's/^I .* \(lib.*\)$/  {\"\1\", (void *) 0},/p'\
+  -e 's/^I .* \(.*\)$/  {\"lib\1\", (void *) 0},/p'"
+else
+  # Disable hooks by default.
+  lt_cv_sys_global_symbol_to_import=
+  lt_cdecl_hook=
+  lt_c_name_hook=
+  lt_c_name_lib_hook=
+fi
+
 # Transform an extracted symbol line into a proper C declaration.
 # Some systems (esp. on ia64) link data and code symbols differently,
 # so use this general approach.
-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+lt_cv_sys_global_symbol_to_cdecl="sed -n"\
+$lt_cdecl_hook\
+" -e 's/^T .* \(.*\)$/extern int \1();/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'"
 
 # Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (void *) \&\2},/p'"
-lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address="sed -n"\
+$lt_c_name_hook\
+" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/p'"
+
+# Transform an extracted symbol line into symbol name with lib prefix and
+# symbol address.
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\
+$lt_c_name_lib_hook\
+" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(lib.*\)$/  {\"\1\", (void *) \&\1},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"lib\1\", (void *) \&\1},/p'"
 
 # Handle CRLF in mingw tool chain
 opt_cr=
@@ -7434,21 +7473,24 @@ for ac_symprfx in "" "_"; do
 
   # Write the raw and C identifiers.
   if test "$lt_cv_nm_interface" = "MS dumpbin"; then
-    # Fake it for dumpbin and say T for any non-static function
-    # and D for any global variable.
+    # Fake it for dumpbin and say T for any non-static function,
+    # D for any global variable and I for any imported variable.
     # Also find C++ and __fastcall symbols from MSVC++,
     # which start with @ or ?.
     lt_cv_sys_global_symbol_pipe="$AWK '"\
 "     {last_section=section; section=\$ 3};"\
 "     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
 "     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+"     /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\
+"     /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\
+"     /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\
 "     \$ 0!~/External *\|/{next};"\
 "     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
 "     {if(hide[section]) next};"\
-"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
-"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
-"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
-"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+"     {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\
+"     {split(\$ 0,a,/\||\r/); split(a[2],s)};"\
+"     s[1]~/^[@?]/{print f,s[1],s[1]; next};"\
+"     s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\
 "     ' prfx=^$ac_symprfx"
   else
     lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[	 ]\($symcode$symcode*\)[	 ][	 ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
@@ -7496,11 +7538,11 @@ _LT_EOF
 	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
 	  cat <<_LT_EOF > conftest.$ac_ext
 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
-#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
-/* DATA imports from DLLs on WIN32 con't be const, because runtime
+#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
+/* DATA imports from DLLs on WIN32 can't be const, because runtime
    relocations are performed -- see ld's documentation on pseudo-relocs.  */
 # define LT_DLSYM_CONST
-#elif defined(__osf__)
+#elif defined __osf__
 /* This system does not cope well with relocations in const data.  */
 # define LT_DLSYM_CONST
 #else
@@ -7526,7 +7568,7 @@ lt__PROGRAM__LTX_preloaded_symbols[] =
 {
   { "@PROGRAM@", (void *) 0 },
 _LT_EOF
-	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+	  $SED "s/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
 	  cat <<\_LT_EOF >> conftest.$ac_ext
   {0, (void *) 0}
 };
@@ -7546,13 +7588,13 @@ _LT_EOF
 	  mv conftest.$ac_objext conftstm.$ac_objext
 	  lt_globsym_save_LIBS=$LIBS
 	  lt_globsym_save_CFLAGS=$CFLAGS
-	  LIBS="conftstm.$ac_objext"
+	  LIBS=conftstm.$ac_objext
 	  CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
 	  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
   (eval $ac_link) 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s conftest${ac_exeext}; then
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
 	    pipe_works=yes
 	  fi
 	  LIBS=$lt_globsym_save_LIBS
@@ -7573,7 +7615,7 @@ _LT_EOF
   rm -rf conftest* conftst*
 
   # Do not use the global_symbol_pipe unless it works.
-  if test "$pipe_works" = yes; then
+  if test yes = "$pipe_works"; then
     break
   else
     lt_cv_sys_global_symbol_pipe=
@@ -7626,6 +7668,16 @@ fi
 
 
 
+
+
+
+
+
+
+
+
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5
 $as_echo_n "checking for sysroot... " >&6; }
 
@@ -7638,9 +7690,9 @@ fi
 
 
 lt_sysroot=
-case ${with_sysroot} in #(
+case $with_sysroot in #(
  yes)
-   if test "$GCC" = yes; then
+   if test yes = "$GCC"; then
      lt_sysroot=`$CC --print-sysroot 2>/dev/null`
    fi
    ;; #(
@@ -7650,8 +7702,8 @@ case ${with_sysroot} in #(
  no|'')
    ;; #(
  *)
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5
-$as_echo "${with_sysroot}" >&6; }
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5
+$as_echo "$with_sysroot" >&6; }
    as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5
    ;;
 esac
@@ -7663,18 +7715,99 @@ $as_echo "${lt_sysroot:-no}" >&6; }
 
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5
+$as_echo_n "checking for a working dd... " >&6; }
+if ${ac_cv_path_lt_DD+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+: ${lt_DD:=$DD}
+if test -z "$lt_DD"; then
+  ac_path_lt_DD_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in dd; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_lt_DD="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_lt_DD" || continue
+if "$ac_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+  cmp -s conftest.i conftest.out \
+  && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=:
+fi
+      $ac_path_lt_DD_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_lt_DD"; then
+    :
+  fi
+else
+  ac_cv_path_lt_DD=$lt_DD
+fi
+
+rm -f conftest.i conftest2.i conftest.out
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5
+$as_echo "$ac_cv_path_lt_DD" >&6; }
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5
+$as_echo_n "checking how to truncate binary pipes... " >&6; }
+if ${lt_cv_truncate_bin+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+lt_cv_truncate_bin=
+if "$ac_cv_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+  cmp -s conftest.i conftest.out \
+  && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1"
+fi
+rm -f conftest.i conftest2.i conftest.out
+test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5
+$as_echo "$lt_cv_truncate_bin" >&6; }
+
+
+
+
+
+
+
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+func_cc_basename ()
+{
+    for cc_temp in $*""; do
+      case $cc_temp in
+        compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+        distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+        \-*) ;;
+        *) break;;
+      esac
+    done
+    func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+}
+
 # Check whether --enable-libtool-lock was given.
 if test "${enable_libtool_lock+set}" = set; then :
   enableval=$enable_libtool_lock;
 fi
 
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+test no = "$enable_libtool_lock" || enable_libtool_lock=yes
 
 # Some flags need to be propagated to the compiler or linker for good
 # libtool support.
 case $host in
 ia64-*-hpux*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set mode
+  # options accordingly.
   echo 'int i;' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
@@ -7683,24 +7816,25 @@ ia64-*-hpux*)
   test $ac_status = 0; }; then
     case `/usr/bin/file conftest.$ac_objext` in
       *ELF-32*)
-	HPUX_IA64_MODE="32"
+	HPUX_IA64_MODE=32
 	;;
       *ELF-64*)
-	HPUX_IA64_MODE="64"
+	HPUX_IA64_MODE=64
 	;;
     esac
   fi
   rm -rf conftest*
   ;;
 *-*-irix6*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
   echo '#line '$LINENO' "configure"' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
-    if test "$lt_cv_prog_gnu_ld" = yes; then
+    if test yes = "$lt_cv_prog_gnu_ld"; then
       case `/usr/bin/file conftest.$ac_objext` in
 	*32-bit*)
 	  LD="${LD-ld} -melf32bsmip"
@@ -7729,9 +7863,50 @@ ia64-*-hpux*)
   rm -rf conftest*
   ;;
 
+mips64*-*linux*)
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
+  echo '#line '$LINENO' "configure"' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    emul=elf
+    case `/usr/bin/file conftest.$ac_objext` in
+      *32-bit*)
+	emul="${emul}32"
+	;;
+      *64-bit*)
+	emul="${emul}64"
+	;;
+    esac
+    case `/usr/bin/file conftest.$ac_objext` in
+      *MSB*)
+	emul="${emul}btsmip"
+	;;
+      *LSB*)
+	emul="${emul}ltsmip"
+	;;
+    esac
+    case `/usr/bin/file conftest.$ac_objext` in
+      *N32*)
+	emul="${emul}n32"
+	;;
+    esac
+    LD="${LD-ld} -m $emul"
+  fi
+  rm -rf conftest*
+  ;;
+
 x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.  Note that the listed cases only cover the
+  # situations where additional linker options are needed (such as when
+  # doing 32-bit compilation for a host where ld defaults to 64-bit, or
+  # vice versa); the common cases where no linker options are needed do
+  # not appear in the list.
   echo 'int i;' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
@@ -7754,10 +7929,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 		;;
 	    esac
 	    ;;
-	  powerpc64le-*)
+	  powerpc64le-*linux*)
 	    LD="${LD-ld} -m elf32lppclinux"
 	    ;;
-	  powerpc64-*)
+	  powerpc64-*linux*)
 	    LD="${LD-ld} -m elf32ppclinux"
 	    ;;
 	  s390x-*linux*)
@@ -7776,10 +7951,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 	  x86_64-*linux*)
 	    LD="${LD-ld} -m elf_x86_64"
 	    ;;
-	  powerpcle-*)
+	  powerpcle-*linux*)
 	    LD="${LD-ld} -m elf64lppc"
 	    ;;
-	  powerpc-*)
+	  powerpc-*linux*)
 	    LD="${LD-ld} -m elf64ppc"
 	    ;;
 	  s390*-*linux*|s390*-*tpf*)
@@ -7797,7 +7972,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
 *-*-sco3.2v5*)
   # On SCO OpenServer 5, we need -belf to get full-featured binaries.
-  SAVE_CFLAGS="$CFLAGS"
+  SAVE_CFLAGS=$CFLAGS
   CFLAGS="$CFLAGS -belf"
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
 $as_echo_n "checking whether the C compiler needs -belf... " >&6; }
@@ -7837,13 +8012,14 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
 $as_echo "$lt_cv_cc_needs_belf" >&6; }
-  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+  if test yes != "$lt_cv_cc_needs_belf"; then
     # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
-    CFLAGS="$SAVE_CFLAGS"
+    CFLAGS=$SAVE_CFLAGS
   fi
   ;;
 *-*solaris*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
   echo 'int i;' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
@@ -7855,7 +8031,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; }
       case $lt_cv_prog_gnu_ld in
       yes*)
         case $host in
-        i?86-*-solaris*)
+        i?86-*-solaris*|x86_64-*-solaris*)
           LD="${LD-ld} -m elf_x86_64"
           ;;
         sparc*-*-solaris*)
@@ -7864,7 +8040,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; }
         esac
         # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.
         if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
-          LD="${LD-ld}_sol2"
+          LD=${LD-ld}_sol2
         fi
         ;;
       *)
@@ -7880,7 +8056,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; }
   ;;
 esac
 
-need_locks="$enable_libtool_lock"
+need_locks=$enable_libtool_lock
 
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args.
@@ -7991,7 +8167,7 @@ else
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5
 $as_echo "$lt_cv_path_mainfest_tool" >&6; }
-if test "x$lt_cv_path_mainfest_tool" != xyes; then
+if test yes != "$lt_cv_path_mainfest_tool"; then
   MANIFEST_TOOL=:
 fi
 
@@ -8494,7 +8670,7 @@ if ${lt_cv_apple_cc_single_mod+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   lt_cv_apple_cc_single_mod=no
-      if test -z "${LT_MULTI_MODULE}"; then
+      if test -z "$LT_MULTI_MODULE"; then
 	# By default we will add the -single_module flag. You can override
 	# by either setting the environment variable LT_MULTI_MODULE
 	# non-empty at configure time, or by adding -multi_module to the
@@ -8512,7 +8688,7 @@ else
 	  cat conftest.err >&5
 	# Otherwise, if the output was created with a 0 exit code from
 	# the compiler, it worked.
-	elif test -f libconftest.dylib && test $_lt_result -eq 0; then
+	elif test -f libconftest.dylib && test 0 = "$_lt_result"; then
 	  lt_cv_apple_cc_single_mod=yes
 	else
 	  cat conftest.err >&5
@@ -8551,7 +8727,7 @@ else
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
-	LDFLAGS="$save_LDFLAGS"
+	LDFLAGS=$save_LDFLAGS
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
@@ -8580,7 +8756,7 @@ _LT_EOF
       _lt_result=$?
       if test -s conftest.err && $GREP force_load conftest.err; then
 	cat conftest.err >&5
-      elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
+      elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then
 	lt_cv_ld_force_load=yes
       else
 	cat conftest.err >&5
@@ -8593,32 +8769,32 @@ fi
 $as_echo "$lt_cv_ld_force_load" >&6; }
     case $host_os in
     rhapsody* | darwin1.[012])
-      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+      _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;;
     darwin1.*)
-      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+      _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
     darwin*) # darwin 5.x on
       # if running on 10.5 or later, the deployment target defaults
       # to the OS version, if on x86, and 10.4, the deployment
       # target defaults to 10.4. Don't you love it?
       case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
 	10.0,*86*-darwin8*|10.0,*-darwin[91]*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
-	10.[012]*)
-	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
+	10.[012][,.]*)
+	  _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
 	10.*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
       esac
     ;;
   esac
-    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+    if test yes = "$lt_cv_apple_cc_single_mod"; then
       _lt_dar_single_mod='$single_module'
     fi
-    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
-      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    if test yes = "$lt_cv_ld_exported_symbols_list"; then
+      _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym'
     else
-      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib'
     fi
-    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
+    if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then
       _lt_dsymutil='~$DSYMUTIL $lib || :'
     else
       _lt_dsymutil=
@@ -8626,6 +8802,41 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
     ;;
   esac
 
+# func_munge_path_list VARIABLE PATH
+# -----------------------------------
+# VARIABLE is name of variable containing _space_ separated list of
+# directories to be munged by the contents of PATH, which is string
+# having a format:
+# "DIR[:DIR]:"
+#       string "DIR[ DIR]" will be prepended to VARIABLE
+# ":DIR[:DIR]"
+#       string "DIR[ DIR]" will be appended to VARIABLE
+# "DIRP[:DIRP]::[DIRA:]DIRA"
+#       string "DIRP[ DIRP]" will be prepended to VARIABLE and string
+#       "DIRA[ DIRA]" will be appended to VARIABLE
+# "DIR[:DIR]"
+#       VARIABLE will be replaced by "DIR[ DIR]"
+func_munge_path_list ()
+{
+    case x$2 in
+    x)
+        ;;
+    *:)
+        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\"
+        ;;
+    x:*)
+        eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\"
+        ;;
+    *::*)
+        eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"
+        eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\"
+        ;;
+    *)
+        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\"
+        ;;
+    esac
+}
+
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -8911,9 +9122,9 @@ done
 
 func_stripname_cnf ()
 {
-  case ${2} in
-  .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
-  *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+  case $2 in
+  .*) func_stripname_result=`$ECHO "$3" | $SED "s%^$1%%; s%\\\\$2\$%%"`;;
+  *)  func_stripname_result=`$ECHO "$3" | $SED "s%^$1%%; s%$2\$%%"`;;
   esac
 } # func_stripname_cnf
 
@@ -8940,14 +9151,14 @@ if test "${enable_shared+set}" = set; then :
     *)
       enable_shared=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_shared=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac
 else
@@ -8971,14 +9182,14 @@ if test "${enable_static+set}" = set; then :
     *)
      enable_static=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_static=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac
 else
@@ -9002,14 +9213,14 @@ if test "${with_pic+set}" = set; then :
     *)
       pic_mode=default
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for lt_pkg in $withval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$lt_pkg" = "X$lt_p"; then
 	  pic_mode=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac
 else
@@ -9017,8 +9228,6 @@ else
 fi
 
 
-test -z "$pic_mode" && pic_mode=default
-
 
 
 
@@ -9034,14 +9243,14 @@ if test "${enable_fast_install+set}" = set; then :
     *)
       enable_fast_install=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_fast_install=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac
 else
@@ -9055,11 +9264,63 @@ fi
 
 
 
+  shared_archive_member_spec=
+case $host,$enable_shared in
+power*-*-aix[5-9]*,yes)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5
+$as_echo_n "checking which variant of shared library versioning to provide... " >&6; }
+
+# Check whether --with-aix-soname was given.
+if test "${with_aix_soname+set}" = set; then :
+  withval=$with_aix_soname; case $withval in
+    aix|svr4|both)
+      ;;
+    *)
+      as_fn_error $? "Unknown argument to --with-aix-soname" "$LINENO" 5
+      ;;
+    esac
+    lt_cv_with_aix_soname=$with_aix_soname
+else
+  if ${lt_cv_with_aix_soname+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_with_aix_soname=aix
+fi
+
+    with_aix_soname=$lt_cv_with_aix_soname
+fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5
+$as_echo "$with_aix_soname" >&6; }
+  if test aix != "$with_aix_soname"; then
+    # For the AIX way of multilib, we name the shared archive member
+    # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
+    # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.
+    # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,
+    # the AIX toolchain works better with OBJECT_MODE set (default 32).
+    if test 64 = "${OBJECT_MODE-32}"; then
+      shared_archive_member_spec=shr_64
+    else
+      shared_archive_member_spec=shr
+    fi
+  fi
+  ;;
+*)
+  with_aix_soname=aix
+  ;;
+esac
+
+
+
+
+
+
+
 
 
 
 # This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ltmain"
+LIBTOOL_DEPS=$ltmain
 
 # Always use our own libtool.
 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
@@ -9108,7 +9369,7 @@ test -z "$LN_S" && LN_S="ln -s"
 
 
 
-if test -n "${ZSH_VERSION+set}" ; then
+if test -n "${ZSH_VERSION+set}"; then
    setopt NO_GLOB_SUBST
 fi
 
@@ -9147,7 +9408,7 @@ aix3*)
   # AIX sometimes has problems with the GCC collect2 program.  For some
   # reason, if we set the COLLECT_NAMES environment variable, the problems
   # vanish in a puff of smoke.
-  if test "X${COLLECT_NAMES+set}" != Xset; then
+  if test set != "${COLLECT_NAMES+set}"; then
     COLLECT_NAMES=
     export COLLECT_NAMES
   fi
@@ -9158,14 +9419,14 @@ esac
 ofile=libtool
 can_build_shared=yes
 
-# All known linkers require a `.a' archive for static linking (except MSVC,
+# All known linkers require a '.a' archive for static linking (except MSVC,
 # which needs '.lib').
 libext=a
 
-with_gnu_ld="$lt_cv_prog_gnu_ld"
+with_gnu_ld=$lt_cv_prog_gnu_ld
 
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
+old_CC=$CC
+old_CFLAGS=$CFLAGS
 
 # Set sane defaults for various variables
 test -z "$CC" && CC=cc
@@ -9174,15 +9435,8 @@ test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
 test -z "$LD" && LD=ld
 test -z "$ac_objext" && ac_objext=o
 
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+func_cc_basename $compiler
+cc_basename=$func_cc_basename_result
 
 
 # Only perform the check for file, if the check method requires it
@@ -9197,22 +9451,22 @@ if ${lt_cv_path_MAGIC_CMD+:} false; then :
 else
   case $MAGIC_CMD in
 [\\/*] |  ?:[\\/]*)
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.
   ;;
 *)
-  lt_save_MAGIC_CMD="$MAGIC_CMD"
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_MAGIC_CMD=$MAGIC_CMD
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
   for ac_dir in $ac_dummy; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/${ac_tool_prefix}file; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
+    if test -f "$ac_dir/${ac_tool_prefix}file"; then
+      lt_cv_path_MAGIC_CMD=$ac_dir/"${ac_tool_prefix}file"
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
 	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
 	    :
@@ -9235,13 +9489,13 @@ _LT_EOF
       break
     fi
   done
-  IFS="$lt_save_ifs"
-  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  IFS=$lt_save_ifs
+  MAGIC_CMD=$lt_save_MAGIC_CMD
   ;;
 esac
 fi
 
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 if test -n "$MAGIC_CMD"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
 $as_echo "$MAGIC_CMD" >&6; }
@@ -9263,22 +9517,22 @@ if ${lt_cv_path_MAGIC_CMD+:} false; then :
 else
   case $MAGIC_CMD in
 [\\/*] |  ?:[\\/]*)
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.
   ;;
 *)
-  lt_save_MAGIC_CMD="$MAGIC_CMD"
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_MAGIC_CMD=$MAGIC_CMD
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
   for ac_dir in $ac_dummy; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/file; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/file"
+    if test -f "$ac_dir/file"; then
+      lt_cv_path_MAGIC_CMD=$ac_dir/"file"
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
 	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
 	    :
@@ -9301,13 +9555,13 @@ _LT_EOF
       break
     fi
   done
-  IFS="$lt_save_ifs"
-  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  IFS=$lt_save_ifs
+  MAGIC_CMD=$lt_save_MAGIC_CMD
   ;;
 esac
 fi
 
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 if test -n "$MAGIC_CMD"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
 $as_echo "$MAGIC_CMD" >&6; }
@@ -9328,7 +9582,7 @@ esac
 
 # Use C for the default configuration in the libtool script
 
-lt_save_CC="$CC"
+lt_save_CC=$CC
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -9390,7 +9644,7 @@ if test -n "$compiler"; then
 
 lt_prog_compiler_no_builtin_flag=
 
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   case $cc_basename in
   nvcc*)
     lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;;
@@ -9406,7 +9660,7 @@ else
   lt_cv_prog_compiler_rtti_exceptions=no
    ac_outfile=conftest.$ac_objext
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="-fno-rtti -fno-exceptions"
+   lt_compiler_flag="-fno-rtti -fno-exceptions"  ## exclude from sc_useless_quotes_in_assignment
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
    # Note that $ac_compile itself does not contain backslashes and begins
@@ -9436,7 +9690,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
 
-if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then
     lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
 else
     :
@@ -9454,17 +9708,18 @@ lt_prog_compiler_pic=
 lt_prog_compiler_static=
 
 
-  if test "$GCC" = yes; then
+  if test yes = "$GCC"; then
     lt_prog_compiler_wl='-Wl,'
     lt_prog_compiler_static='-static'
 
     case $host_os in
       aix*)
       # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	lt_prog_compiler_static='-Bstatic'
       fi
+      lt_prog_compiler_pic='-fPIC'
       ;;
 
     amigaos*)
@@ -9475,8 +9730,8 @@ lt_prog_compiler_static=
         ;;
       m68k)
             # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
+            # adding the '-m68020' flag to GCC prevents building anything better,
+            # like '-m68040'.
             lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
         ;;
       esac
@@ -9492,6 +9747,11 @@ lt_prog_compiler_static=
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
       # (--disable-auto-import) libraries
       lt_prog_compiler_pic='-DDLL_EXPORT'
+      case $host_os in
+      os2*)
+	lt_prog_compiler_static='$wl-static'
+	;;
+      esac
       ;;
 
     darwin* | rhapsody*)
@@ -9562,7 +9822,7 @@ lt_prog_compiler_static=
     case $host_os in
     aix*)
       lt_prog_compiler_wl='-Wl,'
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	lt_prog_compiler_static='-Bstatic'
       else
@@ -9570,10 +9830,29 @@ lt_prog_compiler_static=
       fi
       ;;
 
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic='-fno-common'
+      case $cc_basename in
+      nagfor*)
+        # NAG Fortran compiler
+        lt_prog_compiler_wl='-Wl,-Wl,,'
+        lt_prog_compiler_pic='-PIC'
+        lt_prog_compiler_static='-Bstatic'
+        ;;
+      esac
+      ;;
+
     mingw* | cygwin* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       lt_prog_compiler_pic='-DDLL_EXPORT'
+      case $host_os in
+      os2*)
+	lt_prog_compiler_static='$wl-static'
+	;;
+      esac
       ;;
 
     hpux9* | hpux10* | hpux11*)
@@ -9589,7 +9868,7 @@ lt_prog_compiler_static=
 	;;
       esac
       # Is there a better lt_prog_compiler_static that works with the bundled CC?
-      lt_prog_compiler_static='${wl}-a ${wl}archive'
+      lt_prog_compiler_static='$wl-a ${wl}archive'
       ;;
 
     irix5* | irix6* | nonstopux*)
@@ -9600,7 +9879,7 @@ lt_prog_compiler_static=
 
     linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
       case $cc_basename in
-      # old Intel for x86_64 which still supported -KPIC.
+      # old Intel for x86_64, which still supported -KPIC.
       ecc*)
 	lt_prog_compiler_wl='-Wl,'
 	lt_prog_compiler_pic='-KPIC'
@@ -9625,6 +9904,12 @@ lt_prog_compiler_static=
 	lt_prog_compiler_pic='-PIC'
 	lt_prog_compiler_static='-Bstatic'
 	;;
+      tcc*)
+	# Fabrice Bellard et al's Tiny C Compiler
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='-fPIC'
+	lt_prog_compiler_static='-static'
+	;;
       pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
         # Portland Group compilers (*not* the Pentium gcc compiler,
 	# which looks to be a dead project)
@@ -9722,7 +10007,7 @@ lt_prog_compiler_static=
       ;;
 
     sysv4*MP*)
-      if test -d /usr/nec ;then
+      if test -d /usr/nec; then
 	lt_prog_compiler_pic='-Kconform_pic'
 	lt_prog_compiler_static='-Bstatic'
       fi
@@ -9751,7 +10036,7 @@ lt_prog_compiler_static=
   fi
 
 case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
+  # For platforms that do not support PIC, -DPIC is meaningless:
   *djgpp*)
     lt_prog_compiler_pic=
     ;;
@@ -9783,7 +10068,7 @@ else
   lt_cv_prog_compiler_pic_works=no
    ac_outfile=conftest.$ac_objext
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
+   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"  ## exclude from sc_useless_quotes_in_assignment
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
    # Note that $ac_compile itself does not contain backslashes and begins
@@ -9813,7 +10098,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5
 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; }
 
-if test x"$lt_cv_prog_compiler_pic_works" = xyes; then
+if test yes = "$lt_cv_prog_compiler_pic_works"; then
     case $lt_prog_compiler_pic in
      "" | " "*) ;;
      *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
@@ -9845,7 +10130,7 @@ if ${lt_cv_prog_compiler_static_works+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   lt_cv_prog_compiler_static_works=no
-   save_LDFLAGS="$LDFLAGS"
+   save_LDFLAGS=$LDFLAGS
    LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
    echo "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
@@ -9864,13 +10149,13 @@ else
      fi
    fi
    $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
+   LDFLAGS=$save_LDFLAGS
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5
 $as_echo "$lt_cv_prog_compiler_static_works" >&6; }
 
-if test x"$lt_cv_prog_compiler_static_works" = xyes; then
+if test yes = "$lt_cv_prog_compiler_static_works"; then
     :
 else
     lt_prog_compiler_static=
@@ -9990,8 +10275,8 @@ $as_echo "$lt_cv_prog_compiler_c_o" >&6; }
 
 
 
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
+hard_links=nottested
+if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then
   # do not overwrite the value of need_locks provided by the user
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
 $as_echo_n "checking if we can lock with hard links... " >&6; }
@@ -10003,9 +10288,9 @@ $as_echo_n "checking if we can lock with hard links... " >&6; }
   ln conftest.a conftest.b 2>/dev/null && hard_links=no
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
 $as_echo "$hard_links" >&6; }
-  if test "$hard_links" = no; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+  if test no = "$hard_links"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;}
     need_locks=warn
   fi
 else
@@ -10048,9 +10333,9 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   # included in the symbol list
   include_expsyms=
   # exclude_expsyms can be an extended regexp of symbols to exclude
-  # it will be wrapped by ` (' and `)$', so one must not match beginning or
-  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
-  # as well as any symbol that contains `d'.
+  # it will be wrapped by ' (' and ')$', so one must not match beginning or
+  # end of line.  Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc',
+  # as well as any symbol that contains 'd'.
   exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
   # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
   # platforms (ab)use it in PIC code, but their linkers get confused if
@@ -10065,7 +10350,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
-    if test "$GCC" != yes; then
+    if test yes != "$GCC"; then
       with_gnu_ld=no
     fi
     ;;
@@ -10073,12 +10358,9 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
     # we just hope/assume this is gcc and not c89 (= MSVC++)
     with_gnu_ld=yes
     ;;
-  openbsd*)
+  openbsd* | bitrig*)
     with_gnu_ld=no
     ;;
-  linux* | k*bsd*-gnu | gnu*)
-    link_all_deplibs=no
-    ;;
   esac
 
   ld_shlibs=yes
@@ -10086,7 +10368,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   # On some targets, GNU ld is compatible enough with the native linker
   # that we're better off using the native interface for both.
   lt_use_gnu_ld_interface=no
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     case $host_os in
       aix*)
 	# The AIX port of GNU ld has always aspired to compatibility
@@ -10108,24 +10390,24 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
     esac
   fi
 
-  if test "$lt_use_gnu_ld_interface" = yes; then
+  if test yes = "$lt_use_gnu_ld_interface"; then
     # If archive_cmds runs LD, not CC, wlarc should be empty
-    wlarc='${wl}'
+    wlarc='$wl'
 
     # Set some defaults for GNU ld with shared library support. These
     # are reset later if shared libraries are not supported. Putting them
     # here allows them to be overridden if necessary.
     runpath_var=LD_RUN_PATH
-    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-    export_dynamic_flag_spec='${wl}--export-dynamic'
+    hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
+    export_dynamic_flag_spec='$wl--export-dynamic'
     # ancient GNU ld didn't support --whole-archive et. al.
     if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
-      whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      whole_archive_flag_spec=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
     else
       whole_archive_flag_spec=
     fi
     supports_anon_versioning=no
-    case `$LD -v 2>&1` in
+    case `$LD -v | $SED -e 's/(^)\+)\s\+//' 2>&1` in
       *GNU\ gold*) supports_anon_versioning=yes ;;
       *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
       *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
@@ -10138,7 +10420,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
     case $host_os in
     aix[3-9]*)
       # On AIX/PPC, the GNU linker is very broken
-      if test "$host_cpu" != ia64; then
+      if test ia64 != "$host_cpu"; then
 	ld_shlibs=no
 	cat <<_LT_EOF 1>&2
 
@@ -10157,7 +10439,7 @@ _LT_EOF
       case $host_cpu in
       powerpc)
             # see comment about AmigaOS4 .so support
-            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
             archive_expsym_cmds=''
         ;;
       m68k)
@@ -10173,7 +10455,7 @@ _LT_EOF
 	allow_undefined_flag=unsupported
 	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
 	# support --undefined.  This deserves some investigation.  FIXME
-	archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
       else
 	ld_shlibs=no
       fi
@@ -10183,7 +10465,7 @@ _LT_EOF
       # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
       # as there is no search path for DLLs.
       hardcode_libdir_flag_spec='-L$libdir'
-      export_dynamic_flag_spec='${wl}--export-all-symbols'
+      export_dynamic_flag_spec='$wl--export-all-symbols'
       allow_undefined_flag=unsupported
       always_export_symbols=no
       enable_shared_with_static_runtimes=yes
@@ -10191,61 +10473,89 @@ _LT_EOF
       exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'
 
       if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	# If the export-symbols file already is a .def file (1st line
-	# is EXPORTS), use it as is; otherwise, prepend...
-	archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	  cp $export_symbols $output_objdir/$soname.def;
-	else
-	  echo EXPORTS > $output_objdir/$soname.def;
-	  cat $export_symbols >> $output_objdir/$soname.def;
-	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file, use it as
+	# is; otherwise, prepend EXPORTS...
+	archive_expsym_cmds='if   test DEF = "`$SED -n     -e '\''s/^[	 ]*//'\''     -e '\''/^\(;.*\)*$/d'\''     -e '\''s/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p'\''     -e q     $export_symbols`" ; then
+          cp $export_symbols $output_objdir/$soname.def;
+        else
+          echo EXPORTS > $output_objdir/$soname.def;
+          cat $export_symbols >> $output_objdir/$soname.def;
+        fi~
+        $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
       else
 	ld_shlibs=no
       fi
       ;;
 
     haiku*)
-      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
       link_all_deplibs=yes
       ;;
 
+    os2*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_minus_L=yes
+      allow_undefined_flag=unsupported
+      shrext_cmds=.dll
+      archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	prefix_cmds="$SED"~
+	if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	  prefix_cmds="$prefix_cmds -e 1d";
+	fi~
+	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      enable_shared_with_static_runtimes=yes
+      ;;
+
     interix[3-9]*)
       hardcode_direct=no
       hardcode_shlibpath_var=no
-      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-      export_dynamic_flag_spec='${wl}-E'
+      hardcode_libdir_flag_spec='$wl-rpath,$libdir'
+      export_dynamic_flag_spec='$wl-E'
       # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
       # Instead, shared libraries are loaded at an image base (0x10000000 by
       # default) and relocated if they conflict, which is a slow very memory
       # consuming and fragmenting process.  To avoid this, we pick a random,
       # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
       # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_expsym_cmds='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
       ;;
 
     gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
       tmp_diet=no
-      if test "$host_os" = linux-dietlibc; then
+      if test linux-dietlibc = "$host_os"; then
 	case $cc_basename in
 	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
 	esac
       fi
       if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
-	 && test "$tmp_diet" = no
+	 && test no = "$tmp_diet"
       then
 	tmp_addflag=' $pic_flag'
 	tmp_sharedflag='-shared'
 	case $cc_basename,$host_cpu in
         pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  tmp_addflag=' $pic_flag'
 	  ;;
 	pgf77* | pgf90* | pgf95* | pgfortran*)
 					# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  tmp_addflag=' $pic_flag -Mnomain' ;;
 	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
 	  tmp_addflag=' -i_dynamic' ;;
@@ -10256,42 +10566,47 @@ _LT_EOF
 	lf95*)				# Lahey Fortran 8.1
 	  whole_archive_flag_spec=
 	  tmp_sharedflag='--shared' ;;
+        nagfor*)                        # NAGFOR 5.3
+          tmp_sharedflag='-Wl,-shared' ;;
 	xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below)
 	  tmp_sharedflag='-qmkshrobj'
 	  tmp_addflag= ;;
 	nvcc*)	# Cuda Compiler Driver 2.2
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  compiler_needs_object=yes
 	  ;;
 	esac
 	case `$CC -V 2>&1 | sed 5q` in
 	*Sun\ C*)			# Sun C 5.9
-	  whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  compiler_needs_object=yes
 	  tmp_sharedflag='-G' ;;
 	*Sun\ F*)			# Sun Fortran 8.3
 	  tmp_sharedflag='-G' ;;
 	esac
-	archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
 
-        if test "x$supports_anon_versioning" = xyes; then
+        if test yes = "$supports_anon_versioning"; then
           archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
-	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	    echo "local: *; };" >> $output_objdir/$libname.ver~
-	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+            cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+            echo "local: *; };" >> $output_objdir/$libname.ver~
+            $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
         fi
 
 	case $cc_basename in
+	tcc*)
+	  export_dynamic_flag_spec='-rdynamic'
+	  ;;
 	xlf* | bgf* | bgxlf* | mpixlf*)
 	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
 	  whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'
-	  hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+	  hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
 	  archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
-	  if test "x$supports_anon_versioning" = xyes; then
+	  if test yes = "$supports_anon_versioning"; then
 	    archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
-	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	      echo "local: *; };" >> $output_objdir/$libname.ver~
-	      $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+              cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+              echo "local: *; };" >> $output_objdir/$libname.ver~
+              $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
 	  fi
 	  ;;
 	esac
@@ -10300,13 +10615,13 @@ _LT_EOF
       fi
       ;;
 
-    netbsd* | netbsdelf*-gnu)
+    netbsd*)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 	archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
 	wlarc=
       else
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       fi
       ;;
 
@@ -10324,8 +10639,8 @@ _LT_EOF
 
 _LT_EOF
       elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       else
 	ld_shlibs=no
       fi
@@ -10337,7 +10652,7 @@ _LT_EOF
 	ld_shlibs=no
 	cat <<_LT_EOF 1>&2
 
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot
 *** reliably create shared libraries on SCO systems.  Therefore, libtool
 *** is disabling shared libraries support.  We urge you to upgrade GNU
 *** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
@@ -10352,9 +10667,9 @@ _LT_EOF
 	  # DT_RUNPATH tag from executables and libraries.  But doing so
 	  # requires that you compile everything twice, which is a pain.
 	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-	    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	    hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
+	    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	    archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	  else
 	    ld_shlibs=no
 	  fi
@@ -10371,15 +10686,15 @@ _LT_EOF
 
     *)
       if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       else
 	ld_shlibs=no
       fi
       ;;
     esac
 
-    if test "$ld_shlibs" = no; then
+    if test no = "$ld_shlibs"; then
       runpath_var=
       hardcode_libdir_flag_spec=
       export_dynamic_flag_spec=
@@ -10395,7 +10710,7 @@ _LT_EOF
       # Note: this linker hardcodes the directories in LIBPATH if there
       # are no directories specified by -L.
       hardcode_minus_L=yes
-      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+      if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then
 	# Neither direct hardcoding nor static linking is supported with a
 	# broken collect2.
 	hardcode_direct=unsupported
@@ -10403,34 +10718,57 @@ _LT_EOF
       ;;
 
     aix[4-9]*)
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# On IA64, the linker does run time linking by default, so we don't
 	# have to do anything special.
 	aix_use_runtimelinking=no
 	exp_sym_flag='-Bexport'
-	no_entry_flag=""
+	no_entry_flag=
       else
 	# If we're using GNU nm, then we don't want the "-C" option.
-	# -C means demangle to AIX nm, but means don't demangle with GNU nm
-	# Also, AIX nm treats weak defined symbols like other global
-	# defined symbols, whereas GNU nm marks them as "W".
+	# -C means demangle to GNU nm, but means don't demangle to AIX nm.
+	# Without the "-l" option, or with the "-B" option, AIX nm treats
+	# weak defined symbols like other global defined symbols, whereas
+	# GNU nm marks them as "W".
+	# While the 'weak' keyword is ignored in the Export File, we need
+	# it in the Import File for the 'aix-soname' feature, so we have
+	# to replace the "-B" option with "-P" for AIX nm.
 	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-	  export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	  export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
 	else
-	  export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	  export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
 	fi
 	aix_use_runtimelinking=no
 
 	# Test if we are trying to use run time linking or normal
 	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
-	# need to do runtime linking.
+	# have runtime linking enabled, and use it for executables.
+	# For shared libraries, we enable/disable runtime linking
+	# depending on the kind of the shared library created -
+	# when "with_aix_soname,aix_use_runtimelinking" is:
+	# "aix,no"   lib.a(lib.so.V) shared, rtl:no,  for executables
+	# "aix,yes"  lib.so          shared, rtl:yes, for executables
+	#            lib.a           static archive
+	# "both,no"  lib.so.V(shr.o) shared, rtl:yes
+	#            lib.a(lib.so.V) shared, rtl:no,  for executables
+	# "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+	#            lib.a(lib.so.V) shared, rtl:no
+	# "svr4,*"   lib.so.V(shr.o) shared, rtl:yes, for executables
+	#            lib.a           static archive
 	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
 	  for ld_flag in $LDFLAGS; do
-	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+	  if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then
 	    aix_use_runtimelinking=yes
 	    break
 	  fi
 	  done
+	  if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+	    # With aix-soname=svr4, we create the lib.so.V shared archives only,
+	    # so we don't have lib.a shared libs to link our executables.
+	    # We have to force runtime linking in this case.
+	    aix_use_runtimelinking=yes
+	    LDFLAGS="$LDFLAGS -Wl,-brtl"
+	  fi
 	  ;;
 	esac
 
@@ -10449,13 +10787,21 @@ _LT_EOF
       hardcode_direct_absolute=yes
       hardcode_libdir_separator=':'
       link_all_deplibs=yes
-      file_list_spec='${wl}-f,'
+      file_list_spec='$wl-f,'
+      case $with_aix_soname,$aix_use_runtimelinking in
+      aix,*) ;; # traditional, no import file
+      svr4,* | *,yes) # use import file
+	# The Import File defines what to hardcode.
+	hardcode_direct=no
+	hardcode_direct_absolute=no
+	;;
+      esac
 
-      if test "$GCC" = yes; then
+      if test yes = "$GCC"; then
 	case $host_os in aix4.[012]|aix4.[012].*)
 	# We only want to do this on AIX 4.2 and lower, the check
 	# below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
+	  collect2name=`$CC -print-prog-name=collect2`
 	  if test -f "$collect2name" &&
 	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
 	  then
@@ -10474,36 +10820,42 @@ _LT_EOF
 	  ;;
 	esac
 	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
+	if test yes = "$aix_use_runtimelinking"; then
+	  shared_flag="$shared_flag "'$wl-G'
 	fi
-	link_all_deplibs=no
+	# Need to ensure runtime linking is disabled for the traditional
+	# shared library, or the linker may eventually find shared libraries
+	# /with/ Import File - we do not want to mix them.
+	shared_flag_aix='-shared'
+	shared_flag_svr4='-shared $wl-G'
       else
 	# not using gcc
-	if test "$host_cpu" = ia64; then
+	if test ia64 = "$host_cpu"; then
 	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
 	# chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
 	else
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag='${wl}-G'
+	  if test yes = "$aix_use_runtimelinking"; then
+	    shared_flag='$wl-G'
 	  else
-	    shared_flag='${wl}-bM:SRE'
+	    shared_flag='$wl-bM:SRE'
 	  fi
+	  shared_flag_aix='$wl-bM:SRE'
+	  shared_flag_svr4='$wl-G'
 	fi
       fi
 
-      export_dynamic_flag_spec='${wl}-bexpall'
+      export_dynamic_flag_spec='$wl-bexpall'
       # It seems that -bexpall does not export symbols beginning with
       # underscore (_), so it is better to generate a list of symbols to export.
       always_export_symbols=yes
-      if test "$aix_use_runtimelinking" = yes; then
+      if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
 	# Warning - without using the other runtime loading flags (-brtl),
 	# -berok will link without error, but may produce a broken library.
 	allow_undefined_flag='-berok'
         # Determine the default libpath from the value encoded in an
         # empty executable.
-        if test "${lt_cv_aix_libpath+set}" = set; then
+        if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
   if ${lt_cv_aix_libpath_+:} false; then :
@@ -10538,7 +10890,7 @@ fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
   if test -z "$lt_cv_aix_libpath_"; then
-    lt_cv_aix_libpath_="/usr/lib:/lib"
+    lt_cv_aix_libpath_=/usr/lib:/lib
   fi
 
 fi
@@ -10546,17 +10898,17 @@ fi
   aix_libpath=$lt_cv_aix_libpath_
 fi
 
-        hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
-        archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+        hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath"
+        archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
       else
-	if test "$host_cpu" = ia64; then
-	  hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+	if test ia64 = "$host_cpu"; then
+	  hardcode_libdir_flag_spec='$wl-R $libdir:/usr/lib:/lib'
 	  allow_undefined_flag="-z nodefs"
-	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
 	else
 	 # Determine the default libpath from the value encoded in an
 	 # empty executable.
-	 if test "${lt_cv_aix_libpath+set}" = set; then
+	 if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
   if ${lt_cv_aix_libpath_+:} false; then :
@@ -10591,7 +10943,7 @@ fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
   if test -z "$lt_cv_aix_libpath_"; then
-    lt_cv_aix_libpath_="/usr/lib:/lib"
+    lt_cv_aix_libpath_=/usr/lib:/lib
   fi
 
 fi
@@ -10599,21 +10951,33 @@ fi
   aix_libpath=$lt_cv_aix_libpath_
 fi
 
-	 hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+	 hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath"
 	  # Warning - without using the other run time loading flags,
 	  # -berok will link without error, but may produce a broken library.
-	  no_undefined_flag=' ${wl}-bernotok'
-	  allow_undefined_flag=' ${wl}-berok'
-	  if test "$with_gnu_ld" = yes; then
+	  no_undefined_flag=' $wl-bernotok'
+	  allow_undefined_flag=' $wl-berok'
+	  if test yes = "$with_gnu_ld"; then
 	    # We only use this code for GNU lds that support --whole-archive.
-	    whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    whole_archive_flag_spec='$wl--whole-archive$convenience $wl--no-whole-archive'
 	  else
 	    # Exported symbols can be pulled into shared objects from archives
 	    whole_archive_flag_spec='$convenience'
 	  fi
 	  archive_cmds_need_lc=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
-	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	  archive_expsym_cmds='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+	  # -brtl affects multiple linker settings, -berok does not and is overridden later
+	  compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`'
+	  if test svr4 != "$with_aix_soname"; then
+	    # This is similar to how AIX traditionally builds its shared libraries.
+	    archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+	  fi
+	  if test aix != "$with_aix_soname"; then
+	    archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) >  [...]
+	  else
+	    # used by -dlpreopen to get the symbols
+	    archive_expsym_cmds="$archive_expsym_cmds"'~$MV  $output_objdir/$realname.d/$soname $output_objdir'
+	  fi
+	  archive_expsym_cmds="$archive_expsym_cmds"'~$RM -r $output_objdir/$realname.d'
 	fi
       fi
       ;;
@@ -10622,7 +10986,7 @@ fi
       case $host_cpu in
       powerpc)
             # see comment about AmigaOS4 .so support
-            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
             archive_expsym_cmds=''
         ;;
       m68k)
@@ -10652,16 +11016,17 @@ fi
 	# Tell ltmain to make .lib files, not .a files.
 	libext=lib
 	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
+	shrext_cmds=.dll
 	# FIXME: Setting linknames here is a bad hack.
-	archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	    sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	  else
-	    sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	  fi~
-	  $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	  linknames='
+	archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+	archive_expsym_cmds='if   test DEF = "`$SED -n     -e '\''s/^[	 ]*//'\''     -e '\''/^\(;.*\)*$/d'\''     -e '\''s/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p'\''     -e q     $export_symbols`" ; then
+            cp "$export_symbols" "$output_objdir/$soname.def";
+            echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+          else
+            $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+          fi~
+          $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+          linknames='
 	# The linker will not automatically build a static lib if we build a DLL.
 	# _LT_TAGVAR(old_archive_from_new_cmds, )='true'
 	enable_shared_with_static_runtimes=yes
@@ -10670,18 +11035,18 @@ fi
 	# Don't use ranlib
 	old_postinstall_cmds='chmod 644 $oldlib'
 	postlink_cmds='lt_outputfile="@OUTPUT@"~
-	  lt_tool_outputfile="@TOOL_OUTPUT@"~
-	  case $lt_outputfile in
-	    *.exe|*.EXE) ;;
-	    *)
-	      lt_outputfile="$lt_outputfile.exe"
-	      lt_tool_outputfile="$lt_tool_outputfile.exe"
-	      ;;
-	  esac~
-	  if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	    $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	    $RM "$lt_outputfile.manifest";
-	  fi'
+          lt_tool_outputfile="@TOOL_OUTPUT@"~
+          case $lt_outputfile in
+            *.exe|*.EXE) ;;
+            *)
+              lt_outputfile=$lt_outputfile.exe
+              lt_tool_outputfile=$lt_tool_outputfile.exe
+              ;;
+          esac~
+          if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+            $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+            $RM "$lt_outputfile.manifest";
+          fi'
 	;;
       *)
 	# Assume MSVC wrapper
@@ -10690,7 +11055,7 @@ fi
 	# Tell ltmain to make .lib files, not .a files.
 	libext=lib
 	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
+	shrext_cmds=.dll
 	# FIXME: Setting linknames here is a bad hack.
 	archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
 	# The linker will automatically build a .lib file if we build a DLL.
@@ -10709,24 +11074,24 @@ fi
   hardcode_direct=no
   hardcode_automatic=yes
   hardcode_shlibpath_var=unsupported
-  if test "$lt_cv_ld_force_load" = "yes"; then
-    whole_archive_flag_spec='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+  if test yes = "$lt_cv_ld_force_load"; then
+    whole_archive_flag_spec='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
 
   else
     whole_archive_flag_spec=''
   fi
   link_all_deplibs=yes
-  allow_undefined_flag="$_lt_dar_allow_undefined"
+  allow_undefined_flag=$_lt_dar_allow_undefined
   case $cc_basename in
-     ifort*) _lt_dar_can_shared=yes ;;
+     ifort*|nagfor*) _lt_dar_can_shared=yes ;;
      *) _lt_dar_can_shared=$GCC ;;
   esac
-  if test "$_lt_dar_can_shared" = "yes"; then
+  if test yes = "$_lt_dar_can_shared"; then
     output_verbose_link_cmd=func_echo_all
-    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil"
+    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil"
+    archive_expsym_cmds="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil"
+    module_expsym_cmds="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil"
 
   else
   ld_shlibs=no
@@ -10768,33 +11133,33 @@ fi
       ;;
 
     hpux9*)
-      if test "$GCC" = yes; then
-	archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      if test yes = "$GCC"; then
+	archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
       else
-	archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+	archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
       fi
-      hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      hardcode_libdir_flag_spec='$wl+b $wl$libdir'
       hardcode_libdir_separator=:
       hardcode_direct=yes
 
       # hardcode_minus_L: Not really in the search PATH,
       # but as the default location of the library.
       hardcode_minus_L=yes
-      export_dynamic_flag_spec='${wl}-E'
+      export_dynamic_flag_spec='$wl-E'
       ;;
 
     hpux10*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
-	archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes,no = "$GCC,$with_gnu_ld"; then
+	archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
       else
 	archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
       fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      if test no = "$with_gnu_ld"; then
+	hardcode_libdir_flag_spec='$wl+b $wl$libdir'
 	hardcode_libdir_separator=:
 	hardcode_direct=yes
 	hardcode_direct_absolute=yes
-	export_dynamic_flag_spec='${wl}-E'
+	export_dynamic_flag_spec='$wl-E'
 	# hardcode_minus_L: Not really in the search PATH,
 	# but as the default location of the library.
 	hardcode_minus_L=yes
@@ -10802,25 +11167,25 @@ fi
       ;;
 
     hpux11*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+      if test yes,no = "$GCC,$with_gnu_ld"; then
 	case $host_cpu in
 	hppa*64*)
-	  archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	ia64*)
-	  archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
-	  archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	esac
       else
 	case $host_cpu in
 	hppa*64*)
-	  archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	ia64*)
-	  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
 
@@ -10832,7 +11197,7 @@ if ${lt_cv_prog_compiler__b+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   lt_cv_prog_compiler__b=no
-   save_LDFLAGS="$LDFLAGS"
+   save_LDFLAGS=$LDFLAGS
    LDFLAGS="$LDFLAGS -b"
    echo "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
@@ -10851,14 +11216,14 @@ else
      fi
    fi
    $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
+   LDFLAGS=$save_LDFLAGS
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5
 $as_echo "$lt_cv_prog_compiler__b" >&6; }
 
-if test x"$lt_cv_prog_compiler__b" = xyes; then
-    archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+if test yes = "$lt_cv_prog_compiler__b"; then
+    archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 else
     archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
 fi
@@ -10866,8 +11231,8 @@ fi
 	  ;;
 	esac
       fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      if test no = "$with_gnu_ld"; then
+	hardcode_libdir_flag_spec='$wl+b $wl$libdir'
 	hardcode_libdir_separator=:
 
 	case $host_cpu in
@@ -10878,7 +11243,7 @@ fi
 	*)
 	  hardcode_direct=yes
 	  hardcode_direct_absolute=yes
-	  export_dynamic_flag_spec='${wl}-E'
+	  export_dynamic_flag_spec='$wl-E'
 
 	  # hardcode_minus_L: Not really in the search PATH,
 	  # but as the default location of the library.
@@ -10889,8 +11254,8 @@ fi
       ;;
 
     irix5* | irix6* | nonstopux*)
-      if test "$GCC" = yes; then
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      if test yes = "$GCC"; then
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 	# Try to use the -exported_symbol ld option, if it does not
 	# work, assume that -exports_file does not work either and
 	# implicitly export all symbols.
@@ -10900,8 +11265,8 @@ $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >
 if ${lt_cv_irix_exported_symbol+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  save_LDFLAGS="$LDFLAGS"
-	   LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+  save_LDFLAGS=$LDFLAGS
+	   LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null"
 	   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 int foo (void) { return 0; }
@@ -10913,25 +11278,35 @@ else
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
-           LDFLAGS="$save_LDFLAGS"
+           LDFLAGS=$save_LDFLAGS
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5
 $as_echo "$lt_cv_irix_exported_symbol" >&6; }
-	if test "$lt_cv_irix_exported_symbol" = yes; then
-          archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+	if test yes = "$lt_cv_irix_exported_symbol"; then
+          archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'
 	fi
       else
-	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'
       fi
       archive_cmds_need_lc='no'
-      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
       hardcode_libdir_separator=:
       inherit_rpath=yes
       link_all_deplibs=yes
       ;;
 
-    netbsd* | netbsdelf*-gnu)
+    linux*)
+      case $cc_basename in
+      tcc*)
+	# Fabrice Bellard et al's Tiny C Compiler
+	ld_shlibs=yes
+	archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+      esac
+      ;;
+
+    netbsd*)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 	archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
       else
@@ -10945,7 +11320,7 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
     newsos6)
       archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
       hardcode_direct=yes
-      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
       hardcode_libdir_separator=:
       hardcode_shlibpath_var=no
       ;;
@@ -10953,27 +11328,19 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
     *nto* | *qnx*)
       ;;
 
-    openbsd*)
+    openbsd* | bitrig*)
       if test -f /usr/libexec/ld.so; then
 	hardcode_direct=yes
 	hardcode_shlibpath_var=no
 	hardcode_direct_absolute=yes
-	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
 	  archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-	  hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-	  export_dynamic_flag_spec='${wl}-E'
+	  archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols'
+	  hardcode_libdir_flag_spec='$wl-rpath,$libdir'
+	  export_dynamic_flag_spec='$wl-E'
 	else
-	  case $host_os in
-	   openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
-	     archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-	     hardcode_libdir_flag_spec='-R$libdir'
-	     ;;
-	   *)
-	     archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	     hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-	     ;;
-	  esac
+	  archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  hardcode_libdir_flag_spec='$wl-rpath,$libdir'
 	fi
       else
 	ld_shlibs=no
@@ -10984,33 +11351,53 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       hardcode_libdir_flag_spec='-L$libdir'
       hardcode_minus_L=yes
       allow_undefined_flag=unsupported
-      archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
-      old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      shrext_cmds=.dll
+      archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	prefix_cmds="$SED"~
+	if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	  prefix_cmds="$prefix_cmds -e 1d";
+	fi~
+	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      enable_shared_with_static_runtimes=yes
       ;;
 
     osf3*)
-      if test "$GCC" = yes; then
-	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      if test yes = "$GCC"; then
+	allow_undefined_flag=' $wl-expect_unresolved $wl\*'
+	archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
       else
 	allow_undefined_flag=' -expect_unresolved \*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
       fi
       archive_cmds_need_lc='no'
-      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
       hardcode_libdir_separator=:
       ;;
 
     osf4* | osf5*)	# as osf3* with the addition of -msym flag
-      if test "$GCC" = yes; then
-	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      if test yes = "$GCC"; then
+	allow_undefined_flag=' $wl-expect_unresolved $wl\*'
+	archive_cmds='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
+	hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
       else
 	allow_undefined_flag=' -expect_unresolved \*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 	archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
-	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+          $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp'
 
 	# Both c and cxx compiler support -rpath directly
 	hardcode_libdir_flag_spec='-rpath $libdir'
@@ -11021,24 +11408,24 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
 
     solaris*)
       no_undefined_flag=' -z defs'
-      if test "$GCC" = yes; then
-	wlarc='${wl}'
-	archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	wlarc='$wl'
+	archive_cmds='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+          $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
       else
 	case `$CC -V 2>&1` in
 	*"Compilers 5.0"*)
 	  wlarc=''
-	  archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  archive_cmds='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags'
 	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+            $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
 	  ;;
 	*)
-	  wlarc='${wl}'
-	  archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	  wlarc='$wl'
+	  archive_cmds='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags'
 	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+            $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
 	  ;;
 	esac
       fi
@@ -11048,11 +11435,11 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       solaris2.[0-5] | solaris2.[0-5].*) ;;
       *)
 	# The compiler driver will combine and reorder linker options,
-	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but understands '-z linker_flag'.  GCC discards it without '$wl',
 	# but is careful enough not to reorder.
 	# Supported since Solaris 2.6 (maybe 2.5.1?)
-	if test "$GCC" = yes; then
-	  whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	if test yes = "$GCC"; then
+	  whole_archive_flag_spec='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
 	else
 	  whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
 	fi
@@ -11062,10 +11449,10 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       ;;
 
     sunos4*)
-      if test "x$host_vendor" = xsequent; then
+      if test sequent = "$host_vendor"; then
 	# Use $CC to link under sequent, because it throws in some extra .o
 	# files that make .init and .fini sections work.
-	archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_cmds='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags'
       else
 	archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
       fi
@@ -11114,43 +11501,43 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       ;;
 
     sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
-      no_undefined_flag='${wl}-z,text'
+      no_undefined_flag='$wl-z,text'
       archive_cmds_need_lc=no
       hardcode_shlibpath_var=no
       runpath_var='LD_RUN_PATH'
 
-      if test "$GCC" = yes; then
-	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
       ;;
 
     sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We can NOT use -z defs as we might desire, because we do not
+      # Note: We CANNOT use -z defs as we might desire, because we do not
       # link with -lc, and that would cause any symbols used from libc to
       # always be unresolved, which means just about no library would
       # ever link correctly.  If we're not using GNU ld we use -z text
       # though, which does catch some bad symbols but isn't as heavy-handed
       # as -z defs.
-      no_undefined_flag='${wl}-z,text'
-      allow_undefined_flag='${wl}-z,nodefs'
+      no_undefined_flag='$wl-z,text'
+      allow_undefined_flag='$wl-z,nodefs'
       archive_cmds_need_lc=no
       hardcode_shlibpath_var=no
-      hardcode_libdir_flag_spec='${wl}-R,$libdir'
+      hardcode_libdir_flag_spec='$wl-R,$libdir'
       hardcode_libdir_separator=':'
       link_all_deplibs=yes
-      export_dynamic_flag_spec='${wl}-Bexport'
+      export_dynamic_flag_spec='$wl-Bexport'
       runpath_var='LD_RUN_PATH'
 
-      if test "$GCC" = yes; then
-	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
       ;;
 
@@ -11165,10 +11552,10 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       ;;
     esac
 
-    if test x$host_vendor = xsni; then
+    if test sni = "$host_vendor"; then
       case $host in
       sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
-	export_dynamic_flag_spec='${wl}-Blargedynsym'
+	export_dynamic_flag_spec='$wl-Blargedynsym'
 	;;
       esac
     fi
@@ -11176,7 +11563,7 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5
 $as_echo "$ld_shlibs" >&6; }
-test "$ld_shlibs" = no && can_build_shared=no
+test no = "$ld_shlibs" && can_build_shared=no
 
 with_gnu_ld=$with_gnu_ld
 
@@ -11202,7 +11589,7 @@ x|xyes)
   # Assume -lc should be added
   archive_cmds_need_lc=yes
 
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
+  if test yes,yes = "$GCC,$enable_shared"; then
     case $archive_cmds in
     *'~'*)
       # FIXME: we may have to deal with multi-command sequences.
@@ -11417,14 +11804,14 @@ esac
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
 $as_echo_n "checking dynamic linker characteristics... " >&6; }
 
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   case $host_os in
-    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
-    *) lt_awk_arg="/^libraries:/" ;;
+    darwin*) lt_awk_arg='/^libraries:/,/LR/' ;;
+    *) lt_awk_arg='/^libraries:/' ;;
   esac
   case $host_os in
-    mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;;
-    *) lt_sed_strip_eq="s,=/,/,g" ;;
+    mingw* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;;
+    *) lt_sed_strip_eq='s|=/|/|g' ;;
   esac
   lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
   case $lt_search_path_spec in
@@ -11440,28 +11827,35 @@ if test "$GCC" = yes; then
     ;;
   esac
   # Ok, now we have the path, separated by spaces, we can step through it
-  # and add multilib dir if necessary.
+  # and add multilib dir if necessary...
   lt_tmp_lt_search_path_spec=
-  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  # ...but if some path component already ends with the multilib dir we assume
+  # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer).
+  case "$lt_multi_os_dir; $lt_search_path_spec " in
+  "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*)
+    lt_multi_os_dir=
+    ;;
+  esac
   for lt_sys_path in $lt_search_path_spec; do
-    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
-      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
-    else
+    if test -d "$lt_sys_path$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir"
+    elif test -n "$lt_multi_os_dir"; then
       test -d "$lt_sys_path" && \
 	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
     fi
   done
   lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
-BEGIN {RS=" "; FS="/|\n";} {
-  lt_foo="";
-  lt_count=0;
+BEGIN {RS = " "; FS = "/|\n";} {
+  lt_foo = "";
+  lt_count = 0;
   for (lt_i = NF; lt_i > 0; lt_i--) {
     if ($lt_i != "" && $lt_i != ".") {
       if ($lt_i == "..") {
         lt_count++;
       } else {
         if (lt_count == 0) {
-          lt_foo="/" $lt_i lt_foo;
+          lt_foo = "/" $lt_i lt_foo;
         } else {
           lt_count--;
         }
@@ -11475,7 +11869,7 @@ BEGIN {RS=" "; FS="/|\n";} {
   # for these hosts.
   case $host_os in
     mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
-      $SED 's,/\([A-Za-z]:\),\1,g'` ;;
+      $SED 's|/\([A-Za-z]:\)|\1|g'` ;;
   esac
   sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
 else
@@ -11484,7 +11878,7 @@ fi
 library_names_spec=
 libname_spec='lib$name'
 soname_spec=
-shrext_cmds=".so"
+shrext_cmds=.so
 postinstall_cmds=
 postuninstall_cmds=
 finish_cmds=
@@ -11501,14 +11895,16 @@ hardcode_into_libs=no
 # flags to be left without arguments
 need_version=unknown
 
+
+
 case $host_os in
 aix3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname.a'
   shlibpath_var=LIBPATH
 
   # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
+  soname_spec='$libname$release$shared_ext$major'
   ;;
 
 aix[4-9]*)
@@ -11516,41 +11912,91 @@ aix[4-9]*)
   need_lib_prefix=no
   need_version=no
   hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext'
     shlibpath_var=LD_LIBRARY_PATH
   else
     # With GCC up to 2.95.x, collect2 would create an import file
     # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
+    # the line '#! .'.  This would cause the generated library to
+    # depend on '.', always an invalid library.  This was fixed in
     # development snapshots of GCC prior to 3.0.
     case $host_os in
       aix4 | aix4.[01] | aix4.[01].*)
       if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
 	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	   echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then
 	:
       else
 	can_build_shared=no
       fi
       ;;
     esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # Using Import Files as archive members, it is possible to support
+    # filename-based versioning of shared library archives on AIX. While
+    # this would work for both with and without runtime linking, it will
+    # prevent static linking of such archives. So we do filename-based
+    # shared library versioning with .so extension only, which is used
+    # when both runtime linking and shared linking is enabled.
+    # Unfortunately, runtime linking may impact performance, so we do
+    # not want this to be the default eventually. Also, we use the
+    # versioned .so libs for executables only if there is the -brtl
+    # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only.
+    # To allow for filename-based versioning support, we need to create
+    # libNAME.so.V as an archive file, containing:
+    # *) an Import File, referring to the versioned filename of the
+    #    archive as well as the shared archive member, telling the
+    #    bitwidth (32 or 64) of that shared object, and providing the
+    #    list of exported symbols of that shared object, eventually
+    #    decorated with the 'weak' keyword
+    # *) the shared object with the F_LOADONLY flag set, to really avoid
+    #    it being seen by the linker.
+    # At run time we better use the real file rather than another symlink,
+    # but for link time we create the symlink libNAME.so -> libNAME.so.V
+
+    case $with_aix_soname,$aix_use_runtimelinking in
+    # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct
     # soname into executable. Probably we can add versioning support to
     # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
+    aix,yes) # traditional libtool
+      dynamic_linker='AIX unversionable lib.so'
       # If using run time linking (on AIX 4.2 or later) use lib<name>.so
       # instead of lib<name>.a to let people know that these are not
       # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      ;;
+    aix,no) # traditional AIX only
+      dynamic_linker='AIX lib.a(lib.so.V)'
       # We preserve .a as extension for shared libraries through AIX4.2
       # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      ;;
+    svr4,*) # full svr4 only
+      dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,yes) # both, prefer svr4
+      dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # unpreferred sharedlib libNAME.a needs extra handling
+      postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"'
+      postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,no) # both, prefer aix
+      dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)"
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling
+      postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)'
+      postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"'
+      ;;
+    esac
     shlibpath_var=LIBPATH
   fi
   ;;
@@ -11560,18 +12006,18 @@ amigaos*)
   powerpc)
     # Since July 2007 AmigaOS4 officially supports .so libraries.
     # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
     ;;
   m68k)
     library_names_spec='$libname.ixlibrary $libname.a'
     # Create ${libname}_ixlibrary.a entries in /sys/libs.
-    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
     ;;
   esac
   ;;
 
 beos*)
-  library_names_spec='${libname}${shared_ext}'
+  library_names_spec='$libname$shared_ext'
   dynamic_linker="$host_os ld.so"
   shlibpath_var=LIBRARY_PATH
   ;;
@@ -11579,8 +12025,8 @@ beos*)
 bsdi[45]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
@@ -11592,7 +12038,7 @@ bsdi[45]*)
 
 cygwin* | mingw* | pw32* | cegcc*)
   version_type=windows
-  shrext_cmds=".dll"
+  shrext_cmds=.dll
   need_version=no
   need_lib_prefix=no
 
@@ -11601,8 +12047,8 @@ cygwin* | mingw* | pw32* | cegcc*)
     # gcc
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname~
@@ -11618,17 +12064,17 @@ cygwin* | mingw* | pw32* | cegcc*)
     case $host_os in
     cygwin*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
 
       sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
       ;;
     mingw* | cegcc*)
       # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
       ;;
     esac
     dynamic_linker='Win32 ld.exe'
@@ -11637,8 +12083,8 @@ cygwin* | mingw* | pw32* | cegcc*)
   *,cl*)
     # Native MSVC
     libname_spec='$name'
-    soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-    library_names_spec='${libname}.dll.lib'
+    soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
+    library_names_spec='$libname.dll.lib'
 
     case $build_os in
     mingw*)
@@ -11665,7 +12111,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
       ;;
     *)
-      sys_lib_search_path_spec="$LIB"
+      sys_lib_search_path_spec=$LIB
       if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
         # It is most probably a Windows format PATH.
         sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
@@ -11678,8 +12124,8 @@ cygwin* | mingw* | pw32* | cegcc*)
     esac
 
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname'
@@ -11692,7 +12138,7 @@ cygwin* | mingw* | pw32* | cegcc*)
 
   *)
     # Assume MSVC wrapper
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib'
     dynamic_linker='Win32 ld.exe'
     ;;
   esac
@@ -11705,8 +12151,8 @@ darwin* | rhapsody*)
   version_type=darwin
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
+  library_names_spec='$libname$release$major$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$major$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
   shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
@@ -11719,8 +12165,8 @@ dgux*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -11738,12 +12184,13 @@ freebsd* | dragonfly*)
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      soname_spec='$libname$release$shared_ext$major'
       need_version=no
       need_lib_prefix=no
       ;;
     freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
       need_version=yes
       ;;
   esac
@@ -11773,10 +12220,10 @@ haiku*)
   need_lib_prefix=no
   need_version=no
   dynamic_linker="$host_os runtime_loader"
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
+  shlibpath_overrides_runpath=no
   sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
   hardcode_into_libs=yes
   ;;
@@ -11794,14 +12241,15 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.so"
     shlibpath_var=LD_LIBRARY_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
+    if test 32 = "$HPUX_IA64_MODE"; then
       sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux32
     else
       sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux64
     fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
   hppa*64*)
     shrext_cmds='.sl'
@@ -11809,8 +12257,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
@@ -11819,8 +12267,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=SHLIB_PATH
     shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     ;;
   esac
   # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
@@ -11833,8 +12281,8 @@ interix[3-9]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -11845,7 +12293,7 @@ irix5* | irix6* | nonstopux*)
   case $host_os in
     nonstopux*) version_type=nonstopux ;;
     *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
+	if test yes = "$lt_cv_prog_gnu_ld"; then
 		version_type=linux # correct to gnu/linux during the next big refactor
 	else
 		version_type=irix
@@ -11853,8 +12301,8 @@ irix5* | irix6* | nonstopux*)
   esac
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext'
   case $host_os in
   irix5* | nonstopux*)
     libsuff= shlibsuff=
@@ -11873,8 +12321,8 @@ irix5* | irix6* | nonstopux*)
   esac
   shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
   shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff"
+  sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff"
   hardcode_into_libs=yes
   ;;
 
@@ -11883,13 +12331,33 @@ linux*oldld* | linux*aout* | linux*coff*)
   dynamic_linker=no
   ;;
 
+linux*android*)
+  version_type=none # Android doesn't support versioned libraries.
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='$libname$release$shared_ext'
+  soname_spec='$libname$release$shared_ext'
+  finish_cmds=
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  dynamic_linker='Android linker'
+  # Don't embed -rpath directories since the linker doesn't support them.
+  hardcode_libdir_flag_spec='-L$libdir'
+  ;;
+
 # This must be glibc/ELF.
 linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -11933,7 +12401,12 @@ fi
   # before this can be enabled.
   hardcode_into_libs=yes
 
-  # Append ld.so.conf contents to the search path
+  # Ideally, we could use ldconfig to report *all* directores which are
+  # searched for libraries, however this is still not possible.  Aside from not
+  # being certain /sbin/ldconfig is available, command
+  # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64,
+  # even though it is searched at run-time.  Try to do the best guess by
+  # appending ld.so.conf contents (and includes) to the search path.
   if test -f /etc/ld.so.conf; then
     lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
     sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
@@ -11948,29 +12421,17 @@ fi
   dynamic_linker='GNU/Linux ld.so'
   ;;
 
-netbsdelf*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='NetBSD ld.elf_so'
-  ;;
-
 netbsd*)
   version_type=sunos
   need_lib_prefix=no
   need_version=no
   if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
     finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
     dynamic_linker='NetBSD (a.out) ld.so'
   else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     dynamic_linker='NetBSD ld.elf_so'
   fi
   shlibpath_var=LD_LIBRARY_PATH
@@ -11980,7 +12441,7 @@ netbsd*)
 
 newsos6)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   ;;
@@ -11989,58 +12450,68 @@ newsos6)
   version_type=qnx
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
   dynamic_linker='ldqnx.so'
   ;;
 
-openbsd*)
+openbsd* | bitrig*)
   version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
+  sys_lib_dlsearch_path_spec=/usr/lib
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
-    *)				need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[89] | openbsd2.[89].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
-      esac
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
+    need_version=no
   else
-    shlibpath_overrides_runpath=yes
+    need_version=yes
   fi
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
   ;;
 
 os2*)
   libname_spec='$name'
-  shrext_cmds=".dll"
+  version_type=windows
+  shrext_cmds=.dll
+  need_version=no
   need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
+  # OS/2 can only load a DLL with a base name of 8 characters or less.
+  soname_spec='`test -n "$os2dllname" && libname="$os2dllname";
+    v=$($ECHO $release$versuffix | tr -d .-);
+    n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _);
+    $ECHO $n$v`$shared_ext'
+  library_names_spec='${libname}_dll.$libext'
   dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
+  shlibpath_var=BEGINLIBPATH
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+  postinstall_cmds='base_file=`basename \$file`~
+    dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~
+    dldir=$destdir/`dirname \$dlpath`~
+    test -d \$dldir || mkdir -p \$dldir~
+    $install_prog $dir/$dlname \$dldir/$dlname~
+    chmod a+x \$dldir/$dlname~
+    if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+      eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+    fi'
+  postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~
+    dlpath=$dir/\$dldll~
+    $RM \$dlpath'
   ;;
 
 osf3* | osf4* | osf5*)
   version_type=osf
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
   ;;
 
 rdos*)
@@ -12051,8 +12522,8 @@ solaris*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
@@ -12062,11 +12533,11 @@ solaris*)
 
 sunos4*)
   version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
   finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     need_lib_prefix=no
   fi
   need_version=yes
@@ -12074,8 +12545,8 @@ sunos4*)
 
 sysv4 | sysv4.3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   case $host_vendor in
     sni)
@@ -12096,24 +12567,24 @@ sysv4 | sysv4.3*)
   ;;
 
 sysv4*MP*)
-  if test -d /usr/nec ;then
+  if test -d /usr/nec; then
     version_type=linux # correct to gnu/linux during the next big refactor
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
+    library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext'
+    soname_spec='$libname$shared_ext.$major'
     shlibpath_var=LD_LIBRARY_PATH
   fi
   ;;
 
 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
+  version_type=sco
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
   else
     sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
@@ -12131,7 +12602,7 @@ tpf*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
@@ -12139,8 +12610,8 @@ tpf*)
 
 uts4*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -12150,20 +12621,35 @@ uts4*)
 esac
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
 $as_echo "$dynamic_linker" >&6; }
-test "$dynamic_linker" = no && can_build_shared=no
+test no = "$dynamic_linker" && can_build_shared=no
 
 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
 fi
 
-if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
-  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then
+  sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec
 fi
-if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
-  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then
+  sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec
 fi
 
+# remember unaugmented sys_lib_dlsearch_path content for libtool script decls...
+configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec
+
+# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code
+func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH"
+
+# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool
+configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH
+
+
+
+
+
+
 
 
 
@@ -12260,15 +12746,15 @@ $as_echo_n "checking how to hardcode library paths into programs... " >&6; }
 hardcode_action=
 if test -n "$hardcode_libdir_flag_spec" ||
    test -n "$runpath_var" ||
-   test "X$hardcode_automatic" = "Xyes" ; then
+   test yes = "$hardcode_automatic"; then
 
   # We can hardcode non-existent directories.
-  if test "$hardcode_direct" != no &&
+  if test no != "$hardcode_direct" &&
      # If the only mechanism to avoid hardcoding is shlibpath_var, we
      # have to relink, otherwise we might link with an installed library
      # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no &&
-     test "$hardcode_minus_L" != no; then
+     ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, )" &&
+     test no != "$hardcode_minus_L"; then
     # Linking always hardcodes the temporary library directory.
     hardcode_action=relink
   else
@@ -12283,12 +12769,12 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5
 $as_echo "$hardcode_action" >&6; }
 
-if test "$hardcode_action" = relink ||
-   test "$inherit_rpath" = yes; then
+if test relink = "$hardcode_action" ||
+   test yes = "$inherit_rpath"; then
   # Fast installation is not supported
   enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
+elif test yes = "$shlibpath_overrides_runpath" ||
+     test no = "$enable_shared"; then
   # Fast installation is not necessary
   enable_fast_install=needless
 fi
@@ -12298,7 +12784,7 @@ fi
 
 
 
-  if test "x$enable_dlopen" != xyes; then
+  if test yes != "$enable_dlopen"; then
   enable_dlopen=unknown
   enable_dlopen_self=unknown
   enable_dlopen_self_static=unknown
@@ -12308,23 +12794,23 @@ else
 
   case $host_os in
   beos*)
-    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen=load_add_on
     lt_cv_dlopen_libs=
     lt_cv_dlopen_self=yes
     ;;
 
   mingw* | pw32* | cegcc*)
-    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen=LoadLibrary
     lt_cv_dlopen_libs=
     ;;
 
   cygwin*)
-    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen=dlopen
     lt_cv_dlopen_libs=
     ;;
 
   darwin*)
-  # if libdl is installed we need to link against it
+    # if libdl is installed we need to link against it
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
 $as_echo_n "checking for dlopen in -ldl... " >&6; }
 if ${ac_cv_lib_dl_dlopen+:} false; then :
@@ -12362,10 +12848,10 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
 $as_echo "$ac_cv_lib_dl_dlopen" >&6; }
 if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+  lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl
 else
 
-    lt_cv_dlopen="dyld"
+    lt_cv_dlopen=dyld
     lt_cv_dlopen_libs=
     lt_cv_dlopen_self=yes
 
@@ -12373,10 +12859,18 @@ fi
 
     ;;
 
-  *)
-    ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
+  tpf*)
+    # Don't try to run any link tests for TPF.  We know it's impossible
+    # because TPF is a cross-compiler, and we know how we open DSOs.
+    lt_cv_dlopen=dlopen
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=no
+    ;;
+
+  *)
+    ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
 if test "x$ac_cv_func_shl_load" = xyes; then :
-  lt_cv_dlopen="shl_load"
+  lt_cv_dlopen=shl_load
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
 $as_echo_n "checking for shl_load in -ldld... " >&6; }
@@ -12415,11 +12909,11 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
 $as_echo "$ac_cv_lib_dld_shl_load" >&6; }
 if test "x$ac_cv_lib_dld_shl_load" = xyes; then :
-  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
+  lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld
 else
   ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
 if test "x$ac_cv_func_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen"
+  lt_cv_dlopen=dlopen
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
 $as_echo_n "checking for dlopen in -ldl... " >&6; }
@@ -12458,7 +12952,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
 $as_echo "$ac_cv_lib_dl_dlopen" >&6; }
 if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+  lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
 $as_echo_n "checking for dlopen in -lsvld... " >&6; }
@@ -12497,7 +12991,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
 $as_echo "$ac_cv_lib_svld_dlopen" >&6; }
 if test "x$ac_cv_lib_svld_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+  lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
 $as_echo_n "checking for dld_link in -ldld... " >&6; }
@@ -12536,7 +13030,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
 $as_echo "$ac_cv_lib_dld_dld_link" >&6; }
 if test "x$ac_cv_lib_dld_dld_link" = xyes; then :
-  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
+  lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld
 fi
 
 
@@ -12557,21 +13051,21 @@ fi
     ;;
   esac
 
-  if test "x$lt_cv_dlopen" != xno; then
-    enable_dlopen=yes
-  else
+  if test no = "$lt_cv_dlopen"; then
     enable_dlopen=no
+  else
+    enable_dlopen=yes
   fi
 
   case $lt_cv_dlopen in
   dlopen)
-    save_CPPFLAGS="$CPPFLAGS"
-    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+    save_CPPFLAGS=$CPPFLAGS
+    test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
 
-    save_LDFLAGS="$LDFLAGS"
+    save_LDFLAGS=$LDFLAGS
     wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
 
-    save_LIBS="$LIBS"
+    save_LIBS=$LIBS
     LIBS="$lt_cv_dlopen_libs $LIBS"
 
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
@@ -12579,7 +13073,7 @@ $as_echo_n "checking whether a program can dlopen itself... " >&6; }
 if ${lt_cv_dlopen_self+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  	  if test "$cross_compiling" = yes; then :
+  	  if test yes = "$cross_compiling"; then :
   lt_cv_dlopen_self=cross
 else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
@@ -12626,9 +13120,9 @@ else
 #  endif
 #endif
 
-/* When -fvisbility=hidden is used, assume the code has been annotated
+/* When -fvisibility=hidden is used, assume the code has been annotated
    correspondingly for the symbols needed.  */
-#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
 int fnord () __attribute__((visibility("default")));
 #endif
 
@@ -12658,7 +13152,7 @@ _LT_EOF
   (eval $ac_link) 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+  test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then
     (./conftest; exit; ) >&5 2>/dev/null
     lt_status=$?
     case x$lt_status in
@@ -12678,14 +13172,14 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
 $as_echo "$lt_cv_dlopen_self" >&6; }
 
-    if test "x$lt_cv_dlopen_self" = xyes; then
+    if test yes = "$lt_cv_dlopen_self"; then
       wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
       { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
 if ${lt_cv_dlopen_self_static+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  	  if test "$cross_compiling" = yes; then :
+  	  if test yes = "$cross_compiling"; then :
   lt_cv_dlopen_self_static=cross
 else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
@@ -12732,9 +13226,9 @@ else
 #  endif
 #endif
 
-/* When -fvisbility=hidden is used, assume the code has been annotated
+/* When -fvisibility=hidden is used, assume the code has been annotated
    correspondingly for the symbols needed.  */
-#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
 int fnord () __attribute__((visibility("default")));
 #endif
 
@@ -12764,7 +13258,7 @@ _LT_EOF
   (eval $ac_link) 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+  test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then
     (./conftest; exit; ) >&5 2>/dev/null
     lt_status=$?
     case x$lt_status in
@@ -12785,9 +13279,9 @@ fi
 $as_echo "$lt_cv_dlopen_self_static" >&6; }
     fi
 
-    CPPFLAGS="$save_CPPFLAGS"
-    LDFLAGS="$save_LDFLAGS"
-    LIBS="$save_LIBS"
+    CPPFLAGS=$save_CPPFLAGS
+    LDFLAGS=$save_LDFLAGS
+    LIBS=$save_LIBS
     ;;
   esac
 
@@ -12831,7 +13325,7 @@ else
 # FIXME - insert some real tests, host_os isn't really good enough
   case $host_os in
   darwin*)
-    if test -n "$STRIP" ; then
+    if test -n "$STRIP"; then
       striplib="$STRIP -x"
       old_striplib="$STRIP -S"
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
@@ -12859,7 +13353,7 @@ fi
 
 
 
-  # Report which library types will actually be built
+  # Report what library types will actually be built
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
 $as_echo_n "checking if libtool supports shared libraries... " >&6; }
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
@@ -12867,13 +13361,13 @@ $as_echo "$can_build_shared" >&6; }
 
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
 $as_echo_n "checking whether to build shared libraries... " >&6; }
-  test "$can_build_shared" = "no" && enable_shared=no
+  test no = "$can_build_shared" && enable_shared=no
 
   # On AIX, shared libraries and static libraries use the same namespace, and
   # are all built from PIC.
   case $host_os in
   aix3*)
-    test "$enable_shared" = yes && enable_static=no
+    test yes = "$enable_shared" && enable_static=no
     if test -n "$RANLIB"; then
       archive_cmds="$archive_cmds~\$RANLIB \$lib"
       postinstall_cmds='$RANLIB $lib'
@@ -12881,8 +13375,12 @@ $as_echo_n "checking whether to build shared libraries... " >&6; }
     ;;
 
   aix[4-9]*)
-    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-      test "$enable_shared" = yes && enable_static=no
+    if test ia64 != "$host_cpu"; then
+      case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+      yes,aix,yes) ;;			# shared object as lib.so file only
+      yes,svr4,*) ;;			# shared object as lib.so archive member only
+      yes,*) enable_static=no ;;	# shared object in lib.a archive as well
+      esac
     fi
     ;;
   esac
@@ -12892,7 +13390,7 @@ $as_echo "$enable_shared" >&6; }
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
 $as_echo_n "checking whether to build static libraries... " >&6; }
   # Make sure either enable_shared or enable_static is yes.
-  test "$enable_shared" = yes || enable_static=yes
+  test yes = "$enable_shared" || enable_static=yes
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
 $as_echo "$enable_static" >&6; }
 
@@ -12906,11 +13404,11 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-CC="$lt_save_CC"
+CC=$lt_save_CC
 
-      if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-    (test "X$CXX" != "Xg++"))) ; then
+      if test -n "$CXX" && ( test no != "$CXX" &&
+    ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) ||
+    (test g++ != "$CXX"))); then
   ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -13089,7 +13587,7 @@ objext_CXX=$objext
 # the CXX compiler isn't working.  Some variables (like enable_shared)
 # are currently assumed to apply to all compilers on this platform,
 # and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_caught_CXX_error" != yes; then
+if test yes != "$_lt_caught_CXX_error"; then
   # Code to be used in simple compile tests
   lt_simple_compile_test_code="int some_variable = 0;"
 
@@ -13150,46 +13648,39 @@ $RM -r conftest*
   CFLAGS=$CXXFLAGS
   compiler=$CC
   compiler_CXX=$CC
-  for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+  func_cc_basename $compiler
+cc_basename=$func_cc_basename_result
 
 
   if test -n "$compiler"; then
     # We don't want -fno-exception when compiling C++ code, so set the
     # no_builtin_flag separately
-    if test "$GXX" = yes; then
+    if test yes = "$GXX"; then
       lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin'
     else
       lt_prog_compiler_no_builtin_flag_CXX=
     fi
 
-    if test "$GXX" = yes; then
+    if test yes = "$GXX"; then
       # Set up default GNU C++ configuration
 
 
 
 # Check whether --with-gnu-ld was given.
 if test "${with_gnu_ld+set}" = set; then :
-  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+  withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes
 else
   with_gnu_ld=no
 fi
 
 ac_prog=ld
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   # Check if gcc -print-prog-name=ld gives a path.
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
 $as_echo_n "checking for ld used by $CC... " >&6; }
   case $host in
   *-*-mingw*)
-    # gcc leaves a trailing carriage return which upsets mingw
+    # gcc leaves a trailing carriage return, which upsets mingw
     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
   *)
     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
@@ -13203,7 +13694,7 @@ $as_echo_n "checking for ld used by $CC... " >&6; }
       while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
 	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
       done
-      test -z "$LD" && LD="$ac_prog"
+      test -z "$LD" && LD=$ac_prog
       ;;
   "")
     # If it fails, then pretend we aren't using GCC.
@@ -13214,7 +13705,7 @@ $as_echo_n "checking for ld used by $CC... " >&6; }
     with_gnu_ld=unknown
     ;;
   esac
-elif test "$with_gnu_ld" = yes; then
+elif test yes = "$with_gnu_ld"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
 $as_echo_n "checking for GNU ld... " >&6; }
 else
@@ -13225,32 +13716,32 @@ if ${lt_cv_path_LD+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -z "$LD"; then
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   for ac_dir in $PATH; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-      lt_cv_path_LD="$ac_dir/$ac_prog"
+      lt_cv_path_LD=$ac_dir/$ac_prog
       # Check to see if the program is GNU ld.  I'd rather use --version,
       # but apparently some variants of GNU ld only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
       *GNU* | *'with BFD'*)
-	test "$with_gnu_ld" != no && break
+	test no != "$with_gnu_ld" && break
 	;;
       *)
-	test "$with_gnu_ld" != yes && break
+	test yes != "$with_gnu_ld" && break
 	;;
       esac
     fi
   done
-  IFS="$lt_save_ifs"
+  IFS=$lt_save_ifs
 else
-  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+  lt_cv_path_LD=$LD # Let the user override the test with a path.
 fi
 fi
 
-LD="$lt_cv_path_LD"
+LD=$lt_cv_path_LD
 if test -n "$LD"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
 $as_echo "$LD" >&6; }
@@ -13286,22 +13777,22 @@ with_gnu_ld=$lt_cv_prog_gnu_ld
 
       # Check if GNU C++ uses GNU ld as the underlying linker, since the
       # archiving commands below assume that GNU ld is being used.
-      if test "$with_gnu_ld" = yes; then
-        archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-        archive_expsym_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      if test yes = "$with_gnu_ld"; then
+        archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+        archive_expsym_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 
-        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
-        export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+        hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir'
+        export_dynamic_flag_spec_CXX='$wl--export-dynamic'
 
         # If archive_cmds runs LD, not CC, wlarc should be empty
         # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
         #     investigate it a little bit more. (MM)
-        wlarc='${wl}'
+        wlarc='$wl'
 
         # ancient GNU ld didn't support --whole-archive et. al.
         if eval "`$CC -print-prog-name=ld` --help 2>&1" |
 	  $GREP 'no-whole-archive' > /dev/null; then
-          whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+          whole_archive_flag_spec_CXX=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
         else
           whole_archive_flag_spec_CXX=
         fi
@@ -13338,18 +13829,30 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
         ld_shlibs_CXX=no
         ;;
       aix[4-9]*)
-        if test "$host_cpu" = ia64; then
+        if test ia64 = "$host_cpu"; then
           # On IA64, the linker does run time linking by default, so we don't
           # have to do anything special.
           aix_use_runtimelinking=no
           exp_sym_flag='-Bexport'
-          no_entry_flag=""
+          no_entry_flag=
         else
           aix_use_runtimelinking=no
 
           # Test if we are trying to use run time linking or normal
           # AIX style linking. If -brtl is somewhere in LDFLAGS, we
-          # need to do runtime linking.
+          # have runtime linking enabled, and use it for executables.
+          # For shared libraries, we enable/disable runtime linking
+          # depending on the kind of the shared library created -
+          # when "with_aix_soname,aix_use_runtimelinking" is:
+          # "aix,no"   lib.a(lib.so.V) shared, rtl:no,  for executables
+          # "aix,yes"  lib.so          shared, rtl:yes, for executables
+          #            lib.a           static archive
+          # "both,no"  lib.so.V(shr.o) shared, rtl:yes
+          #            lib.a(lib.so.V) shared, rtl:no,  for executables
+          # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+          #            lib.a(lib.so.V) shared, rtl:no
+          # "svr4,*"   lib.so.V(shr.o) shared, rtl:yes, for executables
+          #            lib.a           static archive
           case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
 	    for ld_flag in $LDFLAGS; do
 	      case $ld_flag in
@@ -13359,6 +13862,13 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
 	        ;;
 	      esac
 	    done
+	    if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+	      # With aix-soname=svr4, we create the lib.so.V shared archives only,
+	      # so we don't have lib.a shared libs to link our executables.
+	      # We have to force runtime linking in this case.
+	      aix_use_runtimelinking=yes
+	      LDFLAGS="$LDFLAGS -Wl,-brtl"
+	    fi
 	    ;;
           esac
 
@@ -13377,13 +13887,21 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
         hardcode_direct_absolute_CXX=yes
         hardcode_libdir_separator_CXX=':'
         link_all_deplibs_CXX=yes
-        file_list_spec_CXX='${wl}-f,'
+        file_list_spec_CXX='$wl-f,'
+        case $with_aix_soname,$aix_use_runtimelinking in
+        aix,*) ;;	# no import file
+        svr4,* | *,yes) # use import file
+          # The Import File defines what to hardcode.
+          hardcode_direct_CXX=no
+          hardcode_direct_absolute_CXX=no
+          ;;
+        esac
 
-        if test "$GXX" = yes; then
+        if test yes = "$GXX"; then
           case $host_os in aix4.[012]|aix4.[012].*)
           # We only want to do this on AIX 4.2 and lower, the check
           # below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
+	  collect2name=`$CC -print-prog-name=collect2`
 	  if test -f "$collect2name" &&
 	     strings "$collect2name" | $GREP resolve_lib_name >/dev/null
 	  then
@@ -13401,36 +13919,44 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
 	  fi
           esac
           shared_flag='-shared'
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag="$shared_flag "'${wl}-G'
+	  if test yes = "$aix_use_runtimelinking"; then
+	    shared_flag=$shared_flag' $wl-G'
 	  fi
+	  # Need to ensure runtime linking is disabled for the traditional
+	  # shared library, or the linker may eventually find shared libraries
+	  # /with/ Import File - we do not want to mix them.
+	  shared_flag_aix='-shared'
+	  shared_flag_svr4='-shared $wl-G'
         else
           # not using gcc
-          if test "$host_cpu" = ia64; then
+          if test ia64 = "$host_cpu"; then
 	  # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
 	  # chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
           else
-	    if test "$aix_use_runtimelinking" = yes; then
-	      shared_flag='${wl}-G'
+	    if test yes = "$aix_use_runtimelinking"; then
+	      shared_flag='$wl-G'
 	    else
-	      shared_flag='${wl}-bM:SRE'
+	      shared_flag='$wl-bM:SRE'
 	    fi
+	    shared_flag_aix='$wl-bM:SRE'
+	    shared_flag_svr4='$wl-G'
           fi
         fi
 
-        export_dynamic_flag_spec_CXX='${wl}-bexpall'
+        export_dynamic_flag_spec_CXX='$wl-bexpall'
         # It seems that -bexpall does not export symbols beginning with
         # underscore (_), so it is better to generate a list of symbols to
 	# export.
         always_export_symbols_CXX=yes
-        if test "$aix_use_runtimelinking" = yes; then
+	if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
           # Warning - without using the other runtime loading flags (-brtl),
           # -berok will link without error, but may produce a broken library.
-          allow_undefined_flag_CXX='-berok'
+          # The "-G" linker flag allows undefined symbols.
+          no_undefined_flag_CXX='-bernotok'
           # Determine the default libpath from the value encoded in an empty
           # executable.
-          if test "${lt_cv_aix_libpath+set}" = set; then
+          if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
   if ${lt_cv_aix_libpath__CXX+:} false; then :
@@ -13465,7 +13991,7 @@ fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
   if test -z "$lt_cv_aix_libpath__CXX"; then
-    lt_cv_aix_libpath__CXX="/usr/lib:/lib"
+    lt_cv_aix_libpath__CXX=/usr/lib:/lib
   fi
 
 fi
@@ -13473,18 +13999,18 @@ fi
   aix_libpath=$lt_cv_aix_libpath__CXX
 fi
 
-          hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+          hardcode_libdir_flag_spec_CXX='$wl-blibpath:$libdir:'"$aix_libpath"
 
-          archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+          archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
         else
-          if test "$host_cpu" = ia64; then
-	    hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib'
+          if test ia64 = "$host_cpu"; then
+	    hardcode_libdir_flag_spec_CXX='$wl-R $libdir:/usr/lib:/lib'
 	    allow_undefined_flag_CXX="-z nodefs"
-	    archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	    archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
           else
 	    # Determine the default libpath from the value encoded in an
 	    # empty executable.
-	    if test "${lt_cv_aix_libpath+set}" = set; then
+	    if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
   if ${lt_cv_aix_libpath__CXX+:} false; then :
@@ -13519,7 +14045,7 @@ fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
   if test -z "$lt_cv_aix_libpath__CXX"; then
-    lt_cv_aix_libpath__CXX="/usr/lib:/lib"
+    lt_cv_aix_libpath__CXX=/usr/lib:/lib
   fi
 
 fi
@@ -13527,22 +14053,34 @@ fi
   aix_libpath=$lt_cv_aix_libpath__CXX
 fi
 
-	    hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+	    hardcode_libdir_flag_spec_CXX='$wl-blibpath:$libdir:'"$aix_libpath"
 	    # Warning - without using the other run time loading flags,
 	    # -berok will link without error, but may produce a broken library.
-	    no_undefined_flag_CXX=' ${wl}-bernotok'
-	    allow_undefined_flag_CXX=' ${wl}-berok'
-	    if test "$with_gnu_ld" = yes; then
+	    no_undefined_flag_CXX=' $wl-bernotok'
+	    allow_undefined_flag_CXX=' $wl-berok'
+	    if test yes = "$with_gnu_ld"; then
 	      # We only use this code for GNU lds that support --whole-archive.
-	      whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	      whole_archive_flag_spec_CXX='$wl--whole-archive$convenience $wl--no-whole-archive'
 	    else
 	      # Exported symbols can be pulled into shared objects from archives
 	      whole_archive_flag_spec_CXX='$convenience'
 	    fi
 	    archive_cmds_need_lc_CXX=yes
-	    # This is similar to how AIX traditionally builds its shared
-	    # libraries.
-	    archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	    archive_expsym_cmds_CXX='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+	    # -brtl affects multiple linker settings, -berok does not and is overridden later
+	    compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`'
+	    if test svr4 != "$with_aix_soname"; then
+	      # This is similar to how AIX traditionally builds its shared
+	      # libraries. Need -bnortl late, we may have -brtl in LDFLAGS.
+	      archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+	    fi
+	    if test aix != "$with_aix_soname"; then
+	      archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_sy [...]
+	    else
+	      # used by -dlpreopen to get the symbols
+	      archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$MV  $output_objdir/$realname.d/$soname $output_objdir'
+	    fi
+	    archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$RM -r $output_objdir/$realname.d'
           fi
         fi
         ;;
@@ -13552,7 +14090,7 @@ fi
 	  allow_undefined_flag_CXX=unsupported
 	  # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
 	  # support --undefined.  This deserves some investigation.  FIXME
-	  archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	  archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
 	else
 	  ld_shlibs_CXX=no
 	fi
@@ -13580,57 +14118,58 @@ fi
 	  # Tell ltmain to make .lib files, not .a files.
 	  libext=lib
 	  # Tell ltmain to make .dll files, not .so files.
-	  shrext_cmds=".dll"
+	  shrext_cmds=.dll
 	  # FIXME: Setting linknames here is a bad hack.
-	  archive_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	  archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	    else
-	      $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	    fi~
-	    $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	    linknames='
+	  archive_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+	  archive_expsym_cmds_CXX='if   test DEF = "`$SED -n     -e '\''s/^[	 ]*//'\''     -e '\''/^\(;.*\)*$/d'\''     -e '\''s/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p'\''     -e q     $export_symbols`" ; then
+              cp "$export_symbols" "$output_objdir/$soname.def";
+              echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+            else
+              $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+            fi~
+            $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+            linknames='
 	  # The linker will not automatically build a static lib if we build a DLL.
 	  # _LT_TAGVAR(old_archive_from_new_cmds, CXX)='true'
 	  enable_shared_with_static_runtimes_CXX=yes
 	  # Don't use ranlib
 	  old_postinstall_cmds_CXX='chmod 644 $oldlib'
 	  postlink_cmds_CXX='lt_outputfile="@OUTPUT@"~
-	    lt_tool_outputfile="@TOOL_OUTPUT@"~
-	    case $lt_outputfile in
-	      *.exe|*.EXE) ;;
-	      *)
-		lt_outputfile="$lt_outputfile.exe"
-		lt_tool_outputfile="$lt_tool_outputfile.exe"
-		;;
-	    esac~
-	    func_to_tool_file "$lt_outputfile"~
-	    if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	      $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	      $RM "$lt_outputfile.manifest";
-	    fi'
+            lt_tool_outputfile="@TOOL_OUTPUT@"~
+            case $lt_outputfile in
+              *.exe|*.EXE) ;;
+              *)
+                lt_outputfile=$lt_outputfile.exe
+                lt_tool_outputfile=$lt_tool_outputfile.exe
+                ;;
+            esac~
+            func_to_tool_file "$lt_outputfile"~
+            if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+              $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+              $RM "$lt_outputfile.manifest";
+            fi'
 	  ;;
 	*)
 	  # g++
 	  # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,
 	  # as there is no search path for DLLs.
 	  hardcode_libdir_flag_spec_CXX='-L$libdir'
-	  export_dynamic_flag_spec_CXX='${wl}--export-all-symbols'
+	  export_dynamic_flag_spec_CXX='$wl--export-all-symbols'
 	  allow_undefined_flag_CXX=unsupported
 	  always_export_symbols_CXX=no
 	  enable_shared_with_static_runtimes_CXX=yes
 
 	  if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-	    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	    # If the export-symbols file already is a .def file (1st line
-	    # is EXPORTS), use it as is; otherwise, prepend...
-	    archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      cp $export_symbols $output_objdir/$soname.def;
-	    else
-	      echo EXPORTS > $output_objdir/$soname.def;
-	      cat $export_symbols >> $output_objdir/$soname.def;
-	    fi~
-	    $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	    # If the export-symbols file already is a .def file, use it as
+	    # is; otherwise, prepend EXPORTS...
+	    archive_expsym_cmds_CXX='if   test DEF = "`$SED -n     -e '\''s/^[	 ]*//'\''     -e '\''/^\(;.*\)*$/d'\''     -e '\''s/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p'\''     -e q     $export_symbols`" ; then
+              cp $export_symbols $output_objdir/$soname.def;
+            else
+              echo EXPORTS > $output_objdir/$soname.def;
+              cat $export_symbols >> $output_objdir/$soname.def;
+            fi~
+            $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
 	  else
 	    ld_shlibs_CXX=no
 	  fi
@@ -13644,27 +14183,27 @@ fi
   hardcode_direct_CXX=no
   hardcode_automatic_CXX=yes
   hardcode_shlibpath_var_CXX=unsupported
-  if test "$lt_cv_ld_force_load" = "yes"; then
-    whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+  if test yes = "$lt_cv_ld_force_load"; then
+    whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
 
   else
     whole_archive_flag_spec_CXX=''
   fi
   link_all_deplibs_CXX=yes
-  allow_undefined_flag_CXX="$_lt_dar_allow_undefined"
+  allow_undefined_flag_CXX=$_lt_dar_allow_undefined
   case $cc_basename in
-     ifort*) _lt_dar_can_shared=yes ;;
+     ifort*|nagfor*) _lt_dar_can_shared=yes ;;
      *) _lt_dar_can_shared=$GCC ;;
   esac
-  if test "$_lt_dar_can_shared" = "yes"; then
+  if test yes = "$_lt_dar_can_shared"; then
     output_verbose_link_cmd=func_echo_all
-    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-    module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-    module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-       if test "$lt_cv_apple_cc_single_mod" != "yes"; then
-      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
-      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil"
+    module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil"
+    archive_expsym_cmds_CXX="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil"
+    module_expsym_cmds_CXX="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil"
+       if test yes != "$lt_cv_apple_cc_single_mod"; then
+      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil"
+      archive_expsym_cmds_CXX="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil"
     fi
 
   else
@@ -13673,6 +14212,34 @@ fi
 
 	;;
 
+      os2*)
+	hardcode_libdir_flag_spec_CXX='-L$libdir'
+	hardcode_minus_L_CXX=yes
+	allow_undefined_flag_CXX=unsupported
+	shrext_cmds=.dll
+	archive_cmds_CXX='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	  $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	  $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	  $ECHO EXPORTS >> $output_objdir/$libname.def~
+	  emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	  $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	  emximp -o $lib $output_objdir/$libname.def'
+	archive_expsym_cmds_CXX='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	  $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	  $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	  $ECHO EXPORTS >> $output_objdir/$libname.def~
+	  prefix_cmds="$SED"~
+	  if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	    prefix_cmds="$prefix_cmds -e 1d";
+	  fi~
+	  prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	  cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	  $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	  emximp -o $lib $output_objdir/$libname.def'
+	old_archive_From_new_cmds_CXX='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+	enable_shared_with_static_runtimes_CXX=yes
+	;;
+
       dgux*)
         case $cc_basename in
           ec++*)
@@ -13708,14 +14275,14 @@ fi
         ;;
 
       haiku*)
-        archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+        archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
         link_all_deplibs_CXX=yes
         ;;
 
       hpux9*)
-        hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+        hardcode_libdir_flag_spec_CXX='$wl+b $wl$libdir'
         hardcode_libdir_separator_CXX=:
-        export_dynamic_flag_spec_CXX='${wl}-E'
+        export_dynamic_flag_spec_CXX='$wl-E'
         hardcode_direct_CXX=yes
         hardcode_minus_L_CXX=yes # Not in the search PATH,
 				             # but as the default
@@ -13727,7 +14294,7 @@ fi
             ld_shlibs_CXX=no
             ;;
           aCC*)
-            archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
             # Commands to make compiler produce verbose output that lists
             # what "hidden" libraries, object files and flags are used when
             # linking a shared library.
@@ -13736,11 +14303,11 @@ fi
             # explicitly linking system object files so we need to strip them
             # from the output so that they don't get included in the library
             # dependencies.
-            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
             ;;
           *)
-            if test "$GXX" = yes; then
-              archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            if test yes = "$GXX"; then
+              archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
             else
               # FIXME: insert proper C++ library support
               ld_shlibs_CXX=no
@@ -13750,15 +14317,15 @@ fi
         ;;
 
       hpux10*|hpux11*)
-        if test $with_gnu_ld = no; then
-	  hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+        if test no = "$with_gnu_ld"; then
+	  hardcode_libdir_flag_spec_CXX='$wl+b $wl$libdir'
 	  hardcode_libdir_separator_CXX=:
 
           case $host_cpu in
             hppa*64*|ia64*)
               ;;
             *)
-	      export_dynamic_flag_spec_CXX='${wl}-E'
+	      export_dynamic_flag_spec_CXX='$wl-E'
               ;;
           esac
         fi
@@ -13784,13 +14351,13 @@ fi
           aCC*)
 	    case $host_cpu in
 	      hppa*64*)
-	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        archive_cmds_CXX='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	      ia64*)
-	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        archive_cmds_CXX='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	      *)
-	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        archive_cmds_CXX='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	    esac
 	    # Commands to make compiler produce verbose output that lists
@@ -13801,20 +14368,20 @@ fi
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 	    ;;
           *)
-	    if test "$GXX" = yes; then
-	      if test $with_gnu_ld = no; then
+	    if test yes = "$GXX"; then
+	      if test no = "$with_gnu_ld"; then
 	        case $host_cpu in
 	          hppa*64*)
-	            archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            archive_cmds_CXX='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	          ia64*)
-	            archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            archive_cmds_CXX='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	          *)
-	            archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            archive_cmds_CXX='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	        esac
 	      fi
@@ -13829,22 +14396,22 @@ fi
       interix[3-9]*)
 	hardcode_direct_CXX=no
 	hardcode_shlibpath_var_CXX=no
-	hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	export_dynamic_flag_spec_CXX='${wl}-E'
+	hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir'
+	export_dynamic_flag_spec_CXX='$wl-E'
 	# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
 	# Instead, shared libraries are loaded at an image base (0x10000000 by
 	# default) and relocated if they conflict, which is a slow very memory
 	# consuming and fragmenting process.  To avoid this, we pick a random,
 	# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
 	# time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-	archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-	archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	archive_expsym_cmds_CXX='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
 	;;
       irix5* | irix6*)
         case $cc_basename in
           CC*)
 	    # SGI C++
-	    archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	    archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 
 	    # Archives containing C++ object files must be created using
 	    # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
@@ -13853,17 +14420,17 @@ fi
 	    old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs'
 	    ;;
           *)
-	    if test "$GXX" = yes; then
-	      if test "$with_gnu_ld" = no; then
-	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	    if test yes = "$GXX"; then
+	      if test no = "$with_gnu_ld"; then
+	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 	      else
-	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
+	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib'
 	      fi
 	    fi
 	    link_all_deplibs_CXX=yes
 	    ;;
         esac
-        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+        hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir'
         hardcode_libdir_separator_CXX=:
         inherit_rpath_CXX=yes
         ;;
@@ -13876,8 +14443,8 @@ fi
 	    # KCC will only create a shared library if the output file
 	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
 	    # to its proper name (with version) after linking.
-	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-	    archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib'
 	    # Commands to make compiler produce verbose output that lists
 	    # what "hidden" libraries, object files and flags are used when
 	    # linking a shared library.
@@ -13886,10 +14453,10 @@ fi
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 
-	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+	    hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir'
+	    export_dynamic_flag_spec_CXX='$wl--export-dynamic'
 
 	    # Archives containing C++ object files must be created using
 	    # "CC -Bstatic", where "CC" is the KAI C++ compiler.
@@ -13903,59 +14470,59 @@ fi
 	    # earlier do not add the objects themselves.
 	    case `$CC -V 2>&1` in
 	      *"Version 7."*)
-	        archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	        archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+		archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 		;;
 	      *)  # Version 8.0 or newer
 	        tmp_idyn=
 	        case $host_cpu in
 		  ia64*) tmp_idyn=' -i_dynamic';;
 		esac
-	        archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	        archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+		archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 		;;
 	    esac
 	    archive_cmds_need_lc_CXX=no
-	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-	    whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir'
+	    export_dynamic_flag_spec_CXX='$wl--export-dynamic'
+	    whole_archive_flag_spec_CXX='$wl--whole-archive$convenience $wl--no-whole-archive'
 	    ;;
           pgCC* | pgcpp*)
             # Portland Group C++ compiler
 	    case `$CC -V` in
 	    *pgCC\ [1-5].* | *pgcpp\ [1-5].*)
 	      prelink_cmds_CXX='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
-		compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
+               rm -rf $tpldir~
+               $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+               compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
 	      old_archive_cmds_CXX='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
-		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
-		$RANLIB $oldlib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+                $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
+                $RANLIB $oldlib'
 	      archive_cmds_CXX='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+                $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
 	      archive_expsym_cmds_CXX='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+                $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	      ;;
 	    *) # Version 6 and above use weak symbols
-	      archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-	      archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+	      archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+	      archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	      ;;
 	    esac
 
-	    hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
-	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-	    whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	    hardcode_libdir_flag_spec_CXX='$wl--rpath $wl$libdir'
+	    export_dynamic_flag_spec_CXX='$wl--export-dynamic'
+	    whole_archive_flag_spec_CXX='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
             ;;
 	  cxx*)
 	    # Compaq C++
-	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+	    archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname  -o $lib $wl-retain-symbols-file $wl$export_symbols'
 
 	    runpath_var=LD_RUN_PATH
 	    hardcode_libdir_flag_spec_CXX='-rpath $libdir'
@@ -13969,18 +14536,18 @@ fi
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
 	    ;;
 	  xl* | mpixl* | bgxl*)
 	    # IBM XL 8.0 on PPC, with GNU ld
-	    hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
-	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-	    archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    if test "x$supports_anon_versioning" = xyes; then
+	    hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir'
+	    export_dynamic_flag_spec_CXX='$wl--export-dynamic'
+	    archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	    if test yes = "$supports_anon_versioning"; then
 	      archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~
-		cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-		echo "local: *; };" >> $output_objdir/$libname.ver~
-		$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+                cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+                echo "local: *; };" >> $output_objdir/$libname.ver~
+                $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
 	    fi
 	    ;;
 	  *)
@@ -13988,10 +14555,10 @@ fi
 	    *Sun\ C*)
 	      # Sun C++ 5.9
 	      no_undefined_flag_CXX=' -zdefs'
-	      archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	      archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+	      archive_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      archive_expsym_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols'
 	      hardcode_libdir_flag_spec_CXX='-R$libdir'
-	      whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	      whole_archive_flag_spec_CXX='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	      compiler_needs_object_CXX=yes
 
 	      # Not sure whether something based on
@@ -14049,22 +14616,17 @@ fi
         ld_shlibs_CXX=yes
 	;;
 
-      openbsd2*)
-        # C++ shared libraries are fairly broken
-	ld_shlibs_CXX=no
-	;;
-
-      openbsd*)
+      openbsd* | bitrig*)
 	if test -f /usr/libexec/ld.so; then
 	  hardcode_direct_CXX=yes
 	  hardcode_shlibpath_var_CXX=no
 	  hardcode_direct_absolute_CXX=yes
 	  archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-	  hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	    archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
-	    export_dynamic_flag_spec_CXX='${wl}-E'
-	    whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+	  hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir'
+	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then
+	    archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib'
+	    export_dynamic_flag_spec_CXX='$wl-E'
+	    whole_archive_flag_spec_CXX=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
 	  fi
 	  output_verbose_link_cmd=func_echo_all
 	else
@@ -14080,9 +14642,9 @@ fi
 	    # KCC will only create a shared library if the output file
 	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
 	    # to its proper name (with version) after linking.
-	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
 
-	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+	    hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir'
 	    hardcode_libdir_separator_CXX=:
 
 	    # Archives containing C++ object files must be created using
@@ -14100,17 +14662,17 @@ fi
           cxx*)
 	    case $host in
 	      osf3*)
-	        allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
-	        archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+	        allow_undefined_flag_CXX=' $wl-expect_unresolved $wl\*'
+	        archive_cmds_CXX='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+	        hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir'
 		;;
 	      *)
 	        allow_undefined_flag_CXX=' -expect_unresolved \*'
-	        archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	        archive_cmds_CXX='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 	        archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
-	          echo "-hidden">> $lib.exp~
-	          $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
-	          $RM $lib.exp'
+                  echo "-hidden">> $lib.exp~
+                  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~
+                  $RM $lib.exp'
 	        hardcode_libdir_flag_spec_CXX='-rpath $libdir'
 		;;
 	    esac
@@ -14125,21 +14687,21 @@ fi
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 	    ;;
 	  *)
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+	    if test yes,no = "$GXX,$with_gnu_ld"; then
+	      allow_undefined_flag_CXX=' $wl-expect_unresolved $wl\*'
 	      case $host in
 	        osf3*)
-	          archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	          archive_cmds_CXX='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 		  ;;
 	        *)
-	          archive_cmds_CXX='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	          archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 		  ;;
 	      esac
 
-	      hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+	      hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir'
 	      hardcode_libdir_separator_CXX=:
 
 	      # Commands to make compiler produce verbose output that lists
@@ -14185,9 +14747,9 @@ fi
 	    # Sun C++ 4.2, 5.x and Centerline C++
             archive_cmds_need_lc_CXX=yes
 	    no_undefined_flag_CXX=' -zdefs'
-	    archive_cmds_CXX='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	    archive_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	    archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	      $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+              $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	    hardcode_libdir_flag_spec_CXX='-R$libdir'
 	    hardcode_shlibpath_var_CXX=no
@@ -14195,7 +14757,7 @@ fi
 	      solaris2.[0-5] | solaris2.[0-5].*) ;;
 	      *)
 		# The compiler driver will combine and reorder linker options,
-		# but understands `-z linker_flag'.
+		# but understands '-z linker_flag'.
 	        # Supported since Solaris 2.6 (maybe 2.5.1?)
 		whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract'
 	        ;;
@@ -14212,30 +14774,30 @@ fi
 	    ;;
           gcx*)
 	    # Green Hills C++ Compiler
-	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 
 	    # The C++ compiler must be used to create the archive.
 	    old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
 	    ;;
           *)
 	    # GNU C++ compiler with Solaris linker
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      no_undefined_flag_CXX=' ${wl}-z ${wl}defs'
+	    if test yes,no = "$GXX,$with_gnu_ld"; then
+	      no_undefined_flag_CXX=' $wl-z ${wl}defs'
 	      if $CC --version | $GREP -v '^2\.7' > /dev/null; then
-	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 	        archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+                  $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	        # Commands to make compiler produce verbose output that lists
 	        # what "hidden" libraries, object files and flags are used when
 	        # linking a shared library.
 	        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
 	      else
-	        # g++ 2.7 appears to require `-G' NOT `-shared' on this
+	        # g++ 2.7 appears to require '-G' NOT '-shared' on this
 	        # platform.
-	        archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        archive_cmds_CXX='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 	        archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+                  $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	        # Commands to make compiler produce verbose output that lists
 	        # what "hidden" libraries, object files and flags are used when
@@ -14243,11 +14805,11 @@ fi
 	        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
 	      fi
 
-	      hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir'
+	      hardcode_libdir_flag_spec_CXX='$wl-R $wl$libdir'
 	      case $host_os in
 		solaris2.[0-5] | solaris2.[0-5].*) ;;
 		*)
-		  whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+		  whole_archive_flag_spec_CXX='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
 		  ;;
 	      esac
 	    fi
@@ -14256,52 +14818,52 @@ fi
         ;;
 
     sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
-      no_undefined_flag_CXX='${wl}-z,text'
+      no_undefined_flag_CXX='$wl-z,text'
       archive_cmds_need_lc_CXX=no
       hardcode_shlibpath_var_CXX=no
       runpath_var='LD_RUN_PATH'
 
       case $cc_basename in
         CC*)
-	  archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds_CXX='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_CXX='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
-	  archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds_CXX='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_CXX='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
       esac
       ;;
 
       sysv5* | sco3.2v5* | sco5v6*)
-	# Note: We can NOT use -z defs as we might desire, because we do not
+	# Note: We CANNOT use -z defs as we might desire, because we do not
 	# link with -lc, and that would cause any symbols used from libc to
 	# always be unresolved, which means just about no library would
 	# ever link correctly.  If we're not using GNU ld we use -z text
 	# though, which does catch some bad symbols but isn't as heavy-handed
 	# as -z defs.
-	no_undefined_flag_CXX='${wl}-z,text'
-	allow_undefined_flag_CXX='${wl}-z,nodefs'
+	no_undefined_flag_CXX='$wl-z,text'
+	allow_undefined_flag_CXX='$wl-z,nodefs'
 	archive_cmds_need_lc_CXX=no
 	hardcode_shlibpath_var_CXX=no
-	hardcode_libdir_flag_spec_CXX='${wl}-R,$libdir'
+	hardcode_libdir_flag_spec_CXX='$wl-R,$libdir'
 	hardcode_libdir_separator_CXX=':'
 	link_all_deplibs_CXX=yes
-	export_dynamic_flag_spec_CXX='${wl}-Bexport'
+	export_dynamic_flag_spec_CXX='$wl-Bexport'
 	runpath_var='LD_RUN_PATH'
 
 	case $cc_basename in
           CC*)
-	    archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    archive_cmds_CXX='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    archive_expsym_cmds_CXX='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	    old_archive_cmds_CXX='$CC -Tprelink_objects $oldobjs~
-	      '"$old_archive_cmds_CXX"
+              '"$old_archive_cmds_CXX"
 	    reload_cmds_CXX='$CC -Tprelink_objects $reload_objs~
-	      '"$reload_cmds_CXX"
+              '"$reload_cmds_CXX"
 	    ;;
 	  *)
-	    archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    archive_cmds_CXX='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    archive_expsym_cmds_CXX='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	    ;;
 	esac
       ;;
@@ -14333,10 +14895,10 @@ fi
 
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
 $as_echo "$ld_shlibs_CXX" >&6; }
-    test "$ld_shlibs_CXX" = no && can_build_shared=no
+    test no = "$ld_shlibs_CXX" && can_build_shared=no
 
-    GCC_CXX="$GXX"
-    LD_CXX="$LD"
+    GCC_CXX=$GXX
+    LD_CXX=$LD
 
     ## CAVEAT EMPTOR:
     ## There is no encapsulation within the following macros, do not change
@@ -14380,13 +14942,13 @@ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   pre_test_object_deps_done=no
 
   for p in `eval "$output_verbose_link_cmd"`; do
-    case ${prev}${p} in
+    case $prev$p in
 
     -L* | -R* | -l*)
        # Some compilers place space between "-{L,R}" and the path.
        # Remove the space.
-       if test $p = "-L" ||
-          test $p = "-R"; then
+       if test x-L = "$p" ||
+          test x-R = "$p"; then
 	 prev=$p
 	 continue
        fi
@@ -14402,16 +14964,16 @@ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
        case $p in
        =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
        esac
-       if test "$pre_test_object_deps_done" = no; then
-	 case ${prev} in
+       if test no = "$pre_test_object_deps_done"; then
+	 case $prev in
 	 -L | -R)
 	   # Internal compiler library paths should come after those
 	   # provided the user.  The postdeps already come after the
 	   # user supplied libs so there is no need to process them.
 	   if test -z "$compiler_lib_search_path_CXX"; then
-	     compiler_lib_search_path_CXX="${prev}${p}"
+	     compiler_lib_search_path_CXX=$prev$p
 	   else
-	     compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}"
+	     compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} $prev$p"
 	   fi
 	   ;;
 	 # The "-l" case would never come before the object being
@@ -14419,9 +14981,9 @@ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
 	 esac
        else
 	 if test -z "$postdeps_CXX"; then
-	   postdeps_CXX="${prev}${p}"
+	   postdeps_CXX=$prev$p
 	 else
-	   postdeps_CXX="${postdeps_CXX} ${prev}${p}"
+	   postdeps_CXX="${postdeps_CXX} $prev$p"
 	 fi
        fi
        prev=
@@ -14436,15 +14998,15 @@ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
 	 continue
        fi
 
-       if test "$pre_test_object_deps_done" = no; then
+       if test no = "$pre_test_object_deps_done"; then
 	 if test -z "$predep_objects_CXX"; then
-	   predep_objects_CXX="$p"
+	   predep_objects_CXX=$p
 	 else
 	   predep_objects_CXX="$predep_objects_CXX $p"
 	 fi
        else
 	 if test -z "$postdep_objects_CXX"; then
-	   postdep_objects_CXX="$p"
+	   postdep_objects_CXX=$p
 	 else
 	   postdep_objects_CXX="$postdep_objects_CXX $p"
 	 fi
@@ -14474,51 +15036,6 @@ interix[3-9]*)
   postdep_objects_CXX=
   postdeps_CXX=
   ;;
-
-linux*)
-  case `$CC -V 2>&1 | sed 5q` in
-  *Sun\ C*)
-    # Sun C++ 5.9
-
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
-    esac
-
-    if test "$solaris_use_stlport4" != yes; then
-      postdeps_CXX='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
-
-solaris*)
-  case $cc_basename in
-  CC* | sunCC*)
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
-    esac
-
-    # Adding this requires a known-good setup of shared libraries for
-    # Sun compiler versions before 5.6, else PIC objects from an old
-    # archive will be linked into the output, leading to subtle bugs.
-    if test "$solaris_use_stlport4" != yes; then
-      postdeps_CXX='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
 esac
 
 
@@ -14527,7 +15044,7 @@ case " $postdeps_CXX " in
 esac
  compiler_lib_search_dirs_CXX=
 if test -n "${compiler_lib_search_path_CXX}"; then
- compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+ compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | $SED -e 's! -L! !g' -e 's!^ !!'`
 fi
 
 
@@ -14566,17 +15083,18 @@ lt_prog_compiler_static_CXX=
 
 
   # C++ specific cases for pic, static, wl, etc.
-  if test "$GXX" = yes; then
+  if test yes = "$GXX"; then
     lt_prog_compiler_wl_CXX='-Wl,'
     lt_prog_compiler_static_CXX='-static'
 
     case $host_os in
     aix*)
       # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	lt_prog_compiler_static_CXX='-Bstatic'
       fi
+      lt_prog_compiler_pic_CXX='-fPIC'
       ;;
 
     amigaos*)
@@ -14587,8 +15105,8 @@ lt_prog_compiler_static_CXX=
         ;;
       m68k)
             # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
+            # adding the '-m68020' flag to GCC prevents building anything better,
+            # like '-m68040'.
             lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4'
         ;;
       esac
@@ -14603,6 +15121,11 @@ lt_prog_compiler_static_CXX=
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
       # (--disable-auto-import) libraries
       lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
+      case $host_os in
+      os2*)
+	lt_prog_compiler_static_CXX='$wl-static'
+	;;
+      esac
       ;;
     darwin* | rhapsody*)
       # PIC is the default on this platform
@@ -14652,7 +15175,7 @@ lt_prog_compiler_static_CXX=
     case $host_os in
       aix[4-9]*)
 	# All AIX code is PIC.
-	if test "$host_cpu" = ia64; then
+	if test ia64 = "$host_cpu"; then
 	  # AIX 5 now supports IA64 processor
 	  lt_prog_compiler_static_CXX='-Bstatic'
 	else
@@ -14692,14 +15215,14 @@ lt_prog_compiler_static_CXX=
 	case $cc_basename in
 	  CC*)
 	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
-	    if test "$host_cpu" != ia64; then
+	    lt_prog_compiler_static_CXX='$wl-a ${wl}archive'
+	    if test ia64 != "$host_cpu"; then
 	      lt_prog_compiler_pic_CXX='+Z'
 	    fi
 	    ;;
 	  aCC*)
 	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
+	    lt_prog_compiler_static_CXX='$wl-a ${wl}archive'
 	    case $host_cpu in
 	    hppa*64*|ia64*)
 	      # +Z the default
@@ -14736,7 +15259,7 @@ lt_prog_compiler_static_CXX=
 	    lt_prog_compiler_pic_CXX='-fPIC'
 	    ;;
 	  ecpc* )
-	    # old Intel C++ for x86_64 which still supported -KPIC.
+	    # old Intel C++ for x86_64, which still supported -KPIC.
 	    lt_prog_compiler_wl_CXX='-Wl,'
 	    lt_prog_compiler_pic_CXX='-KPIC'
 	    lt_prog_compiler_static_CXX='-static'
@@ -14792,7 +15315,7 @@ lt_prog_compiler_static_CXX=
 	    ;;
 	esac
 	;;
-      netbsd* | netbsdelf*-gnu)
+      netbsd*)
 	;;
       *qnx* | *nto*)
         # QNX uses GNU C++, but need to define -shared option too, otherwise
@@ -14881,7 +15404,7 @@ lt_prog_compiler_static_CXX=
   fi
 
 case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
+  # For platforms that do not support PIC, -DPIC is meaningless:
   *djgpp*)
     lt_prog_compiler_pic_CXX=
     ;;
@@ -14913,7 +15436,7 @@ else
   lt_cv_prog_compiler_pic_works_CXX=no
    ac_outfile=conftest.$ac_objext
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"
+   lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"  ## exclude from sc_useless_quotes_in_assignment
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
    # Note that $ac_compile itself does not contain backslashes and begins
@@ -14943,7 +15466,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5
 $as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; }
 
-if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then
+if test yes = "$lt_cv_prog_compiler_pic_works_CXX"; then
     case $lt_prog_compiler_pic_CXX in
      "" | " "*) ;;
      *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;;
@@ -14969,7 +15492,7 @@ if ${lt_cv_prog_compiler_static_works_CXX+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   lt_cv_prog_compiler_static_works_CXX=no
-   save_LDFLAGS="$LDFLAGS"
+   save_LDFLAGS=$LDFLAGS
    LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
    echo "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
@@ -14988,13 +15511,13 @@ else
      fi
    fi
    $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
+   LDFLAGS=$save_LDFLAGS
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5
 $as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; }
 
-if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then
+if test yes = "$lt_cv_prog_compiler_static_works_CXX"; then
     :
 else
     lt_prog_compiler_static_CXX=
@@ -15108,8 +15631,8 @@ $as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; }
 
 
 
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then
+hard_links=nottested
+if test no = "$lt_cv_prog_compiler_c_o_CXX" && test no != "$need_locks"; then
   # do not overwrite the value of need_locks provided by the user
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
 $as_echo_n "checking if we can lock with hard links... " >&6; }
@@ -15121,9 +15644,9 @@ $as_echo_n "checking if we can lock with hard links... " >&6; }
   ln conftest.a conftest.b 2>/dev/null && hard_links=no
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
 $as_echo "$hard_links" >&6; }
-  if test "$hard_links" = no; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+  if test no = "$hard_links"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;}
     need_locks=warn
   fi
 else
@@ -15140,17 +15663,21 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   case $host_os in
   aix[4-9]*)
     # If we're using GNU nm, then we don't want the "-C" option.
-    # -C means demangle to AIX nm, but means don't demangle with GNU nm
-    # Also, AIX nm treats weak defined symbols like other global defined
-    # symbols, whereas GNU nm marks them as "W".
+    # -C means demangle to GNU nm, but means don't demangle to AIX nm.
+    # Without the "-l" option, or with the "-B" option, AIX nm treats
+    # weak defined symbols like other global defined symbols, whereas
+    # GNU nm marks them as "W".
+    # While the 'weak' keyword is ignored in the Export File, we need
+    # it in the Import File for the 'aix-soname' feature, so we have
+    # to replace the "-B" option with "-P" for AIX nm.
     if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-      export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+      export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
     else
-      export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+      export_symbols_cmds_CXX='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
     fi
     ;;
   pw32*)
-    export_symbols_cmds_CXX="$ltdll_cmds"
+    export_symbols_cmds_CXX=$ltdll_cmds
     ;;
   cygwin* | mingw* | cegcc*)
     case $cc_basename in
@@ -15163,9 +15690,6 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
       ;;
     esac
     ;;
-  linux* | k*bsd*-gnu | gnu*)
-    link_all_deplibs_CXX=no
-    ;;
   *)
     export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
     ;;
@@ -15173,7 +15697,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
 $as_echo "$ld_shlibs_CXX" >&6; }
-test "$ld_shlibs_CXX" = no && can_build_shared=no
+test no = "$ld_shlibs_CXX" && can_build_shared=no
 
 with_gnu_ld_CXX=$with_gnu_ld
 
@@ -15190,7 +15714,7 @@ x|xyes)
   # Assume -lc should be added
   archive_cmds_need_lc_CXX=yes
 
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
+  if test yes,yes = "$GCC,$enable_shared"; then
     case $archive_cmds_CXX in
     *'~'*)
       # FIXME: we may have to deal with multi-command sequences.
@@ -15318,7 +15842,7 @@ $as_echo_n "checking dynamic linker characteristics... " >&6; }
 library_names_spec=
 libname_spec='lib$name'
 soname_spec=
-shrext_cmds=".so"
+shrext_cmds=.so
 postinstall_cmds=
 postuninstall_cmds=
 finish_cmds=
@@ -15335,14 +15859,16 @@ hardcode_into_libs=no
 # flags to be left without arguments
 need_version=unknown
 
+
+
 case $host_os in
 aix3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname.a'
   shlibpath_var=LIBPATH
 
   # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
+  soname_spec='$libname$release$shared_ext$major'
   ;;
 
 aix[4-9]*)
@@ -15350,41 +15876,91 @@ aix[4-9]*)
   need_lib_prefix=no
   need_version=no
   hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext'
     shlibpath_var=LD_LIBRARY_PATH
   else
     # With GCC up to 2.95.x, collect2 would create an import file
     # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
+    # the line '#! .'.  This would cause the generated library to
+    # depend on '.', always an invalid library.  This was fixed in
     # development snapshots of GCC prior to 3.0.
     case $host_os in
       aix4 | aix4.[01] | aix4.[01].*)
       if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
 	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	   echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then
 	:
       else
 	can_build_shared=no
       fi
       ;;
     esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # Using Import Files as archive members, it is possible to support
+    # filename-based versioning of shared library archives on AIX. While
+    # this would work for both with and without runtime linking, it will
+    # prevent static linking of such archives. So we do filename-based
+    # shared library versioning with .so extension only, which is used
+    # when both runtime linking and shared linking is enabled.
+    # Unfortunately, runtime linking may impact performance, so we do
+    # not want this to be the default eventually. Also, we use the
+    # versioned .so libs for executables only if there is the -brtl
+    # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only.
+    # To allow for filename-based versioning support, we need to create
+    # libNAME.so.V as an archive file, containing:
+    # *) an Import File, referring to the versioned filename of the
+    #    archive as well as the shared archive member, telling the
+    #    bitwidth (32 or 64) of that shared object, and providing the
+    #    list of exported symbols of that shared object, eventually
+    #    decorated with the 'weak' keyword
+    # *) the shared object with the F_LOADONLY flag set, to really avoid
+    #    it being seen by the linker.
+    # At run time we better use the real file rather than another symlink,
+    # but for link time we create the symlink libNAME.so -> libNAME.so.V
+
+    case $with_aix_soname,$aix_use_runtimelinking in
+    # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct
     # soname into executable. Probably we can add versioning support to
     # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
+    aix,yes) # traditional libtool
+      dynamic_linker='AIX unversionable lib.so'
       # If using run time linking (on AIX 4.2 or later) use lib<name>.so
       # instead of lib<name>.a to let people know that these are not
       # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      ;;
+    aix,no) # traditional AIX only
+      dynamic_linker='AIX lib.a(lib.so.V)'
       # We preserve .a as extension for shared libraries through AIX4.2
       # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      ;;
+    svr4,*) # full svr4 only
+      dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,yes) # both, prefer svr4
+      dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # unpreferred sharedlib libNAME.a needs extra handling
+      postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"'
+      postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,no) # both, prefer aix
+      dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)"
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling
+      postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)'
+      postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"'
+      ;;
+    esac
     shlibpath_var=LIBPATH
   fi
   ;;
@@ -15394,18 +15970,18 @@ amigaos*)
   powerpc)
     # Since July 2007 AmigaOS4 officially supports .so libraries.
     # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
     ;;
   m68k)
     library_names_spec='$libname.ixlibrary $libname.a'
     # Create ${libname}_ixlibrary.a entries in /sys/libs.
-    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
     ;;
   esac
   ;;
 
 beos*)
-  library_names_spec='${libname}${shared_ext}'
+  library_names_spec='$libname$shared_ext'
   dynamic_linker="$host_os ld.so"
   shlibpath_var=LIBRARY_PATH
   ;;
@@ -15413,8 +15989,8 @@ beos*)
 bsdi[45]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
@@ -15426,7 +16002,7 @@ bsdi[45]*)
 
 cygwin* | mingw* | pw32* | cegcc*)
   version_type=windows
-  shrext_cmds=".dll"
+  shrext_cmds=.dll
   need_version=no
   need_lib_prefix=no
 
@@ -15435,8 +16011,8 @@ cygwin* | mingw* | pw32* | cegcc*)
     # gcc
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname~
@@ -15452,16 +16028,16 @@ cygwin* | mingw* | pw32* | cegcc*)
     case $host_os in
     cygwin*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
 
       ;;
     mingw* | cegcc*)
       # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
       ;;
     esac
     dynamic_linker='Win32 ld.exe'
@@ -15470,8 +16046,8 @@ cygwin* | mingw* | pw32* | cegcc*)
   *,cl*)
     # Native MSVC
     libname_spec='$name'
-    soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-    library_names_spec='${libname}.dll.lib'
+    soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
+    library_names_spec='$libname.dll.lib'
 
     case $build_os in
     mingw*)
@@ -15498,7 +16074,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
       ;;
     *)
-      sys_lib_search_path_spec="$LIB"
+      sys_lib_search_path_spec=$LIB
       if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
         # It is most probably a Windows format PATH.
         sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
@@ -15511,8 +16087,8 @@ cygwin* | mingw* | pw32* | cegcc*)
     esac
 
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname'
@@ -15525,7 +16101,7 @@ cygwin* | mingw* | pw32* | cegcc*)
 
   *)
     # Assume MSVC wrapper
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib'
     dynamic_linker='Win32 ld.exe'
     ;;
   esac
@@ -15538,8 +16114,8 @@ darwin* | rhapsody*)
   version_type=darwin
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
+  library_names_spec='$libname$release$major$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$major$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
   shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
@@ -15551,8 +16127,8 @@ dgux*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -15570,12 +16146,13 @@ freebsd* | dragonfly*)
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      soname_spec='$libname$release$shared_ext$major'
       need_version=no
       need_lib_prefix=no
       ;;
     freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
       need_version=yes
       ;;
   esac
@@ -15605,10 +16182,10 @@ haiku*)
   need_lib_prefix=no
   need_version=no
   dynamic_linker="$host_os runtime_loader"
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
+  shlibpath_overrides_runpath=no
   sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
   hardcode_into_libs=yes
   ;;
@@ -15626,14 +16203,15 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.so"
     shlibpath_var=LD_LIBRARY_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
+    if test 32 = "$HPUX_IA64_MODE"; then
       sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux32
     else
       sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux64
     fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
   hppa*64*)
     shrext_cmds='.sl'
@@ -15641,8 +16219,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
@@ -15651,8 +16229,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=SHLIB_PATH
     shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     ;;
   esac
   # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
@@ -15665,8 +16243,8 @@ interix[3-9]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -15677,7 +16255,7 @@ irix5* | irix6* | nonstopux*)
   case $host_os in
     nonstopux*) version_type=nonstopux ;;
     *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
+	if test yes = "$lt_cv_prog_gnu_ld"; then
 		version_type=linux # correct to gnu/linux during the next big refactor
 	else
 		version_type=irix
@@ -15685,8 +16263,8 @@ irix5* | irix6* | nonstopux*)
   esac
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext'
   case $host_os in
   irix5* | nonstopux*)
     libsuff= shlibsuff=
@@ -15705,8 +16283,8 @@ irix5* | irix6* | nonstopux*)
   esac
   shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
   shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff"
+  sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff"
   hardcode_into_libs=yes
   ;;
 
@@ -15715,13 +16293,33 @@ linux*oldld* | linux*aout* | linux*coff*)
   dynamic_linker=no
   ;;
 
+linux*android*)
+  version_type=none # Android doesn't support versioned libraries.
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='$libname$release$shared_ext'
+  soname_spec='$libname$release$shared_ext'
+  finish_cmds=
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  dynamic_linker='Android linker'
+  # Don't embed -rpath directories since the linker doesn't support them.
+  hardcode_libdir_flag_spec_CXX='-L$libdir'
+  ;;
+
 # This must be glibc/ELF.
 linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -15765,7 +16363,12 @@ fi
   # before this can be enabled.
   hardcode_into_libs=yes
 
-  # Append ld.so.conf contents to the search path
+  # Ideally, we could use ldconfig to report *all* directores which are
+  # searched for libraries, however this is still not possible.  Aside from not
+  # being certain /sbin/ldconfig is available, command
+  # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64,
+  # even though it is searched at run-time.  Try to do the best guess by
+  # appending ld.so.conf contents (and includes) to the search path.
   if test -f /etc/ld.so.conf; then
     lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
     sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
@@ -15780,29 +16383,17 @@ fi
   dynamic_linker='GNU/Linux ld.so'
   ;;
 
-netbsdelf*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='NetBSD ld.elf_so'
-  ;;
-
 netbsd*)
   version_type=sunos
   need_lib_prefix=no
   need_version=no
   if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
     finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
     dynamic_linker='NetBSD (a.out) ld.so'
   else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     dynamic_linker='NetBSD ld.elf_so'
   fi
   shlibpath_var=LD_LIBRARY_PATH
@@ -15812,7 +16403,7 @@ netbsd*)
 
 newsos6)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   ;;
@@ -15821,58 +16412,68 @@ newsos6)
   version_type=qnx
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
   dynamic_linker='ldqnx.so'
   ;;
 
-openbsd*)
+openbsd* | bitrig*)
   version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
+  sys_lib_dlsearch_path_spec=/usr/lib
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
-    *)				need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[89] | openbsd2.[89].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
-      esac
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
+    need_version=no
   else
-    shlibpath_overrides_runpath=yes
+    need_version=yes
   fi
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
   ;;
 
 os2*)
   libname_spec='$name'
-  shrext_cmds=".dll"
+  version_type=windows
+  shrext_cmds=.dll
+  need_version=no
   need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
+  # OS/2 can only load a DLL with a base name of 8 characters or less.
+  soname_spec='`test -n "$os2dllname" && libname="$os2dllname";
+    v=$($ECHO $release$versuffix | tr -d .-);
+    n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _);
+    $ECHO $n$v`$shared_ext'
+  library_names_spec='${libname}_dll.$libext'
   dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
+  shlibpath_var=BEGINLIBPATH
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+  postinstall_cmds='base_file=`basename \$file`~
+    dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~
+    dldir=$destdir/`dirname \$dlpath`~
+    test -d \$dldir || mkdir -p \$dldir~
+    $install_prog $dir/$dlname \$dldir/$dlname~
+    chmod a+x \$dldir/$dlname~
+    if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+      eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+    fi'
+  postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~
+    dlpath=$dir/\$dldll~
+    $RM \$dlpath'
   ;;
 
 osf3* | osf4* | osf5*)
   version_type=osf
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
   ;;
 
 rdos*)
@@ -15883,8 +16484,8 @@ solaris*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
@@ -15894,11 +16495,11 @@ solaris*)
 
 sunos4*)
   version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
   finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     need_lib_prefix=no
   fi
   need_version=yes
@@ -15906,8 +16507,8 @@ sunos4*)
 
 sysv4 | sysv4.3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   case $host_vendor in
     sni)
@@ -15928,24 +16529,24 @@ sysv4 | sysv4.3*)
   ;;
 
 sysv4*MP*)
-  if test -d /usr/nec ;then
+  if test -d /usr/nec; then
     version_type=linux # correct to gnu/linux during the next big refactor
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
+    library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext'
+    soname_spec='$libname$shared_ext.$major'
     shlibpath_var=LD_LIBRARY_PATH
   fi
   ;;
 
 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
+  version_type=sco
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
   else
     sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
@@ -15963,7 +16564,7 @@ tpf*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
@@ -15971,8 +16572,8 @@ tpf*)
 
 uts4*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -15982,20 +16583,32 @@ uts4*)
 esac
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
 $as_echo "$dynamic_linker" >&6; }
-test "$dynamic_linker" = no && can_build_shared=no
+test no = "$dynamic_linker" && can_build_shared=no
 
 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
 fi
 
-if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
-  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then
+  sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec
 fi
-if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
-  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then
+  sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec
 fi
 
+# remember unaugmented sys_lib_dlsearch_path content for libtool script decls...
+configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec
+
+# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code
+func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH"
+
+# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool
+configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH
+
+
+
 
 
 
@@ -16038,15 +16651,15 @@ $as_echo_n "checking how to hardcode library paths into programs... " >&6; }
 hardcode_action_CXX=
 if test -n "$hardcode_libdir_flag_spec_CXX" ||
    test -n "$runpath_var_CXX" ||
-   test "X$hardcode_automatic_CXX" = "Xyes" ; then
+   test yes = "$hardcode_automatic_CXX"; then
 
   # We can hardcode non-existent directories.
-  if test "$hardcode_direct_CXX" != no &&
+  if test no != "$hardcode_direct_CXX" &&
      # If the only mechanism to avoid hardcoding is shlibpath_var, we
      # have to relink, otherwise we might link with an installed library
      # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" != no &&
-     test "$hardcode_minus_L_CXX" != no; then
+     ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" &&
+     test no != "$hardcode_minus_L_CXX"; then
     # Linking always hardcodes the temporary library directory.
     hardcode_action_CXX=relink
   else
@@ -16061,12 +16674,12 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5
 $as_echo "$hardcode_action_CXX" >&6; }
 
-if test "$hardcode_action_CXX" = relink ||
-   test "$inherit_rpath_CXX" = yes; then
+if test relink = "$hardcode_action_CXX" ||
+   test yes = "$inherit_rpath_CXX"; then
   # Fast installation is not supported
   enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
+elif test yes = "$shlibpath_overrides_runpath" ||
+     test no = "$enable_shared"; then
   # Fast installation is not necessary
   enable_fast_install=needless
 fi
@@ -16089,7 +16702,7 @@ fi
   lt_cv_path_LD=$lt_save_path_LD
   lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
   lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
-fi # test "$_lt_caught_CXX_error" != yes
+fi # test yes != "$_lt_caught_CXX_error"
 
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
@@ -16224,9 +16837,15 @@ $as_echo "#define LLVM_3_6 /**/" >>confdefs.h
      LLVM_3_6=true
      LLVM_LDFLAGS="$LLVM_LDFLAGS `$LLVM_CONFIG --system-libs`"
    ;;
+     3.7*)
+
+$as_echo "#define LLVM_3_7 /**/" >>confdefs.h
+
+     LLVM_LDFLAGS="$LLVM_LDFLAGS `$LLVM_CONFIG --system-libs`"
+   ;;
      *)
    as_fn_error $? "
-Unsupported LLVM version. Please use LLVM version 3.2, 3.3, 3.4, 3.5 or 3.6.
+Unsupported LLVM version. Please use LLVM version 3.2, 3.3, 3.4, 3.5, 3.6, 3.7.
    " "$LINENO" 5
    LLVM_VERSION=
    ;;
@@ -16268,18 +16887,35 @@ if test "$link_llvm_static" = "yes"; then
   LLVM_LIBS=$($LLVM_CONFIG --libfiles)
 else
   LLVM_LIBS=-lLLVM-$LLVM_VERSION
-if test ! -e $LLVM_SHARED_LIB_FILE;
-then
-  LLVM_LIBS=$($LLVM_CONFIG --libs)
-  { $as_echo "$as_me:${as_lineno-$LINENO}:
-$LLVM_SHARED_LIB_FILE not found. LLVM is built with cmake." >&5
-$as_echo "$as_me:
-$LLVM_SHARED_LIB_FILE not found. LLVM is built with cmake." >&6;}
-fi
+  if test ! -e $LLVM_SHARED_LIB_FILE;
+  then
+    # Cmake's -DLLVM_BUILD_LLVM_DYLIB=on builds a dynlib
+    # named libLLVM.so.VERSION. Let's see if we can find it.
+    LLVM_SHARED_LIB_FILE=$LLVM_LIBDIR/libLLVM$LIBRARY_SUFFIX.$LLVM_VERSION
+    if test ! -e $LLVM_SHARED_LIB_FILE;
+    then
+      LLVM_LIBS=$($LLVM_CONFIG --libs)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: LLVM shared library $LLVM_SHARED_LIB_FILE not found." >&5
+$as_echo "$as_me: LLVM shared library $LLVM_SHARED_LIB_FILE not found." >&6;}
+    else
+      # The Cmake built libLLVM.so seems to be missing a lot of symbols
+      # to the point of being useless. Fall back to the static lib.
+      LLVM_LIBS=$($LLVM_CONFIG --libs)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: LLVM shared library $LLVM_SHARED_LIB_FILE built with cmake found, using the static lib instead." >&5
+$as_echo "$as_me: LLVM shared library $LLVM_SHARED_LIB_FILE built with cmake found, using the static lib instead." >&6;}
+    fi
+  fi
 fi
 
 
 
+if `$LLVM_CONFIG --build-mode | grep -q Asserts`;
+then
+
+$as_echo "#define LLVM_BUILT_WITH_ASSERTS /**/" >>confdefs.h
+
+fi
+
 LLVM_RTTI_CHECK=$($LLVM_CONFIG --cxxflags | grep -i "\-fno-rtti")
 
 if test x"$LLVM_RTTI_CHECK" != x; then
@@ -16322,6 +16958,8 @@ enable_testsuite_amdsdk2_9=no
 enable_testsuite_vexcl=no
 enable_testsuite_piglit=no
 enable_testsuite_halide=no
+enable_testsuite_opencv=no
+enable_testsuite_hsa=no
 if test x"$enable_testsuites" = xcheck ; then
   if test -d "$srcdir/examples/opencl-book-samples/checkout" ; then
     enable_testsuite_opencl_book_samples=yes
@@ -16352,13 +16990,16 @@ if test x"$enable_testsuites" = xcheck ; then
   if test -f "$srcdir/examples/Halide/Halide/Makefile" ; then
     enable_testsuite_halide=yes
   fi
+  if test -f "$srcdir/examples/OpenCV/opencv-3.0.0-beta.zip" ; then
+    enable_testsuite_opencv=yes
+  fi
   if test -f "$srcdir/examples/CloverLeaf/CloverLeaf_OpenCL/Makefile" ; then
     enable_testsuite_cloverleaf=yes
   fi
 fi
 case ,"$enable_testsuites", in #(
   *,all,*|*,yes,*) :
-    enable_testsuites="opencl-book-samples,ViennaCL,Rodinia,Parboil,amd,amdsdk2_9,VexCL,piglit,Halide,CloverLeaf" ;; #(
+    enable_testsuites="opencl-book-samples,ViennaCL,Rodinia,Parboil,amd,amdsdk2_9,VexCL,piglit,Halide,OpenCV,CloverLeaf" ;; #(
   *,no,*) :
     enable_testsuites=""
  ;; #(
@@ -16431,6 +17072,14 @@ case ,"$enable_testsuites", in #(
      ;;
 esac
 case ,"$enable_testsuites", in #(
+  *,opencv,*|*,OpenCV,*) :
+
+    enable_testsuite_opencv=yes
+   ;; #(
+  *) :
+     ;;
+esac
+case ,"$enable_testsuites", in #(
   *,cloverleaf,*|*,CloverLeaf,*) :
 
     enable_testsuite_cloverleaf=yes
@@ -17254,6 +17903,14 @@ $as_echo "$as_me: WARNING: disabling Piglit testsuite: piglit-run.py not found i
   fi
 fi
 
+if test "$enable_testsuite_opencv" = "yes" ; then
+  if ! test -f "$srcdir/examples/OpenCV/opencv-3.0.0-beta.zip" ; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: disabling OpenCV testsuite: opencv-3.0.0-beta.zip not found in '$srcdir/examples/OpenCV'" >&5
+$as_echo "$as_me: WARNING: disabling OpenCV testsuite: opencv-3.0.0-beta.zip not found in '$srcdir/examples/OpenCV'" >&2;}
+    enable_testsuite_opencv=no
+  fi
+fi
+
  if test "$enable_testsuite_opencl_book_samples" = "yes"; then
   TEST_SUITE_SAMPLES_TRUE=
   TEST_SUITE_SAMPLES_FALSE='#'
@@ -17326,6 +17983,14 @@ else
   TEST_SUITE_HALIDE_FALSE=
 fi
 
+ if test "$enable_testsuite_opencv" = "yes"; then
+  TEST_SUITE_OPENCV_TRUE=
+  TEST_SUITE_OPENCV_FALSE='#'
+else
+  TEST_SUITE_OPENCV_TRUE='#'
+  TEST_SUITE_OPENCV_FALSE=
+fi
+
  if test "$enable_testsuite_cloverleaf" = "yes"; then
   TEST_SUITE_CLOVERLEAF_TRUE=
   TEST_SUITE_CLOVERLEAF_FALSE='#'
@@ -17411,6 +18076,14 @@ else
   { $as_echo "$as_me:${as_lineno-$LINENO}: tests from Halide are disabled" >&5
 $as_echo "$as_me: tests from Halide are disabled" >&6;}
 fi
+if test "$enable_testsuite_opencv" = "yes"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: tests from OpenCV are enabled" >&5
+$as_echo "$as_me: tests from OpenCV are enabled" >&6;}
+  POAT_TESTSUITES="$POAT_TESTSUITES OpenCV"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: tests from OpenCV are disabled" >&5
+$as_echo "$as_me: tests from OpenCV are disabled" >&6;}
+fi
 if test "$enable_testsuite_cloverleaf" = "yes"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: tests from CloverLeaf are enabled" >&5
 $as_echo "$as_me: tests from CloverLeaf are enabled" >&6;}
@@ -17421,9 +18094,6 @@ $as_echo "$as_me: tests from CloverLeaf are disabled" >&6;}
 fi
 
 
-
-
-
 ####################################################################
 # Pthread Library
 
@@ -18183,26 +18853,7 @@ if test x"$ioh" = "yes"; then
    CPPFLAGS="-Iinclude $CPPFLAGS"
 fi
 
-# Check for OpenGL.h headers as they are required to compile
-# test cases that use cl.hpp (which requires it).
-for ac_header in GL/gl.h OpenGL/OpenGL.h
-do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
- opengl_found="ok"; break
-fi
-
-done
-
-test -z "$opengl_found" && \
-{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "Please install an OpenGL implementation with gl.h or OpenGL.h. It is required by the C++ bindings.
-See \`config.log' for more details" "$LINENO" 5; }
+# Using cl2.hpp shipped with pocl
  if true; then
   HAVE_OPENCL_HPP_TRUE=
   HAVE_OPENCL_HPP_FALSE='#'
@@ -18685,18 +19336,24 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
 #
 # A few work-arounds for llvm-config issues
-# - '-fno-rtti' is a work-around for llvm bug 14200
+# - '-fno-rtti' is a work-around for llvm bug 14200 - this should be fixed in 3.7
 # - '-DNDEBUG' is a work-around for llvm bug 18253
 # - pocl doesn't compile with '-pedantic'
 
 LLVM_CXX_FLAGS=$($LLVM_CONFIG --cxxflags | sed -e 's/ -pedantic / /g')
-LLVM_CXX_FLAGS="$LLVM_CXX_FLAGS -fno-rtti"
+LLVM_MINOR=$(echo $LLVM_VERSION | cut -d '.' -f 2)
+if test $LLVM_MINOR -lt 7; then
+  LLVM_CXX_FLAGS="$LLVM_CXX_FLAGS -fno-rtti"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: Detected LLVM 3.7+, not adding -fno-rtti to LLVM CXXFLAGS" >&5
+$as_echo "$as_me: Detected LLVM 3.7+, not adding -fno-rtti to LLVM CXXFLAGS" >&6;}
+fi
 
 # llvm-config does not always report the "-DNDEBUG" flag correctly
 # (see LLVM bug 18253). If LLVM and the pocl passes are built with
 # different NDEBUG settings, problems arise
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if LLVM is built with assertions" >&5
-$as_echo_n "checking if LLVM is built with assertions... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if llvm-config reports -DNDEBUG properly" >&5
+$as_echo_n "checking if llvm-config reports -DNDEBUG properly... " >&6; }
 CXXFLAGS="$CXXFLAGS $($LLVM_CONFIG --cxxflags) -UNDEBUG"
 LIBS="$LIBS $($LLVM_CONFIG --libs)"
 LDFLAGS="$LDFLAGS $LLVM_LDFLAGS"
@@ -19770,6 +20427,290 @@ else
 fi
 
 
+# Enable HSA by default in case the dependencies are met.
+# Check whether --enable-hsa-amdgcn was given.
+if test "${enable_hsa_amdgcn+set}" = set; then :
+  enableval=$enable_hsa_amdgcn; enable_hsa="$enableval"
+else
+  enable_hsa="yes"
+fi
+
+
+HSA_RUNTIME_DIR=""
+
+# Check whether --with-hsa-runtime-dir was given.
+if test "${with_hsa_runtime_dir+set}" = set; then :
+  withval=$with_hsa_runtime_dir;
+  HSA_RUNTIME_DIR="${withval}"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: Using provided HSA runtime location: ${HSA_RUNTIME_DIR}" >&5
+$as_echo "$as_me: Using provided HSA runtime location: ${HSA_RUNTIME_DIR}" >&6;}
+
+else
+
+  HSA_RUNTIME_DIR="/opt/hsa"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: Using default HSA runtime location: ${HSA_RUNTIME_DIR}" >&5
+$as_echo "$as_me: Using default HSA runtime location: ${HSA_RUNTIME_DIR}" >&6;}
+
+
+fi
+
+
+HSA_INCLUDES="-I${HSA_RUNTIME_DIR}/include"
+
+
+# Search for the HSA runtime lib.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for HSA runtime" >&5
+$as_echo_n "checking for HSA runtime... " >&6; }
+old_LIBS="$LIBS"
+old_LDFLAGS="$LDFLAGS"
+LDFLAGS="$LDFLAGS -L${HSA_RUNTIME_DIR}/lib"
+LIBS=""
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing hsa_executable_get_symbol" >&5
+$as_echo_n "checking for library containing hsa_executable_get_symbol... " >&6; }
+if ${ac_cv_search_hsa_executable_get_symbol+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char hsa_executable_get_symbol ();
+int
+main ()
+{
+return hsa_executable_get_symbol ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' hsa-runtime64; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_cxx_try_link "$LINENO"; then :
+  ac_cv_search_hsa_executable_get_symbol=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if ${ac_cv_search_hsa_executable_get_symbol+:} false; then :
+  break
+fi
+done
+if ${ac_cv_search_hsa_executable_get_symbol+:} false; then :
+
+else
+  ac_cv_search_hsa_executable_get_symbol=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_hsa_executable_get_symbol" >&5
+$as_echo "$ac_cv_search_hsa_executable_get_symbol" >&6; }
+ac_res=$ac_cv_search_hsa_executable_get_symbol
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+HSA_LIBS="$LIBS"
+
+
+else
+
+enable_hsa=no
+LDFLAGS="$old_LDFLAGS"
+
+fi
+
+LIBS=$old_LIBS
+
+# test that Clang supports the amdgcn--amdhsa target
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+
+_ACEOF
+
+LLVM_AMDGCN_TARGET=no
+
+# TODO The native compilation for AMDGCN via the HSA driver.
+#AC_MSG_CHECKING([if the amdgcn--amdhsa target is supported in Clang/LLVM])
+#if $LLVM_BINDIR/clang conftest.c -target amdgcn--amdhsa -emit-llvm -S -c -o - 2>/dev/null | grep -cq 'target triple = "amdgcn--amdhsa"';
+#then
+#   AC_MSG_RESULT([yes])
+#   LLVM_AMDGCN_TARGET=yes
+#   AC_DEFINE([AMDGCN_ENABLED], [1], [Defined in case AMDGCN device support enabled.])
+#
+#else
+#   AC_MSG_RESULT([no])
+#   enable_hsa=no
+#fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the hsail64 target is supported in Clang/LLVM" >&5
+$as_echo_n "checking if the hsail64 target is supported in Clang/LLVM... " >&6; }
+if $LLVM_BINDIR/clang conftest.c -target hsail64 -emit-llvm -S -c -o - 2>/dev/null | grep -cq 'target triple = "hsail64"';
+then
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+   LLVM_HSAIL64_TARGET=yes
+else
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+   enable_hsa=no
+fi
+
+tempCPPFLAGS=$CPPFLAGS
+CPPFLAGS="$CPPFLAGS -I${HSA_RUNTIME_DIR}/include"
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for HSA runtime headers" >&5
+$as_echo_n "checking for HSA runtime headers... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+ #include <hsa.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+enable_hsa="no"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+CPPFLAGS=$tempCPPFLAGS
+
+
+for ac_prog in HSAILasm
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_HSAILASM+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $HSAILASM in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_HSAILASM="$HSAILASM" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_HSAILASM="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+HSAILASM=$ac_cv_path_HSAILASM
+if test -n "$HSAILASM"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HSAILASM" >&5
+$as_echo "$HSAILASM" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$HSAILASM" && break
+done
+
+if test ! -z "$HSAILASM"; then
+
+cat >>confdefs.h <<_ACEOF
+#define HSAIL_ASM "$HSAILASM"
+_ACEOF
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find HSAILasm executable, disabling HSA support" >&5
+$as_echo "$as_me: Could not find HSAILasm executable, disabling HSA support" >&6;}
+  enable_hsa="no"
+fi
+
+if test "$enable_hsa" = "yes";
+then
+  OCL_DRIVERS="$OCL_DRIVERS hsa"
+  OCL_TARGETS="$OCL_TARGETS hsail64"
+
+$as_echo "#define BUILD_HSA 1" >>confdefs.h
+
+  enable_testsuite_hsa=yes
+  POAT_TESTSUITES="$POAT_TESTSUITES hsa"
+
+  # -lHSAILUtil is missing from llvm-config --libfiles
+  LLVM_LIBS="$LLVM_LIBS -lLLVMHSAILUtil"
+fi
+
+# TODO: move above
+
+# Enable the HSA test suite in case HSA support enabled.
+ if test "$enable_testsuite_hsa" = "yes"; then
+  TEST_SUITE_HSA_TRUE=
+  TEST_SUITE_HSA_FALSE='#'
+else
+  TEST_SUITE_HSA_TRUE='#'
+  TEST_SUITE_HSA_FALSE=
+fi
+
+
+
+ if echo $OCL_TARGETS | grep amdgcn; then
+  BUILD_AMDGCN_TRUE=
+  BUILD_AMDGCN_FALSE='#'
+else
+  BUILD_AMDGCN_TRUE='#'
+  BUILD_AMDGCN_FALSE=
+fi
+
+ if echo $OCL_DRIVERS | grep hsa; then
+  BUILD_HSA_TRUE=
+  BUILD_HSA_FALSE='#'
+else
+  BUILD_HSA_TRUE='#'
+  BUILD_HSA_FALSE=
+fi
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: Building the following device drivers: $OCL_DRIVERS" >&5
 $as_echo "$as_me: Building the following device drivers: $OCL_DRIVERS" >&6;}
 
@@ -20553,9 +21494,10 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
 # 3:0:2 == 0.9 (currently backwards compatible with 0.7, thus age = 2).
 # 4:0:3 == 0.10 (currently backwards compatible with 0.7, thus age = 3).
 # 5:0:4 == 0.11 (currently backwards compatible with 0.7, thus age = 4).
-LIB_CURRENT_VERSION=5
+# 6:0:5 == 0.12 (currently backwards compatible with 0.7, thus age = 5).
+LIB_CURRENT_VERSION=6
 LIB_REVISION_VERSION=0
-LIB_AGE_VERSION=4
+LIB_AGE_VERSION=5
 LIB_FIRST_VERSION=$(($LIB_CURRENT_VERSION - $LIB_AGE_VERSION))
 BUILD_TIMESTAMP=""
 LIB_VERSION="$LIB_CURRENT_VERSION:$LIB_REVISION_VERSION:$LIB_AGE_VERSION"
@@ -20585,7 +21527,7 @@ KERNEL_COMPILER_LIB_VERSION="$LIB_CURRENT_VERSION:0:0"
 
 
 
-ac_config_files="$ac_config_files Makefile pocl.pc tests/atlocal ocl-vendors/pocl-tests.icd include/Makefile include/CL/Makefile include/OpenCL/Makefile lib/Makefile lib/CL/Makefile lib/CL/devices/Makefile lib/CL/devices/pthread/Makefile lib/CL/devices/basic/Makefile lib/CL/devices/tce/Makefile lib/CL/devices/tce/ttasim/Makefile lib/CL/devices/topology/Makefile lib/CL/devices/cellspu/Makefile lib/llvmopencl/Makefile lib/kernel/Makefile lib/kernel/cellspu/Makefile lib/kernel/host/Makefile [...]
+ac_config_files="$ac_config_files Makefile pocl.pc tests/atlocal ocl-vendors/pocl-tests.icd include/Makefile include/CL/Makefile include/OpenCL/Makefile lib/Makefile lib/CL/Makefile lib/CL/devices/Makefile lib/CL/devices/pthread/Makefile lib/CL/devices/basic/Makefile lib/CL/devices/tce/Makefile lib/CL/devices/tce/ttasim/Makefile lib/CL/devices/topology/Makefile lib/CL/devices/cellspu/Makefile lib/CL/devices/hsa/Makefile lib/llvmopencl/Makefile lib/kernel/Makefile lib/kernel/cellspu/Makef [...]
 
 
 cat >confcache <<\_ACEOF
@@ -20785,6 +21727,10 @@ if test -z "${TEST_SUITE_HALIDE_TRUE}" && test -z "${TEST_SUITE_HALIDE_FALSE}";
   as_fn_error $? "conditional \"TEST_SUITE_HALIDE\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${TEST_SUITE_OPENCV_TRUE}" && test -z "${TEST_SUITE_OPENCV_FALSE}"; then
+  as_fn_error $? "conditional \"TEST_SUITE_OPENCV\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${TEST_SUITE_CLOVERLEAF_TRUE}" && test -z "${TEST_SUITE_CLOVERLEAF_FALSE}"; then
   as_fn_error $? "conditional \"TEST_SUITE_CLOVERLEAF\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -20837,6 +21783,18 @@ if test -z "${BUILD_SPU_TRUE}" && test -z "${BUILD_SPU_FALSE}"; then
   as_fn_error $? "conditional \"BUILD_SPU\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${TEST_SUITE_HSA_TRUE}" && test -z "${TEST_SUITE_HSA_FALSE}"; then
+  as_fn_error $? "conditional \"TEST_SUITE_HSA\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${BUILD_AMDGCN_TRUE}" && test -z "${BUILD_AMDGCN_FALSE}"; then
+  as_fn_error $? "conditional \"BUILD_AMDGCN\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${BUILD_HSA_TRUE}" && test -z "${BUILD_HSA_FALSE}"; then
+  as_fn_error $? "conditional \"BUILD_HSA\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 
 
 : "${CONFIG_STATUS=./config.status}"
@@ -21235,7 +22193,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by pocl $as_me 0.11, which was
+This file was extended by pocl $as_me 0.12, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -21301,7 +22259,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-pocl config.status 0.11
+pocl config.status 0.12
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
@@ -21437,6 +22395,7 @@ enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`'
 enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`'
 pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`'
 enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`'
+shared_archive_member_spec='`$ECHO "$shared_archive_member_spec" | $SED "$delay_single_quote_subst"`'
 SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`'
 ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`'
 PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`'
@@ -21486,10 +22445,13 @@ compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`'
 GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`'
 lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`'
 lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_import='`$ECHO "$lt_cv_sys_global_symbol_to_import" | $SED "$delay_single_quote_subst"`'
 lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`'
 lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`'
+lt_cv_nm_interface='`$ECHO "$lt_cv_nm_interface" | $SED "$delay_single_quote_subst"`'
 nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`'
 lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`'
+lt_cv_truncate_bin='`$ECHO "$lt_cv_truncate_bin" | $SED "$delay_single_quote_subst"`'
 objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`'
 MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`'
 lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`'
@@ -21554,7 +22516,8 @@ finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`'
 finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`'
 hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`'
 sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`'
-sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`'
+configure_time_dlsearch_path='`$ECHO "$configure_time_dlsearch_path" | $SED "$delay_single_quote_subst"`'
+configure_time_lt_sys_library_path='`$ECHO "$configure_time_lt_sys_library_path" | $SED "$delay_single_quote_subst"`'
 hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`'
 enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`'
 enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`'
@@ -21659,9 +22622,12 @@ CFLAGS \
 compiler \
 lt_cv_sys_global_symbol_pipe \
 lt_cv_sys_global_symbol_to_cdecl \
+lt_cv_sys_global_symbol_to_import \
 lt_cv_sys_global_symbol_to_c_name_address \
 lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \
+lt_cv_nm_interface \
 nm_file_list_spec \
+lt_cv_truncate_bin \
 lt_prog_compiler_no_builtin_flag \
 lt_prog_compiler_pic \
 lt_prog_compiler_wl \
@@ -21727,7 +22693,7 @@ postdeps_CXX \
 compiler_lib_search_path_CXX; do
     case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
     *[\\\\\\\`\\"\\\$]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
       ;;
     *)
       eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -21754,7 +22720,8 @@ postinstall_cmds \
 postuninstall_cmds \
 finish_cmds \
 sys_lib_search_path_spec \
-sys_lib_dlsearch_path_spec \
+configure_time_dlsearch_path \
+configure_time_lt_sys_library_path \
 reload_cmds_CXX \
 old_archive_cmds_CXX \
 old_archive_from_new_cmds_CXX \
@@ -21768,7 +22735,7 @@ prelink_cmds_CXX \
 postlink_cmds_CXX; do
     case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
     *[\\\\\\\`\\"\\\$]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
       ;;
     *)
       eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -21777,19 +22744,16 @@ postlink_cmds_CXX; do
 done
 
 ac_aux_dir='$ac_aux_dir'
-xsi_shell='$xsi_shell'
-lt_shell_append='$lt_shell_append'
 
-# See if we are running on zsh, and set the options which allow our
+# See if we are running on zsh, and set the options that allow our
 # commands through without removal of \ escapes INIT.
-if test -n "\${ZSH_VERSION+set}" ; then
+if test -n "\${ZSH_VERSION+set}"; then
    setopt NO_GLOB_SUBST
 fi
 
 
     PACKAGE='$PACKAGE'
     VERSION='$VERSION'
-    TIMESTAMP='$TIMESTAMP'
     RM='$RM'
     ofile='$ofile'
 
@@ -21826,11 +22790,13 @@ do
     "lib/CL/devices/tce/ttasim/Makefile") CONFIG_FILES="$CONFIG_FILES lib/CL/devices/tce/ttasim/Makefile" ;;
     "lib/CL/devices/topology/Makefile") CONFIG_FILES="$CONFIG_FILES lib/CL/devices/topology/Makefile" ;;
     "lib/CL/devices/cellspu/Makefile") CONFIG_FILES="$CONFIG_FILES lib/CL/devices/cellspu/Makefile" ;;
+    "lib/CL/devices/hsa/Makefile") CONFIG_FILES="$CONFIG_FILES lib/CL/devices/hsa/Makefile" ;;
     "lib/llvmopencl/Makefile") CONFIG_FILES="$CONFIG_FILES lib/llvmopencl/Makefile" ;;
     "lib/kernel/Makefile") CONFIG_FILES="$CONFIG_FILES lib/kernel/Makefile" ;;
     "lib/kernel/cellspu/Makefile") CONFIG_FILES="$CONFIG_FILES lib/kernel/cellspu/Makefile" ;;
     "lib/kernel/host/Makefile") CONFIG_FILES="$CONFIG_FILES lib/kernel/host/Makefile" ;;
     "lib/kernel/tce/Makefile") CONFIG_FILES="$CONFIG_FILES lib/kernel/tce/Makefile" ;;
+    "lib/kernel/hsail64/Makefile") CONFIG_FILES="$CONFIG_FILES lib/kernel/hsail64/Makefile" ;;
     "lib/poclu/Makefile") CONFIG_FILES="$CONFIG_FILES lib/poclu/Makefile" ;;
     "examples/Makefile") CONFIG_FILES="$CONFIG_FILES examples/Makefile" ;;
     "examples/example1/Makefile") CONFIG_FILES="$CONFIG_FILES examples/example1/Makefile" ;;
@@ -21851,6 +22817,7 @@ do
     "examples/VexCL/Makefile") CONFIG_FILES="$CONFIG_FILES examples/VexCL/Makefile" ;;
     "examples/piglit/Makefile") CONFIG_FILES="$CONFIG_FILES examples/piglit/Makefile" ;;
     "examples/Halide/Makefile") CONFIG_FILES="$CONFIG_FILES examples/Halide/Makefile" ;;
+    "examples/OpenCV/Makefile") CONFIG_FILES="$CONFIG_FILES examples/OpenCV/Makefile" ;;
     "examples/CloverLeaf/Makefile") CONFIG_FILES="$CONFIG_FILES examples/CloverLeaf/Makefile" ;;
     "scripts/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/Makefile" ;;
     "tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;;
@@ -22577,55 +23544,53 @@ $as_echo X"$file" |
  ;;
     "libtool":C)
 
-    # See if we are running on zsh, and set the options which allow our
+    # See if we are running on zsh, and set the options that allow our
     # commands through without removal of \ escapes.
-    if test -n "${ZSH_VERSION+set}" ; then
+    if test -n "${ZSH_VERSION+set}"; then
       setopt NO_GLOB_SUBST
     fi
 
-    cfgfile="${ofile}T"
+    cfgfile=${ofile}T
     trap "$RM \"$cfgfile\"; exit 1" 1 2 15
     $RM "$cfgfile"
 
     cat <<_LT_EOF >> "$cfgfile"
 #! $SHELL
-
-# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Generated automatically by $as_me ($PACKAGE) $VERSION
 # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
+
+# Provide generalized library-building support services.
+# Written by Gordon Matzigkeit, 1996
+
+# Copyright (C) 2014 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# GNU Libtool is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of of the License, or
+# (at your option) any later version.
 #
-#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-#                 Foundation, Inc.
-#   Written by Gordon Matzigkeit, 1996
-#
-#   This file is part of GNU Libtool.
-#
-# GNU Libtool is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 2 of
-# the License, or (at your option) any later version.
-#
-# As a special exception to the GNU General Public License,
-# if you distribute this file as part of a program or library that
-# is built using GNU Libtool, you may include this file under the
-# same distribution terms that you use for the rest of that program.
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program or library that is built
+# using GNU Libtool, you may include this file under the  same
+# distribution terms that you use for the rest of that program.
 #
-# GNU Libtool is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# GNU Libtool is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with GNU Libtool; see the file COPYING.  If not, a copy
-# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
-# obtained by writing to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
 # The names of the tagged configurations supported by this script.
-available_tags="CXX "
+available_tags='CXX '
+
+# Configured defaults for sys_lib_dlsearch_path munging.
+: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"}
 
 # ### BEGIN LIBTOOL CONFIG
 
@@ -22645,6 +23610,9 @@ pic_mode=$pic_mode
 # Whether or not to optimize for fast installation.
 fast_install=$enable_fast_install
 
+# Shared archive member basename,for filename based shared library versioning on AIX.
+shared_archive_member_spec=$shared_archive_member_spec
+
 # Shell to use when invoking shell scripts.
 SHELL=$lt_SHELL
 
@@ -22762,18 +23730,27 @@ global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
 # Transform the output of nm in a proper C declaration.
 global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
 
+# Transform the output of nm into a list of symbols to manually relocate.
+global_symbol_to_import=$lt_lt_cv_sys_global_symbol_to_import
+
 # Transform the output of nm in a C name address pair.
 global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
 
 # Transform the output of nm in a C name address pair when lib prefix is needed.
 global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix
 
+# The name lister interface.
+nm_interface=$lt_lt_cv_nm_interface
+
 # Specify filename containing input files for \$NM.
 nm_file_list_spec=$lt_nm_file_list_spec
 
-# The root where to search for dependent libraries,and in which our libraries should be installed.
+# The root where to search for dependent libraries,and where our libraries should be installed.
 lt_sysroot=$lt_sysroot
 
+# Command to truncate a binary pipe.
+lt_truncate_bin=$lt_lt_cv_truncate_bin
+
 # The name of the directory that contains temporary libtool files.
 objdir=$objdir
 
@@ -22864,8 +23841,11 @@ hardcode_into_libs=$hardcode_into_libs
 # Compile-time system search path for libraries.
 sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
 
-# Run-time system search path for libraries.
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+# Detected run-time system search path for libraries.
+sys_lib_dlsearch_path_spec=$lt_configure_time_dlsearch_path
+
+# Explicit LT_SYS_LIBRARY_PATH set during ./configure time.
+configure_time_lt_sys_library_path=$lt_configure_time_lt_sys_library_path
 
 # Whether dlopen is supported.
 dlopen_support=$enable_dlopen
@@ -22958,13 +23938,13 @@ hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
 # Whether we need a single "-rpath" flag with a separated argument.
 hardcode_libdir_separator=$lt_hardcode_libdir_separator
 
-# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes
 # DIR into the resulting binary.
 hardcode_direct=$hardcode_direct
 
-# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes
 # DIR into the resulting binary and the resulting library dependency is
-# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# "absolute",i.e impossible to change by setting \$shlibpath_var if the
 # library is relocated.
 hardcode_direct_absolute=$hardcode_direct_absolute
 
@@ -23030,13 +24010,72 @@ compiler_lib_search_path=$lt_compiler_lib_search_path
 
 _LT_EOF
 
+    cat <<'_LT_EOF' >> "$cfgfile"
+
+# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE
+
+# func_munge_path_list VARIABLE PATH
+# -----------------------------------
+# VARIABLE is name of variable containing _space_ separated list of
+# directories to be munged by the contents of PATH, which is string
+# having a format:
+# "DIR[:DIR]:"
+#       string "DIR[ DIR]" will be prepended to VARIABLE
+# ":DIR[:DIR]"
+#       string "DIR[ DIR]" will be appended to VARIABLE
+# "DIRP[:DIRP]::[DIRA:]DIRA"
+#       string "DIRP[ DIRP]" will be prepended to VARIABLE and string
+#       "DIRA[ DIRA]" will be appended to VARIABLE
+# "DIR[:DIR]"
+#       VARIABLE will be replaced by "DIR[ DIR]"
+func_munge_path_list ()
+{
+    case x$2 in
+    x)
+        ;;
+    *:)
+        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\"
+        ;;
+    x:*)
+        eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\"
+        ;;
+    *::*)
+        eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"
+        eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\"
+        ;;
+    *)
+        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\"
+        ;;
+    esac
+}
+
+
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+func_cc_basename ()
+{
+    for cc_temp in $*""; do
+      case $cc_temp in
+        compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+        distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+        \-*) ;;
+        *) break;;
+      esac
+    done
+    func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+}
+
+
+# ### END FUNCTIONS SHARED WITH CONFIGURE
+
+_LT_EOF
+
   case $host_os in
   aix3*)
     cat <<\_LT_EOF >> "$cfgfile"
 # AIX sometimes has problems with the GCC collect2 program.  For some
 # reason, if we set the COLLECT_NAMES environment variable, the problems
 # vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
+if test set != "${COLLECT_NAMES+set}"; then
   COLLECT_NAMES=
   export COLLECT_NAMES
 fi
@@ -23045,7 +24084,7 @@ _LT_EOF
   esac
 
 
-ltmain="$ac_aux_dir/ltmain.sh"
+ltmain=$ac_aux_dir/ltmain.sh
 
 
   # We use sed instead of cat because bash on DJGPP gets confused if
@@ -23055,165 +24094,6 @@ ltmain="$ac_aux_dir/ltmain.sh"
   sed '$q' "$ltmain" >> "$cfgfile" \
      || (rm -f "$cfgfile"; exit 1)
 
-  if test x"$xsi_shell" = xyes; then
-  sed -e '/^func_dirname ()$/,/^} # func_dirname /c\
-func_dirname ()\
-{\
-\    case ${1} in\
-\      */*) func_dirname_result="${1%/*}${2}" ;;\
-\      *  ) func_dirname_result="${3}" ;;\
-\    esac\
-} # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_basename ()$/,/^} # func_basename /c\
-func_basename ()\
-{\
-\    func_basename_result="${1##*/}"\
-} # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\
-func_dirname_and_basename ()\
-{\
-\    case ${1} in\
-\      */*) func_dirname_result="${1%/*}${2}" ;;\
-\      *  ) func_dirname_result="${3}" ;;\
-\    esac\
-\    func_basename_result="${1##*/}"\
-} # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_stripname ()$/,/^} # func_stripname /c\
-func_stripname ()\
-{\
-\    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\
-\    # positional parameters, so assign one to ordinary parameter first.\
-\    func_stripname_result=${3}\
-\    func_stripname_result=${func_stripname_result#"${1}"}\
-\    func_stripname_result=${func_stripname_result%"${2}"}\
-} # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\
-func_split_long_opt ()\
-{\
-\    func_split_long_opt_name=${1%%=*}\
-\    func_split_long_opt_arg=${1#*=}\
-} # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\
-func_split_short_opt ()\
-{\
-\    func_split_short_opt_arg=${1#??}\
-\    func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\
-} # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\
-func_lo2o ()\
-{\
-\    case ${1} in\
-\      *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\
-\      *)    func_lo2o_result=${1} ;;\
-\    esac\
-} # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_xform ()$/,/^} # func_xform /c\
-func_xform ()\
-{\
-    func_xform_result=${1%.*}.lo\
-} # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_arith ()$/,/^} # func_arith /c\
-func_arith ()\
-{\
-    func_arith_result=$(( $* ))\
-} # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_len ()$/,/^} # func_len /c\
-func_len ()\
-{\
-    func_len_result=${#1}\
-} # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-fi
-
-if test x"$lt_shell_append" = xyes; then
-  sed -e '/^func_append ()$/,/^} # func_append /c\
-func_append ()\
-{\
-    eval "${1}+=\\${2}"\
-} # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\
-func_append_quoted ()\
-{\
-\    func_quote_for_eval "${2}"\
-\    eval "${1}+=\\\\ \\$func_quote_for_eval_result"\
-} # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  # Save a `func_append' function call where possible by direct use of '+='
-  sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-else
-  # Save a `func_append' function call even when '+=' is not available
-  sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-fi
-
-if test x"$_lt_function_replace_fail" = x":"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5
-$as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;}
-fi
-
-
    mv -f "$cfgfile" "$ofile" ||
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
@@ -23300,13 +24180,13 @@ hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX
 # Whether we need a single "-rpath" flag with a separated argument.
 hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX
 
-# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes
 # DIR into the resulting binary.
 hardcode_direct=$hardcode_direct_CXX
 
-# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes
 # DIR into the resulting binary and the resulting library dependency is
-# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# "absolute",i.e impossible to change by setting \$shlibpath_var if the
 # library is relocated.
 hardcode_direct_absolute=$hardcode_direct_absolute_CXX
 
diff --git a/configure.ac b/configure.ac
index 9c0be35..06f1133 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@
 # THE SOFTWARE.
 
 AC_PREREQ([2.64])
-AC_INIT([pocl], [0.11], [pocl-devel at lists.sourceforge.net])
+AC_INIT([pocl], [0.12], [pocl-devel at lists.sourceforge.net])
 AC_CONFIG_SRCDIR([config.h.in])
 AC_CONFIG_HEADER([config.h])
 AC_CONFIG_AUX_DIR([config])
@@ -99,25 +99,29 @@ case "$LLVM_VERSION" in
      NEW_PRINTF_WORKS=false
    ;;
      3.3*)
-     AC_DEFINE([LLVM_3_3], [], "Using LLVM 3.3")     
+     AC_DEFINE([LLVM_3_3], [], "Using LLVM 3.3")
      NEW_PRINTF_WORKS=false
-   ;; 
+   ;;
      3.4*)
-     AC_DEFINE([LLVM_3_4], [], "Using LLVM 3.4")     
-   ;;   
+     AC_DEFINE([LLVM_3_4], [], "Using LLVM 3.4")
+   ;;
      3.5*)
      AC_DEFINE([LLVM_3_5], [], "Using LLVM 3.5")
      LLVM_LDFLAGS="$LLVM_LDFLAGS `$LLVM_CONFIG --system-libs`"
    ;;
      3.6*)
-     AC_DEFINE([LLVM_3_6], [], "Using LLVM svn, upcoming 3.6")
+     AC_DEFINE([LLVM_3_6], [], "Using LLVM 3.6")
      LLVM_3_6=true
      LLVM_LDFLAGS="$LLVM_LDFLAGS `$LLVM_CONFIG --system-libs`"
    ;;
+     3.7*)
+     AC_DEFINE([LLVM_3_7], [], "Using LLVM svn, upcoming 3.7")
+     LLVM_LDFLAGS="$LLVM_LDFLAGS `$LLVM_CONFIG --system-libs`"
+   ;;
      *)
    AC_MSG_ERROR(
    [
-Unsupported LLVM version. Please use LLVM version 3.2, 3.3, 3.4, 3.5 or 3.6.
+Unsupported LLVM version. Please use LLVM version 3.2, 3.3, 3.4, 3.5, 3.6, 3.7.
    ])
    LLVM_VERSION=
    ;;
@@ -143,16 +147,31 @@ if test "$link_llvm_static" = "yes"; then
   LLVM_LIBS=$($LLVM_CONFIG --libfiles)
 else
   LLVM_LIBS=-lLLVM-$LLVM_VERSION
-if test ! -e $LLVM_SHARED_LIB_FILE;
-then
-  LLVM_LIBS=$($LLVM_CONFIG --libs)
-  AC_MSG_NOTICE([
-$LLVM_SHARED_LIB_FILE not found. LLVM is built with cmake.])
-fi
+  if test ! -e $LLVM_SHARED_LIB_FILE;
+  then
+    # Cmake's -DLLVM_BUILD_LLVM_DYLIB=on builds a dynlib
+    # named libLLVM.so.VERSION. Let's see if we can find it.
+    LLVM_SHARED_LIB_FILE=$LLVM_LIBDIR/libLLVM$LIBRARY_SUFFIX.$LLVM_VERSION
+    if test ! -e $LLVM_SHARED_LIB_FILE;
+    then
+      LLVM_LIBS=$($LLVM_CONFIG --libs)
+      AC_MSG_NOTICE([LLVM shared library $LLVM_SHARED_LIB_FILE not found.])
+    else
+      # The Cmake built libLLVM.so seems to be missing a lot of symbols
+      # to the point of being useless. Fall back to the static lib.
+      LLVM_LIBS=$($LLVM_CONFIG --libs)
+      AC_MSG_NOTICE([LLVM shared library $LLVM_SHARED_LIB_FILE built with cmake found, using the static lib instead.])
+    fi
+  fi
 fi
 
 AC_SUBST([LLVM_LIBS])
 
+if `$LLVM_CONFIG --build-mode | grep -q Asserts`;
+then
+AC_DEFINE([LLVM_BUILT_WITH_ASSERTS], [], "LLVM was built with Assertions on.")
+fi
+
 LLVM_RTTI_CHECK=$($LLVM_CONFIG --cxxflags | grep -i "\-fno-rtti")
 
 if test x"$LLVM_RTTI_CHECK" != x; then
@@ -175,7 +194,7 @@ AC_DEFINE([CUSTOM_BUFFER_ALLOCATOR], [], "Use a custom buffer allocator")
 # Option to choose external testsuites
 AC_ARG_ENABLE([testsuites],
 	      [AS_HELP_STRING([--enable-testsuites=suite1,suite2,...],
-          [choose enabled external project testsuites (all,opencl-book-samples,ViennaCL,Rodinia,Parboil,amd,amdsdk2_9,VexCL,Piglit,Halide,CloverLeaf])],
+          [choose enabled external project testsuites (all,opencl-book-samples,ViennaCL,Rodinia,Parboil,amd,amdsdk2_9,VexCL,Piglit,Halide,OpenCV,CloverLeaf,hsa])],
 	      [],[enable_testsuites=check])
 
 enable_testsuite_opencl_book_samples=no
@@ -187,6 +206,8 @@ enable_testsuite_amdsdk2_9=no
 enable_testsuite_vexcl=no
 enable_testsuite_piglit=no
 enable_testsuite_halide=no
+enable_testsuite_opencv=no
+enable_testsuite_hsa=no
 if test x"$enable_testsuites" = xcheck ; then
   if test -d "$srcdir/examples/opencl-book-samples/checkout" ; then
     enable_testsuite_opencl_book_samples=yes
@@ -216,13 +237,16 @@ if test x"$enable_testsuites" = xcheck ; then
   fi  
   if test -f "$srcdir/examples/Halide/Halide/Makefile" ; then
     enable_testsuite_halide=yes
+  fi
+  if test -f "$srcdir/examples/OpenCV/opencv-3.0.0-beta.zip" ; then
+    enable_testsuite_opencv=yes
   fi  
   if test -f "$srcdir/examples/CloverLeaf/CloverLeaf_OpenCL/Makefile" ; then
     enable_testsuite_cloverleaf=yes
   fi  
 fi
 AS_CASE([,"$enable_testsuites",],
-  [*,all,*|*,yes,*], [enable_testsuites="opencl-book-samples,ViennaCL,Rodinia,Parboil,amd,amdsdk2_9,VexCL,piglit,Halide,CloverLeaf"],
+  [*,all,*|*,yes,*], [enable_testsuites="opencl-book-samples,ViennaCL,Rodinia,Parboil,amd,amdsdk2_9,VexCL,piglit,Halide,OpenCV,CloverLeaf"],
   [*,no,*], [enable_testsuites=""]
 )
 AS_CASE([,"$enable_testsuites",],
@@ -259,6 +283,10 @@ AS_CASE([,"$enable_testsuites",],
     enable_testsuite_halide=yes
   ])
 AS_CASE([,"$enable_testsuites",],
+  [*,opencv,*|*,OpenCV,*], [
+    enable_testsuite_opencv=yes
+  ])
+AS_CASE([,"$enable_testsuites",],
   [*,cloverleaf,*|*,CloverLeaf,*], [
     enable_testsuite_cloverleaf=yes
   ])
@@ -346,7 +374,14 @@ if test "$enable_testsuite_piglit" = "yes" ; then
     AC_MSG_WARN([disabling Piglit testsuite: piglit-run.py not found in '$srcdir/examples/piglit/piglit/'])
     enable_testsuite_piglit=no
   fi
-fi   
+fi
+
+if test "$enable_testsuite_opencv" = "yes" ; then
+  if ! test -f "$srcdir/examples/OpenCV/opencv-3.0.0-beta.zip" ; then
+    AC_MSG_WARN([disabling OpenCV testsuite: opencv-3.0.0-beta.zip not found in '$srcdir/examples/OpenCV'])
+    enable_testsuite_opencv=no
+  fi
+fi      
 
 AM_CONDITIONAL([TEST_SUITE_SAMPLES], [test "$enable_testsuite_opencl_book_samples" = "yes"])
 AM_CONDITIONAL([TEST_SUITE_VIENNACL], [test "$enable_testsuite_viennacl" = "yes"])
@@ -357,6 +392,7 @@ AM_CONDITIONAL([TEST_SUITE_AMDSDK2_9], [test "$enable_testsuite_amdsdk2_9" = "ye
 AM_CONDITIONAL([TEST_SUITE_VEXCL], [test "$enable_testsuite_vexcl" = "yes"])
 AM_CONDITIONAL([TEST_SUITE_PIGLIT], [test "$enable_testsuite_piglit" = "yes"])
 AM_CONDITIONAL([TEST_SUITE_HALIDE], [test "$enable_testsuite_halide" = "yes"])
+AM_CONDITIONAL([TEST_SUITE_OPENCV], [test "$enable_testsuite_opencv" = "yes"])
 AM_CONDITIONAL([TEST_SUITE_CLOVERLEAF], [test "$enable_testsuite_cloverleaf" = "yes"])
 
 # Some information for the user
@@ -416,6 +452,12 @@ if test "$enable_testsuite_halide" = "yes"; then
 else
   AC_MSG_NOTICE([tests from Halide are disabled])
 fi
+if test "$enable_testsuite_opencv" = "yes"; then
+  AC_MSG_NOTICE([tests from OpenCV are enabled])
+  POAT_TESTSUITES="$POAT_TESTSUITES OpenCV"
+else
+  AC_MSG_NOTICE([tests from OpenCV are disabled])
+fi
 if test "$enable_testsuite_cloverleaf" = "yes"; then
   AC_MSG_NOTICE([tests from CloverLeaf are enabled])
   POAT_TESTSUITES="$POAT_TESTSUITES CloverLeaf"
@@ -424,9 +466,6 @@ else
 fi
 
 
-AC_SUBST([POAT_TESTSUITES])
-
-
 ####################################################################
 # Pthread Library
 
@@ -582,11 +621,7 @@ if test x"$ioh" = "yes"; then
    CPPFLAGS="-Iinclude $CPPFLAGS"
 fi
 
-# Check for OpenGL.h headers as they are required to compile
-# test cases that use cl.hpp (which requires it).
-AC_CHECK_HEADERS([GL/gl.h OpenGL/OpenGL.h], [opengl_found="ok"; break])
-test -z "$opengl_found" && \
-AC_MSG_FAILURE([Please install an OpenGL implementation with gl.h or OpenGL.h. It is required by the C++ bindings.])
+# Using cl2.hpp shipped with pocl
 AM_CONDITIONAL([HAVE_OPENCL_HPP], true)
 AC_DEFINE([HAVE_OPENCL_HPP], [] ,[Defined if system cl.hpp found to be working])
 
@@ -752,17 +787,22 @@ AC_COMPILE_IFELSE(
 
 #
 # A few work-arounds for llvm-config issues
-# - '-fno-rtti' is a work-around for llvm bug 14200
+# - '-fno-rtti' is a work-around for llvm bug 14200 - this should be fixed in 3.7
 # - '-DNDEBUG' is a work-around for llvm bug 18253
 # - pocl doesn't compile with '-pedantic'
 
 LLVM_CXX_FLAGS=$($LLVM_CONFIG --cxxflags | sed -e 's/ -pedantic / /g')
-LLVM_CXX_FLAGS="$LLVM_CXX_FLAGS -fno-rtti"
+LLVM_MINOR=$(echo $LLVM_VERSION | cut -d '.' -f 2)
+if test $LLVM_MINOR -lt 7; then
+  LLVM_CXX_FLAGS="$LLVM_CXX_FLAGS -fno-rtti"
+else
+  AC_MSG_NOTICE([Detected LLVM 3.7+, not adding -fno-rtti to LLVM CXXFLAGS])
+fi
 
 # llvm-config does not always report the "-DNDEBUG" flag correctly
 # (see LLVM bug 18253). If LLVM and the pocl passes are built with 
 # different NDEBUG settings, problems arise 
-AC_MSG_CHECKING([if LLVM is built with assertions])
+AC_MSG_CHECKING([if llvm-config reports -DNDEBUG properly])
 CXXFLAGS="$CXXFLAGS $($LLVM_CONFIG --cxxflags) -UNDEBUG"
 LIBS="$LIBS $($LLVM_CONFIG --libs)"
 LDFLAGS="$LDFLAGS $LLVM_LDFLAGS"
@@ -1208,6 +1248,120 @@ PKG_CHECK_MODULES([LIBSPE], [libspe2 >= 2.2.80],
 fi
 AM_CONDITIONAL([BUILD_SPU],[echo $OCL_DRIVERS | grep spu])
 
+# Enable HSA by default in case the dependencies are met.
+AC_ARG_ENABLE([hsa-amdgcn],
+              [AS_HELP_STRING([--disable-hsa-amdgcn],
+              [Disable the HSA device driver for AMD GCN devices.])],
+              [enable_hsa="$enableval"], [enable_hsa="yes"])
+
+HSA_RUNTIME_DIR=""
+AC_ARG_WITH(hsa-runtime-dir,
+[AS_HELP_STRING([--with-hsa-runtime-dir],[absolute path where HSA runtime files (include,libs) are found, defaults to /opt/hsa])],
+[
+  HSA_RUNTIME_DIR="${withval}"
+  AC_MSG_NOTICE([Using provided HSA runtime location: ${HSA_RUNTIME_DIR}])
+],
+[
+  HSA_RUNTIME_DIR="/opt/hsa"
+  AC_MSG_NOTICE([Using default HSA runtime location: ${HSA_RUNTIME_DIR}])
+]
+)
+
+AC_SUBST([HSA_INCLUDES], ["-I${HSA_RUNTIME_DIR}/include"] )
+
+# Search for the HSA runtime lib.
+AC_MSG_CHECKING([for HSA runtime])
+old_LIBS="$LIBS"
+old_LDFLAGS="$LDFLAGS"
+LDFLAGS="$LDFLAGS -L${HSA_RUNTIME_DIR}/lib"
+LIBS=""
+AC_SEARCH_LIBS([hsa_executable_get_symbol], [hsa-runtime64], [
+HSA_LIBS="$LIBS"
+AC_SUBST([HSA_LIBS])
+],
+[
+enable_hsa=no
+LDFLAGS="$old_LDFLAGS"
+])
+LIBS=$old_LIBS
+
+# test that Clang supports the amdgcn--amdhsa target
+AC_LANG([C])
+ AC_LANG_CONFTEST(
+ [AC_LANG_PROGRAM(
+       [])
+       ])
+
+LLVM_AMDGCN_TARGET=no
+
+# TODO The native compilation for AMDGCN via the HSA driver.
+#AC_MSG_CHECKING([if the amdgcn--amdhsa target is supported in Clang/LLVM])
+#if $LLVM_BINDIR/clang conftest.c -target amdgcn--amdhsa -emit-llvm -S -c -o - 2>/dev/null | grep -cq 'target triple = "amdgcn--amdhsa"';
+#then
+#   AC_MSG_RESULT([yes])
+#   LLVM_AMDGCN_TARGET=yes
+#   AC_DEFINE([AMDGCN_ENABLED], [1], [Defined in case AMDGCN device support enabled.])
+#
+#else
+#   AC_MSG_RESULT([no])
+#   enable_hsa=no
+#fi
+
+AC_MSG_CHECKING([if the hsail64 target is supported in Clang/LLVM])
+if $LLVM_BINDIR/clang conftest.c -target hsail64 -emit-llvm -S -c -o - 2>/dev/null | grep -cq 'target triple = "hsail64"';
+then
+   AC_MSG_RESULT([yes])
+   LLVM_HSAIL64_TARGET=yes
+else
+   AC_MSG_RESULT([no])
+   enable_hsa=no
+fi
+
+tempCPPFLAGS=$CPPFLAGS
+CPPFLAGS="$CPPFLAGS -I${HSA_RUNTIME_DIR}/include"
+
+AC_MSG_CHECKING([for HSA runtime headers])
+AC_COMPILE_IFELSE(
+  [AC_LANG_PROGRAM(
+    [[ #include <hsa.h> ]]
+  )],
+[AC_MSG_RESULT(yes)],
+[AC_MSG_RESULT(no)
+enable_hsa="no"
+])
+
+CPPFLAGS=$tempCPPFLAGS
+
+AC_ARG_VAR([HSAILASM], [Path to HSAILasm executable])
+AC_PATH_PROGS([HSAILASM], [HSAILasm])
+if test ! -z "$HSAILASM"; then
+  AC_DEFINE_UNQUOTED([HSAIL_ASM], ["$HSAILASM"], [Path to HSAILasm executable])
+else
+  AC_MSG_NOTICE([Could not find HSAILasm executable, disabling HSA support])
+  enable_hsa="no"
+fi
+
+if test "$enable_hsa" = "yes";
+then
+  OCL_DRIVERS="$OCL_DRIVERS hsa"
+  OCL_TARGETS="$OCL_TARGETS hsail64"
+  AC_DEFINE([BUILD_HSA], [1], [Defined to 1 in case the HSA driver should be built.])
+  enable_testsuite_hsa=yes
+  POAT_TESTSUITES="$POAT_TESTSUITES hsa"
+
+  # -lHSAILUtil is missing from llvm-config --libfiles
+  LLVM_LIBS="$LLVM_LIBS -lLLVMHSAILUtil"
+fi
+
+# TODO: move above
+
+# Enable the HSA test suite in case HSA support enabled.
+AM_CONDITIONAL([TEST_SUITE_HSA], [test "$enable_testsuite_hsa" = "yes"])
+AC_SUBST([POAT_TESTSUITES])
+
+AM_CONDITIONAL([BUILD_AMDGCN],[echo $OCL_TARGETS | grep amdgcn])
+AM_CONDITIONAL([BUILD_HSA],[echo $OCL_DRIVERS | grep hsa])
+
 AC_MSG_NOTICE([Building the following device drivers: $OCL_DRIVERS])
 
 AC_SUBST([OCL_TARGETS])
@@ -1363,9 +1517,10 @@ AC_C_BIGENDIAN(
 # 3:0:2 == 0.9 (currently backwards compatible with 0.7, thus age = 2).
 # 4:0:3 == 0.10 (currently backwards compatible with 0.7, thus age = 3).
 # 5:0:4 == 0.11 (currently backwards compatible with 0.7, thus age = 4).
-LIB_CURRENT_VERSION=5
+# 6:0:5 == 0.12 (currently backwards compatible with 0.7, thus age = 5).
+LIB_CURRENT_VERSION=6
 LIB_REVISION_VERSION=0
-LIB_AGE_VERSION=4
+LIB_AGE_VERSION=5
 LIB_FIRST_VERSION=$(($LIB_CURRENT_VERSION - $LIB_AGE_VERSION))
 BUILD_TIMESTAMP=""
 AC_SUBST([LIB_VERSION], ["$LIB_CURRENT_VERSION:$LIB_REVISION_VERSION:$LIB_AGE_VERSION"])
@@ -1400,11 +1555,13 @@ AC_CONFIG_FILES([Makefile
                  lib/CL/devices/tce/ttasim/Makefile
                  lib/CL/devices/topology/Makefile
                  lib/CL/devices/cellspu/Makefile
+                 lib/CL/devices/hsa/Makefile
                  lib/llvmopencl/Makefile
                  lib/kernel/Makefile
                  lib/kernel/cellspu/Makefile
                  lib/kernel/host/Makefile
                  lib/kernel/tce/Makefile
+                 lib/kernel/hsail64/Makefile
                  lib/poclu/Makefile
                  examples/Makefile
                  examples/example1/Makefile
@@ -1425,6 +1582,7 @@ AC_CONFIG_FILES([Makefile
                  examples/VexCL/Makefile
                  examples/piglit/Makefile
                  examples/Halide/Makefile
+                 examples/OpenCV/Makefile
                  examples/CloverLeaf/Makefile
                  scripts/Makefile
                  tests/Makefile
diff --git a/doc/sphinx/source/conf.py b/doc/sphinx/source/conf.py
index 367151e..ab52649 100644
--- a/doc/sphinx/source/conf.py
+++ b/doc/sphinx/source/conf.py
@@ -45,9 +45,9 @@ copyright = u'2010-2015, pocl developers'
 # built documents.
 #
 # The short X.Y version.
-version = '0.11'
+version = '0.12'
 # The full version, including alpha/beta/rc tags.
-release = '0.11-pre'
+release = '0.12'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff --git a/doc/sphinx/source/development.rst b/doc/sphinx/source/development.rst
index b179546..312637f 100644
--- a/doc/sphinx/source/development.rst
+++ b/doc/sphinx/source/development.rst
@@ -160,7 +160,9 @@ POCL_BUILDING setups the OCL_ICD_VENDORS path to point to the pocl in
 the build tree. This removes the need to install pocl to test the 
 built version. It should be executed in the source root::
 
-  . tools/scripts/devel-envs.sh
+  . tools/scripts/devel-envs.sh [cmake]
+
+The ``cmake`` argument is required when pocl is built with cmake.
 
 To test as much as possible link options, it is recommended to
 configure pocl two times and run "make check" with both. One should be
diff --git a/doc/sphinx/source/env_variables.rst b/doc/sphinx/source/env_variables.rst
index 4729499..b1d0495 100644
--- a/doc/sphinx/source/env_variables.rst
+++ b/doc/sphinx/source/env_variables.rst
@@ -1,17 +1,29 @@
-The behavior of pocl can be controlled with multiple environment variables listed
-below.
+Tuning pocl behavior
+--------------------
+
+The behavior of pocl can be controlled with multiple environment variables
+listed below. The variables are helpful both when using and when developing
+pocl.
 
 * POCL_BUILDING
 
- If set, the pocl helper scripts, kernel library and headers are 
+ If  set, the pocl helper scripts, kernel library and headers are 
  searched first from the pocl build directory.
 
+* POCL_BBVECTORIZE
+
+ If set to 1, makes the pocl kernel compiler execute the LLVM BBVectorizer in
+ addition to the SLP vectorizer and the inner loop vectorizer. BBVectorizer
+ has known stability issues, therefore it's disabled by default, but it can
+ provide performance improvements. See: https://github.com/pocl/pocl/issues/251
+
 * POCL_CACHE_DIR
 
  If this is set to an existing directory, pocl uses it as the cache
  directory for all compilation results. This allows reusing compilation
  results between pocl invocations. If this env is not set, then the
- default cache directory will be used
+ default cache directory will be used, which is ``$XDG_CACHE_DIR/pocl/kcache``
+ (if set) or ``$HOME/.cache/pocl/kcache/`` on Unix-like systems.
 
 * POCL_DEBUG
 
@@ -35,6 +47,9 @@ below.
                         TCE's ttasim library. Enabled only if TCE libraries
                         installed.
 
+ *         hsa          Uses HSA Runtime API to control HSA-compliant
+                        kernel agents that support HSAIL finalization.
+
  If POCL_DEVICES is not set, one pthread device will be used.
  To specify parameters for drivers, the POCL_<drivername><instance>_PARAMETERS
  environment variable can be specified (where drivername is in uppercase).
@@ -58,16 +73,12 @@ below.
 
 * POCL_KERNEL_CACHE
 
- If this is set to 0 at runtime, kernel-cache will be forcefully disabled even if
- its enabled in configure step
-
-* POCL_KERNEL_CACHE_IGNORE_INCLUDES
-
- By default, the kernel compiler cache does not cache kernels that 
- have #include clauses. Setting this to 1 changes this so that the
- includes are ignored and not scanned for changes. Use this to
- improve the kernel compiler hit ratio in case you know that the 
- included files are not modified across runs.
+ If this is set to 0 at runtime, kernel compilation files will be deleted at
+ clReleaseProgram(). Note that it's currently not possible for pocl to avoid
+ interacting with LLVM via on-disk files, so pocl requires some disk space at
+ least temporarily (at runtime). Also, the locking mechanism on cache files
+ does not work with LLVM < 3.5, so you might get errors if you try to run
+ multiple processes running the same CL code via pocl.
 
 * POCL_KERNEL_COMPILER_OPT_SWITCH
 
diff --git a/doc/sphinx/source/faq.rst b/doc/sphinx/source/faq.rst
index 2b087cf..afb3b65 100644
--- a/doc/sphinx/source/faq.rst
+++ b/doc/sphinx/source/faq.rst
@@ -7,6 +7,29 @@ are listed here.
 Using pocl
 ----------
 
+Supported compilers and compiler combinations
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Note that pocl usually uses two different compilers (though may be built
+using only one). One is used to compile C and C++ files - this is usually
+the "system compiler". It's specified by CC and CXX vars to configure
+script, or CMAKE_C{,XX}_COMPILER variables to cmake, but usually just
+left to default. The second compiler is used to build OpenCL files - this
+is always clang+llvm. It's specified by LLVM_CONFIG=<path> to configure,
+or -DWITH_LLVM_CONFIG=<path> to cmake.
+
+You may use clang as both "system" and OpenCL compiler for pocl.
+Note however that pocl uses the CXX_FLAGS *which the 2nd compiler (clang)
+was built with*, to build parts of pocl that link with that compiler. This
+may cause some issues, if you try to build pocl with a different compiler
+as the one used to build the 2nd compiler - because gcc and clang are not
+100% compatible with each other in flags. So far though we've only seen
+warnings about unknown flags, not actual bugs.
+
+Anyway, the most trouble-free solution is to use the same "system" compiler
+to build pocl, as the one that was used to build the 2nd compiler. Note that
+while most Linux distributions use gcc to build their clang/llvm,
+the official downloads from llvm.org are built using clang.
+
 Deadlocks (freezes) on FreeBSD
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
@@ -54,3 +77,42 @@ hwloc "plugins" package installed (with the opencl plugin). What happens is:
 
 The solution is either to use ``--enable-icd --disable-direct-linkage``, or
 to uninstall the hwloc "plugins" package.
+
+Why is pocl slow?
+^^^^^^^^^^^^^^^^^
+
+If pocl's kernel build seems really slow, it is very possible you have
+built your LLVM with Debug+Asserts on (not configure --enable-optimized).
+This should result in up to 10x kernel compiler slow downs. You can
+really feel it when running 'make check', for example.
+
+The kernel compiler cache often removes that overhead when you
+run your OpenCL app the next time.
+
+If pocl is otherwise slower than other OpenCL implementations, it's normal. 
+pocl is known to run certain benchmarks faster, certain ones slower, 
+when comparing against the Intel and AMD OpenCL SDKs. We hope to improve 
+the performance in each release, so if you encounter performance 
+regressions (an older pocl/LLVM version used to run an app faster), 
+please report a bug.
+
+Also you might want to try to set the `POCL_BBVECTORIZER` environment
+variable to 1. More info :doc:`here </env_variables>`.
+
+pocl source code
+----------------
+
+Why C99 in host library?
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+The kernel compiler passes are in C++11 and it's much faster to implement
+things in C++11. Why use C99 in the host library?
+
+pocl is meant to be very portable to various type of devices, also
+to those with very little resources (no operating systems at all, simple
+runtime libraries). C has better portability to low end CPUs.
+
+Thus, in order for a CPU to act as an OpenCL host without online kernel
+compilation support, now only C99 support is required from the target,
+no C++ compiler or C++ runtime is needed. Also, C programs are said to produce
+more "lightweight" binaries, but that is debatable.
diff --git a/doc/sphinx/source/hsa.rst b/doc/sphinx/source/hsa.rst
new file mode 100644
index 0000000..d2c44e6
--- /dev/null
+++ b/doc/sphinx/source/hsa.rst
@@ -0,0 +1,106 @@
+===
+HSA
+===
+
+Note: pocl's HSA support is currently in experimental stage.
+
+The experimental HSA driver works only with an AMD Kaveri or Carrizo APUs
+using the HSAIL-supported LLVM and Clang. Other than that, you will need
+a recent linux (4.0+) and some software.
+
+Installing prerequisite software
+---------------------------------
+
+1) Install the HSA AMD runtime library
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  Pre-built binaries can be found here:
+
+  https://github.com/HSAFoundation/HSA-Runtime-AMD
+
+  This usually installs into /opt/hsa. Make sure to read Q&A in README.md, it
+  lists some common issues (like /dev/kfd permissions) and run sample/vector_copy
+  to verify you have a working runtime.
+
+2) Build HSAIL-Tools
+~~~~~~~~~~~~~~~~~~~~~
+
+   `git clone https://github.com/HSAFoundation/HSAIL-Tools`
+
+   In particular **HSAILasm** executable will be required by pocl.
+
+3) Build & install the LLVM with HSAIL support
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+  `git clone https://github.com/HSAFoundation/HLC-HSAIL-Development-LLVM/`
+
+  Use the branch hsail-stable-3.7; before build, patch it with
+
+  `pocl/tools/patches/llvm-3.7-hsail-branch.patch`
+
+  Build it with a Clang 3.7 (branch release_37)
+
+  `cd tools; svn co http://llvm.org/svn/llvm-project/cfe/branches/release_37 clang`
+
+  patched with
+
+  `pocl/tools/patches/clang-3.7-hsail-branch.patch`
+
+  to get the HSAIL Clang support.
+
+  An LLVM cmake configuration command like this worked for me:
+
+  `mkdir build; cd build; cmake .. -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=HSAIL
+  -DBUILD_SHARED_LIBS=off -DCMAKE_INSTALL_PREFIX=INSTALL_DIR -DLLVM_ENABLE_RTTI=on
+  -DLLVM_BUILD_LLVM_DYLIB=on -DLLVM_ENABLE_EH=ON`
+
+  Note that these are **required** :
+
+  `-DLLVM_ENABLE_RTTI=ON -DLLVM_ENABLE_EH=ON
+  -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=HSAIL`
+
+  Also, if you don't want to build all the default targets, you'll need AMDGPU.
+
+
+4) Build pocl.
+~~~~~~~~~~~~~~~
+  Using autotools:
+
+    `./configure --with-hsa-runtime-dir=\</opt/hsa\>
+    LLVM_CONFIG=<hsail-built-llvm-dir>/bin/llvm-config
+    HSAILASM=\<path/to/HSAILasm\>`
+
+  Or using cmake:
+    `cmake -DENABLE_HSA=ON -DWITH_HSA_RUNTIME_DIR=\</opt/hsa\>
+    -DWITH_HSAILASM_PATH=\<path/to/HSAILasm\>`
+
+  Both should result in "hsa" appearing in pocl's targets to build ("OCL_TARGETS"
+  in cmake output, "Enabled device drivers:" in autoconf output)
+
+5) Run tests & play around
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+  After building pocl, you can smoke test the HSA driver by executing the HSA
+  tests of the pocl testsuite:
+
+  `make check TESTSUITEFLAGS="-k hsa"`
+
+
+HSA Support notes
+------------------
+Note that the support is still experimental and very much unfinished. You're
+welcome to try it out and report any issues, though.
+
+What's implemented:
+ * global/local/private memory
+ * atomics, barriers
+ * most of the OpenCL kernel library builtins
+
+What's missing
+ * printf() is not implemented
+ * several builtins are not implemented yet (erf(c), lgamma, tgamma,
+   logb, remainder, nextafter) and some are suboptimal or may give incorrect
+   results with under/overflows (e.g. hypot, length, distance). We're working on
+   this, if you find any problem  please let us know)
+ * image support is not implemented
+ * OpenCL 2.0 features (SVM) are unimplemented
+ * Performance is suboptimal in many cases
diff --git a/doc/sphinx/source/index.rst b/doc/sphinx/source/index.rst
index 6a0f24f..eddb50d 100644
--- a/doc/sphinx/source/index.rst
+++ b/doc/sphinx/source/index.rst
@@ -12,11 +12,14 @@ Contents:
    :maxdepth: 2
 
    using
+   env_variables
    faq
+   env_variables
    development
    releasing
    design
    features
+   hsa
 
 Back to `pocl home page <http://pocl.sourceforge.net>`_.
 
diff --git a/doc/sphinx/source/kernel_compiler.rst b/doc/sphinx/source/kernel_compiler.rst
index db84a2f..a79e2f4 100644
--- a/doc/sphinx/source/kernel_compiler.rst
+++ b/doc/sphinx/source/kernel_compiler.rst
@@ -282,6 +282,27 @@ Some of them are listed in the following:
  types of local buffers, the ones passed as arguments and the ones instantiated
  in the kernel.
 
+* ``TargetAddressSpaces``
+
+ Internally pocl uses fixed address space ids to denote the different OpenCL
+ address spaces.  That is, Clang generates LLVM IR that uses these address space
+ ids, even with targets that have a single flat address space in reality.
+ This is to differentiate the different type of pointers for treating locals
+ correctly, and also for assisting alias analysis (different address spaces are
+ disjoint, thus accesses to them won't alias each other).
+
+ TargetAddressSpaces is a pass that converts these fake ids to the ones expected
+ by the target.  This pass can be short cutted in case the backend for the target
+ can flatten the ids safely.  However, recently (as of LLVM 3.7) there has been new
+ problems with some optimizations (at least LoopVectorizer) that get confused with
+ the fake ids.  Therefore it is recommended the ids are flattened even if not
+ strictly needed for a target at hand to avoid these issues and make some LLVM
+ optimizations more efficient.
+
+ A more robust version of AS handling might be to rely on metadata when differentiating
+ the pointers and already in Clang use the target's address spaces in the IR. This
+ would ensure the LLVM IR passes would not get confused by the fake ids.
+
 
 .. _opencl-optimizations:
 
diff --git a/doc/sphinx/source/releasing.rst b/doc/sphinx/source/releasing.rst
index da5e5f7..1fa2fb0 100644
--- a/doc/sphinx/source/releasing.rst
+++ b/doc/sphinx/source/releasing.rst
@@ -61,6 +61,7 @@ A checklist and hints for testing and making a release successfully:
 In case of any problems, ask any previous release manager for help.
 Previous releases were managed by the following pocl developers:
 
+* 0.11: Michal Babej
 * 0.10: Pekka Jääskeläinen
 * 0.9: Kalle Raiskila
 * 0.8: Erik Schnetter
diff --git a/doc/sphinx/source/using.rst b/doc/sphinx/source/using.rst
index 7afe4dc..3680d6c 100644
--- a/doc/sphinx/source/using.rst
+++ b/doc/sphinx/source/using.rst
@@ -104,15 +104,10 @@ distributed with pocl for convenience in the directory
 To use VML, you need to have a functional clang++ installed.
 Currently, VML is enabled only for x86_64.
 
-Tuning pocl behavior
---------------------
-
-.. include:: env_variables.rst
-
 Wiki
 ----
 
-`Wiki <http://sourceforge.net/apps/mediawiki/pocl/index.php?title=Main_Page>`_
+`Wiki <https://github.com/pocl/pocl/wiki>`_
 contains some further information and serves as a "scratch pad".
 
 
diff --git a/examples/AMD/AMDSDK.patch b/examples/AMD/AMDSDK.patch
index 2a63d9d..4ad8ec8 100644
--- a/examples/AMD/AMDSDK.patch
+++ b/examples/AMD/AMDSDK.patch
@@ -487,7 +487,22 @@ index d310168..32358da 100755
  		retValue = deviceInfo.setDeviceInfo(Devices[i]);
  		CHECK_ERROR(retValue, 0, "SDKDeviceInfo::setDeviceInfo() failed");
 -		if (deviceInfo.dType == CL_DEVICE_TYPE_CPU)
-+		if (deviceInfo.dType & CL_DEVICE_TYPE_CPU == CL_DEVICE_TYPE_CPU)
++		if (deviceInfo.dType & CL_DEVICE_TYPE_CPU)
  		{
  			cpuDevice = Devices[i];
  		}
+@@ -131,6 +131,14 @@
+ 	status = clCreateSubDevices(cpuDevice, partitionPrty, numSubDevices, subDevices, NULL);
+ 	CHECK_OPENCL_ERROR( status, "clCreateSubDevices failed.");
+ 
++    // recreate the context with the subdevices
++    status = clReleaseContext(rContext);
++    CHECK_OPENCL_ERROR( status, "clReleaseContext failed.");
++
++    rContext = clCreateContext(platform ? cps : NULL,
++	    numSubDevices, subDevices, NULL, NULL, &status);
++    CHECK_OPENCL_ERROR( status, "clCreateContext failed.");
++
+     return SDK_SUCCESS;
+ }
+ 
diff --git a/examples/AMD/Makefile.in b/examples/AMD/Makefile.in
index 75484d3..4c32cc4 100644
--- a/examples/AMD/Makefile.in
+++ b/examples/AMD/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -104,7 +114,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = examples/AMD
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am README
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -113,6 +122,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -137,6 +147,7 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in README
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -188,6 +199,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -224,6 +238,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -357,7 +372,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/AMD/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign examples/AMD/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -532,6 +546,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 AMD-APP-SDK-v2.8-RC-lnx64.tgz:
 	cd $(srcdir) && \
diff --git a/examples/AMDSDK2.9/AMDSDK2_9.patch b/examples/AMDSDK2.9/AMDSDK2_9.patch
index 377ec5f..7977739 100644
--- a/examples/AMDSDK2.9/AMDSDK2_9.patch
+++ b/examples/AMDSDK2.9/AMDSDK2_9.patch
@@ -192,8 +192,22 @@ diff -uNr a/AMD-APP-SDK-v2.9-RC-lnx64/samples/opencl/cpp_cl/HistogramAtomics/His
          retValue = deviceInfo.setDeviceInfo(Devices[i]);
          CHECK_ERROR(retValue, 0, "SDKDeviceInfo::setDeviceInfo() failed");
 -        if (deviceInfo.dType == CL_DEVICE_TYPE_CPU)
-+        if (deviceInfo.dType & CL_DEVICE_TYPE_CPU == CL_DEVICE_TYPE_CPU)
++        if (deviceInfo.dType & CL_DEVICE_TYPE_CPU)
          {
              cpuDevice = Devices[i];
          }
-
+@@ -137,6 +137,14 @@
+                                 NULL);
+     CHECK_OPENCL_ERROR( status, "clCreateSubDevices failed.");
+ 
++    // recreate the context with the subdevices
++    status = clReleaseContext(rContext);
++    CHECK_OPENCL_ERROR( status, "clReleaseContext failed.");
++
++    rContext = clCreateContext(platform ? cps : NULL,
++	    numSubDevices, subDevices, NULL, NULL, &status);
++    CHECK_OPENCL_ERROR( status, "clCreateContext failed.");
++
+     return SDK_SUCCESS;
+ }
+ 
diff --git a/examples/AMDSDK2.9/Makefile.in b/examples/AMDSDK2.9/Makefile.in
index da40556..9a914d8 100644
--- a/examples/AMDSDK2.9/Makefile.in
+++ b/examples/AMDSDK2.9/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -104,7 +114,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = examples/AMDSDK2.9
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am README
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -113,6 +122,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -137,6 +147,7 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in README
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -188,6 +199,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -224,6 +238,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -357,7 +372,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/AMDSDK2.9/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign examples/AMDSDK2.9/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -532,6 +546,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 @TEST_SUITE_AMDSDK2_9_TRUE at .PHONY: build prepare-examples
 
diff --git a/examples/CloverLeaf/Makefile.in b/examples/CloverLeaf/Makefile.in
index bec2610..61d6061 100644
--- a/examples/CloverLeaf/Makefile.in
+++ b/examples/CloverLeaf/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -38,7 +38,17 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -103,7 +113,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = examples/CloverLeaf
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am README
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -112,6 +121,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -136,6 +146,7 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in README
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -187,6 +198,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -223,6 +237,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -352,7 +367,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/CloverLeaf/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign examples/CloverLeaf/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -527,6 +541,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 @TEST_SUITE_CLOVERLEAF_TRUE at .PHONY: build
 
diff --git a/examples/EinsteinToolkit/Makefile.in b/examples/EinsteinToolkit/Makefile.in
index 417349d..4433cc1 100644
--- a/examples/EinsteinToolkit/Makefile.in
+++ b/examples/EinsteinToolkit/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -105,8 +115,6 @@ host_triplet = @host@
 target_triplet = @target@
 noinst_PROGRAMS = EinsteinToolkit$(EXEEXT)
 subdir = examples/EinsteinToolkit
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -115,6 +123,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -192,6 +201,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -243,6 +253,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -279,6 +292,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -413,7 +427,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/EinsteinToolkit/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign examples/EinsteinToolkit/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -697,6 +710,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/examples/Halide/Makefile.in b/examples/Halide/Makefile.in
index 8060101..36fc874 100644
--- a/examples/Halide/Makefile.in
+++ b/examples/Halide/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -38,7 +38,17 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -103,7 +113,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = examples/Halide
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am README
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -112,6 +121,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -136,6 +146,7 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in README
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -187,6 +198,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -223,6 +237,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -352,7 +367,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/Halide/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign examples/Halide/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -527,6 +541,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 @TEST_SUITE_HALIDE_TRUE at .PHONY: build
 
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 313bdc2..feb3457 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -31,12 +31,12 @@
 
 SUBDIRS = example1 example1-spir32 example1-spir64 example2 example2a trig \
 	scalarwave standalone opencl-book-samples VexCL ViennaCL Rodinia Parboil \
-	AMD AMDSDK2.9 EinsteinToolkit piglit Halide CloverLeaf
+	AMD AMDSDK2.9 EinsteinToolkit piglit Halide OpenCV CloverLeaf
 
 BASIC_EXAMPLES = example1 example1-spir32 example1-spir64 example2 example2a trig \
 	scalarwave standalone opencl-book-samples EinsteinToolkit
 
-EXTRA_DIST = CMakeLists.txt
+EXTRA_DIST = CMakeLists.txt PyOpenCL/README
 
 # The external examples which should be prepared only
 # once by calling "make prepare-examples".
@@ -70,6 +70,10 @@ if TEST_SUITE_CLOVERLEAF
 EXAMPLES_TO_PREPARE += "CloverLeaf "
 endif
 
+if TEST_SUITE_OPENCV
+EXAMPLES_TO_PREPARE += "OpenCV "
+endif
+
 prepare-examples:
 	for dir in $(EXAMPLES_TO_PREPARE); do \
 	   $(MAKE) -C $$dir prepare-examples; \
diff --git a/examples/Makefile.in b/examples/Makefile.in
index 0d6c04b..ff82c22 100644
--- a/examples/Makefile.in
+++ b/examples/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -45,7 +45,17 @@
 # 'make check' is executed because they are not affected by pocl changes nor
 # should itself change.
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -118,8 +128,8 @@ target_triplet = @target@
 @TEST_SUITE_PIGLIT_TRUE at am__append_7 = "piglit "
 @TEST_SUITE_HALIDE_TRUE at am__append_8 = "Halide "
 @TEST_SUITE_CLOVERLEAF_TRUE at am__append_9 = "CloverLeaf "
+ at TEST_SUITE_OPENCV_TRUE@am__append_10 = "OpenCV "
 subdir = examples
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -128,6 +138,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -187,6 +198,7 @@ am__define_uniq_tagged_files = \
 ETAGS = etags
 CTAGS = ctags
 DIST_SUBDIRS = $(SUBDIRS)
+am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 am__relativize = \
   dir0=`pwd`; \
@@ -263,6 +275,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -299,6 +314,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -415,18 +431,19 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 SUBDIRS = example1 example1-spir32 example1-spir64 example2 example2a trig \
 	scalarwave standalone opencl-book-samples VexCL ViennaCL Rodinia Parboil \
-	AMD AMDSDK2.9 EinsteinToolkit piglit Halide CloverLeaf
+	AMD AMDSDK2.9 EinsteinToolkit piglit Halide OpenCV CloverLeaf
 
 BASIC_EXAMPLES = example1 example1-spir32 example1-spir64 example2 example2a trig \
 	scalarwave standalone opencl-book-samples EinsteinToolkit
 
-EXTRA_DIST = CMakeLists.txt
+EXTRA_DIST = CMakeLists.txt PyOpenCL/README
 
 # The external examples which should be prepared only
 # once by calling "make prepare-examples".
 EXAMPLES_TO_PREPARE = $(am__append_1) $(am__append_2) $(am__append_3) \
 	$(am__append_4) $(am__append_5) $(am__append_6) \
-	$(am__append_7) $(am__append_8) $(am__append_9)
+	$(am__append_7) $(am__append_8) $(am__append_9) \
+	$(am__append_10)
 all: all-recursive
 
 .SUFFIXES:
@@ -442,7 +459,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign examples/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -735,6 +751,8 @@ uninstall-am:
 	mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
 	ps ps-am tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 prepare-examples:
 	for dir in $(EXAMPLES_TO_PREPARE); do \
diff --git a/examples/OpenCV/Makefile.am b/examples/OpenCV/Makefile.am
new file mode 100644
index 0000000..ddb8cea
--- /dev/null
+++ b/examples/OpenCV/Makefile.am
@@ -0,0 +1,263 @@
+# Process this file with automake to produce Makefile.in (in this,
+# and all subdirectories).
+# Makefile.am for pocl/examples/OpenCV.
+# 
+# Copyright (c) 2012 Lassi Koskinen
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+if TEST_SUITE_OPENCV
+opencv_local_src_dir=opencv-3.0.0-beta
+opencv_zip=opencv-3.0.0-beta.zip
+testsuite_pocl_dir=${abs_top_srcdir}/examples/OpenCV
+testsuite_src_dir=${testsuite_pocl_dir}/${opencv_local_src_dir}
+
+.PHONY: prepare-examples
+
+$(srcdir)/$(opencv_zip):
+	cd $(srcdir) && \
+	wget https://github.com/Itseez/opencv/archive/$(opencv_zip)
+
+EXTRA_DIST = opencv.patch
+
+$(opencv_local_src_dir):
+	$(MAKE) $(srcdir)/$(opencv_zip) 
+	cd $(testsuite_pocl_dir) && \
+	unzip $(opencv_zip)
+
+test_UMat:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=UMat.*
+
+test_Core_UMat:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=Core_UMat.*
+
+test_Image2D:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=Image2D.*
+
+test_UMat/UMatBasicTests:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=UMat/UMatBasicTests.*
+
+test_UMat/UMatTestReshape:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=UMat/UMatTestReshape.*
+
+test_UMat/UMatTestRoi:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=UMat/UMatTestRoi.*
+
+test_UMat/UMatTestSizeOperations:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=UMat/UMatTestSizeOperations.*
+
+test_UMat/UMatTestUMatOperations:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=UMat/UMatTestUMatOperations.*
+
+test_OCL_MeanStdDev_:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_MeanStdDev_.*
+
+test_OCL_Channels/Merge:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Channels/Merge.*
+
+test_OCL_Channels/Split:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Channels/Split.*
+
+test_OCL_Channels/MixChannels:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Channels/MixChannels.*
+
+test_OCL_Channels/InsertChannels:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Channels/InsertChannels.*
+
+test_OCL_Channels/ExtractChannels:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Channels/ExtractChannels.*
+
+test_OCL_Arithm/Lut:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Lut.*
+
+test_OCL_Arithm/Add:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Add.*
+
+test_OCL_Arithm/Subtract:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Substract.*
+
+test_OCL_Arithm/Mul:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Mul.*
+
+test_OCL_Arithm/Div:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Div.*
+
+test_OCL_Arithm/AddWeighted:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/AddWeighted.*
+
+test_OCL_Arithm/Min:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Min.*
+
+test_OCL_Arithm/Max:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Max.*
+
+test_OCL_Arithm/Absdiff:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Absdiff.*
+
+test_OCL_Arithm/CartToPolar:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/CartToPolar.*
+
+test_OCL_Arithm/PolarToCart:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/PolarToCart.*
+
+test_OCL_Arithm/Transpose:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Transpose.*
+
+test_OCL_Arithm/Bitwise_and:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/BitWise_and.*
+
+test_OCL_Arithm/Bitwise_or:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Bitwise_or.*
+
+test_OCL_Arithm/Bitwise_xor:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Bitwise_xor.*
+
+test_OCL_Arithm/Bitwise_not:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Bitwise_not.*
+
+test_OCL_Arithm/Compare:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Compare.*
+
+test_OCL_Arithm/Pow:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Pow.*
+
+test_OCL_Arithm/SetIdentity:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/SetIdentity.*
+
+test_OCL_Arithm/Repeat:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Repeat.*
+
+test_OCL_Arithm/CountNonZero:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/CountNonZero.*
+
+test_OCL_Arithm/Sum:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Sum.*
+
+test_OCL_Arithm/MeanStdDev:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/MeanStdDev.*
+
+test_OCL_Arithm/Log:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Log.*
+
+test_OCL_Arithm/Exp:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Exp.*
+
+test_OCL_Arithm/Phase:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Phase.*
+
+test_OCL_Arithm/Magnitude:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Magnitude.*
+
+test_OCL_Arithm/Flip:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Flip.*
+
+test_OCL_Arithm/MinMaxIdx:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/MinMaxIdx.*
+
+test_OCL_Arithm/MinMaxIdx_Mask:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/MinMaxIdx_Mask.*
+
+test_OCL_Arithm/Norm:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Norm.*
+
+test_OCL_Arithm/UMatDot:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/UMatDot.*
+
+test_OCL_Arithm/Sqrt:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Sqrt.*
+
+test_OCL_Arithm/Normalize:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Normalize.*
+
+test_OCL_Arithm/InRange:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/InRange.*
+
+test_OCL_Arithm/ConvertScaleAbs:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/ConvertScaleAbs.*
+
+test_OCL_Arithm/ScaleAdd:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/ScaleAdd.*
+
+test_OCL_Arithm/PatchNaNs:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/PatchNaNs.*
+
+test_OCL_Arithm/Psnr:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Psnr.*
+
+test_OCL_Arithm/ReduceSum:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/ReduceSum.*
+
+test_OCL_Arithm/ReduceMax:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/ReduceMax.*
+
+test_OCL_Arithm/ReduceMin:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/ReduceMin.*
+
+test_OCL_Arithm/ReduceAvg:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/ReduceAvg.*
+
+test_OCL_Core/Gemm:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Core/Gemm.*
+
+test_OCL_Core/Dft:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Core/Dft.*
+
+test_OCL_OCL_ImgProc/MultiSpectrums:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_OCL_ImgProc/MultiSpectrums.*
+
+test_OCL_MatrixOperation/ConvertTo:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_MatrixOperation/ConvertTo.*
+
+test_OCL_MatrixOperation/CopyTo:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_MatrixOperation/CopyTo.*
+
+test_OCL_MatrixOperation/SetTo:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_MatrixOperation/SetTo.*
+
+test_OCL_MatrixOperation/UMatExpr:
+	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_MatrixOperation/UMatExpr.*
+
+# OpenCV must be built in the subdirectory build/ of the extracted source
+# (it does not work elsewhere) and its source tree is modified.
+# So, copying the source tree in our build tree if required
+# (ie if $(srcdir) is not $(CURDIR) )
+build:
+	if [ ! -d $(opencv_local_src_dir) ]; then cp -aL $(testsuite_src_dir) . ; fi
+	( patch -sNp1 < $(testsuite_pocl_dir)/opencv.patch || true )
+	mkdir $(opencv_local_src_dir)/build; \
+	cd $(opencv_local_src_dir)/build; \
+	cmake \
+		-D CMAKE_BUILD_TYPE=RELEASE \
+		-D WITH_CUDA=OFF \
+		-D WITH_OPENCL=ON \
+		-D WITH_FFMPEG=OFF \
+		-D BUILD_TESTS=ON \
+		-D BUILD_PERF_TESTS=ON \
+                -D BUILD_EXAMPLES=ON \
+		-D BUILD_DOCS=ON \
+		.. && \
+	$(MAKE) -s
+
+prepare-examples: $(opencv_local_src_dir) build
+
+clean-examples:
+	rm -fr $(opencv_local_src_dir)
+
+endif
+
diff --git a/examples/OpenCV/Makefile.in b/examples/OpenCV/Makefile.in
new file mode 100644
index 0000000..2b8bc70
--- /dev/null
+++ b/examples/OpenCV/Makefile.in
@@ -0,0 +1,783 @@
+# Makefile.in generated by automake 1.15 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+# Process this file with automake to produce Makefile.in (in this,
+# and all subdirectories).
+# Makefile.am for pocl/examples/OpenCV.
+# 
+# Copyright (c) 2012 Lassi Koskinen
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+VPATH = @srcdir@
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = examples/OpenCV
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_P = $(am__v_P_ at AM_V@)
+am__v_P_ = $(am__v_P_ at AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_ at AM_V@)
+am__v_GEN_ = $(am__v_GEN_ at AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_ at AM_V@)
+am__v_at_ = $(am__v_at_ at AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+SOURCES =
+DIST_SOURCES =
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in README
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+BUILD_TIMESTAMP = @BUILD_TIMESTAMP@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CLANG = @CLANG@
+CLANGXX = @CLANGXX@
+CLANGXX_FLAGS = @CLANGXX_FLAGS@
+CLFLAGS = @CLFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+FORCED_CLFLAGS = @FORCED_CLFLAGS@
+GLEW_CFLAGS = @GLEW_CFLAGS@
+GLEW_LIBS = @GLEW_LIBS@
+GREP = @GREP@
+HOST = @HOST@
+HOST_AS_FLAGS = @HOST_AS_FLAGS@
+HOST_CLANG_FLAGS = @HOST_CLANG_FLAGS@
+HOST_CPU = @HOST_CPU@
+HOST_LD_FLAGS = @HOST_LD_FLAGS@
+HOST_LLC_FLAGS = @HOST_LLC_FLAGS@
+HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
+HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
+HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
+HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
+HWLOC_CFLAGS = @HWLOC_CFLAGS@
+HWLOC_LIBS = @HWLOC_LIBS@
+ICD_LD_FLAGS = @ICD_LD_FLAGS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KERNEL_COMPILER_LIB_VERSION = @KERNEL_COMPILER_LIB_VERSION@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LD_FLAGS_BIN = @LD_FLAGS_BIN@
+LIBOBJS = @LIBOBJS@
+LIBRARY_SUFFIX = @LIBRARY_SUFFIX@
+LIBS = @LIBS@
+LIBSPE_CFLAGS = @LIBSPE_CFLAGS@
+LIBSPE_LIBS = @LIBSPE_LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_AGE_VERSION = @LIB_AGE_VERSION@
+LIB_CURRENT_VERSION = @LIB_CURRENT_VERSION@
+LIB_FIRST_VERSION = @LIB_FIRST_VERSION@
+LIB_REVISION_VERSION = @LIB_REVISION_VERSION@
+LIB_VERSION = @LIB_VERSION@
+LIPO = @LIPO@
+LLC = @LLC@
+LLVM_AS = @LLVM_AS@
+LLVM_CONFIG = @LLVM_CONFIG@
+LLVM_CXX_FLAGS = @LLVM_CXX_FLAGS@
+LLVM_LDFLAGS = @LLVM_LDFLAGS@
+LLVM_LIBS = @LLVM_LIBS@
+LLVM_LINK = @LLVM_LINK@
+LLVM_OPT = @LLVM_OPT@
+LLVM_VERSION = @LLVM_VERSION@
+LN_S = @LN_S@
+LTDL_LIBS = @LTDL_LIBS@
+LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OCL_ICD_CFLAGS = @OCL_ICD_CFLAGS@
+OCL_ICD_LIBS = @OCL_ICD_LIBS@
+OCL_KERNEL_ARCH = @OCL_KERNEL_ARCH@
+OCL_KERNEL_TARGET = @OCL_KERNEL_TARGET@
+OCL_KERNEL_TARGET_CPU = @OCL_KERNEL_TARGET_CPU@
+OCL_TARGETS = @OCL_TARGETS@
+OPENCL_CFLAGS = @OPENCL_CFLAGS@
+OPENCL_CMAKE = @OPENCL_CMAKE@
+OPENCL_EXTLIBS = @OPENCL_EXTLIBS@
+OPENCL_LIBS = @OPENCL_LIBS@
+OPT = @OPT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+POAT_TESTSUITES = @POAT_TESTSUITES@
+POCL_DEVICE_ADDRESS_BITS = @POCL_DEVICE_ADDRESS_BITS@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TARGET = @TARGET@
+TARGET_CLANG_FLAGS = @TARGET_CLANG_FLAGS@
+TARGET_CPU = @TARGET_CPU@
+TARGET_LLC_FLAGS = @TARGET_LLC_FLAGS@
+TARGET_SIZEOF_DOUBLE = @TARGET_SIZEOF_DOUBLE@
+TARGET_SIZEOF_HALF = @TARGET_SIZEOF_HALF@
+TARGET_SIZEOF_LONG = @TARGET_SIZEOF_LONG@
+TARGET_SIZEOF_VOID_P = @TARGET_SIZEOF_VOID_P@
+TCECC = @TCECC@
+TCEMC_AVAILABLE = @TCEMC_AVAILABLE@
+TCE_AVAILABLE = @TCE_AVAILABLE@
+TCE_CONFIG = @TCE_CONFIG@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+ at TEST_SUITE_OPENCV_TRUE@opencv_local_src_dir = opencv-3.0.0-beta
+ at TEST_SUITE_OPENCV_TRUE@opencv_zip = opencv-3.0.0-beta.zip
+ at TEST_SUITE_OPENCV_TRUE@testsuite_pocl_dir = ${abs_top_srcdir}/examples/OpenCV
+ at TEST_SUITE_OPENCV_TRUE@testsuite_src_dir = ${testsuite_pocl_dir}/${opencv_local_src_dir}
+ at TEST_SUITE_OPENCV_TRUE@EXTRA_DIST = opencv.patch
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/OpenCV/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign examples/OpenCV/Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+tags TAGS:
+
+ctags CTAGS:
+
+cscope cscopelist:
+
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+	cscopelist-am ctags-am distclean distclean-generic \
+	distclean-libtool distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-ps install-ps-am \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags-am uninstall uninstall-am
+
+.PRECIOUS: Makefile
+
+
+ at TEST_SUITE_OPENCV_TRUE@.PHONY: prepare-examples
+
+ at TEST_SUITE_OPENCV_TRUE@$(srcdir)/$(opencv_zip):
+ at TEST_SUITE_OPENCV_TRUE@	cd $(srcdir) && \
+ at TEST_SUITE_OPENCV_TRUE@	wget https://github.com/Itseez/opencv/archive/$(opencv_zip)
+
+ at TEST_SUITE_OPENCV_TRUE@$(opencv_local_src_dir):
+ at TEST_SUITE_OPENCV_TRUE@	$(MAKE) $(srcdir)/$(opencv_zip) 
+ at TEST_SUITE_OPENCV_TRUE@	cd $(testsuite_pocl_dir) && \
+ at TEST_SUITE_OPENCV_TRUE@	unzip $(opencv_zip)
+
+ at TEST_SUITE_OPENCV_TRUE@test_UMat:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=UMat.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_Core_UMat:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=Core_UMat.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_Image2D:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=Image2D.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_UMat/UMatBasicTests:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=UMat/UMatBasicTests.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_UMat/UMatTestReshape:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=UMat/UMatTestReshape.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_UMat/UMatTestRoi:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=UMat/UMatTestRoi.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_UMat/UMatTestSizeOperations:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=UMat/UMatTestSizeOperations.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_UMat/UMatTestUMatOperations:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=UMat/UMatTestUMatOperations.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_MeanStdDev_:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_MeanStdDev_.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Channels/Merge:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Channels/Merge.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Channels/Split:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Channels/Split.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Channels/MixChannels:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Channels/MixChannels.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Channels/InsertChannels:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Channels/InsertChannels.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Channels/ExtractChannels:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Channels/ExtractChannels.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Lut:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Lut.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Add:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Add.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Subtract:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Substract.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Mul:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Mul.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Div:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Div.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/AddWeighted:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/AddWeighted.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Min:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Min.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Max:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Max.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Absdiff:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Absdiff.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/CartToPolar:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/CartToPolar.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/PolarToCart:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/PolarToCart.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Transpose:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Transpose.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Bitwise_and:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/BitWise_and.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Bitwise_or:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Bitwise_or.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Bitwise_xor:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Bitwise_xor.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Bitwise_not:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Bitwise_not.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Compare:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Compare.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Pow:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Pow.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/SetIdentity:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/SetIdentity.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Repeat:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Repeat.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/CountNonZero:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/CountNonZero.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Sum:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Sum.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/MeanStdDev:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/MeanStdDev.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Log:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Log.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Exp:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Exp.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Phase:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Phase.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Magnitude:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Magnitude.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Flip:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Flip.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/MinMaxIdx:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/MinMaxIdx.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/MinMaxIdx_Mask:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/MinMaxIdx_Mask.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Norm:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Norm.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/UMatDot:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/UMatDot.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Sqrt:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Sqrt.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Normalize:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Normalize.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/InRange:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/InRange.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/ConvertScaleAbs:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/ConvertScaleAbs.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/ScaleAdd:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/ScaleAdd.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/PatchNaNs:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/PatchNaNs.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/Psnr:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/Psnr.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/ReduceSum:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/ReduceSum.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/ReduceMax:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/ReduceMax.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/ReduceMin:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/ReduceMin.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Arithm/ReduceAvg:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Arithm/ReduceAvg.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Core/Gemm:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Core/Gemm.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_Core/Dft:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_Core/Dft.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_OCL_ImgProc/MultiSpectrums:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_OCL_ImgProc/MultiSpectrums.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_MatrixOperation/ConvertTo:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_MatrixOperation/ConvertTo.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_MatrixOperation/CopyTo:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_MatrixOperation/CopyTo.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_MatrixOperation/SetTo:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_MatrixOperation/SetTo.*
+
+ at TEST_SUITE_OPENCV_TRUE@test_OCL_MatrixOperation/UMatExpr:
+ at TEST_SUITE_OPENCV_TRUE@	OCL_ICD_VENDORS=$(abs_top_builddir)/ocl-vendors $(opencv_local_src_dir)/build/bin/opencv_test_core --gtest_filter=OCL_MatrixOperation/UMatExpr.*
+
+# OpenCV must be built in the subdirectory build/ of the extracted source
+# (it does not work elsewhere) and its source tree is modified.
+# So, copying the source tree in our build tree if required
+# (ie if $(srcdir) is not $(CURDIR) )
+ at TEST_SUITE_OPENCV_TRUE@build:
+ at TEST_SUITE_OPENCV_TRUE@	if [ ! -d $(opencv_local_src_dir) ]; then cp -aL $(testsuite_src_dir) . ; fi
+ at TEST_SUITE_OPENCV_TRUE@	( patch -sNp1 < $(testsuite_pocl_dir)/opencv.patch || true )
+ at TEST_SUITE_OPENCV_TRUE@	mkdir $(opencv_local_src_dir)/build; \
+ at TEST_SUITE_OPENCV_TRUE@	cd $(opencv_local_src_dir)/build; \
+ at TEST_SUITE_OPENCV_TRUE@	cmake \
+ at TEST_SUITE_OPENCV_TRUE@		-D CMAKE_BUILD_TYPE=RELEASE \
+ at TEST_SUITE_OPENCV_TRUE@		-D WITH_CUDA=OFF \
+ at TEST_SUITE_OPENCV_TRUE@		-D WITH_OPENCL=ON \
+ at TEST_SUITE_OPENCV_TRUE@		-D WITH_FFMPEG=OFF \
+ at TEST_SUITE_OPENCV_TRUE@		-D BUILD_TESTS=ON \
+ at TEST_SUITE_OPENCV_TRUE@		-D BUILD_PERF_TESTS=ON \
+ at TEST_SUITE_OPENCV_TRUE@                -D BUILD_EXAMPLES=ON \
+ at TEST_SUITE_OPENCV_TRUE@		-D BUILD_DOCS=ON \
+ at TEST_SUITE_OPENCV_TRUE@		.. && \
+ at TEST_SUITE_OPENCV_TRUE@	$(MAKE) -s
+
+ at TEST_SUITE_OPENCV_TRUE@prepare-examples: $(opencv_local_src_dir) build
+
+ at TEST_SUITE_OPENCV_TRUE@clean-examples:
+ at TEST_SUITE_OPENCV_TRUE@	rm -fr $(opencv_local_src_dir)
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/examples/OpenCV/README b/examples/OpenCV/README
new file mode 100644
index 0000000..fb31570
--- /dev/null
+++ b/examples/OpenCV/README
@@ -0,0 +1,24 @@
+To enable the OpenCV tests:
+
+1) run 
+   'wget https://github.com/Itseez/opencv/archive/3.0.0-beta.zip -O opencv-3.0.0-beta.zip' 
+   to download OpenCV
+
+2) configure pocl, it should now detect the OpenCV benchmark and
+   enable it. You need cmake to get it built.
+
+   Also you might need to install the following libraries:
+   VTK (libvtk6-dev)
+
+3) call 'make prepare-examples' once to get the examples built
+
+4) call 'make check TESTSUITEFLAGS="-k opencv"', it should build 
+   the OpenCV cases and run the pocl test suite for the OpenCV.
+
+Known issues:
+
+The CMake of OpenCV doesn't like ccache, so if you have CXX='ccache g++-4.7'
+you might need to prepare the example without the ccache in front. E.g.:
+
+  make prepare-examples CXX=g++-4.7 CC=g++-4.7
+
diff --git a/examples/Parboil/Makefile.in b/examples/Parboil/Makefile.in
index 5a389db..1d45f4a 100644
--- a/examples/Parboil/Makefile.in
+++ b/examples/Parboil/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -38,7 +38,17 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -103,7 +113,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = examples/Parboil
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am README
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -112,6 +121,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -136,6 +146,7 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in README
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -187,6 +198,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -223,6 +237,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -359,7 +374,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/Parboil/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign examples/Parboil/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -534,6 +548,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 @TEST_SUITE_PARBOIL_TRUE at .PHONY: build
 
diff --git a/examples/PyOpenCL/README b/examples/PyOpenCL/README
new file mode 100644
index 0000000..5a6dae9
--- /dev/null
+++ b/examples/PyOpenCL/README
@@ -0,0 +1,49 @@
+Installation:
+
+$ git clone --recursive git://github.com/inducer/pyopencl
+$ apt-get install python-pip python-virtualenv
+
+  (or equivalent, for example:
+  curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
+  sudo python get-pip.py 
+  sudo pip install virtualenv)
+
+$ virtualenv --system-site-packages mypy
+$ source mypy/bin/activate
+$ cd pyopencl
+$ ./configure.py
+[Edit siteconf.py to taste--for example to find CL headers.]
+$ python setup.py install
+
+Update:
+
+$ source mypy/bin/activate
+$ cd pyopencl
+$ git pull
+$ git submodule update
+$ python setup.py install
+
+Run test:
+
+$ source mypy/bin/activate
+$ cd pyopencl/test
+$ PYOPENCL_NO_CACHE=1 PYOPENCL_TEST=portable py.test -v --tb=native
+
+'PYOPENCL_NO_CACHE=1' turns off binary caching (aka use of
+clCreateProgramWithBinary), which pocl doesn't appear to
+support. (results in 'out of host memory' error)
+
+'PYOPENCL_TEST=portable' restricts the test run to pocl.
+
+You can also append individual test_*.py files to that command line to
+only run these tests. Many of the algorithmic tests are already looking
+pretty good.
+
+test_wrapper.py on the other hand is pretty brutal. It tests a few
+corner cases (all GetInfo queries, invalid kernel names, ...) and
+crashes with SIGSEGV pretty much immediately.
+
+Thank you for your work on pocl. I'm lurking on the pocl list if you
+need me to help somehow.
+
+--Andreas Klöckner @ pocl-devel ML
diff --git a/examples/Rodinia/Makefile.am b/examples/Rodinia/Makefile.am
index 73d2fd3..9eaee18 100644
--- a/examples/Rodinia/Makefile.am
+++ b/examples/Rodinia/Makefile.am
@@ -125,3 +125,5 @@ clean-examples:
 	$(RM) -r $(testsuite_src_dir)
 
 endif
+
+EXTRA_DIST = Rodinia.patch
diff --git a/examples/Rodinia/Makefile.in b/examples/Rodinia/Makefile.in
index df897bb..3475dfd 100644
--- a/examples/Rodinia/Makefile.in
+++ b/examples/Rodinia/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -104,7 +114,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = examples/Rodinia
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am README
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -113,6 +122,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -137,6 +147,7 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in README
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -188,6 +199,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -224,6 +238,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -343,6 +358,7 @@ top_srcdir = @top_srcdir@
 @TEST_SUITE_RODINIA_TRUE at tarfile = rodinia_2.0.1.tar.gz
 @TEST_SUITE_RODINIA_TRUE at MAKE_OPTS = OPENCL_LIBS="$(OPENCL_EXTLIBS) $(LDFLAGS)" OPENCL_CFLAGS="-I${abs_top_srcdir}/include $(OPENCL_CFLAGS)"
 @TEST_SUITE_RODINIA_TRUE at src = rodinia_2.0.1/opencl
+EXTRA_DIST = Rodinia.patch
 all: all-am
 
 .SUFFIXES:
@@ -358,7 +374,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/Rodinia/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign examples/Rodinia/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -533,6 +548,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 @TEST_SUITE_RODINIA_TRUE at .PHONY: prepare-examples
 
diff --git a/examples/Rodinia/Rodinia.patch b/examples/Rodinia/Rodinia.patch
new file mode 100644
index 0000000..ab15841
--- /dev/null
+++ b/examples/Rodinia/Rodinia.patch
@@ -0,0 +1,16 @@
+diff -uNr a/rodinia_2.0.1/opencl/pathfinder/OpenCL.cpp b/rodinia_2.0.1/opencl/pathfinder/OpenCL.cpp
+--- a/rodinia_2.0.1/opencl/pathfinder/OpenCL.cpp	2011-09-20 16:45:58.000000000 +0300
++++ b/rodinia_2.0.1/opencl/pathfinder/OpenCL.cpp	2014-02-14 13:00:35.137395239 +0200
+@@ -120,10 +120,10 @@
+ 	source_size = ftell(theFile);
+ 	rewind(theFile);
+ 	// Read in the file.
+-	source_str = (char*) malloc(sizeof(char) * source_size);
++	source_str = (char*) malloc(sizeof(char) * source_size + 1);
+ 	fread(source_str, 1, source_size, theFile);
+ 	fclose(theFile);
+-
++	source_str[source_size] = 0;
+ 	// Create a program from the kernel source.
+ 	program = clCreateProgramWithSource(context,
+ 	                                    1,
diff --git a/examples/VexCL/Makefile.in b/examples/VexCL/Makefile.in
index d9210fe..96339b2 100644
--- a/examples/VexCL/Makefile.in
+++ b/examples/VexCL/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -38,7 +38,17 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -103,7 +113,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = examples/VexCL
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am README
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -112,6 +121,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -136,6 +146,7 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in README
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -187,6 +198,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -223,6 +237,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -352,7 +367,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/VexCL/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign examples/VexCL/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -527,6 +541,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 @TEST_SUITE_VEXCL_TRUE at .PHONY: prepare-examples
 
diff --git a/examples/ViennaCL/Makefile.in b/examples/ViennaCL/Makefile.in
index 1bcdaf0..be94001 100644
--- a/examples/ViennaCL/Makefile.in
+++ b/examples/ViennaCL/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -104,7 +114,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = examples/ViennaCL
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am README
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -113,6 +122,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -137,6 +147,7 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in README
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -188,6 +199,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -224,6 +238,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -383,7 +398,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/ViennaCL/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign examples/ViennaCL/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -558,6 +572,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 @TEST_SUITE_VIENNACL_TRUE at .PHONY: prepare-examples
 
diff --git a/examples/example1-spir32/Makefile.in b/examples/example1-spir32/Makefile.in
index 57d74d8..b24b203 100644
--- a/examples/example1-spir32/Makefile.in
+++ b/examples/example1-spir32/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -105,8 +115,6 @@ host_triplet = @host@
 target_triplet = @target@
 noinst_PROGRAMS = example1-spir32$(EXEEXT)
 subdir = examples/example1-spir32
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -115,6 +123,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -192,6 +201,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -243,6 +253,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -279,6 +292,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -414,7 +428,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/example1-spir32/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign examples/example1-spir32/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -713,6 +726,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/examples/example1-spir32/example1.c b/examples/example1-spir32/example1.c
index 4b13679..5dcd372 100644
--- a/examples/example1-spir32/example1.c
+++ b/examples/example1-spir32/example1.c
@@ -74,14 +74,14 @@ main (void)
 
   for (i = 0; i < N; ++i)
     {
-      srcA[i].s[0] = i;
-      srcA[i].s[1] = i;
-      srcA[i].s[2] = i;
-      srcA[i].s[3] = i;
-      srcB[i].s[0] = i;
-      srcB[i].s[1] = i;
-      srcB[i].s[2] = i;
-      srcB[i].s[3] = i;
+      srcA[i].s[0] = (cl_float)i;
+      srcA[i].s[1] = (cl_float)i;
+      srcA[i].s[2] = (cl_float)i;
+      srcA[i].s[3] = (cl_float)i;
+      srcB[i].s[0] = (cl_float)i;
+      srcB[i].s[1] = (cl_float)i;
+      srcB[i].s[2] = (cl_float)i;
+      srcB[i].s[3] = (cl_float)i;
     }
 
   ierr = exec_dot_product_kernel (source, source_size, N, srcA, srcB, dst);
diff --git a/examples/example1-spir32/example1_exec.c b/examples/example1-spir32/example1_exec.c
index ea8131b..94a132a 100644
--- a/examples/example1-spir32/example1_exec.c
+++ b/examples/example1-spir32/example1_exec.c
@@ -35,7 +35,7 @@ exec_dot_product_kernel(const char *program_source, size_t source_size,
  
   // get the list of GPU devices associated with context 
   clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &cb); 
-  devices = (cl_device_id *) malloc(cb); 
+  devices = (cl_device_id *) malloc(cb);
   clGetContextInfo(context, CL_CONTEXT_DEVICES, cb, devices, NULL); 
  
   // create a command-queue 
diff --git a/examples/example1-spir64/Makefile.in b/examples/example1-spir64/Makefile.in
index 8141036..0cf501e 100644
--- a/examples/example1-spir64/Makefile.in
+++ b/examples/example1-spir64/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -105,8 +115,6 @@ host_triplet = @host@
 target_triplet = @target@
 noinst_PROGRAMS = example1-spir$(EXEEXT)
 subdir = examples/example1-spir64
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -115,6 +123,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -191,6 +200,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -242,6 +252,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -278,6 +291,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -413,7 +427,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/example1-spir64/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign examples/example1-spir64/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -712,6 +725,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/examples/example1-spir64/example1.c b/examples/example1-spir64/example1.c
index 4b13679..5dcd372 100644
--- a/examples/example1-spir64/example1.c
+++ b/examples/example1-spir64/example1.c
@@ -74,14 +74,14 @@ main (void)
 
   for (i = 0; i < N; ++i)
     {
-      srcA[i].s[0] = i;
-      srcA[i].s[1] = i;
-      srcA[i].s[2] = i;
-      srcA[i].s[3] = i;
-      srcB[i].s[0] = i;
-      srcB[i].s[1] = i;
-      srcB[i].s[2] = i;
-      srcB[i].s[3] = i;
+      srcA[i].s[0] = (cl_float)i;
+      srcA[i].s[1] = (cl_float)i;
+      srcA[i].s[2] = (cl_float)i;
+      srcA[i].s[3] = (cl_float)i;
+      srcB[i].s[0] = (cl_float)i;
+      srcB[i].s[1] = (cl_float)i;
+      srcB[i].s[2] = (cl_float)i;
+      srcB[i].s[3] = (cl_float)i;
     }
 
   ierr = exec_dot_product_kernel (source, source_size, N, srcA, srcB, dst);
diff --git a/examples/example1-spir64/example1_exec.c b/examples/example1-spir64/example1_exec.c
index ea8131b..94a132a 100644
--- a/examples/example1-spir64/example1_exec.c
+++ b/examples/example1-spir64/example1_exec.c
@@ -35,7 +35,7 @@ exec_dot_product_kernel(const char *program_source, size_t source_size,
  
   // get the list of GPU devices associated with context 
   clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &cb); 
-  devices = (cl_device_id *) malloc(cb); 
+  devices = (cl_device_id *) malloc(cb);
   clGetContextInfo(context, CL_CONTEXT_DEVICES, cb, devices, NULL); 
  
   // create a command-queue 
diff --git a/examples/example1/Makefile.in b/examples/example1/Makefile.in
index 856e882..5ab44b4 100644
--- a/examples/example1/Makefile.in
+++ b/examples/example1/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -105,8 +115,6 @@ host_triplet = @host@
 target_triplet = @target@
 noinst_PROGRAMS = example1$(EXEEXT)
 subdir = examples/example1
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -115,6 +123,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -191,6 +200,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -242,6 +252,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -278,6 +291,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -413,7 +427,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/example1/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign examples/example1/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -712,6 +725,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/examples/example1/example1.c b/examples/example1/example1.c
index 0154393..c6b1a22 100644
--- a/examples/example1/example1.c
+++ b/examples/example1/example1.c
@@ -45,7 +45,6 @@ main (void)
   int source_size;
   cl_float4 *srcA, *srcB;
   cl_float *dst;
-  int ierr;
   int i;
 
   source_file = fopen("example1.cl", "r");
@@ -72,18 +71,21 @@ main (void)
 
   for (i = 0; i < N; ++i)
     {
-      srcA[i].s[0] = i;
-      srcA[i].s[1] = i;
-      srcA[i].s[2] = i;
-      srcA[i].s[3] = i;
-      srcB[i].s[0] = i;
-      srcB[i].s[1] = i;
-      srcB[i].s[2] = i;
-      srcB[i].s[3] = i;
+      srcA[i].s[0] = (cl_float)i;
+      srcA[i].s[1] = (cl_float)i;
+      srcA[i].s[2] = (cl_float)i;
+      srcA[i].s[3] = (cl_float)i;
+      srcB[i].s[0] = (cl_float)i;
+      srcB[i].s[1] = (cl_float)i;
+      srcB[i].s[2] = (cl_float)i;
+      srcB[i].s[3] = (cl_float)i;
     }
 
-  ierr = exec_dot_product_kernel (source, N, srcA, srcB, dst);
-  if (ierr) printf ("ERROR\n");
+  if (exec_dot_product_kernel (source, N, srcA, srcB, dst))
+    {
+      printf ("Error running the tests\n");
+      return -1;
+    }
 
   for (i = 0; i < 4; ++i)
     {
diff --git a/examples/example1/example1_exec.c b/examples/example1/example1_exec.c
index dd65485..27d3838 100644
--- a/examples/example1/example1_exec.c
+++ b/examples/example1/example1_exec.c
@@ -35,7 +35,7 @@ exec_dot_product_kernel(const char *program_source,
  
   // get the list of GPU devices associated with context 
   clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &cb); 
-  devices = (cl_device_id *) malloc(cb); 
+  devices = (cl_device_id *) malloc(cb);
   clGetContextInfo(context, CL_CONTEXT_DEVICES, cb, devices, NULL); 
  
   // create a command-queue 
diff --git a/examples/example2/Makefile.in b/examples/example2/Makefile.in
index 9818a10..50c33c9 100644
--- a/examples/example2/Makefile.in
+++ b/examples/example2/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -105,8 +115,6 @@ host_triplet = @host@
 target_triplet = @target@
 noinst_PROGRAMS = example2$(EXEEXT)
 subdir = examples/example2
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -115,6 +123,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -190,6 +199,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -241,6 +251,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -277,6 +290,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -412,7 +426,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/example2/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign examples/example2/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -696,6 +709,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/examples/example2/example2.c b/examples/example2/example2.c
index 3fabf47..a43655e 100644
--- a/examples/example2/example2.c
+++ b/examples/example2/example2.c
@@ -82,7 +82,7 @@ main (void)
   for (i = 0; i < HEIGHT; ++i)
     {
       for (j = 0; j < WIDTH; ++j)
-	input[i * WIDTH + j] = drand48();
+      input[i * WIDTH + j] = (cl_float)drand48();
     }
   
   context = poclu_create_any_context();
@@ -91,7 +91,7 @@ main (void)
     return -1; 
 
   clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &cb); 
-  devices = (cl_device_id *) malloc(cb); 
+  devices = (cl_device_id *) malloc(cb);
   clGetContextInfo(context, CL_CONTEXT_DEVICES, cb, devices, NULL); 
  
   cmd_queue = clCreateCommandQueue(context, devices[0], 0, NULL); 
diff --git a/examples/example2a/Makefile.in b/examples/example2a/Makefile.in
index d5ff85d..b84e0c1 100644
--- a/examples/example2a/Makefile.in
+++ b/examples/example2a/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -105,8 +115,6 @@ host_triplet = @host@
 target_triplet = @target@
 noinst_PROGRAMS = example2a$(EXEEXT)
 subdir = examples/example2a
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -115,6 +123,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -190,6 +199,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -241,6 +251,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -277,6 +290,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -412,7 +426,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/example2a/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign examples/example2a/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -696,6 +709,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/examples/example2a/example2a.c b/examples/example2a/example2a.c
index aaff051..663f56d 100644
--- a/examples/example2a/example2a.c
+++ b/examples/example2a/example2a.c
@@ -83,7 +83,7 @@ main (void)
   for (i = 0; i < HEIGHT; ++i)
     {
       for (j = 0; j < WIDTH; ++j)
-	input[i * WIDTH + j] = drand48();
+      input[i * WIDTH + j] = (cl_float)drand48();
     }
   
   context = poclu_create_any_context();
@@ -91,7 +91,7 @@ main (void)
     return -1; 
 
   clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &cb); 
-  devices = (cl_device_id *) malloc(cb); 
+  devices = (cl_device_id *) malloc(cb);
   clGetContextInfo(context, CL_CONTEXT_DEVICES, cb, devices, NULL); 
  
   cmd_queue = clCreateCommandQueue(context, devices[0], 0, NULL); 
diff --git a/examples/opencl-book-samples/HelloBinaryWorld.stdout b/examples/opencl-book-samples/HelloBinaryWorld.stdout
new file mode 100644
index 0000000..cb9177d
--- /dev/null
+++ b/examples/opencl-book-samples/HelloBinaryWorld.stdout
@@ -0,0 +1,9 @@
+Attempting to create program from binary...
+Binary not loaded, create from source...
+Save program binary for future run...
+0 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63 66 69 72 75 78 81 84 87 90 93 96 99 102 105 108 111 114 117 120 123 126 129 132 135 138 141 144 147 150 153 156 159 162 165 168 171 174 177 180 183 186 189 192 195 198 201 204 207 210 213 216 219 222 225 228 231 234 237 240 243 246 249 252 255 258 261 264 267 270 273 276 279 282 285 288 291 294 297 300 303 306 309 312 315 318 321 324 327 330 333 336 339 342 345 348 351 354 357 360 363 366 369 372 375 378 381 384 387 390 393 39 [...]
+Executed program succesfully.
+Attempting to create program from binary...
+Read program from binary.
+0 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63 66 69 72 75 78 81 84 87 90 93 96 99 102 105 108 111 114 117 120 123 126 129 132 135 138 141 144 147 150 153 156 159 162 165 168 171 174 177 180 183 186 189 192 195 198 201 204 207 210 213 216 219 222 225 228 231 234 237 240 243 246 249 252 255 258 261 264 267 270 273 276 279 282 285 288 291 294 297 300 303 306 309 312 315 318 321 324 327 330 333 336 339 342 345 348 351 354 357 360 363 366 369 372 375 378 381 384 387 390 393 39 [...]
+Executed program succesfully.
diff --git a/examples/opencl-book-samples/HelloWorld.stdout b/examples/opencl-book-samples/HelloWorld.stdout
new file mode 100644
index 0000000..8147b84
--- /dev/null
+++ b/examples/opencl-book-samples/HelloWorld.stdout
@@ -0,0 +1,2 @@
+0 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63 66 69 72 75 78 81 84 87 90 93 96 99 102 105 108 111 114 117 120 123 126 129 132 135 138 141 144 147 150 153 156 159 162 165 168 171 174 177 180 183 186 189 192 195 198 201 204 207 210 213 216 219 222 225 228 231 234 237 240 243 246 249 252 255 258 261 264 267 270 273 276 279 282 285 288 291 294 297 300 303 306 309 312 315 318 321 324 327 330 333 336 339 342 345 348 351 354 357 360 363 366 369 372 375 378 381 384 387 390 393 39 [...]
+Executed program succesfully.
diff --git a/examples/opencl-book-samples/ImageFilter2D.cl b/examples/opencl-book-samples/ImageFilter2D.cl
new file mode 100644
index 0000000..3c6890d
--- /dev/null
+++ b/examples/opencl-book-samples/ImageFilter2D.cl
@@ -0,0 +1,34 @@
+
+    // Gaussian Kernel is:
+    // 1  2  1
+    // 2  4  2
+    // 1  2  1
+float kernelWeights[9] = { 1.0f, 2.0f, 1.0f, 2.0f, 4.0f, 2.0f,1.0f, 2.0f, 1.0f };  
+
+// Gaussian filter of image
+__kernel void gaussian_filter(__read_only image2d_t srcImg,
+                              __write_only image2d_t dstImg,
+                              sampler_t sampler,
+                              int width, int height)
+{
+    int2 startImageCoord = (int2) (get_global_id(0) - 1, get_global_id(1) - 1);
+    int2 endImageCoord   = (int2) (get_global_id(0) + 1, get_global_id(1) + 1);
+    int2 outImageCoord = (int2) (get_global_id(0), get_global_id(1));
+
+    if (outImageCoord.x < width && outImageCoord.y < height)
+    {
+        int weight = 0;
+        float4 outColor = (float4)(0.0f, 0.0f, 0.0f, 0.0f);
+        for( int y = startImageCoord.y; y <= endImageCoord.y; y++)
+        {
+            for( int x = startImageCoord.x; x <= endImageCoord.x; x++)
+            {
+                outColor += (read_imagef(srcImg, sampler, (int2)(x, y)) * (kernelWeights[weight] / 16.0f));
+                weight += 1;
+            }
+        }
+
+        // Write the output value to image
+        write_imagef(dstImg, outImageCoord, outColor);
+    }
+}
diff --git a/examples/opencl-book-samples/Makefile.am b/examples/opencl-book-samples/Makefile.am
index 25a91a8..2b6bcbe 100644
--- a/examples/opencl-book-samples/Makefile.am
+++ b/examples/opencl-book-samples/Makefile.am
@@ -115,3 +115,7 @@ distclean-local: clean-local
 	$(RM) -r $(book_samples_dir)
 	$(RM) $(book_samples_base_dir)/stamp-patched
 endif
+
+
+EXTRA_DIST = HelloBinaryWorld.stdout OpenCLConvolutionChap3.stdout ImageFilter2D.cl \
+             VectorAdd.stdout HelloWorld.stdout SimpleBufferSubBuffer.stdout
diff --git a/examples/opencl-book-samples/Makefile.in b/examples/opencl-book-samples/Makefile.in
index 93b16f7..b1eafb8 100644
--- a/examples/opencl-book-samples/Makefile.in
+++ b/examples/opencl-book-samples/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -38,7 +38,17 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -103,7 +113,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = examples/opencl-book-samples
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -112,6 +121,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -136,6 +146,7 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -187,6 +198,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -223,6 +237,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -339,6 +354,9 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 @TEST_SUITE_SAMPLES_TRUE at book_samples_base_dir = ${abs_top_srcdir}/examples/opencl-book-samples
 @TEST_SUITE_SAMPLES_TRUE at book_samples_dir = ${book_samples_base_dir}/checkout
+EXTRA_DIST = HelloBinaryWorld.stdout OpenCLConvolutionChap3.stdout ImageFilter2D.cl \
+             VectorAdd.stdout HelloWorld.stdout SimpleBufferSubBuffer.stdout
+
 all: all-am
 
 .SUFFIXES:
@@ -354,7 +372,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/opencl-book-samples/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign examples/opencl-book-samples/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -532,6 +549,8 @@ uninstall-am:
 	mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \
 	uninstall-am
 
+.PRECIOUS: Makefile
+
 
 @TEST_SUITE_SAMPLES_TRUE at .PHONY: build run_all run_working check_dir run_HelloWorld run_OpenCLInfo run_OpenCLConvolutionChap3
 @TEST_SUITE_SAMPLES_TRUE at .PHONY: run_SimpleBufferSubBuffer run_spmv run_VectorAdd run_Dijkstra
diff --git a/examples/opencl-book-samples/OpenCLConvolutionChap3.stdout b/examples/opencl-book-samples/OpenCLConvolutionChap3.stdout
new file mode 100644
index 0000000..9732441
--- /dev/null
+++ b/examples/opencl-book-samples/OpenCLConvolutionChap3.stdout
@@ -0,0 +1,8 @@
+22 27 19 35 41 12 
+21 35 10 26 48 24 
+27 35 29 16 31 26 
+25 31 33 6 34 48 
+22 31 39 22 9 37 
+16 27 43 31 0 38 
+
+Executed program succesfully.
diff --git a/examples/opencl-book-samples/SimpleBufferSubBuffer.stdout b/examples/opencl-book-samples/SimpleBufferSubBuffer.stdout
new file mode 100644
index 0000000..0b513ce
--- /dev/null
+++ b/examples/opencl-book-samples/SimpleBufferSubBuffer.stdout
@@ -0,0 +1,6 @@
+Simple buffer and sub-buffer Example
+Number of platforms: 	1
+	CL_PLATFORM_VENDOR:	The pocl project
+		CL_DEVICE_TYPE:	CL_DEVICE_TYPE_CPU | CL_DEVICE_TYPE_DEFAULT
+ 0 1 4 9 16 25 36 49 64 81 100 121 144 169 196 225
+Program completed successfully
diff --git a/examples/opencl-book-samples/VectorAdd.stdout b/examples/opencl-book-samples/VectorAdd.stdout
new file mode 100644
index 0000000..19e495d
--- /dev/null
+++ b/examples/opencl-book-samples/VectorAdd.stdout
@@ -0,0 +1 @@
+0 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 
diff --git a/examples/piglit/Makefile.am b/examples/piglit/Makefile.am
index 01bb33c..b534d3c 100644
--- a/examples/piglit/Makefile.am
+++ b/examples/piglit/Makefile.am
@@ -44,3 +44,5 @@ clean-examples:
 	cd piglit; make clean
 
 endif
+
+EXTRA_DIST = produce_results.sh
diff --git a/examples/piglit/Makefile.in b/examples/piglit/Makefile.in
index 987f5ad..5364c6e 100644
--- a/examples/piglit/Makefile.in
+++ b/examples/piglit/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -38,7 +38,17 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -103,7 +113,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = examples/piglit
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am README
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -112,6 +121,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -136,6 +146,7 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in README
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -187,6 +198,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -223,6 +237,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -337,6 +352,7 @@ target_vendor = @target_vendor@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
+EXTRA_DIST = produce_results.sh
 all: all-am
 
 .SUFFIXES:
@@ -352,7 +368,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/piglit/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign examples/piglit/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -527,6 +542,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 @TEST_SUITE_PIGLIT_TRUE at .PHONY: build
 
diff --git a/examples/piglit/README b/examples/piglit/README
index f59b8a8..b3d1bbb 100644
--- a/examples/piglit/README
+++ b/examples/piglit/README
@@ -32,6 +32,6 @@ can be used to browse the test results and logs.
 If you do something affecting piglit test results (fix something to make a 
 test pass) then you should make new reference file by 
 running:
-piglit/piglit-run.py -v piglit/tests/all_cl.tests results/all 2>&1 | grep "pass ::" | LC_ALL=C sort -o sorted_ref
+piglit/piglit-run.py -v piglit/tests/cl.tests results/all 2>&1 | grep "pass " | LC_ALL=C sort -o sorted_ref
 
 
diff --git a/examples/piglit/produce_results.sh b/examples/piglit/produce_results.sh
new file mode 100755
index 0000000..979e7cf
--- /dev/null
+++ b/examples/piglit/produce_results.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+# The below test cases seem to pass indeterministically. Filter them out
+# _for now_ to make regression checking feasible.
+piglit/piglit-run.py -v piglit/tests/cl.tests piglit/results/all 2>&1 | egrep "^pass:" | \
+egrep -v "program at execute@builtin at builtin-float-asinh-1.0.generated|\
+program at execute@store at store-uint2-global" > result
+sed -i "s/[ \t]*$//" result
+LC_ALL=C sort result -o sorted_result
diff --git a/examples/scalarwave/Makefile.in b/examples/scalarwave/Makefile.in
index 286eba4..0ae8676 100644
--- a/examples/scalarwave/Makefile.in
+++ b/examples/scalarwave/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -105,8 +115,6 @@ host_triplet = @host@
 target_triplet = @target@
 noinst_PROGRAMS = scalarwave$(EXEEXT)
 subdir = examples/scalarwave
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -115,6 +123,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -190,6 +199,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -241,6 +251,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -277,6 +290,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -412,7 +426,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/scalarwave/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign examples/scalarwave/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -696,6 +709,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/examples/scalarwave/scalarwave.c b/examples/scalarwave/scalarwave.c
index e3b3b61..361b1ac 100644
--- a/examples/scalarwave/scalarwave.c
+++ b/examples/scalarwave/scalarwave.c
@@ -1,6 +1,7 @@
 /* scalarwave - Scalar wave evolution */
 
 #define _BSD_SOURCE             // define M_PI
+#define _DEFAULT_SOURCE
 
 #include <assert.h>
 
@@ -163,9 +164,9 @@ main(void)
   source[source_size] = '\0';
   
   fclose(source_file);
-  
-  
-  
+
+
+
   grid_t grid;
   grid.dt = ALPHA/(NX-1);
   grid.dx = grid.dy = grid.dz = 1.0/(NX-1);
diff --git a/examples/standalone/Makefile.in b/examples/standalone/Makefile.in
index 144da5b..7236b07 100644
--- a/examples/standalone/Makefile.in
+++ b/examples/standalone/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -104,7 +114,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = examples/standalone
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -113,6 +122,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -138,6 +148,7 @@ am__can_run_installinfo = \
   esac
 DATA = $(noinst_DATA)
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -189,6 +200,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -225,6 +239,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -357,7 +372,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/standalone/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign examples/standalone/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -532,6 +546,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 .cl.bc:
 	../../scripts/pocl-standalone -h $(@:.bc=.h) -o $@ $<
diff --git a/examples/trig/Makefile.in b/examples/trig/Makefile.in
index 259f766..7c7508c 100644
--- a/examples/trig/Makefile.in
+++ b/examples/trig/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -105,8 +115,6 @@ host_triplet = @host@
 target_triplet = @target@
 noinst_PROGRAMS = trig$(EXEEXT)
 subdir = examples/trig
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -115,6 +123,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -190,6 +199,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -241,6 +251,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -277,6 +290,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -412,7 +426,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/trig/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign examples/trig/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -711,6 +724,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/examples/trig/trig.c b/examples/trig/trig.c
index 87e1be6..943b964 100644
--- a/examples/trig/trig.c
+++ b/examples/trig/trig.c
@@ -67,10 +67,10 @@ main (void)
 
   for (i = 0; i < N; ++i)
     {
-      srcA[i].s[0] = i;
-      srcA[i].s[1] = i;
-      srcA[i].s[2] = i;
-      srcA[i].s[3] = i;
+      srcA[i].s[0] = (cl_float)i;
+      srcA[i].s[1] = (cl_float)i;
+      srcA[i].s[2] = (cl_float)i;
+      srcA[i].s[3] = (cl_float)i;
       switch (i % 5) {
       case 0: dstS[i] = cosf((float)i); break;
       case 1: dstS[i] = fabsf((float)i) + 7.3f; break;
diff --git a/examples/trig/trig_exec.c b/examples/trig/trig_exec.c
index d03aae4..8f4425b 100644
--- a/examples/trig/trig_exec.c
+++ b/examples/trig/trig_exec.c
@@ -34,7 +34,7 @@ exec_trig_kernel(const char *program_source,
  
   // get the list of GPU devices associated with context 
   clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &cb); 
-  devices = (cl_device_id *) malloc(cb); 
+  devices = (cl_device_id *) malloc(cb);
   clGetContextInfo(context, CL_CONTEXT_DEVICES, cb, devices, NULL); 
  
   // create a command-queue 
diff --git a/include/CL/CMakeLists.txt b/include/CL/CMakeLists.txt
index 7cfabe4..69afd50 100644
--- a/include/CL/CMakeLists.txt
+++ b/include/CL/CMakeLists.txt
@@ -29,8 +29,8 @@ set(_CL_HPP "${CMAKE_CURRENT_SOURCE_DIR}/cl.hpp")
 # TODO apple
 add_custom_command(OUTPUT "${_CL_HPP}"
     COMMAND ${PATCH_EXEC} -i "${CMAKE_SOURCE_DIR}/tools/patches/khronos_cl.hpp.patch"
-     -o "${_CL_HPP}"
-     "${CMAKE_CURRENT_SOURCE_DIR}/cl.hpp.in" )
+     -o "${_CL_HPP}.patched" "${CMAKE_CURRENT_SOURCE_DIR}/cl.hpp.in"
+    COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_CL_HPP}.patched" "${_CL_HPP}" )
 
 add_custom_target("patched_cl_hpp" ALL DEPENDS "${_CL_HPP}" COMMENT "Patching cl.hpp")
 
diff --git a/include/CL/Makefile.am b/include/CL/Makefile.am
index 0e9d7c4..4bc4994 100644
--- a/include/CL/Makefile.am
+++ b/include/CL/Makefile.am
@@ -36,7 +36,8 @@ if INSTALL_OPENCL_HEADERS
 library_includedir = $(includedir)/CL
 library_include_HEADERS = cl.h cl_ext.h			\
                           cl_gl.h cl_gl_ext.h		\
-                          cl_platform.h opencl.h
+                          cl_platform.h opencl.h \
+                          cl2.hpp
 nodist_library_include_HEADERS = cl.hpp
 endif
 
diff --git a/include/CL/Makefile.in b/include/CL/Makefile.in
index 390ebf9..4a89437 100644
--- a/include/CL/Makefile.in
+++ b/include/CL/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -104,8 +114,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = include/CL
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(am__library_include_HEADERS_DIST)
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -114,6 +122,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am \
+	$(am__library_include_HEADERS_DIST) $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -138,7 +148,7 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 am__library_include_HEADERS_DIST = cl.h cl_ext.h cl_gl.h cl_gl_ext.h \
-	cl_platform.h opencl.h
+	cl_platform.h opencl.h cl2.hpp
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
 am__vpath_adj = case $$p in \
     $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
@@ -188,6 +198,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -239,6 +250,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -275,6 +289,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -396,7 +411,8 @@ CLEANFILES = ${BUILT_SOURCES}
 @INSTALL_OPENCL_HEADERS_TRUE at library_includedir = $(includedir)/CL
 @INSTALL_OPENCL_HEADERS_TRUE at library_include_HEADERS = cl.h cl_ext.h			\
 @INSTALL_OPENCL_HEADERS_TRUE@                          cl_gl.h cl_gl_ext.h		\
- at INSTALL_OPENCL_HEADERS_TRUE@                          cl_platform.h opencl.h
+ at INSTALL_OPENCL_HEADERS_TRUE@                          cl_platform.h opencl.h \
+ at INSTALL_OPENCL_HEADERS_TRUE@                          cl2.hpp
 
 @INSTALL_OPENCL_HEADERS_TRUE at nodist_library_include_HEADERS = cl.hpp
 EXTRA_DIST = cl.hpp.in $(top_srcdir)/tools/patches/khronos_cl.hpp.patch CMakeLists.txt
@@ -416,7 +432,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/CL/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign include/CL/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -691,6 +706,8 @@ uninstall-am: uninstall-library_includeHEADERS \
 	uninstall-am uninstall-library_includeHEADERS \
 	uninstall-nodist_library_includeHEADERS
 
+.PRECIOUS: Makefile
+
 #note - this gets run on every build, so don't fail if patch detects a
 #previously applied patch. The copy is a workaround for OSX's 'patch'
 cl.hpp: $(top_srcdir)/include/CL/cl.hpp.in $(top_srcdir)/tools/patches/khronos_cl.hpp.patch
diff --git a/include/CL/cl.hpp.in b/include/CL/cl.hpp.in
index 38fac19..ee867de 100644
--- a/include/CL/cl.hpp.in
+++ b/include/CL/cl.hpp.in
@@ -399,8 +399,8 @@ static inline cl_int errHandler (cl_int err, const char * errStr = NULL)
 #define __ENQUEUE_READ_BUFFER_RECT_ERR      __ERR_STR(clEnqueueReadBufferRect)
 #define __ENQUEUE_WRITE_BUFFER_ERR          __ERR_STR(clEnqueueWriteBuffer)
 #define __ENQUEUE_WRITE_BUFFER_RECT_ERR     __ERR_STR(clEnqueueWriteBufferRect)
-#define __ENQEUE_COPY_BUFFER_ERR            __ERR_STR(clEnqueueCopyBuffer)
-#define __ENQEUE_COPY_BUFFER_RECT_ERR       __ERR_STR(clEnqueueCopyBufferRect)
+#define __ENQUEUE_COPY_BUFFER_ERR            __ERR_STR(clEnqueueCopyBuffer)
+#define __ENQUEUE_COPY_BUFFER_RECT_ERR       __ERR_STR(clEnqueueCopyBufferRect)
 #define __ENQUEUE_FILL_BUFFER_ERR           __ERR_STR(clEnqueueFillBuffer)
 #define __ENQUEUE_READ_IMAGE_ERR            __ERR_STR(clEnqueueReadImage)
 #define __ENQUEUE_WRITE_IMAGE_ERR           __ERR_STR(clEnqueueWriteImage)
@@ -5336,7 +5336,7 @@ public:
                 (events != NULL) ? (cl_uint) events->size() : 0,
                 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
                 (event != NULL) ? &tmp : NULL),
-            __ENQEUE_COPY_BUFFER_ERR);
+            __ENQUEUE_COPY_BUFFER_ERR);
 
         if (event != NULL && err == CL_SUCCESS)
             *event = tmp;
@@ -5451,7 +5451,7 @@ public:
                 (events != NULL) ? (cl_uint) events->size() : 0,
                 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
                 (event != NULL) ? &tmp : NULL),
-            __ENQEUE_COPY_BUFFER_RECT_ERR);
+            __ENQUEUE_COPY_BUFFER_RECT_ERR);
 
         if (event != NULL && err == CL_SUCCESS)
             *event = tmp;
@@ -12405,8 +12405,8 @@ public:
 #undef __ENQUEUE_WRITE_BUFFER_ERR
 #undef __ENQUEUE_READ_BUFFER_RECT_ERR
 #undef __ENQUEUE_WRITE_BUFFER_RECT_ERR
-#undef __ENQEUE_COPY_BUFFER_ERR
-#undef __ENQEUE_COPY_BUFFER_RECT_ERR
+#undef __ENQUEUE_COPY_BUFFER_ERR
+#undef __ENQUEUE_COPY_BUFFER_RECT_ERR
 #undef __ENQUEUE_READ_IMAGE_ERR
 #undef __ENQUEUE_WRITE_IMAGE_ERR
 #undef __ENQUEUE_COPY_IMAGE_ERR
diff --git a/include/CL/cl2.hpp b/include/CL/cl2.hpp
new file mode 100644
index 0000000..07b1c99
--- /dev/null
+++ b/include/CL/cl2.hpp
@@ -0,0 +1,8926 @@
+/*******************************************************************************
+ * Copyright (c) 2008-2015 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ ******************************************************************************/
+
+/*! \file
+ *
+ *   \brief C++ bindings for OpenCL 1.0 (rev 48), OpenCL 1.1 (rev 33), 
+ *       OpenCL 1.2 (rev 15) and OpenCL 2.0 (rev 29)
+ *   \author Lee Howes and Bruce Merry
+ *   
+ *   Derived from the OpenCL 1.x C++ bindings written by 
+ *   Benedict R. Gaster, Laurent Morichetti and Lee Howes
+ *   With additions and fixes from:
+ *       Brian Cole, March 3rd 2010 and April 2012
+ *       Matt Gruenke, April 2012.
+ *       Bruce Merry, February 2013.
+ *       Tom Deakin and Simon McIntosh-Smith, July 2013
+ *   
+ *   \version 2.0.5
+ *   \date 2015-08-10
+ *
+ *   Optional extension support
+ *
+ *         cl_ext_device_fission
+ *         #define CL_HPP_USE_CL_DEVICE_FISSION
+ *         cl_khr_d3d10_sharing
+ *         #define USE_DX_INTEROP
+ */
+
+/*! \mainpage
+ * \section intro Introduction
+ * For many large applications C++ is the language of choice and so it seems
+ * reasonable to define C++ bindings for OpenCL.
+ *
+ * The interface is contained with a single C++ header file \em cl2.hpp and all
+ * definitions are contained within the namespace \em cl. There is no additional
+ * requirement to include \em cl.h and to use either the C++ or original C
+ * bindings; it is enough to simply include \em cl.hpp.
+ *
+ * The bindings themselves are lightweight and correspond closely to the
+ * underlying C API. Using the C++ bindings introduces no additional execution
+ * overhead.
+ *
+ * There are numerous compatibility, portability and memory management
+ * fixes in the new header as well as additional OpenCL 2.0 features.
+ * As a result the header is not directly backward compatible and for this
+ * reason we release it as cl2.hpp rather than a new version of cl.hpp.
+ * 
+ *
+ * \section compatibility Compatibility
+ * Due to the evolution of the underlying OpenCL API the 2.0 C++ bindings
+ * include an updated approach to defining supported feature versions
+ * and the range of valid underlying OpenCL runtime versions supported.
+ *
+ * The combination of preprocessor macros CL_HPP_TARGET_OPENCL_VERSION and 
+ * CL_HPP_MINIMUM_OPENCL_VERSION control this range. These are three digit
+ * decimal values representing OpenCL runime versions. The default for 
+ * the target is 200, representing OpenCL 2.0 and the minimum is also 
+ * defined as 200. These settings would use 2.0 API calls only.
+ * If backward compatibility with a 1.2 runtime is required, the minimum
+ * version may be set to 120.
+ *
+ * Note that this is a compile-time setting, and so affects linking against
+ * a particular SDK version rather than the versioning of the loaded runtime.
+ *
+ * The earlier versions of the header included basic vector and string 
+ * classes based loosely on STL versions. These were difficult to 
+ * maintain and very rarely used. For the 2.0 header we now assume
+ * the presence of the standard library unless requested otherwise.
+ * We use std::array, std::vector, std::shared_ptr and std::string 
+ * throughout to safely manage memory and reduce the chance of a 
+ * recurrance of earlier memory management bugs.
+ *
+ * These classes are used through typedefs in the cl namespace: 
+ * cl::array, cl::vector, cl::pointer and cl::string.
+ * In addition cl::allocate_pointer forwards to std::allocate_shared
+ * by default.
+ * In all cases these standard library classes can be replaced with 
+ * custom interface-compatible versions using the CL_HPP_NO_STD_ARRAY, 
+ * CL_HPP_NO_STD_VECTOR, CL_HPP_NO_STD_SHARED_PTR and 
+ * CL_HPP_NO_STD_STRING macros.
+ *
+ * The OpenCL 1.x versions of the C++ bindings included a size_t wrapper
+ * class to interface with kernel enqueue. This caused unpleasant interactions
+ * with the standard size_t declaration and led to namespacing bugs.
+ * In the 2.0 version we have replaced this with a std::array-based interface.
+ * However, the old behaviour can be regained for backward compatibility
+ * using the CL_HPP_ENABLE_SIZE_T_COMPATIBILITY macro.
+ *
+ * Finally, the program construction interface used a clumsy vector-of-pairs
+ * design in the earlier versions. We have replaced that with a cleaner 
+ * vector-of-vectors and vector-of-strings design. However, for backward 
+ * compatibility old behaviour can be regained with the
+ * CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY macro.
+ * 
+ * In OpenCL 2.0 OpenCL C is not entirely backward compatibility with 
+ * earlier versions. As a result a flag must be passed to the OpenCL C
+ * compiled to request OpenCL 2.0 compilation of kernels with 1.2 as
+ * the default in the absence of the flag.
+ * In some cases the C++ bindings automatically compile code for ease.
+ * For those cases the compilation defaults to OpenCL C 2.0.
+ * If this is not wanted, the CL_HPP_CL_1_2_DEFAULT_BUILD macro may
+ * be specified to assume 1.2 compilation.
+ * If more fine-grained decisions on a per-kernel bases are required
+ * then explicit build operations that take the flag should be used.
+ *
+ *
+ * \section parameterization Parameters
+ * This header may be parameterized by a set of preprocessor macros.
+ * CL_HPP_TARGET_OPENCL_VERSION
+ *  - Defines the target OpenCL runtime version to build the header against.
+ *    Defaults to 200, representing OpenCL 2.0.
+ * CL_HPP_NO_STD_STRING
+ *  - Do not use the standard library string class.
+ *    cl::string is not defined and may be defined by the user before 
+ *    cl2.hpp is included.
+ * CL_HPP_NO_STD_VECTOR
+ *  - Do not use the standard library vector class.
+ *    cl::vector is not defined and may be defined by the user before
+ *    cl2.hpp is included. 
+ * CL_HPP_NO_STD_ARRAY
+ *  - Do not use the standard library array class.
+ *    cl::array is not defined and may be defined by the user before
+ *    cl2.hpp is included.
+ * CL_HPP_NO_STD_SHARED_PTR
+ *  - Do not use the standard library shared_ptr class.
+ *    cl::pointer and the cl::allocate_pointer function are not defined 
+ *    and may be defined by the user before cl2.hpp is included.
+ * CL_HPP_ENABLE_DEVICE_FISSION 
+ *  - Enables device fission for OpenCL 1.2 platforms
+ * CL_HPP_ENABLE_EXCEPTIONS
+ *  - Enable exceptions for use in the C++ bindings header.
+ *    This is the preferred error handling mechanism but is not required.
+ * CL_HPP_ENABLE_SIZE_T_COMPATIBILITY
+ *  - Backward compatibility option to support cl.hpp-style size_t class.
+ *    Replaces the updated std::array derived version and removal of size_t
+ *    from the namespace. Note that in this case the new size_t class
+ *    is placed in the cl::compatibility namespace and thus requires
+ *    an additional using declaration for direct backward compatibility.
+ * CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY 
+ *  - Enable older vector of pairs interface for construction of programs.
+ * CL_HPP_CL_1_2_DEFAULT_BUILD
+ *  - Default to OpenCL C 1.2 compilation rather than OpenCL C 2.0
+ *  - applies to use of cl::Program construction and other program build variants.
+ *
+ *
+ * \section example Example
+ *
+ * The following example shows a general use case for the C++
+ * bindings, including support for the optional exception feature and
+ * also the supplied vector and string classes, see following sections for
+ * decriptions of these features.
+ * 
+ * \code
+    #define CL_HPP_ENABLE_EXCEPTIONS
+    #define CL_HPP_TARGET_OPENCL_VERSION 200
+   
+    #include <CL/cl2.hpp>
+    #include <iostream>
+    #include <vector>
+    #include <memory>
+    #include <algorithm>
+  
+    const int numElements = 32;
+  
+    int main(void)
+    {
+        // Filter for a 2.0 platform and set it as the default
+        std::vector<cl::Platform> platforms;
+        cl::Platform::get(&platforms);
+        cl::Platform plat;
+        for (auto &p : platforms) {
+            std::string platver = p.getInfo<CL_PLATFORM_VERSION>();
+            if (platver.find("OpenCL 2.") != std::string::npos) {
+                plat = p;
+            }
+        }
+        if (plat() == 0)  {
+            std::cout << "No OpenCL 2.0 platform found.";
+            return -1;
+        }
+
+        cl::Platform newP = cl::Platform::setDefault(plat);
+        if (newP != plat) {
+            std::cout << "Error setting default platform.";
+            return -1;
+        }
+    
+        std::string kernel1{
+            "global int globalA;"
+            "kernel void updateGlobal(){"
+            "  globalA = 75;"
+            "}"};
+        std::string kernel2{
+            "typedef struct { global int *bar; } Foo; kernel void vectorAdd(global const Foo* aNum, global const int *inputA, global const int *inputB, global int *output, int val, write_only pipe int outPipe, queue_t childQueue){"
+            "  output[get_global_id(0)] = inputA[get_global_id(0)] + inputB[get_global_id(0)] + val + *(aNum->bar);"
+            "  write_pipe(outPipe, &val);"
+            "  queue_t default_queue = get_default_queue(); "
+            "  ndrange_t ndrange = ndrange_1D(get_global_size(0)/2, get_global_size(0)/2); "
+            // Have a child kernel write into third quarter of output
+            "  enqueue_kernel(default_queue, CLK_ENQUEUE_FLAGS_WAIT_KERNEL, ndrange, "
+            "    ^{"
+            "      output[get_global_size(0)*2 + get_global_id(0)] = inputA[get_global_size(0)*2+get_global_id(0)] + inputB[get_global_size(0)*2+get_global_id(0)] + globalA;"
+            "    });"
+            // Have a child kernel write into last quarter of output
+            "  enqueue_kernel(childQueue, CLK_ENQUEUE_FLAGS_WAIT_KERNEL, ndrange, "
+            "    ^{"
+            "      output[get_global_size(0)*3 + get_global_id(0)] = inputA[get_global_size(0)*3 + get_global_id(0)] + inputB[get_global_size(0)*3 + get_global_id(0)] + globalA + 2;"
+            "    });"
+            "}" };
+
+        // New simpler string interface style
+        std::vector<std::string> programStrings {kernel1, kernel2};
+
+        cl::Program vectorAddProgram(
+            programStrings);
+        try {
+            vectorAddProgram.build("-cl-std=CL2.0");
+        }
+        catch (...) {
+            // Print build info for all devices
+            cl_int buildErr = CL_SUCCESS;
+            auto buildInfo = vectorAddProgram.getBuildInfo<CL_PROGRAM_BUILD_LOG>(&buildErr);
+            for (auto &pair : buildInfo) {
+                std::cerr << pair.second << std::endl << std::endl;
+            }
+        
+            return 1;
+        }
+
+        typedef struct { int *bar; } Foo;
+
+        // Get and run kernel that initializes the program-scope global
+        // A test for kernels that take no arguments
+        auto program2Kernel =
+            cl::KernelFunctor<>(vectorAddProgram, "updateGlobal");
+        program2Kernel(
+            cl::EnqueueArgs(
+            cl::NDRange(1)));
+    
+        //////////////////
+        // SVM allocations
+    
+        cl::pointer<int> anSVMInt = cl::allocate_svm<int, cl::SVMTraitCoarse<>>();
+        *anSVMInt = 5;
+        cl::SVMAllocator<int, cl::SVMTraitCoarse<cl::SVMTraitReadOnly<>>> svmAllocReadOnly;
+        cl::pointer<Foo> fooPointer = cl::allocate_pointer<Foo>(svmAllocReadOnly);
+        fooPointer->bar = anSVMInt.get();
+        cl::SVMAllocator<int, cl::SVMTraitCoarse<>> svmAlloc;
+        std::vector<int, cl::SVMAllocator<int, cl::SVMTraitCoarse<>>> inputA(numElements, 1, svmAlloc);    
+        cl::coarse_svm_vector<int> inputB(numElements, 2, svmAlloc);
+
+        //
+        //////////////
+
+        // Traditional cl_mem allocations
+        std::vector<int> output(numElements, 0xdeadbeef);
+        cl::Buffer outputBuffer(begin(output), end(output), false);
+        cl::Pipe aPipe(sizeof(cl_int), numElements / 2);
+    
+        // Default command queue, also passed in as a parameter
+        cl::DeviceCommandQueue defaultDeviceQueue = cl::DeviceCommandQueue::makeDefault(
+            cl::Context::getDefault(), cl::Device::getDefault());
+    
+        auto vectorAddKernel =
+            cl::KernelFunctor<
+                cl::pointer<Foo>,
+                int*,
+                cl::coarse_svm_vector<int>&,
+                cl::Buffer,
+                int,
+                cl::Pipe&,
+                cl::DeviceCommandQueue
+                >(vectorAddProgram, "vectorAdd");
+
+        // Ensure that the additional SVM pointer is available to the kernel
+        // This one was not passed as a parameter
+        vectorAddKernel.setSVMPointers(anSVMInt);
+
+	    cl_int error;
+	    vectorAddKernel(
+            cl::EnqueueArgs(
+                cl::NDRange(numElements/2),
+                cl::NDRange(numElements/2)),
+            fooPointer,
+            inputA.data(),
+            inputB,
+            outputBuffer,
+            3,
+            aPipe,
+            defaultDeviceQueue,
+		    error
+            );
+
+        cl::copy(outputBuffer, begin(output), end(output));
+
+        cl::Device d = cl::Device::getDefault();
+
+        std::cout << "Output:\n";
+        for (int i = 1; i < numElements; ++i) {
+            std::cout << "\t" << output[i] << "\n";
+        }
+        std::cout << "\n\n";
+
+        return 0;
+    }
+ * 
+ * \endcode
+ *
+ */
+#ifndef CL_HPP_
+#define CL_HPP_
+
+/* Handle deprecated preprocessor definitions. In each case, we only check for
+ * the old name if the new name is not defined, so that user code can define
+ * both and hence work with either version of the bindings.
+ */
+#if !defined(CL_HPP_USE_DX_INTEROP) && defined(USE_DX_INTEROP)
+# pragma message("cl2.hpp: USE_DX_INTEROP is deprecated. Define CL_HPP_USE_DX_INTEROP instead")
+# define CL_HPP_USE_DX_INTEROP
+#endif
+#if !defined(CL_HPP_USE_CL_DEVICE_FISSION) && defined(USE_CL_DEVICE_FISSION)
+# pragma message("cl2.hpp: USE_CL_DEVICE_FISSION is deprecated. Define CL_HPP_USE_CL_DEVICE_FISSION instead")
+# define CL_HPP_USE_CL_DEVICE_FISSION
+#endif
+#if !defined(CL_HPP_ENABLE_EXCEPTIONS) && defined(__CL_ENABLE_EXCEPTIONS)
+# pragma message("cl2.hpp: __CL_ENABLE_EXCEPTIONS is deprecated. Define CL_HPP_ENABLE_EXCEPTIONS instead")
+# define CL_HPP_ENABLE_EXCEPTIONS
+#endif
+#if !defined(CL_HPP_NO_STD_VECTOR) && defined(__NO_STD_VECTOR)
+# pragma message("cl2.hpp: __NO_STD_VECTOR is deprecated. Define CL_HPP_NO_STD_VECTOR instead")
+# define CL_HPP_NO_STD_VECTOR
+#endif
+#if !defined(CL_HPP_NO_STD_STRING) && defined(__NO_STD_STRING)
+# pragma message("cl2.hpp: __NO_STD_STRING is deprecated. Define CL_HPP_NO_STD_STRING instead")
+# define CL_HPP_NO_STD_STRING
+#endif
+#if defined(VECTOR_CLASS)
+# pragma message("cl2.hpp: VECTOR_CLASS is deprecated. Alias cl::vector instead")
+#endif
+#if defined(STRING_CLASS)
+# pragma message("cl2.hpp: STRING_CLASS is deprecated. Alias cl::string instead.")
+#endif
+#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS) && defined(__CL_USER_OVERRIDE_ERROR_STRINGS)
+# pragma message("cl2.hpp: __CL_USER_OVERRIDE_ERROR_STRINGS is deprecated. Define CL_HPP_USER_OVERRIDE_ERROR_STRINGS instead")
+# define CL_HPP_USER_OVERRIDE_ERROR_STRINGS
+#endif
+
+/* Warn about features that are no longer supported
+ */
+#if defined(__USE_DEV_VECTOR)
+# pragma message("cl2.hpp: __USE_DEV_VECTOR is no longer supported. Expect compilation errors")
+#endif
+#if defined(__USE_DEV_STRING)
+# pragma message("cl2.hpp: __USE_DEV_STRING is no longer supported. Expect compilation errors")
+#endif
+
+/* Detect which version to target */
+#if !defined(CL_HPP_TARGET_OPENCL_VERSION)
+# pragma message("cl2.hpp: CL_HPP_TARGET_OPENCL_VERSION is not defined. It will default to 200 (OpenCL 2.0)")
+# define CL_HPP_TARGET_OPENCL_VERSION 200
+#endif
+#if CL_HPP_TARGET_OPENCL_VERSION != 100 && CL_HPP_TARGET_OPENCL_VERSION != 110 && CL_HPP_TARGET_OPENCL_VERSION != 120 && CL_HPP_TARGET_OPENCL_VERSION != 200
+# pragma message("cl2.hpp: CL_HPP_TARGET_OPENCL_VERSION is not a valid value (100, 110, 120 or 200). It will be set to 200")
+# undef CL_HPP_TARGET_OPENCL_VERSION
+# define CL_HPP_TARGET_OPENCL_VERSION 200
+#endif
+
+#if !defined(CL_HPP_MINIMUM_OPENCL_VERSION)
+# define CL_HPP_MINIMUM_OPENCL_VERSION 200
+#endif
+#if CL_HPP_MINIMUM_OPENCL_VERSION != 100 && CL_HPP_MINIMUM_OPENCL_VERSION != 110 && CL_HPP_MINIMUM_OPENCL_VERSION != 120 && CL_HPP_MINIMUM_OPENCL_VERSION != 200
+# pragma message("cl2.hpp: CL_HPP_MINIMUM_OPENCL_VERSION is not a valid value (100, 110, 120 or 200). It will be set to 100")
+# undef CL_HPP_MINIMUM_OPENCL_VERSION
+# define CL_HPP_MINIMUM_OPENCL_VERSION 100
+#endif
+#if CL_HPP_MINIMUM_OPENCL_VERSION > CL_HPP_TARGET_OPENCL_VERSION
+# error "CL_HPP_MINIMUM_OPENCL_VERSION must not be greater than CL_HPP_TARGET_OPENCL_VERSION"
+#endif
+
+#if CL_HPP_MINIMUM_OPENCL_VERSION <= 100 && !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS)
+# define CL_USE_DEPRECATED_OPENCL_1_0_APIS
+#endif
+#if CL_HPP_MINIMUM_OPENCL_VERSION <= 110 && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
+# define CL_USE_DEPRECATED_OPENCL_1_1_APIS
+#endif
+#if CL_HPP_MINIMUM_OPENCL_VERSION <= 120 && !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
+# define CL_USE_DEPRECATED_OPENCL_1_2_APIS
+#endif
+#if CL_HPP_MINIMUM_OPENCL_VERSION <= 200 && !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS)
+# define CL_USE_DEPRECATED_OPENCL_2_0_APIS
+#endif
+
+#ifdef _WIN32
+
+#include <malloc.h>
+
+#if defined(CL_HPP_USE_DX_INTEROP)
+#include <CL/cl_d3d10.h>
+#include <CL/cl_dx9_media_sharing.h>
+#endif
+#endif // _WIN32
+
+#if defined(_MSC_VER)
+#include <intrin.h>
+#endif // _MSC_VER 
+ 
+ // Check for a valid C++ version
+
+// Need to do both tests here because for some reason __cplusplus is not 
+// updated in visual studio
+#if (!defined(_MSC_VER) && __cplusplus < 201103L) || (defined(_MSC_VER) && _MSC_VER < 1700)
+#error Visual studio 2013 or another C++11-supporting compiler required
+#endif
+
+// 
+#if defined(CL_HPP_USE_CL_DEVICE_FISSION) || defined(CL_HPP_USE_CL_SUB_GROUPS_KHR)
+#include <CL/cl_ext.h>
+#endif
+
+#if defined(__APPLE__) || defined(__MACOSX)
+#include <OpenCL/opencl.h>
+#else
+#include <CL/opencl.h>
+#endif // !__APPLE__
+
+#if (__cplusplus >= 201103L)
+#define CL_HPP_NOEXCEPT_ noexcept
+#else
+#define CL_HPP_NOEXCEPT_
+#endif
+
+#if defined(_MSC_VER)
+# define CL_HPP_DEFINE_STATIC_MEMBER_ __declspec(selectany)
+#else
+# define CL_HPP_DEFINE_STATIC_MEMBER_ __attribute__((weak))
+#endif // !_MSC_VER
+
+// Define deprecated prefixes and suffixes to ensure compilation
+// in case they are not pre-defined
+#if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED)
+#define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED  
+#endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED)
+#if !defined(CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED)
+#define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
+#endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED)
+
+#if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED)
+#define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED  
+#endif // #if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED)
+#if !defined(CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED)
+#define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
+#endif // #if !defined(CL_EXT_PREFIX__VERSION_1_2_DEPRECATED)
+
+#if !defined(CL_CALLBACK)
+#define CL_CALLBACK
+#endif //CL_CALLBACK
+
+#include <utility>
+#include <limits>
+#include <iterator>
+#include <mutex>
+#include <cstring>
+#include <functional>
+
+
+// Define a size_type to represent a correctly resolved size_t
+#if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
+namespace cl {
+    using size_type = ::size_t;
+} // namespace cl
+#else // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
+namespace cl {
+    using size_type = size_t;
+} // namespace cl
+#endif // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
+
+
+#if defined(CL_HPP_ENABLE_EXCEPTIONS)
+#include <exception>
+#endif // #if defined(CL_HPP_ENABLE_EXCEPTIONS)
+
+#if !defined(CL_HPP_NO_STD_VECTOR)
+#include <vector>
+namespace cl {
+    template < class T, class Alloc = std::allocator<T> >
+    using vector = std::vector<T, Alloc>;
+} // namespace cl
+#endif // #if !defined(CL_HPP_NO_STD_VECTOR)
+
+#if !defined(CL_HPP_NO_STD_STRING)
+#include <string>
+namespace cl {
+    using string = std::string;
+} // namespace cl
+#endif // #if !defined(CL_HPP_NO_STD_STRING)
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+
+#if !defined(CL_HPP_NO_STD_SHARED_PTR)
+#include <memory>
+namespace cl {
+    // Replace shared_ptr and allocate_ptr for internal use
+    // to allow user to replace them
+    template<class T>
+    using pointer = std::shared_ptr<T>;
+
+    template <class T, class Alloc, class... Args>
+    auto allocate_pointer(const Alloc &alloc, Args&&... args) -> 
+        decltype(std::allocate_shared<T>(
+            alloc, std::forward<Args>(args)...))
+    {
+        return std::allocate_shared<T>(
+            alloc, std::forward<Args>(args)...);
+    }
+} // namespace cl
+#endif 
+#endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
+#if !defined(CL_HPP_NO_STD_ARRAY)
+#include <array>
+namespace cl {
+    template < class T, size_type N >
+    using array = std::array<T, N>;
+}
+#endif // #if !defined(CL_HPP_NO_STD_ARRAY)
+
+// Define size_type appropriately to allow backward-compatibility
+// use of the old size_t interface class
+#if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
+namespace cl {
+    namespace compatibility {
+        /*! \brief class used to interface between C++ and
+        *  OpenCL C calls that require arrays of size_t values, whose
+        *  size is known statically.
+        */
+        template <int N>
+        class size_t
+        {
+        private:
+            size_type data_[N];
+
+        public:
+            //! \brief Initialize size_t to all 0s
+            size_t()
+            {
+                for (int i = 0; i < N; ++i) {
+                    data_[i] = 0;
+                }
+            }
+
+            size_t(const array<size_type, N> &rhs)
+            {
+                for (int i = 0; i < N; ++i) {
+                    data_[i] = rhs[i];
+                }
+            }
+
+            size_type& operator[](int index)
+            {
+                return data_[index];
+            }
+
+            const size_type& operator[](int index) const
+            {
+                return data_[index];
+            }
+
+            //! \brief Conversion operator to T*.
+            operator size_type* ()             { return data_; }
+
+            //! \brief Conversion operator to const T*.
+            operator const size_type* () const { return data_; }
+
+            operator array<size_type, N>() const
+            {
+                array<size_type, N> ret;
+
+                for (int i = 0; i < N; ++i) {
+                    ret[i] = data_[i];
+                }
+                return ret;
+            }
+        };
+    } // namespace compatibility
+
+    template<int N>
+    using size_t = compatibility::size_t<N>;
+} // namespace cl
+#endif // #if defined(CL_HPP_ENABLE_SIZE_T_COMPATIBILITY)
+
+// Helper alias to avoid confusing the macros
+namespace cl{
+    namespace detail {
+        using size_t_array = array<size_type, 3>;
+    }
+}
+
+
+/*! \namespace cl
+ *
+ * \brief The OpenCL C++ bindings are defined within this namespace.
+ *
+ */
+namespace cl {
+    class Memory;
+
+#define CL_HPP_INIT_CL_EXT_FCN_PTR_(name) \
+    if (!pfn_##name) {    \
+    pfn_##name = (PFN_##name) \
+    clGetExtensionFunctionAddress(#name); \
+    if (!pfn_##name) {    \
+    } \
+    }
+
+#define CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, name) \
+    if (!pfn_##name) {    \
+    pfn_##name = (PFN_##name) \
+    clGetExtensionFunctionAddressForPlatform(platform, #name); \
+    if (!pfn_##name) {    \
+    } \
+    }
+
+    class Program;
+    class Device;
+    class Context;
+    class CommandQueue;
+    class DeviceCommandQueue;
+    class Memory;
+    class Buffer;
+    class Pipe;
+
+#if defined(CL_HPP_ENABLE_EXCEPTIONS)
+    /*! \brief Exception class 
+     * 
+     *  This may be thrown by API functions when CL_HPP_ENABLE_EXCEPTIONS is defined.
+     */
+    class Error : public std::exception
+    {
+    private:
+        cl_int err_;
+        const char * errStr_;
+    public:
+        /*! \brief Create a new CL error exception for a given error code
+         *  and corresponding message.
+         * 
+         *  \param err error code value.
+         *
+         *  \param errStr a descriptive string that must remain in scope until
+         *                handling of the exception has concluded.  If set, it
+         *                will be returned by what().
+         */
+        Error(cl_int err, const char * errStr = NULL) : err_(err), errStr_(errStr)
+        {}
+
+        ~Error() throw() {}
+
+        /*! \brief Get error string associated with exception
+         *
+         * \return A memory pointer to the error message string.
+         */
+        virtual const char * what() const throw ()
+        {
+            if (errStr_ == NULL) {
+                return "empty";
+            }
+            else {
+                return errStr_;
+            }
+        }
+
+        /*! \brief Get error code associated with exception
+         *
+         *  \return The error code.
+         */
+        cl_int err(void) const { return err_; }
+    };
+#define CL_HPP_ERR_STR_(x) #x
+#else
+#define CL_HPP_ERR_STR_(x) NULL
+#endif // CL_HPP_ENABLE_EXCEPTIONS
+
+
+namespace detail
+{
+#if defined(CL_HPP_ENABLE_EXCEPTIONS)
+static inline cl_int errHandler (
+    cl_int err,
+    const char * errStr = NULL)
+{
+    if (err != CL_SUCCESS) {
+        throw Error(err, errStr);
+    }
+    return err;
+}
+#else
+static inline cl_int errHandler (cl_int err, const char * errStr = NULL)
+{
+    (void) errStr; // suppress unused variable warning
+    return err;
+}
+#endif // CL_HPP_ENABLE_EXCEPTIONS
+}
+
+
+
+//! \cond DOXYGEN_DETAIL
+#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
+#define __GET_DEVICE_INFO_ERR               CL_HPP_ERR_STR_(clGetDeviceInfo)
+#define __GET_PLATFORM_INFO_ERR             CL_HPP_ERR_STR_(clGetPlatformInfo)
+#define __GET_DEVICE_IDS_ERR                CL_HPP_ERR_STR_(clGetDeviceIDs)
+#define __GET_PLATFORM_IDS_ERR              CL_HPP_ERR_STR_(clGetPlatformIDs)
+#define __GET_CONTEXT_INFO_ERR              CL_HPP_ERR_STR_(clGetContextInfo)
+#define __GET_EVENT_INFO_ERR                CL_HPP_ERR_STR_(clGetEventInfo)
+#define __GET_EVENT_PROFILE_INFO_ERR        CL_HPP_ERR_STR_(clGetEventProfileInfo)
+#define __GET_MEM_OBJECT_INFO_ERR           CL_HPP_ERR_STR_(clGetMemObjectInfo)
+#define __GET_IMAGE_INFO_ERR                CL_HPP_ERR_STR_(clGetImageInfo)
+#define __GET_SAMPLER_INFO_ERR              CL_HPP_ERR_STR_(clGetSamplerInfo)
+#define __GET_KERNEL_INFO_ERR               CL_HPP_ERR_STR_(clGetKernelInfo)
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+#define __GET_KERNEL_ARG_INFO_ERR           CL_HPP_ERR_STR_(clGetKernelArgInfo)
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+#define __GET_KERNEL_WORK_GROUP_INFO_ERR    CL_HPP_ERR_STR_(clGetKernelWorkGroupInfo)
+#define __GET_PROGRAM_INFO_ERR              CL_HPP_ERR_STR_(clGetProgramInfo)
+#define __GET_PROGRAM_BUILD_INFO_ERR        CL_HPP_ERR_STR_(clGetProgramBuildInfo)
+#define __GET_COMMAND_QUEUE_INFO_ERR        CL_HPP_ERR_STR_(clGetCommandQueueInfo)
+
+#define __CREATE_CONTEXT_ERR                CL_HPP_ERR_STR_(clCreateContext)
+#define __CREATE_CONTEXT_FROM_TYPE_ERR      CL_HPP_ERR_STR_(clCreateContextFromType)
+#define __GET_SUPPORTED_IMAGE_FORMATS_ERR   CL_HPP_ERR_STR_(clGetSupportedImageFormats)
+
+#define __CREATE_BUFFER_ERR                 CL_HPP_ERR_STR_(clCreateBuffer)
+#define __COPY_ERR                          CL_HPP_ERR_STR_(cl::copy)
+#define __CREATE_SUBBUFFER_ERR              CL_HPP_ERR_STR_(clCreateSubBuffer)
+#define __CREATE_GL_BUFFER_ERR              CL_HPP_ERR_STR_(clCreateFromGLBuffer)
+#define __CREATE_GL_RENDER_BUFFER_ERR       CL_HPP_ERR_STR_(clCreateFromGLBuffer)
+#define __GET_GL_OBJECT_INFO_ERR            CL_HPP_ERR_STR_(clGetGLObjectInfo)
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+#define __CREATE_IMAGE_ERR                  CL_HPP_ERR_STR_(clCreateImage)
+#define __CREATE_GL_TEXTURE_ERR             CL_HPP_ERR_STR_(clCreateFromGLTexture)
+#define __IMAGE_DIMENSION_ERR               CL_HPP_ERR_STR_(Incorrect image dimensions)
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+#define __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR CL_HPP_ERR_STR_(clSetMemObjectDestructorCallback)
+
+#define __CREATE_USER_EVENT_ERR             CL_HPP_ERR_STR_(clCreateUserEvent)
+#define __SET_USER_EVENT_STATUS_ERR         CL_HPP_ERR_STR_(clSetUserEventStatus)
+#define __SET_EVENT_CALLBACK_ERR            CL_HPP_ERR_STR_(clSetEventCallback)
+#define __WAIT_FOR_EVENTS_ERR               CL_HPP_ERR_STR_(clWaitForEvents)
+
+#define __CREATE_KERNEL_ERR                 CL_HPP_ERR_STR_(clCreateKernel)
+#define __SET_KERNEL_ARGS_ERR               CL_HPP_ERR_STR_(clSetKernelArg)
+#define __CREATE_PROGRAM_WITH_SOURCE_ERR    CL_HPP_ERR_STR_(clCreateProgramWithSource)
+#define __CREATE_PROGRAM_WITH_BINARY_ERR    CL_HPP_ERR_STR_(clCreateProgramWithBinary)
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+#define __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR    CL_HPP_ERR_STR_(clCreateProgramWithBuiltInKernels)
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+#define __BUILD_PROGRAM_ERR                 CL_HPP_ERR_STR_(clBuildProgram)
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+#define __COMPILE_PROGRAM_ERR               CL_HPP_ERR_STR_(clCompileProgram)
+#define __LINK_PROGRAM_ERR                  CL_HPP_ERR_STR_(clLinkProgram)
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+#define __CREATE_KERNELS_IN_PROGRAM_ERR     CL_HPP_ERR_STR_(clCreateKernelsInProgram)
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+#define __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR          CL_HPP_ERR_STR_(clCreateCommandQueueWithProperties)
+#define __CREATE_SAMPLER_WITH_PROPERTIES_ERR                CL_HPP_ERR_STR_(clCreateSamplerWithProperties)
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
+#define __SET_COMMAND_QUEUE_PROPERTY_ERR    CL_HPP_ERR_STR_(clSetCommandQueueProperty)
+#define __ENQUEUE_READ_BUFFER_ERR           CL_HPP_ERR_STR_(clEnqueueReadBuffer)
+#define __ENQUEUE_READ_BUFFER_RECT_ERR      CL_HPP_ERR_STR_(clEnqueueReadBufferRect)
+#define __ENQUEUE_WRITE_BUFFER_ERR          CL_HPP_ERR_STR_(clEnqueueWriteBuffer)
+#define __ENQUEUE_WRITE_BUFFER_RECT_ERR     CL_HPP_ERR_STR_(clEnqueueWriteBufferRect)
+#define __ENQEUE_COPY_BUFFER_ERR            CL_HPP_ERR_STR_(clEnqueueCopyBuffer)
+#define __ENQEUE_COPY_BUFFER_RECT_ERR       CL_HPP_ERR_STR_(clEnqueueCopyBufferRect)
+#define __ENQUEUE_FILL_BUFFER_ERR           CL_HPP_ERR_STR_(clEnqueueFillBuffer)
+#define __ENQUEUE_READ_IMAGE_ERR            CL_HPP_ERR_STR_(clEnqueueReadImage)
+#define __ENQUEUE_WRITE_IMAGE_ERR           CL_HPP_ERR_STR_(clEnqueueWriteImage)
+#define __ENQUEUE_COPY_IMAGE_ERR            CL_HPP_ERR_STR_(clEnqueueCopyImage)
+#define __ENQUEUE_FILL_IMAGE_ERR            CL_HPP_ERR_STR_(clEnqueueFillImage)
+#define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR  CL_HPP_ERR_STR_(clEnqueueCopyImageToBuffer)
+#define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR  CL_HPP_ERR_STR_(clEnqueueCopyBufferToImage)
+#define __ENQUEUE_MAP_BUFFER_ERR            CL_HPP_ERR_STR_(clEnqueueMapBuffer)
+#define __ENQUEUE_MAP_IMAGE_ERR             CL_HPP_ERR_STR_(clEnqueueMapImage)
+#define __ENQUEUE_UNMAP_MEM_OBJECT_ERR      CL_HPP_ERR_STR_(clEnqueueUnMapMemObject)
+#define __ENQUEUE_NDRANGE_KERNEL_ERR        CL_HPP_ERR_STR_(clEnqueueNDRangeKernel)
+#define __ENQUEUE_NATIVE_KERNEL             CL_HPP_ERR_STR_(clEnqueueNativeKernel)
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+#define __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR   CL_HPP_ERR_STR_(clEnqueueMigrateMemObjects)
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+
+#define __ENQUEUE_ACQUIRE_GL_ERR            CL_HPP_ERR_STR_(clEnqueueAcquireGLObjects)
+#define __ENQUEUE_RELEASE_GL_ERR            CL_HPP_ERR_STR_(clEnqueueReleaseGLObjects)
+
+#define __GET_PIPE_INFO_ERR           CL_HPP_ERR_STR_(clGetPipeInfo)
+
+
+#define __RETAIN_ERR                        CL_HPP_ERR_STR_(Retain Object)
+#define __RELEASE_ERR                       CL_HPP_ERR_STR_(Release Object)
+#define __FLUSH_ERR                         CL_HPP_ERR_STR_(clFlush)
+#define __FINISH_ERR                        CL_HPP_ERR_STR_(clFinish)
+#define __VECTOR_CAPACITY_ERR               CL_HPP_ERR_STR_(Vector capacity error)
+
+/**
+ * CL 1.2 version that uses device fission.
+ */
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+#define __CREATE_SUB_DEVICES_ERR            CL_HPP_ERR_STR_(clCreateSubDevices)
+#else
+#define __CREATE_SUB_DEVICES_ERR            CL_HPP_ERR_STR_(clCreateSubDevicesEXT)
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+
+/**
+ * Deprecated APIs for 1.2
+ */
+#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
+#define __ENQUEUE_MARKER_ERR                CL_HPP_ERR_STR_(clEnqueueMarker)
+#define __ENQUEUE_WAIT_FOR_EVENTS_ERR       CL_HPP_ERR_STR_(clEnqueueWaitForEvents)
+#define __ENQUEUE_BARRIER_ERR               CL_HPP_ERR_STR_(clEnqueueBarrier)
+#define __UNLOAD_COMPILER_ERR               CL_HPP_ERR_STR_(clUnloadCompiler)
+#define __CREATE_GL_TEXTURE_2D_ERR          CL_HPP_ERR_STR_(clCreateFromGLTexture2D)
+#define __CREATE_GL_TEXTURE_3D_ERR          CL_HPP_ERR_STR_(clCreateFromGLTexture3D)
+#define __CREATE_IMAGE2D_ERR                CL_HPP_ERR_STR_(clCreateImage2D)
+#define __CREATE_IMAGE3D_ERR                CL_HPP_ERR_STR_(clCreateImage3D)
+#endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
+
+/**
+ * Deprecated APIs for 2.0
+ */
+#if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
+#define __CREATE_COMMAND_QUEUE_ERR          CL_HPP_ERR_STR_(clCreateCommandQueue)
+#define __ENQUEUE_TASK_ERR                  CL_HPP_ERR_STR_(clEnqueueTask)
+#define __CREATE_SAMPLER_ERR                CL_HPP_ERR_STR_(clCreateSampler)
+#endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
+
+#endif // CL_HPP_USER_OVERRIDE_ERROR_STRINGS
+//! \endcond
+
+/**
+ * CL 1.2 marker and barrier commands
+ */
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+#define __ENQUEUE_MARKER_WAIT_LIST_ERR                CL_HPP_ERR_STR_(clEnqueueMarkerWithWaitList)
+#define __ENQUEUE_BARRIER_WAIT_LIST_ERR               CL_HPP_ERR_STR_(clEnqueueBarrierWithWaitList)
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+
+
+namespace detail {
+
+// Generic getInfoHelper. The final parameter is used to guide overload
+// resolution: the actual parameter passed is an int, which makes this
+// a worse conversion sequence than a specialization that declares the
+// parameter as an int.
+template<typename Functor, typename T>
+inline cl_int getInfoHelper(Functor f, cl_uint name, T* param, long)
+{
+    return f(name, sizeof(T), param, NULL);
+}
+
+// Specialized for getInfo<CL_PROGRAM_BINARIES>
+// Assumes that the output vector was correctly resized on the way in
+template <typename Func>
+inline cl_int getInfoHelper(Func f, cl_uint name, vector<vector<unsigned char>>* param, int)
+{
+    if (name != CL_PROGRAM_BINARIES) {
+        return CL_INVALID_VALUE;
+    }
+    if (param) {
+        // Create array of pointers, calculate total size and pass pointer array in
+        size_type numBinaries = param->size();
+        vector<unsigned char*> binariesPointers(numBinaries);
+
+        size_type totalSize = 0;
+        for (size_type i = 0; i < numBinaries; ++i)
+        {
+            binariesPointers[i] = (*param)[i].data();
+            totalSize += (*param)[i].size();
+        }
+
+        cl_int err = f(name, totalSize, binariesPointers.data(), NULL);
+
+        if (err != CL_SUCCESS) {
+            return err;
+        }
+    }
+
+
+    return CL_SUCCESS;
+}
+
+// Specialized getInfoHelper for vector params
+template <typename Func, typename T>
+inline cl_int getInfoHelper(Func f, cl_uint name, vector<T>* param, long)
+{
+    size_type required;
+    cl_int err = f(name, 0, NULL, &required);
+    if (err != CL_SUCCESS) {
+        return err;
+    }
+    const size_type elements = required / sizeof(T);
+
+    // Temporary to avoid changing param on an error
+    vector<T> localData(elements);
+    err = f(name, required, localData.data(), NULL);
+    if (err != CL_SUCCESS) {
+        return err;
+    }
+    if (param) {
+        *param = std::move(localData);
+    }
+
+    return CL_SUCCESS;
+}
+
+/* Specialization for reference-counted types. This depends on the
+ * existence of Wrapper<T>::cl_type, and none of the other types having the
+ * cl_type member. Note that simplify specifying the parameter as Wrapper<T>
+ * does not work, because when using a derived type (e.g. Context) the generic
+ * template will provide a better match.
+ */
+template <typename Func, typename T>
+inline cl_int getInfoHelper(
+    Func f, cl_uint name, vector<T>* param, int, typename T::cl_type = 0)
+{
+    size_type required;
+    cl_int err = f(name, 0, NULL, &required);
+    if (err != CL_SUCCESS) {
+        return err;
+    }
+
+    const size_type elements = required / sizeof(typename T::cl_type);
+
+    vector<typename T::cl_type> value(elements);
+    err = f(name, required, value.data(), NULL);
+    if (err != CL_SUCCESS) {
+        return err;
+    }
+
+    if (param) {
+        // Assign to convert CL type to T for each element
+        param->resize(elements);
+
+        // Assign to param, constructing with retain behaviour
+        // to correctly capture each underlying CL object
+        for (size_type i = 0; i < elements; i++) {
+            (*param)[i] = T(value[i], true);
+        }
+    }
+    return CL_SUCCESS;
+}
+
+// Specialized GetInfoHelper for string params
+template <typename Func>
+inline cl_int getInfoHelper(Func f, cl_uint name, string* param, long)
+{
+    size_type required;
+    cl_int err = f(name, 0, NULL, &required);
+    if (err != CL_SUCCESS) {
+        return err;
+    }
+
+    // std::string has a constant data member
+    // a char vector does not
+    vector<char> value(required);
+    err = f(name, required, value.data(), NULL);
+    if (err != CL_SUCCESS) {
+        return err;
+    }
+    if (param) {
+        param->assign(begin(value), prev(end(value)));
+    }
+    return CL_SUCCESS;
+}
+
+// Specialized GetInfoHelper for clsize_t params
+template <typename Func, size_type N>
+inline cl_int getInfoHelper(Func f, cl_uint name, array<size_type, N>* param, long)
+{
+    size_type required;
+    cl_int err = f(name, 0, NULL, &required);
+    if (err != CL_SUCCESS) {
+        return err;
+    }
+
+    size_type elements = required / sizeof(size_type);
+    vector<size_type> value(elements, 0);
+
+    err = f(name, required, value.data(), NULL);
+    if (err != CL_SUCCESS) {
+        return err;
+    }
+    
+    // Bound the copy with N to prevent overruns
+    // if passed N > than the amount copied
+    if (elements > N) {
+        elements = N;
+    }
+    for (size_type i = 0; i < elements; ++i) {
+        (*param)[i] = value[i];
+    }
+
+    return CL_SUCCESS;
+}
+
+template<typename T> struct ReferenceHandler;
+
+/* Specialization for reference-counted types. This depends on the
+ * existence of Wrapper<T>::cl_type, and none of the other types having the
+ * cl_type member. Note that simplify specifying the parameter as Wrapper<T>
+ * does not work, because when using a derived type (e.g. Context) the generic
+ * template will provide a better match.
+ */
+template<typename Func, typename T>
+inline cl_int getInfoHelper(Func f, cl_uint name, T* param, int, typename T::cl_type = 0)
+{
+    typename T::cl_type value;
+    cl_int err = f(name, sizeof(value), &value, NULL);
+    if (err != CL_SUCCESS) {
+        return err;
+    }
+    *param = value;
+    if (value != NULL)
+    {
+        err = param->retain();
+        if (err != CL_SUCCESS) {
+            return err;
+        }
+    }
+    return CL_SUCCESS;
+}
+
+#define CL_HPP_PARAM_NAME_INFO_1_0_(F) \
+    F(cl_platform_info, CL_PLATFORM_PROFILE, string) \
+    F(cl_platform_info, CL_PLATFORM_VERSION, string) \
+    F(cl_platform_info, CL_PLATFORM_NAME, string) \
+    F(cl_platform_info, CL_PLATFORM_VENDOR, string) \
+    F(cl_platform_info, CL_PLATFORM_EXTENSIONS, string) \
+    \
+    F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \
+    F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \
+    F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \
+    F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \
+    F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, size_type) \
+    F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, cl::vector<size_type>) \
+    F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \
+    F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \
+    F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \
+    F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \
+    F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \
+    F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \
+    F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \
+    F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \
+    F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \
+    F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \
+    F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \
+    F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, size_type) \
+    F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, size_type) \
+    F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, size_type) \
+    F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, size_type) \
+    F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, size_type) \
+    F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \
+    F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, size_type) \
+    F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \
+    F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \
+    F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \
+    F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \
+    F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \
+    F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\
+    F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \
+    F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \
+    F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \
+    F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \
+    F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \
+    F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \
+    F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \
+    F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, size_type) \
+    F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \
+    F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \
+    F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \
+    F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \
+    F(cl_device_info, CL_DEVICE_PLATFORM, cl_platform_id) \
+    F(cl_device_info, CL_DEVICE_NAME, string) \
+    F(cl_device_info, CL_DEVICE_VENDOR, string) \
+    F(cl_device_info, CL_DRIVER_VERSION, string) \
+    F(cl_device_info, CL_DEVICE_PROFILE, string) \
+    F(cl_device_info, CL_DEVICE_VERSION, string) \
+    F(cl_device_info, CL_DEVICE_EXTENSIONS, string) \
+    \
+    F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \
+    F(cl_context_info, CL_CONTEXT_DEVICES, cl::vector<Device>) \
+    F(cl_context_info, CL_CONTEXT_PROPERTIES, cl::vector<cl_context_properties>) \
+    \
+    F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \
+    F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \
+    F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \
+    F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_int) \
+    \
+    F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \
+    F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \
+    F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \
+    F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \
+    \
+    F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \
+    F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \
+    F(cl_mem_info, CL_MEM_SIZE, size_type) \
+    F(cl_mem_info, CL_MEM_HOST_PTR, void*) \
+    F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \
+    F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \
+    F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \
+    \
+    F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \
+    F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, size_type) \
+    F(cl_image_info, CL_IMAGE_ROW_PITCH, size_type) \
+    F(cl_image_info, CL_IMAGE_SLICE_PITCH, size_type) \
+    F(cl_image_info, CL_IMAGE_WIDTH, size_type) \
+    F(cl_image_info, CL_IMAGE_HEIGHT, size_type) \
+    F(cl_image_info, CL_IMAGE_DEPTH, size_type) \
+    F(cl_image_info, CL_IMAGE_ARRAY_SIZE, size_type) \
+    F(cl_image_info, CL_IMAGE_NUM_MIP_LEVELS, cl_uint) \
+    F(cl_image_info, CL_IMAGE_NUM_SAMPLES, cl_uint) \
+    \
+    F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \
+    F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \
+    F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_addressing_mode) \
+    F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_filter_mode) \
+    F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_bool) \
+    \
+    F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \
+    F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \
+    F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \
+    F(cl_program_info, CL_PROGRAM_DEVICES, cl::vector<Device>) \
+    F(cl_program_info, CL_PROGRAM_SOURCE, string) \
+    F(cl_program_info, CL_PROGRAM_BINARY_SIZES, cl::vector<size_type>) \
+    F(cl_program_info, CL_PROGRAM_BINARIES, cl::vector<cl::vector<unsigned char>>) \
+    \
+    F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \
+    F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, string) \
+    F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, string) \
+    \
+    F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, string) \
+    F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \
+    F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \
+    F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \
+    F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \
+    \
+    F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, size_type) \
+    F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::detail::size_t_array) \
+    F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \
+    \
+    F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \
+    F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \
+    F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \
+    F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties)
+
+
+#define CL_HPP_PARAM_NAME_INFO_1_1_(F) \
+    F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\
+    F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \
+    F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \
+    F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \
+    F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \
+    F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \
+    F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \
+    F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \
+    F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \
+    F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \
+    F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \
+    F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, string) \
+    \
+    F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \
+    F(cl_mem_info, CL_MEM_OFFSET, size_type) \
+    \
+    F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, size_type) \
+    F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \
+    \
+    F(cl_event_info, CL_EVENT_CONTEXT, cl::Context)
+
+#define CL_HPP_PARAM_NAME_INFO_1_2_(F) \
+    F(cl_program_info, CL_PROGRAM_NUM_KERNELS, size_type) \
+    F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, string) \
+    \
+    F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \
+    \
+    F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, string) \
+    \
+    F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \
+    F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \
+    F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, string) \
+    F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, string) \
+    \
+    F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl_device_id) \
+    F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, cl::vector<cl_device_partition_property>) \
+    F(cl_device_info, CL_DEVICE_PARTITION_TYPE, cl::vector<cl_device_partition_property>)  \
+    F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint) \
+    F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, size_type) \
+    F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \
+    F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS, string)
+
+#define CL_HPP_PARAM_NAME_INFO_2_0_(F) \
+    F(cl_device_info, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, cl_command_queue_properties) \
+    F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, cl_command_queue_properties) \
+    F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE, cl_uint) \
+    F(cl_device_info, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, cl_uint) \
+    F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_QUEUES, cl_uint) \
+    F(cl_device_info, CL_DEVICE_MAX_ON_DEVICE_EVENTS, cl_uint) \
+    F(cl_device_info, CL_DEVICE_MAX_PIPE_ARGS, cl_uint) \
+    F(cl_device_info, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, cl_uint) \
+    F(cl_device_info, CL_DEVICE_PIPE_MAX_PACKET_SIZE, cl_uint) \
+    F(cl_device_info, CL_DEVICE_SVM_CAPABILITIES, cl_device_svm_capabilities) \
+    F(cl_pipe_info, CL_PIPE_PACKET_SIZE, cl_uint) \
+    F(cl_pipe_info, CL_PIPE_MAX_PACKETS, cl_uint)
+
+#define CL_HPP_PARAM_NAME_DEVICE_FISSION_(F) \
+    F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl_device_id) \
+    F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, cl::vector<cl_device_partition_property_ext>) \
+    F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, cl::vector<cl_device_partition_property_ext>) \
+    F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \
+    F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, cl::vector<cl_device_partition_property_ext>)
+
+template <typename enum_type, cl_int Name>
+struct param_traits {};
+
+#define CL_HPP_DECLARE_PARAM_TRAITS_(token, param_name, T) \
+struct token;                                        \
+template<>                                           \
+struct param_traits<detail:: token,param_name>       \
+{                                                    \
+    enum { value = param_name };                     \
+    typedef T param_type;                            \
+};
+
+CL_HPP_PARAM_NAME_INFO_1_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
+#if CL_HPP_TARGET_OPENCL_VERSION >= 110
+CL_HPP_PARAM_NAME_INFO_1_1_(CL_HPP_DECLARE_PARAM_TRAITS_)
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+CL_HPP_PARAM_NAME_INFO_1_2_(CL_HPP_DECLARE_PARAM_TRAITS_)
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
+#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+CL_HPP_PARAM_NAME_INFO_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
+
+
+// Flags deprecated in OpenCL 2.0
+#define CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(F) \
+    F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties)
+
+#define CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(F) \
+    F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool)
+
+#define CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(F) \
+    F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer)
+
+// Include deprecated query flags based on versions
+// Only include deprecated 1.0 flags if 2.0 not active as there is an enum clash
+#if CL_HPP_TARGET_OPENCL_VERSION > 100 && CL_HPP_MINIMUM_OPENCL_VERSION < 200 && CL_HPP_TARGET_OPENCL_VERSION < 200
+CL_HPP_PARAM_NAME_INFO_1_0_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
+#endif // CL_HPP_MINIMUM_OPENCL_VERSION < 110
+#if CL_HPP_TARGET_OPENCL_VERSION > 110 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
+CL_HPP_PARAM_NAME_INFO_1_1_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
+#endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120
+#if CL_HPP_TARGET_OPENCL_VERSION > 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 200
+CL_HPP_PARAM_NAME_INFO_1_2_DEPRECATED_IN_2_0_(CL_HPP_DECLARE_PARAM_TRAITS_)
+#endif // CL_HPP_MINIMUM_OPENCL_VERSION < 200
+
+#if defined(CL_HPP_USE_CL_DEVICE_FISSION)
+CL_HPP_PARAM_NAME_DEVICE_FISSION_(CL_HPP_DECLARE_PARAM_TRAITS_);
+#endif // CL_HPP_USE_CL_DEVICE_FISSION
+
+#ifdef CL_PLATFORM_ICD_SUFFIX_KHR
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR, string)
+#endif
+
+#ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, cl_ulong)
+#endif
+
+#ifdef CL_DEVICE_GLOBAL_FREE_MEMORY_AMD
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_FREE_MEMORY_AMD, vector<size_type>)
+#endif
+#ifdef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD, cl_uint)
+#endif
+#ifdef CL_DEVICE_SIMD_WIDTH_AMD
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_WIDTH_AMD, cl_uint)
+#endif
+#ifdef CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD, cl_uint)
+#endif
+#ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WAVEFRONT_WIDTH_AMD, cl_uint)
+#endif
+#ifdef CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD, cl_uint)
+#endif
+#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD, cl_uint)
+#endif
+#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD, cl_uint)
+#endif
+#ifdef CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD, cl_uint)
+#endif
+#ifdef CL_DEVICE_LOCAL_MEM_BANKS_AMD
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LOCAL_MEM_BANKS_AMD, cl_uint)
+#endif
+
+#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, cl_uint)
+#endif
+#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, cl_uint)
+#endif
+#ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_REGISTERS_PER_BLOCK_NV, cl_uint)
+#endif
+#ifdef CL_DEVICE_WARP_SIZE_NV
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WARP_SIZE_NV, cl_uint)
+#endif
+#ifdef CL_DEVICE_GPU_OVERLAP_NV
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_GPU_OVERLAP_NV, cl_bool)
+#endif
+#ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, cl_bool)
+#endif
+#ifdef CL_DEVICE_INTEGRATED_MEMORY_NV
+CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_bool)
+#endif
+
+// Convenience functions
+
+template <typename Func, typename T>
+inline cl_int
+getInfo(Func f, cl_uint name, T* param)
+{
+    return getInfoHelper(f, name, param, 0);
+}
+
+template <typename Func, typename Arg0>
+struct GetInfoFunctor0
+{
+    Func f_; const Arg0& arg0_;
+    cl_int operator ()(
+        cl_uint param, size_type size, void* value, size_type* size_ret)
+    { return f_(arg0_, param, size, value, size_ret); }
+};
+
+template <typename Func, typename Arg0, typename Arg1>
+struct GetInfoFunctor1
+{
+    Func f_; const Arg0& arg0_; const Arg1& arg1_;
+    cl_int operator ()(
+        cl_uint param, size_type size, void* value, size_type* size_ret)
+    { return f_(arg0_, arg1_, param, size, value, size_ret); }
+};
+
+template <typename Func, typename Arg0, typename T>
+inline cl_int
+getInfo(Func f, const Arg0& arg0, cl_uint name, T* param)
+{
+    GetInfoFunctor0<Func, Arg0> f0 = { f, arg0 };
+    return getInfoHelper(f0, name, param, 0);
+}
+
+template <typename Func, typename Arg0, typename Arg1, typename T>
+inline cl_int
+getInfo(Func f, const Arg0& arg0, const Arg1& arg1, cl_uint name, T* param)
+{
+    GetInfoFunctor1<Func, Arg0, Arg1> f0 = { f, arg0, arg1 };
+    return getInfoHelper(f0, name, param, 0);
+}
+
+
+template<typename T>
+struct ReferenceHandler
+{ };
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+/**
+ * OpenCL 1.2 devices do have retain/release.
+ */
+template <>
+struct ReferenceHandler<cl_device_id>
+{
+    /**
+     * Retain the device.
+     * \param device A valid device created using createSubDevices
+     * \return 
+     *   CL_SUCCESS if the function executed successfully.
+     *   CL_INVALID_DEVICE if device was not a valid subdevice
+     *   CL_OUT_OF_RESOURCES
+     *   CL_OUT_OF_HOST_MEMORY
+     */
+    static cl_int retain(cl_device_id device)
+    { return ::clRetainDevice(device); }
+    /**
+     * Retain the device.
+     * \param device A valid device created using createSubDevices
+     * \return 
+     *   CL_SUCCESS if the function executed successfully.
+     *   CL_INVALID_DEVICE if device was not a valid subdevice
+     *   CL_OUT_OF_RESOURCES
+     *   CL_OUT_OF_HOST_MEMORY
+     */
+    static cl_int release(cl_device_id device)
+    { return ::clReleaseDevice(device); }
+};
+#else // CL_HPP_TARGET_OPENCL_VERSION >= 120
+/**
+ * OpenCL 1.1 devices do not have retain/release.
+ */
+template <>
+struct ReferenceHandler<cl_device_id>
+{
+    // cl_device_id does not have retain().
+    static cl_int retain(cl_device_id)
+    { return CL_SUCCESS; }
+    // cl_device_id does not have release().
+    static cl_int release(cl_device_id)
+    { return CL_SUCCESS; }
+};
+#endif // ! (CL_HPP_TARGET_OPENCL_VERSION >= 120)
+
+template <>
+struct ReferenceHandler<cl_platform_id>
+{
+    // cl_platform_id does not have retain().
+    static cl_int retain(cl_platform_id)
+    { return CL_SUCCESS; }
+    // cl_platform_id does not have release().
+    static cl_int release(cl_platform_id)
+    { return CL_SUCCESS; }
+};
+
+template <>
+struct ReferenceHandler<cl_context>
+{
+    static cl_int retain(cl_context context)
+    { return ::clRetainContext(context); }
+    static cl_int release(cl_context context)
+    { return ::clReleaseContext(context); }
+};
+
+template <>
+struct ReferenceHandler<cl_command_queue>
+{
+    static cl_int retain(cl_command_queue queue)
+    { return ::clRetainCommandQueue(queue); }
+    static cl_int release(cl_command_queue queue)
+    { return ::clReleaseCommandQueue(queue); }
+};
+
+template <>
+struct ReferenceHandler<cl_mem>
+{
+    static cl_int retain(cl_mem memory)
+    { return ::clRetainMemObject(memory); }
+    static cl_int release(cl_mem memory)
+    { return ::clReleaseMemObject(memory); }
+};
+
+template <>
+struct ReferenceHandler<cl_sampler>
+{
+    static cl_int retain(cl_sampler sampler)
+    { return ::clRetainSampler(sampler); }
+    static cl_int release(cl_sampler sampler)
+    { return ::clReleaseSampler(sampler); }
+};
+
+template <>
+struct ReferenceHandler<cl_program>
+{
+    static cl_int retain(cl_program program)
+    { return ::clRetainProgram(program); }
+    static cl_int release(cl_program program)
+    { return ::clReleaseProgram(program); }
+};
+
+template <>
+struct ReferenceHandler<cl_kernel>
+{
+    static cl_int retain(cl_kernel kernel)
+    { return ::clRetainKernel(kernel); }
+    static cl_int release(cl_kernel kernel)
+    { return ::clReleaseKernel(kernel); }
+};
+
+template <>
+struct ReferenceHandler<cl_event>
+{
+    static cl_int retain(cl_event event)
+    { return ::clRetainEvent(event); }
+    static cl_int release(cl_event event)
+    { return ::clReleaseEvent(event); }
+};
+
+
+// Extracts version number with major in the upper 16 bits, minor in the lower 16
+static cl_uint getVersion(const vector<char> &versionInfo)
+{
+    int highVersion = 0;
+    int lowVersion = 0;
+    int index = 7;
+    while(versionInfo[index] != '.' ) {
+        highVersion *= 10;
+        highVersion += versionInfo[index]-'0';
+        ++index;
+    }
+    ++index;
+    while(versionInfo[index] != ' ' &&  versionInfo[index] != '\0') {
+        lowVersion *= 10;
+        lowVersion += versionInfo[index]-'0';
+        ++index;
+    }
+    return (highVersion << 16) | lowVersion;
+}
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
+static cl_uint getPlatformVersion(cl_platform_id platform)
+{
+    size_type size = 0;
+    clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0, NULL, &size);
+    
+    vector<char> versionInfo(size);
+    clGetPlatformInfo(platform, CL_PLATFORM_VERSION, size, versionInfo.data(), &size);
+    return getVersion(versionInfo);
+}
+
+static cl_uint getDevicePlatformVersion(cl_device_id device)
+{
+    cl_platform_id platform;
+    clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform), &platform, NULL);
+    return getPlatformVersion(platform);
+}
+
+static cl_uint getContextPlatformVersion(cl_context context)
+{
+    // The platform cannot be queried directly, so we first have to grab a
+    // device and obtain its context
+    size_type size = 0;
+    clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &size);
+    if (size == 0)
+        return 0;
+    vector<cl_device_id> devices(size/sizeof(cl_device_id));
+    clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices.data(), NULL);
+    return getDevicePlatformVersion(devices[0]);
+}
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
+
+template <typename T>
+class Wrapper
+{
+public:
+    typedef T cl_type;
+
+protected:
+    cl_type object_;
+
+public:
+    Wrapper() : object_(NULL) { }
+    
+    Wrapper(const cl_type &obj, bool retainObject) : object_(obj) 
+    {
+        if (retainObject) { 
+            detail::errHandler(retain(), __RETAIN_ERR); 
+        }
+    }
+
+    ~Wrapper()
+    {
+        if (object_ != NULL) { release(); }
+    }
+
+    Wrapper(const Wrapper<cl_type>& rhs)
+    {
+        object_ = rhs.object_;
+        detail::errHandler(retain(), __RETAIN_ERR);
+    }
+
+    Wrapper(Wrapper<cl_type>&& rhs) CL_HPP_NOEXCEPT_
+    {
+        object_ = rhs.object_;
+        rhs.object_ = NULL;
+    }
+
+    Wrapper<cl_type>& operator = (const Wrapper<cl_type>& rhs)
+    {
+        if (this != &rhs) {
+            detail::errHandler(release(), __RELEASE_ERR);
+            object_ = rhs.object_;
+            detail::errHandler(retain(), __RETAIN_ERR);
+        }
+        return *this;
+    }
+
+    Wrapper<cl_type>& operator = (Wrapper<cl_type>&& rhs)
+    {
+        if (this != &rhs) {
+            detail::errHandler(release(), __RELEASE_ERR);
+            object_ = rhs.object_;
+            rhs.object_ = NULL;
+        }
+        return *this;
+    }
+
+    Wrapper<cl_type>& operator = (const cl_type &rhs)
+    {
+        detail::errHandler(release(), __RELEASE_ERR);
+        object_ = rhs;
+        return *this;
+    }
+
+    const cl_type& operator ()() const { return object_; }
+
+    cl_type& operator ()() { return object_; }
+
+protected:
+    template<typename Func, typename U>
+    friend inline cl_int getInfoHelper(Func, cl_uint, U*, int, typename U::cl_type);
+
+    cl_int retain() const
+    {
+        if (object_ != nullptr) {
+            return ReferenceHandler<cl_type>::retain(object_);
+        }
+        else {
+            return CL_SUCCESS;
+        }
+    }
+
+    cl_int release() const
+    {
+        if (object_ != nullptr) {
+            return ReferenceHandler<cl_type>::release(object_);
+        }
+        else {
+            return CL_SUCCESS;
+        }
+    }
+};
+
+template <>
+class Wrapper<cl_device_id>
+{
+public:
+    typedef cl_device_id cl_type;
+
+protected:
+    cl_type object_;
+    bool referenceCountable_;
+
+    static bool isReferenceCountable(cl_device_id device)
+    {
+        bool retVal = false;
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
+        if (device != NULL) {
+            int version = getDevicePlatformVersion(device);
+            if(version > ((1 << 16) + 1)) {
+                retVal = true;
+            }
+        }
+#else // CL_HPP_MINIMUM_OPENCL_VERSION < 120
+        retVal = true;
+#endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+        return retVal;
+    }
+
+public:
+    Wrapper() : object_(NULL), referenceCountable_(false) 
+    { 
+    }
+    
+    Wrapper(const cl_type &obj, bool retainObject) : 
+        object_(obj), 
+        referenceCountable_(false) 
+    {
+        referenceCountable_ = isReferenceCountable(obj); 
+
+        if (retainObject) {
+            detail::errHandler(retain(), __RETAIN_ERR);
+        }
+    }
+
+    ~Wrapper()
+    {
+        release();
+    }
+    
+    Wrapper(const Wrapper<cl_type>& rhs)
+    {
+        object_ = rhs.object_;
+        referenceCountable_ = isReferenceCountable(object_); 
+        detail::errHandler(retain(), __RETAIN_ERR);
+    }
+
+    Wrapper(Wrapper<cl_type>&& rhs) CL_HPP_NOEXCEPT_
+    {
+        object_ = rhs.object_;
+        referenceCountable_ = rhs.referenceCountable_;
+        rhs.object_ = NULL;
+        rhs.referenceCountable_ = false;
+    }
+
+    Wrapper<cl_type>& operator = (const Wrapper<cl_type>& rhs)
+    {
+        if (this != &rhs) {
+            detail::errHandler(release(), __RELEASE_ERR);
+            object_ = rhs.object_;
+            referenceCountable_ = rhs.referenceCountable_;
+            detail::errHandler(retain(), __RETAIN_ERR);
+        }
+        return *this;
+    }
+
+    Wrapper<cl_type>& operator = (Wrapper<cl_type>&& rhs)
+    {
+        if (this != &rhs) {
+            detail::errHandler(release(), __RELEASE_ERR);
+            object_ = rhs.object_;
+            referenceCountable_ = rhs.referenceCountable_;
+            rhs.object_ = NULL;
+            rhs.referenceCountable_ = false;
+        }
+        return *this;
+    }
+
+    Wrapper<cl_type>& operator = (const cl_type &rhs)
+    {
+        detail::errHandler(release(), __RELEASE_ERR);
+        object_ = rhs;
+        referenceCountable_ = isReferenceCountable(object_); 
+        return *this;
+    }
+
+    const cl_type& operator ()() const { return object_; }
+
+    cl_type& operator ()() { return object_; }
+
+protected:
+    template<typename Func, typename U>
+    friend inline cl_int getInfoHelper(Func, cl_uint, U*, int, typename U::cl_type);
+
+    template<typename Func, typename U>
+    friend inline cl_int getInfoHelper(Func, cl_uint, vector<U>*, int, typename U::cl_type);
+
+    cl_int retain() const
+    {
+        if( object_ != nullptr && referenceCountable_ ) {
+            return ReferenceHandler<cl_type>::retain(object_);
+        }
+        else {
+            return CL_SUCCESS;
+        }
+    }
+
+    cl_int release() const
+    {
+        if (object_ != nullptr && referenceCountable_) {
+            return ReferenceHandler<cl_type>::release(object_);
+        }
+        else {
+            return CL_SUCCESS;
+        }
+    }
+};
+
+template <typename T>
+inline bool operator==(const Wrapper<T> &lhs, const Wrapper<T> &rhs)
+{
+    return lhs() == rhs();
+}
+
+template <typename T>
+inline bool operator!=(const Wrapper<T> &lhs, const Wrapper<T> &rhs)
+{
+    return !operator==(lhs, rhs);
+}
+
+} // namespace detail
+//! \endcond
+
+
+using BuildLogType = vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, CL_PROGRAM_BUILD_LOG>::param_type>>;
+#if defined(CL_HPP_ENABLE_EXCEPTIONS)
+/**
+* Exception class for build errors to carry build info
+*/
+class BuildError : public Error
+{
+private:
+    BuildLogType buildLogs;
+public:
+    BuildError(cl_int err, const char * errStr, const BuildLogType &vec) : Error(err, errStr), buildLogs(vec)
+    {
+    }
+
+    BuildLogType getBuildLog() const
+    {
+        return buildLogs;
+    }
+};
+namespace detail {
+    static inline cl_int buildErrHandler(
+        cl_int err,
+        const char * errStr,
+        const BuildLogType &buildLogs)
+    {
+        if (err != CL_SUCCESS) {
+            throw BuildError(err, errStr, buildLogs);
+        }
+        return err;
+    }
+} // namespace detail
+
+#else
+namespace detail {
+    static inline cl_int buildErrHandler(
+        cl_int err,
+        const char * errStr,
+        const BuildLogType &buildLogs)
+    {
+        (void)buildLogs; // suppress unused variable warning
+        (void)errStr;
+        return err;
+    }
+} // namespace detail
+#endif // #if defined(CL_HPP_ENABLE_EXCEPTIONS)
+
+
+/*! \stuct ImageFormat
+ *  \brief Adds constructors and member functions for cl_image_format.
+ *
+ *  \see cl_image_format
+ */
+struct ImageFormat : public cl_image_format
+{
+    //! \brief Default constructor - performs no initialization.
+    ImageFormat(){}
+
+    //! \brief Initializing constructor.
+    ImageFormat(cl_channel_order order, cl_channel_type type)
+    {
+        image_channel_order = order;
+        image_channel_data_type = type;
+    }
+
+    //! \brief Assignment operator.
+    ImageFormat& operator = (const ImageFormat& rhs)
+    {
+        if (this != &rhs) {
+            this->image_channel_data_type = rhs.image_channel_data_type;
+            this->image_channel_order     = rhs.image_channel_order;
+        }
+        return *this;
+    }
+};
+
+/*! \brief Class interface for cl_device_id.
+ *
+ *  \note Copies of these objects are inexpensive, since they don't 'own'
+ *        any underlying resources or data structures.
+ *
+ *  \see cl_device_id
+ */
+class Device : public detail::Wrapper<cl_device_id>
+{
+private:
+    static std::once_flag default_initialized_;
+    static Device default_;
+    static cl_int default_error_;
+
+    /*! \brief Create the default context.
+    *
+    * This sets @c default_ and @c default_error_. It does not throw
+    * @c cl::Error.
+    */
+    static void makeDefault();
+
+    /*! \brief Create the default platform from a provided platform.
+    *
+    * This sets @c default_. It does not throw
+    * @c cl::Error.
+    */
+    static void makeDefaultProvided(const Device &p) {
+        default_ = p;
+    }
+
+public:
+#ifdef CL_HPP_UNIT_TEST_ENABLE
+    /*! \brief Reset the default.
+    *
+    * This sets @c default_ to an empty value to support cleanup in
+    * the unit test framework.
+    * This function is not thread safe.
+    */
+    static void unitTestClearDefault() {
+        default_ = Device();
+    }
+#endif // #ifdef CL_HPP_UNIT_TEST_ENABLE
+
+    //! \brief Default constructor - initializes to NULL.
+    Device() : detail::Wrapper<cl_type>() { }
+
+    /*! \brief Constructor from cl_device_id.
+     * 
+     *  This simply copies the device ID value, which is an inexpensive operation.
+     */
+    explicit Device(const cl_device_id &device, bool retainObject = false) : 
+        detail::Wrapper<cl_type>(device, retainObject) { }
+
+    /*! \brief Returns the first device on the default context.
+     *
+     *  \see Context::getDefault()
+     */
+    static Device getDefault(
+        cl_int *errResult = NULL)
+    {
+        std::call_once(default_initialized_, makeDefault);
+        detail::errHandler(default_error_);
+        if (errResult != NULL) {
+            *errResult = default_error_;
+        }
+        return default_;
+    }
+
+    /**
+    * Modify the default device to be used by
+    * subsequent operations.
+    * Will only set the default if no default was previously created.
+    * @return updated default device.
+    *         Should be compared to the passed value to ensure that it was updated.
+    */
+    static Device setDefault(const Device &default_device)
+    {
+        std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_device));
+        detail::errHandler(default_error_);
+        return default_;
+    }
+
+    /*! \brief Assignment operator from cl_device_id.
+     * 
+     *  This simply copies the device ID value, which is an inexpensive operation.
+     */
+    Device& operator = (const cl_device_id& rhs)
+    {
+        detail::Wrapper<cl_type>::operator=(rhs);
+        return *this;
+    }
+
+    /*! \brief Copy constructor to forward copy to the superclass correctly.
+    * Required for MSVC.
+    */
+    Device(const Device& dev) : detail::Wrapper<cl_type>(dev) {}
+
+    /*! \brief Copy assignment to forward copy to the superclass correctly.
+    * Required for MSVC.
+    */
+    Device& operator = (const Device &dev)
+    {
+        detail::Wrapper<cl_type>::operator=(dev);
+        return *this;
+    }
+
+    /*! \brief Move constructor to forward move to the superclass correctly.
+    * Required for MSVC.
+    */
+    Device(Device&& dev) CL_HPP_NOEXCEPT_ : detail::Wrapper<cl_type>(std::move(dev)) {}
+
+    /*! \brief Move assignment to forward move to the superclass correctly.
+    * Required for MSVC.
+    */
+    Device& operator = (Device &&dev)
+    {
+        detail::Wrapper<cl_type>::operator=(std::move(dev));
+        return *this;
+    }
+
+    //! \brief Wrapper for clGetDeviceInfo().
+    template <typename T>
+    cl_int getInfo(cl_device_info name, T* param) const
+    {
+        return detail::errHandler(
+            detail::getInfo(&::clGetDeviceInfo, object_, name, param),
+            __GET_DEVICE_INFO_ERR);
+    }
+
+    //! \brief Wrapper for clGetDeviceInfo() that returns by value.
+    template <cl_int name> typename
+    detail::param_traits<detail::cl_device_info, name>::param_type
+    getInfo(cl_int* err = NULL) const
+    {
+        typename detail::param_traits<
+            detail::cl_device_info, name>::param_type param;
+        cl_int result = getInfo(name, &param);
+        if (err != NULL) {
+            *err = result;
+        }
+        return param;
+    }
+
+    /**
+     * CL 1.2 version
+     */
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+    //! \brief Wrapper for clCreateSubDevices().
+    cl_int createSubDevices(
+        const cl_device_partition_property * properties,
+        vector<Device>* devices)
+    {
+        cl_uint n = 0;
+        cl_int err = clCreateSubDevices(object_, properties, 0, NULL, &n);
+        if (err != CL_SUCCESS) {
+            return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
+        }
+
+        vector<cl_device_id> ids(n);
+        err = clCreateSubDevices(object_, properties, n, ids.data(), NULL);
+        if (err != CL_SUCCESS) {
+            return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
+        }
+
+        // Cannot trivially assign because we need to capture intermediates 
+        // with safe construction
+        if (devices) {
+            devices->resize(ids.size());
+
+            // Assign to param, constructing with retain behaviour
+            // to correctly capture each underlying CL object
+            for (size_type i = 0; i < ids.size(); i++) {
+                // We do not need to retain because this device is being created 
+                // by the runtime
+                (*devices)[i] = Device(ids[i], false);
+            }
+        }
+
+        return CL_SUCCESS;
+    }
+#elif defined(CL_HPP_USE_CL_DEVICE_FISSION)
+
+/**
+ * CL 1.1 version that uses device fission extension.
+ */
+    cl_int createSubDevices(
+        const cl_device_partition_property_ext * properties,
+        vector<Device>* devices)
+    {
+        typedef CL_API_ENTRY cl_int 
+            ( CL_API_CALL * PFN_clCreateSubDevicesEXT)(
+                cl_device_id /*in_device*/,
+                const cl_device_partition_property_ext * /* properties */,
+                cl_uint /*num_entries*/,
+                cl_device_id * /*out_devices*/,
+                cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1;
+
+        static PFN_clCreateSubDevicesEXT pfn_clCreateSubDevicesEXT = NULL;
+        CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateSubDevicesEXT);
+
+        cl_uint n = 0;
+        cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0, NULL, &n);
+        if (err != CL_SUCCESS) {
+            return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
+        }
+
+        vector<cl_device_id> ids(n);
+        err = pfn_clCreateSubDevicesEXT(object_, properties, n, ids.data(), NULL);
+        if (err != CL_SUCCESS) {
+            return detail::errHandler(err, __CREATE_SUB_DEVICES_ERR);
+        }
+        // Cannot trivially assign because we need to capture intermediates 
+        // with safe construction
+        if (devices) {
+            devices->resize(ids.size());
+
+            // Assign to param, constructing with retain behaviour
+            // to correctly capture each underlying CL object
+            for (size_type i = 0; i < ids.size(); i++) {
+                // We do not need to retain because this device is being created 
+                // by the runtime
+                (*devices)[i] = Device(ids[i], false);
+            }
+        }
+        return CL_SUCCESS;
+    }
+#endif // defined(CL_HPP_USE_CL_DEVICE_FISSION)
+};
+
+CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Device::default_initialized_;
+CL_HPP_DEFINE_STATIC_MEMBER_ Device Device::default_;
+CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Device::default_error_ = CL_SUCCESS;
+
+/*! \brief Class interface for cl_platform_id.
+ *
+ *  \note Copies of these objects are inexpensive, since they don't 'own'
+ *        any underlying resources or data structures.
+ *
+ *  \see cl_platform_id
+ */
+class Platform : public detail::Wrapper<cl_platform_id>
+{
+private:
+    static std::once_flag default_initialized_;
+    static Platform default_;
+    static cl_int default_error_;
+
+    /*! \brief Create the default context.
+    *
+    * This sets @c default_ and @c default_error_. It does not throw
+    * @c cl::Error.
+    */
+    static void makeDefault() {
+        /* Throwing an exception from a call_once invocation does not do
+        * what we wish, so we catch it and save the error.
+        */
+#if defined(CL_HPP_ENABLE_EXCEPTIONS)
+        try
+#endif
+        {
+            // If default wasn't passed ,generate one
+            // Otherwise set it
+            cl_uint n = 0;
+
+            cl_int err = ::clGetPlatformIDs(0, NULL, &n);
+            if (err != CL_SUCCESS) {
+                default_error_ = err;
+                return;
+            }
+            if (n == 0) {
+                default_error_ = CL_INVALID_PLATFORM;
+                return;
+            }
+
+            vector<cl_platform_id> ids(n);
+            err = ::clGetPlatformIDs(n, ids.data(), NULL);
+            if (err != CL_SUCCESS) {
+                default_error_ = err;
+                return;
+            }
+
+            default_ = Platform(ids[0]);
+        }
+#if defined(CL_HPP_ENABLE_EXCEPTIONS)
+        catch (cl::Error &e) {
+            default_error_ = e.err();
+        }
+#endif
+    }
+
+    /*! \brief Create the default platform from a provided platform.
+     *
+     * This sets @c default_. It does not throw
+     * @c cl::Error.
+     */
+    static void makeDefaultProvided(const Platform &p) {
+       default_ = p;
+    }
+    
+public:
+#ifdef CL_HPP_UNIT_TEST_ENABLE
+    /*! \brief Reset the default.
+    *
+    * This sets @c default_ to an empty value to support cleanup in
+    * the unit test framework.
+    * This function is not thread safe.
+    */
+    static void unitTestClearDefault() {
+        default_ = Platform();
+    }
+#endif // #ifdef CL_HPP_UNIT_TEST_ENABLE
+
+    //! \brief Default constructor - initializes to NULL.
+    Platform() : detail::Wrapper<cl_type>()  { }
+
+    /*! \brief Constructor from cl_platform_id.
+     * 
+     * \param retainObject will cause the constructor to retain its cl object.
+     *                     Defaults to false to maintain compatibility with
+     *                     earlier versions.
+     *  This simply copies the platform ID value, which is an inexpensive operation.
+     */
+    explicit Platform(const cl_platform_id &platform, bool retainObject = false) : 
+        detail::Wrapper<cl_type>(platform, retainObject) { }
+
+    /*! \brief Assignment operator from cl_platform_id.
+     * 
+     *  This simply copies the platform ID value, which is an inexpensive operation.
+     */
+    Platform& operator = (const cl_platform_id& rhs)
+    {
+        detail::Wrapper<cl_type>::operator=(rhs);
+        return *this;
+    }
+
+    static Platform getDefault(
+        cl_int *errResult = NULL)
+    {
+        std::call_once(default_initialized_, makeDefault);
+        detail::errHandler(default_error_);
+        if (errResult != NULL) {
+            *errResult = default_error_;
+        }
+        return default_;
+    }
+
+    /**
+     * Modify the default platform to be used by 
+     * subsequent operations.
+     * Will only set the default if no default was previously created.
+     * @return updated default platform. 
+     *         Should be compared to the passed value to ensure that it was updated.
+     */
+    static Platform setDefault(const Platform &default_platform)
+    {
+        std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_platform));
+        detail::errHandler(default_error_);
+        return default_;
+    }
+
+    //! \brief Wrapper for clGetPlatformInfo().
+    cl_int getInfo(cl_platform_info name, string* param) const
+    {
+        return detail::errHandler(
+            detail::getInfo(&::clGetPlatformInfo, object_, name, param),
+            __GET_PLATFORM_INFO_ERR);
+    }
+
+    //! \brief Wrapper for clGetPlatformInfo() that returns by value.
+    template <cl_int name> typename
+    detail::param_traits<detail::cl_platform_info, name>::param_type
+    getInfo(cl_int* err = NULL) const
+    {
+        typename detail::param_traits<
+            detail::cl_platform_info, name>::param_type param;
+        cl_int result = getInfo(name, &param);
+        if (err != NULL) {
+            *err = result;
+        }
+        return param;
+    }
+
+    /*! \brief Gets a list of devices for this platform.
+     * 
+     *  Wraps clGetDeviceIDs().
+     */
+    cl_int getDevices(
+        cl_device_type type,
+        vector<Device>* devices) const
+    {
+        cl_uint n = 0;
+        if( devices == NULL ) {
+            return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
+        }
+        cl_int err = ::clGetDeviceIDs(object_, type, 0, NULL, &n);
+        if (err != CL_SUCCESS) {
+            return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
+        }
+
+        vector<cl_device_id> ids(n);
+        err = ::clGetDeviceIDs(object_, type, n, ids.data(), NULL);
+        if (err != CL_SUCCESS) {
+            return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
+        }
+
+        // Cannot trivially assign because we need to capture intermediates 
+        // with safe construction
+        // We must retain things we obtain from the API to avoid releasing
+        // API-owned objects.
+        if (devices) {
+            devices->resize(ids.size());
+
+            // Assign to param, constructing with retain behaviour
+            // to correctly capture each underlying CL object
+            for (size_type i = 0; i < ids.size(); i++) {
+                (*devices)[i] = Device(ids[i], true);
+            }
+        }
+        return CL_SUCCESS;
+    }
+
+#if defined(CL_HPP_USE_DX_INTEROP)
+   /*! \brief Get the list of available D3D10 devices.
+     *
+     *  \param d3d_device_source.
+     *
+     *  \param d3d_object.
+     *
+     *  \param d3d_device_set.
+     *
+     *  \param devices returns a vector of OpenCL D3D10 devices found. The cl::Device
+     *  values returned in devices can be used to identify a specific OpenCL
+     *  device. If \a devices argument is NULL, this argument is ignored.
+     *
+     *  \return One of the following values:
+     *    - CL_SUCCESS if the function is executed successfully.
+     *
+     *  The application can query specific capabilities of the OpenCL device(s)
+     *  returned by cl::getDevices. This can be used by the application to
+     *  determine which device(s) to use.
+     *
+     * \note In the case that exceptions are enabled and a return value
+     * other than CL_SUCCESS is generated, then cl::Error exception is
+     * generated.
+     */
+    cl_int getDevices(
+        cl_d3d10_device_source_khr d3d_device_source,
+        void *                     d3d_object,
+        cl_d3d10_device_set_khr    d3d_device_set,
+        vector<Device>* devices) const
+    {
+        typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)(
+            cl_platform_id platform, 
+            cl_d3d10_device_source_khr d3d_device_source, 
+            void * d3d_object,
+            cl_d3d10_device_set_khr d3d_device_set,
+            cl_uint num_entries,
+            cl_device_id * devices,
+            cl_uint* num_devices);
+
+        if( devices == NULL ) {
+            return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR);
+        }
+
+        static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR = NULL;
+        CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(object_, clGetDeviceIDsFromD3D10KHR);
+
+        cl_uint n = 0;
+        cl_int err = pfn_clGetDeviceIDsFromD3D10KHR(
+            object_, 
+            d3d_device_source, 
+            d3d_object,
+            d3d_device_set, 
+            0, 
+            NULL, 
+            &n);
+        if (err != CL_SUCCESS) {
+            return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
+        }
+
+        vector<cl_device_id> ids(n);
+        err = pfn_clGetDeviceIDsFromD3D10KHR(
+            object_, 
+            d3d_device_source, 
+            d3d_object,
+            d3d_device_set,
+            n, 
+            ids.data(), 
+            NULL);
+        if (err != CL_SUCCESS) {
+            return detail::errHandler(err, __GET_DEVICE_IDS_ERR);
+        }
+
+        // Cannot trivially assign because we need to capture intermediates 
+        // with safe construction
+        // We must retain things we obtain from the API to avoid releasing
+        // API-owned objects.
+        if (devices) {
+            devices->resize(ids.size());
+
+            // Assign to param, constructing with retain behaviour
+            // to correctly capture each underlying CL object
+            for (size_type i = 0; i < ids.size(); i++) {
+                (*devices)[i] = Device(ids[i], true);
+            }
+        }
+        return CL_SUCCESS;
+    }
+#endif
+
+    /*! \brief Gets a list of available platforms.
+     * 
+     *  Wraps clGetPlatformIDs().
+     */
+    static cl_int get(
+        vector<Platform>* platforms)
+    {
+        cl_uint n = 0;
+
+        if( platforms == NULL ) {
+            return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR);
+        }
+
+        cl_int err = ::clGetPlatformIDs(0, NULL, &n);
+        if (err != CL_SUCCESS) {
+            return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
+        }
+
+        vector<cl_platform_id> ids(n);
+        err = ::clGetPlatformIDs(n, ids.data(), NULL);
+        if (err != CL_SUCCESS) {
+            return detail::errHandler(err, __GET_PLATFORM_IDS_ERR);
+        }
+
+        if (platforms) {
+            platforms->resize(ids.size());
+
+            // Platforms don't reference count
+            for (size_type i = 0; i < ids.size(); i++) {
+                (*platforms)[i] = Platform(ids[i]);
+            }
+        }
+        return CL_SUCCESS;
+    }
+
+    /*! \brief Gets the first available platform.
+     * 
+     *  Wraps clGetPlatformIDs(), returning the first result.
+     */
+    static cl_int get(
+        Platform * platform)
+    {
+        cl_int err;
+        Platform default_platform = Platform::getDefault(&err);
+        if (platform) {
+            *platform = default_platform;
+        }
+        return err;
+    }
+
+    /*! \brief Gets the first available platform, returning it by value.
+     *
+     * \return Returns a valid platform if one is available.
+     *         If no platform is available will return a null platform.
+     * Throws an exception if no platforms are available
+     * or an error condition occurs.
+     * Wraps clGetPlatformIDs(), returning the first result.
+     */
+    static Platform get(
+        cl_int * errResult = NULL)
+    {
+        cl_int err;
+        Platform default_platform = Platform::getDefault(&err);
+        if (errResult) {
+            *errResult = err;
+        }
+        return default_platform;
+    }    
+    
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+    //! \brief Wrapper for clUnloadCompiler().
+    cl_int
+    unloadCompiler()
+    {
+        return ::clUnloadPlatformCompiler(object_);
+    }
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+}; // class Platform
+
+CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Platform::default_initialized_;
+CL_HPP_DEFINE_STATIC_MEMBER_ Platform Platform::default_;
+CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Platform::default_error_ = CL_SUCCESS;
+
+
+/**
+ * Deprecated APIs for 1.2
+ */
+#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
+/**
+ * Unload the OpenCL compiler.
+ * \note Deprecated for OpenCL 1.2. Use Platform::unloadCompiler instead.
+ */
+inline CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int
+UnloadCompiler() CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
+inline cl_int
+UnloadCompiler()
+{
+    return ::clUnloadCompiler();
+}
+#endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
+
+/*! \brief Class interface for cl_context.
+ *
+ *  \note Copies of these objects are shallow, meaning that the copy will refer
+ *        to the same underlying cl_context as the original.  For details, see
+ *        clRetainContext() and clReleaseContext().
+ *
+ *  \see cl_context
+ */
+class Context 
+    : public detail::Wrapper<cl_context>
+{
+private:
+    static std::once_flag default_initialized_;
+    static Context default_;
+    static cl_int default_error_;
+
+    /*! \brief Create the default context from the default device type in the default platform.
+     *
+     * This sets @c default_ and @c default_error_. It does not throw
+     * @c cl::Error.
+     */
+    static void makeDefault() {
+        /* Throwing an exception from a call_once invocation does not do
+         * what we wish, so we catch it and save the error.
+         */
+#if defined(CL_HPP_ENABLE_EXCEPTIONS)
+        try
+#endif
+        {
+#if !defined(__APPLE__) && !defined(__MACOS)
+            const Platform &p = Platform::getDefault();
+            cl_platform_id defaultPlatform = p();
+            cl_context_properties properties[3] = {
+                CL_CONTEXT_PLATFORM, (cl_context_properties)defaultPlatform, 0
+            };
+#else // #if !defined(__APPLE__) && !defined(__MACOS)
+            cl_context_properties *properties = nullptr;
+#endif // #if !defined(__APPLE__) && !defined(__MACOS)
+
+            default_ = Context(
+                CL_DEVICE_TYPE_DEFAULT,
+                properties,
+                NULL,
+                NULL,
+                &default_error_);
+        }
+#if defined(CL_HPP_ENABLE_EXCEPTIONS)
+        catch (cl::Error &e) {
+            default_error_ = e.err();
+        }
+#endif
+    }
+
+
+    /*! \brief Create the default context from a provided Context.
+     *
+     * This sets @c default_. It does not throw
+     * @c cl::Error.
+     */
+    static void makeDefaultProvided(const Context &c) {
+        default_ = c;
+    }
+    
+public:
+#ifdef CL_HPP_UNIT_TEST_ENABLE
+    /*! \brief Reset the default.
+    *
+    * This sets @c default_ to an empty value to support cleanup in
+    * the unit test framework.
+    * This function is not thread safe.
+    */
+    static void unitTestClearDefault() {
+        default_ = Context();
+    }
+#endif // #ifdef CL_HPP_UNIT_TEST_ENABLE
+
+    /*! \brief Constructs a context including a list of specified devices.
+     *
+     *  Wraps clCreateContext().
+     */
+    Context(
+        const vector<Device>& devices,
+        cl_context_properties* properties = NULL,
+        void (CL_CALLBACK * notifyFptr)(
+            const char *,
+            const void *,
+            size_type,
+            void *) = NULL,
+        void* data = NULL,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+
+        size_type numDevices = devices.size();
+        vector<cl_device_id> deviceIDs(numDevices);
+
+        for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
+            deviceIDs[deviceIndex] = (devices[deviceIndex])();
+        }
+
+        object_ = ::clCreateContext(
+            properties, (cl_uint) numDevices,
+            deviceIDs.data(),
+            notifyFptr, data, &error);
+
+        detail::errHandler(error, __CREATE_CONTEXT_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    Context(
+        const Device& device,
+        cl_context_properties* properties = NULL,
+        void (CL_CALLBACK * notifyFptr)(
+            const char *,
+            const void *,
+            size_type,
+            void *) = NULL,
+        void* data = NULL,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+
+        cl_device_id deviceID = device();
+
+        object_ = ::clCreateContext(
+            properties, 1,
+            &deviceID,
+            notifyFptr, data, &error);
+
+        detail::errHandler(error, __CREATE_CONTEXT_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+    
+    /*! \brief Constructs a context including all or a subset of devices of a specified type.
+     *
+     *  Wraps clCreateContextFromType().
+     */
+    Context(
+        cl_device_type type,
+        cl_context_properties* properties = NULL,
+        void (CL_CALLBACK * notifyFptr)(
+            const char *,
+            const void *,
+            size_type,
+            void *) = NULL,
+        void* data = NULL,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+
+#if !defined(__APPLE__) && !defined(__MACOS)
+        cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0 };
+
+        if (properties == NULL) {
+            // Get a valid platform ID as we cannot send in a blank one
+            vector<Platform> platforms;
+            error = Platform::get(&platforms);
+            if (error != CL_SUCCESS) {
+                detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
+                if (err != NULL) {
+                    *err = error;
+                }
+                return;
+            }
+
+            // Check the platforms we found for a device of our specified type
+            cl_context_properties platform_id = 0;
+            for (unsigned int i = 0; i < platforms.size(); i++) {
+
+                vector<Device> devices;
+
+#if defined(CL_HPP_ENABLE_EXCEPTIONS)
+                try {
+#endif
+
+                    error = platforms[i].getDevices(type, &devices);
+
+#if defined(CL_HPP_ENABLE_EXCEPTIONS)
+                } catch (Error) {}
+    // Catch if exceptions are enabled as we don't want to exit if first platform has no devices of type
+    // We do error checking next anyway, and can throw there if needed
+#endif
+
+                // Only squash CL_SUCCESS and CL_DEVICE_NOT_FOUND
+                if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND) {
+                    detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
+                    if (err != NULL) {
+                        *err = error;
+                    }
+                }
+
+                if (devices.size() > 0) {
+                    platform_id = (cl_context_properties)platforms[i]();
+                    break;
+                }
+            }
+
+            if (platform_id == 0) {
+                detail::errHandler(CL_DEVICE_NOT_FOUND, __CREATE_CONTEXT_FROM_TYPE_ERR);
+                if (err != NULL) {
+                    *err = CL_DEVICE_NOT_FOUND;
+                }
+                return;
+            }
+
+            prop[1] = platform_id;
+            properties = &prop[0];
+        }
+#endif
+        object_ = ::clCreateContextFromType(
+            properties, type, notifyFptr, data, &error);
+
+        detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    /*! \brief Copy constructor to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Context(const Context& ctx) : detail::Wrapper<cl_type>(ctx) {}
+
+    /*! \brief Copy assignment to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Context& operator = (const Context &ctx)
+    {
+        detail::Wrapper<cl_type>::operator=(ctx);
+        return *this;
+    }
+
+    /*! \brief Move constructor to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Context(Context&& ctx) CL_HPP_NOEXCEPT_ : detail::Wrapper<cl_type>(std::move(ctx)) {}
+
+    /*! \brief Move assignment to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Context& operator = (Context &&ctx)
+    {
+        detail::Wrapper<cl_type>::operator=(std::move(ctx));
+        return *this;
+    }
+
+
+    /*! \brief Returns a singleton context including all devices of CL_DEVICE_TYPE_DEFAULT.
+     *
+     *  \note All calls to this function return the same cl_context as the first.
+     */
+    static Context getDefault(cl_int * err = NULL) 
+    {
+        std::call_once(default_initialized_, makeDefault);
+        detail::errHandler(default_error_);
+        if (err != NULL) {
+            *err = default_error_;
+        }
+        return default_;
+    }
+
+    /**
+     * Modify the default context to be used by
+     * subsequent operations.
+     * Will only set the default if no default was previously created.
+     * @return updated default context.
+     *         Should be compared to the passed value to ensure that it was updated.
+     */
+    static Context setDefault(const Context &default_context)
+    {
+        std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_context));
+        detail::errHandler(default_error_);
+        return default_;
+    }
+
+    //! \brief Default constructor - initializes to NULL.
+    Context() : detail::Wrapper<cl_type>() { }
+
+    /*! \brief Constructor from cl_context - takes ownership.
+     * 
+     *  This effectively transfers ownership of a refcount on the cl_context
+     *  into the new Context object.
+     */
+    explicit Context(const cl_context& context, bool retainObject = false) : 
+        detail::Wrapper<cl_type>(context, retainObject) { }
+
+    /*! \brief Assignment operator from cl_context - takes ownership.
+     * 
+     *  This effectively transfers ownership of a refcount on the rhs and calls
+     *  clReleaseContext() on the value previously held by this instance.
+     */
+    Context& operator = (const cl_context& rhs)
+    {
+        detail::Wrapper<cl_type>::operator=(rhs);
+        return *this;
+    }
+
+    //! \brief Wrapper for clGetContextInfo().
+    template <typename T>
+    cl_int getInfo(cl_context_info name, T* param) const
+    {
+        return detail::errHandler(
+            detail::getInfo(&::clGetContextInfo, object_, name, param),
+            __GET_CONTEXT_INFO_ERR);
+    }
+
+    //! \brief Wrapper for clGetContextInfo() that returns by value.
+    template <cl_int name> typename
+    detail::param_traits<detail::cl_context_info, name>::param_type
+    getInfo(cl_int* err = NULL) const
+    {
+        typename detail::param_traits<
+            detail::cl_context_info, name>::param_type param;
+        cl_int result = getInfo(name, &param);
+        if (err != NULL) {
+            *err = result;
+        }
+        return param;
+    }
+
+    /*! \brief Gets a list of supported image formats.
+     *  
+     *  Wraps clGetSupportedImageFormats().
+     */
+    cl_int getSupportedImageFormats(
+        cl_mem_flags flags,
+        cl_mem_object_type type,
+        vector<ImageFormat>* formats) const
+    {
+        cl_uint numEntries;
+        
+        if (!formats) {
+            return CL_SUCCESS;
+        }
+
+        cl_int err = ::clGetSupportedImageFormats(
+           object_, 
+           flags,
+           type, 
+           0, 
+           NULL, 
+           &numEntries);
+        if (err != CL_SUCCESS) {
+            return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
+        }
+
+        if (numEntries > 0) {
+            vector<ImageFormat> value(numEntries);
+            err = ::clGetSupportedImageFormats(
+                object_,
+                flags,
+                type,
+                numEntries,
+                (cl_image_format*)value.data(),
+                NULL);
+            if (err != CL_SUCCESS) {
+                return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
+            }
+
+            formats->assign(begin(value), end(value));
+        }
+        else {
+            // If no values are being returned, ensure an empty vector comes back
+            formats->clear();
+        }
+
+        return CL_SUCCESS;
+    }
+};
+
+inline void Device::makeDefault()
+{
+    /* Throwing an exception from a call_once invocation does not do
+    * what we wish, so we catch it and save the error.
+    */
+#if defined(CL_HPP_ENABLE_EXCEPTIONS)
+    try
+#endif
+    {
+        cl_int error = 0;
+
+        Context context = Context::getDefault(&error);
+        detail::errHandler(error, __CREATE_CONTEXT_ERR);
+
+        if (error != CL_SUCCESS) {
+            default_error_ = error;
+        }
+        else {
+            default_ = context.getInfo<CL_CONTEXT_DEVICES>()[0];
+            default_error_ = CL_SUCCESS;
+        }
+    }
+#if defined(CL_HPP_ENABLE_EXCEPTIONS)
+    catch (cl::Error &e) {
+        default_error_ = e.err();
+    }
+#endif
+}
+
+CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Context::default_initialized_;
+CL_HPP_DEFINE_STATIC_MEMBER_ Context Context::default_;
+CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Context::default_error_ = CL_SUCCESS;
+
+/*! \brief Class interface for cl_event.
+ *
+ *  \note Copies of these objects are shallow, meaning that the copy will refer
+ *        to the same underlying cl_event as the original.  For details, see
+ *        clRetainEvent() and clReleaseEvent().
+ *
+ *  \see cl_event
+ */
+class Event : public detail::Wrapper<cl_event>
+{
+public:
+    //! \brief Default constructor - initializes to NULL.
+    Event() : detail::Wrapper<cl_type>() { }
+
+    /*! \brief Constructor from cl_event - takes ownership.
+     * 
+     * \param retainObject will cause the constructor to retain its cl object.
+     *                     Defaults to false to maintain compatibility with
+     *                     earlier versions.
+     *  This effectively transfers ownership of a refcount on the cl_event
+     *  into the new Event object.
+     */
+    explicit Event(const cl_event& event, bool retainObject = false) : 
+        detail::Wrapper<cl_type>(event, retainObject) { }
+
+    /*! \brief Assignment operator from cl_event - takes ownership.
+     *
+     *  This effectively transfers ownership of a refcount on the rhs and calls
+     *  clReleaseEvent() on the value previously held by this instance.
+     */
+    Event& operator = (const cl_event& rhs)
+    {
+        detail::Wrapper<cl_type>::operator=(rhs);
+        return *this;
+    }
+
+    //! \brief Wrapper for clGetEventInfo().
+    template <typename T>
+    cl_int getInfo(cl_event_info name, T* param) const
+    {
+        return detail::errHandler(
+            detail::getInfo(&::clGetEventInfo, object_, name, param),
+            __GET_EVENT_INFO_ERR);
+    }
+
+    //! \brief Wrapper for clGetEventInfo() that returns by value.
+    template <cl_int name> typename
+    detail::param_traits<detail::cl_event_info, name>::param_type
+    getInfo(cl_int* err = NULL) const
+    {
+        typename detail::param_traits<
+            detail::cl_event_info, name>::param_type param;
+        cl_int result = getInfo(name, &param);
+        if (err != NULL) {
+            *err = result;
+        }
+        return param;
+    }
+
+    //! \brief Wrapper for clGetEventProfilingInfo().
+    template <typename T>
+    cl_int getProfilingInfo(cl_profiling_info name, T* param) const
+    {
+        return detail::errHandler(detail::getInfo(
+            &::clGetEventProfilingInfo, object_, name, param),
+            __GET_EVENT_PROFILE_INFO_ERR);
+    }
+
+    //! \brief Wrapper for clGetEventProfilingInfo() that returns by value.
+    template <cl_int name> typename
+    detail::param_traits<detail::cl_profiling_info, name>::param_type
+    getProfilingInfo(cl_int* err = NULL) const
+    {
+        typename detail::param_traits<
+            detail::cl_profiling_info, name>::param_type param;
+        cl_int result = getProfilingInfo(name, &param);
+        if (err != NULL) {
+            *err = result;
+        }
+        return param;
+    }
+
+    /*! \brief Blocks the calling thread until this event completes.
+     * 
+     *  Wraps clWaitForEvents().
+     */
+    cl_int wait() const
+    {
+        return detail::errHandler(
+            ::clWaitForEvents(1, &object_),
+            __WAIT_FOR_EVENTS_ERR);
+    }
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 110
+    /*! \brief Registers a user callback function for a specific command execution status.
+     *
+     *  Wraps clSetEventCallback().
+     */
+    cl_int setCallback(
+        cl_int type,
+        void (CL_CALLBACK * pfn_notify)(cl_event, cl_int, void *),		
+        void * user_data = NULL)
+    {
+        return detail::errHandler(
+            ::clSetEventCallback(
+                object_,
+                type,
+                pfn_notify,
+                user_data), 
+            __SET_EVENT_CALLBACK_ERR);
+    }
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
+
+    /*! \brief Blocks the calling thread until every event specified is complete.
+     * 
+     *  Wraps clWaitForEvents().
+     */
+    static cl_int
+    waitForEvents(const vector<Event>& events)
+    {
+        return detail::errHandler(
+            ::clWaitForEvents(
+                (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
+            __WAIT_FOR_EVENTS_ERR);
+    }
+};
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 110
+/*! \brief Class interface for user events (a subset of cl_event's).
+ * 
+ *  See Event for details about copy semantics, etc.
+ */
+class UserEvent : public Event
+{
+public:
+    /*! \brief Constructs a user event on a given context.
+     *
+     *  Wraps clCreateUserEvent().
+     */
+    UserEvent(
+        const Context& context,
+        cl_int * err = NULL)
+    {
+        cl_int error;
+        object_ = ::clCreateUserEvent(
+            context(),
+            &error);
+
+        detail::errHandler(error, __CREATE_USER_EVENT_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    //! \brief Default constructor - initializes to NULL.
+    UserEvent() : Event() { }
+
+    /*! \brief Sets the execution status of a user event object.
+     *
+     *  Wraps clSetUserEventStatus().
+     */
+    cl_int setStatus(cl_int status)
+    {
+        return detail::errHandler(
+            ::clSetUserEventStatus(object_,status), 
+            __SET_USER_EVENT_STATUS_ERR);
+    }
+};
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
+
+/*! \brief Blocks the calling thread until every event specified is complete.
+ * 
+ *  Wraps clWaitForEvents().
+ */
+inline static cl_int
+WaitForEvents(const vector<Event>& events)
+{
+    return detail::errHandler(
+        ::clWaitForEvents(
+            (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL),
+        __WAIT_FOR_EVENTS_ERR);
+}
+
+/*! \brief Class interface for cl_mem.
+ *
+ *  \note Copies of these objects are shallow, meaning that the copy will refer
+ *        to the same underlying cl_mem as the original.  For details, see
+ *        clRetainMemObject() and clReleaseMemObject().
+ *
+ *  \see cl_mem
+ */
+class Memory : public detail::Wrapper<cl_mem>
+{
+public:
+    //! \brief Default constructor - initializes to NULL.
+    Memory() : detail::Wrapper<cl_type>() { }
+
+    /*! \brief Constructor from cl_mem - takes ownership.
+     *
+     *  Optionally transfer ownership of a refcount on the cl_mem
+     *  into the new Memory object.
+     *
+     * \param retainObject will cause the constructor to retain its cl object.
+     *                     Defaults to false to maintain compatibility with
+     *                     earlier versions.
+     *
+     *  See Memory for further details.
+     */
+    explicit Memory(const cl_mem& memory, bool retainObject) :
+        detail::Wrapper<cl_type>(memory, retainObject) { }
+
+    /*! \brief Assignment operator from cl_mem - takes ownership.
+     *
+     *  This effectively transfers ownership of a refcount on the rhs and calls
+     *  clReleaseMemObject() on the value previously held by this instance.
+     */
+    Memory& operator = (const cl_mem& rhs)
+    {
+        detail::Wrapper<cl_type>::operator=(rhs);
+        return *this;
+    }
+
+    /*! \brief Copy constructor to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Memory(const Memory& mem) : detail::Wrapper<cl_type>(mem) {}
+
+    /*! \brief Copy assignment to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Memory& operator = (const Memory &mem)
+    {
+        detail::Wrapper<cl_type>::operator=(mem);
+        return *this;
+    }
+
+    /*! \brief Move constructor to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Memory(Memory&& mem) CL_HPP_NOEXCEPT_ : detail::Wrapper<cl_type>(std::move(mem)) {}
+
+    /*! \brief Move assignment to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Memory& operator = (Memory &&mem)
+    {
+        detail::Wrapper<cl_type>::operator=(std::move(mem));
+        return *this;
+    }
+
+
+    //! \brief Wrapper for clGetMemObjectInfo().
+    template <typename T>
+    cl_int getInfo(cl_mem_info name, T* param) const
+    {
+        return detail::errHandler(
+            detail::getInfo(&::clGetMemObjectInfo, object_, name, param),
+            __GET_MEM_OBJECT_INFO_ERR);
+    }
+
+    //! \brief Wrapper for clGetMemObjectInfo() that returns by value.
+    template <cl_int name> typename
+    detail::param_traits<detail::cl_mem_info, name>::param_type
+    getInfo(cl_int* err = NULL) const
+    {
+        typename detail::param_traits<
+            detail::cl_mem_info, name>::param_type param;
+        cl_int result = getInfo(name, &param);
+        if (err != NULL) {
+            *err = result;
+        }
+        return param;
+    }
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 110
+    /*! \brief Registers a callback function to be called when the memory object
+     *         is no longer needed.
+     *
+     *  Wraps clSetMemObjectDestructorCallback().
+     *
+     *  Repeated calls to this function, for a given cl_mem value, will append
+     *  to the list of functions called (in reverse order) when memory object's
+     *  resources are freed and the memory object is deleted.
+     *
+     *  \note
+     *  The registered callbacks are associated with the underlying cl_mem
+     *  value - not the Memory class instance.
+     */
+    cl_int setDestructorCallback(
+        void (CL_CALLBACK * pfn_notify)(cl_mem, void *),		
+        void * user_data = NULL)
+    {
+        return detail::errHandler(
+            ::clSetMemObjectDestructorCallback(
+                object_,
+                pfn_notify,
+                user_data), 
+            __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR);
+    }
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
+
+};
+
+// Pre-declare copy functions
+class Buffer;
+template< typename IteratorType >
+cl_int copy( IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer );
+template< typename IteratorType >
+cl_int copy( const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
+template< typename IteratorType >
+cl_int copy( const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer );
+template< typename IteratorType >
+cl_int copy( const CommandQueue &queue, const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator );
+
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+namespace detail
+{
+    class SVMTraitNull
+    {
+    public:
+        static cl_svm_mem_flags getSVMMemFlags()
+        {
+            return 0;
+        }
+    };
+} // namespace detail
+
+template<class Trait = detail::SVMTraitNull>
+class SVMTraitReadWrite
+{
+public:
+    static cl_svm_mem_flags getSVMMemFlags()
+    {
+        return CL_MEM_READ_WRITE |
+            Trait::getSVMMemFlags();
+    }
+};
+
+template<class Trait = detail::SVMTraitNull>
+class SVMTraitReadOnly
+{
+public:
+    static cl_svm_mem_flags getSVMMemFlags()
+    {
+        return CL_MEM_READ_ONLY |
+            Trait::getSVMMemFlags();
+    }
+};
+
+template<class Trait = detail::SVMTraitNull>
+class SVMTraitWriteOnly
+{
+public:
+    static cl_svm_mem_flags getSVMMemFlags()
+    {
+        return CL_MEM_WRITE_ONLY |
+            Trait::getSVMMemFlags();
+    }
+};
+
+template<class Trait = SVMTraitReadWrite<>>
+class SVMTraitCoarse
+{
+public:
+    static cl_svm_mem_flags getSVMMemFlags()
+    {
+        return Trait::getSVMMemFlags();
+    }
+};
+
+template<class Trait = SVMTraitReadWrite<>>
+class SVMTraitFine
+{
+public:
+    static cl_svm_mem_flags getSVMMemFlags()
+    {
+        return CL_MEM_SVM_FINE_GRAIN_BUFFER |
+            Trait::getSVMMemFlags();
+    }
+};
+
+template<class Trait = SVMTraitReadWrite<>>
+class SVMTraitAtomic
+{
+public:
+    static cl_svm_mem_flags getSVMMemFlags()
+    {
+        return
+            CL_MEM_SVM_FINE_GRAIN_BUFFER |
+            CL_MEM_SVM_ATOMICS |
+            Trait::getSVMMemFlags();
+    }
+};
+
+
+template<typename T, class SVMTrait>
+class SVMAllocator {
+private:
+    Context context_;
+
+public:
+    typedef T value_type;
+    typedef value_type* pointer;
+    typedef const value_type* const_pointer;
+    typedef value_type& reference;
+    typedef const value_type& const_reference;
+    typedef std::size_t size_type;
+    typedef std::ptrdiff_t difference_type;
+
+    template<typename U>
+    struct rebind
+    {
+        typedef SVMAllocator<U, SVMTrait> other;
+    };
+
+    template<typename U, typename V>
+    friend class SVMAllocator;
+
+    explicit SVMAllocator() :
+        context_(Context::getDefault())
+    {
+    }
+
+    explicit SVMAllocator(cl::Context context) :
+        context_(context)
+    {
+    }
+    
+    SVMAllocator(const SVMAllocator &other) :
+        context_(other.context_)
+    {
+    }
+
+    template<typename U>
+    SVMAllocator(const SVMAllocator<U, SVMTrait> &other) :
+        context_(other.context_)
+    {
+    }
+
+    ~SVMAllocator()
+    {
+    }
+
+    pointer address(reference r) CL_HPP_NOEXCEPT_
+    {
+        return std::addressof(r);
+    }
+
+    const_pointer address(const_reference r) CL_HPP_NOEXCEPT_
+    {
+        return std::addressof(r);
+    }
+
+    /**
+     * Allocate an SVM pointer.
+     *
+     */
+    pointer allocate(
+        size_type size,
+        typename cl::SVMAllocator<void, SVMTrait>::const_pointer = 0)
+    {
+        void* voidPointer =
+            clSVMAlloc(
+            context_(),
+            SVMTrait::getSVMMemFlags(),
+            size*sizeof(T),
+            0);
+        pointer retValue = reinterpret_cast<pointer>(
+            voidPointer);
+#if defined(CL_HPP_ENABLE_EXCEPTIONS)
+        if (!retValue) {
+            std::bad_alloc excep;
+            throw excep;
+        }
+#endif // #if defined(CL_HPP_ENABLE_EXCEPTIONS)
+
+        // If exceptions disabled, return null pointer from allocator
+        return retValue;
+    }
+
+    void deallocate(pointer p, size_type)
+    {
+        clSVMFree(context_(), p);
+    }
+
+    /**
+     * Return the maximum possible allocation size.
+     * This is the minimum of the maximum sizes of all devices in the context.
+     */
+    size_type max_size() const CL_HPP_NOEXCEPT_
+    {
+        size_type maxSize = std::numeric_limits<size_type>::max() / sizeof(T);
+
+        for (Device &d : context_.getInfo<CL_CONTEXT_DEVICES>()) {
+            maxSize = std::min(
+                maxSize, 
+                static_cast<size_type>(d.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>()));
+        }
+
+        return maxSize;
+    }
+
+    template< class U, class... Args >
+    void construct(U* p, Args&&... args)
+    {
+        new(p)T(args...);
+    }
+
+    template< class U >
+    void destroy(U* p)
+    {
+        p->~U();
+    }
+
+    /**
+     * Returns true if the contexts match.
+     */
+    inline bool operator==(SVMAllocator const& rhs)
+    {
+        return (context_==rhs.context_);
+    }
+
+    inline bool operator!=(SVMAllocator const& a)
+    {
+        return !operator==(a);
+    }
+}; // class SVMAllocator
+
+
+template<class SVMTrait>
+class SVMAllocator<void, SVMTrait> {
+public:
+    typedef void value_type;
+    typedef value_type* pointer;
+    typedef const value_type* const_pointer;
+
+    template<typename U>
+    struct rebind
+    {
+        typedef SVMAllocator<U, SVMTrait> other;
+    };
+
+    template<typename U, typename V>
+    friend class SVMAllocator;
+};
+
+template< class T, class SVMTrait, class... Args >
+cl::pointer<T> allocate_svm(Args... args)
+{
+    SVMAllocator<T, SVMTrait> alloc;
+    return cl::allocate_pointer<T>(alloc, args...);
+}
+
+template< class T, class SVMTrait, class... Args >
+cl::pointer<T> allocate_svm(const cl::Context &c, Args... args)
+{
+    SVMAllocator<T, SVMTrait> alloc(c);
+    return cl::allocate_pointer<T>(alloc, args...);
+}
+
+/*! \brief Vector alias to simplify contruction of coarse-grained SVM containers.
+ * 
+ */
+template < class T >
+using coarse_svm_vector = vector<T, cl::SVMAllocator<int, cl::SVMTraitCoarse<>>>;
+
+/*! \brief Vector alias to simplify contruction of fine-grained SVM containers.
+*
+*/
+template < class T >
+using fine_svm_vector = vector<T, cl::SVMAllocator<int, cl::SVMTraitFine<>>>;
+
+/*! \brief Vector alias to simplify contruction of fine-grained SVM containers that support platform atomics.
+*
+*/
+template < class T >
+using atomic_svm_vector = vector<T, cl::SVMAllocator<int, cl::SVMTraitAtomic<>>>;
+
+#endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
+
+
+/*! \brief Class interface for Buffer Memory Objects.
+ * 
+ *  See Memory for details about copy semantics, etc.
+ *
+ *  \see Memory
+ */
+class Buffer : public Memory
+{
+public:
+
+    /*! \brief Constructs a Buffer in a specified context.
+     *
+     *  Wraps clCreateBuffer().
+     *
+     *  \param host_ptr Storage to be used if the CL_MEM_USE_HOST_PTR flag was
+     *                  specified.  Note alignment & exclusivity requirements.
+     */
+    Buffer(
+        const Context& context,
+        cl_mem_flags flags,
+        size_type size,
+        void* host_ptr = NULL,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+        object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
+
+        detail::errHandler(error, __CREATE_BUFFER_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    /*! \brief Constructs a Buffer in the default context.
+     *
+     *  Wraps clCreateBuffer().
+     *
+     *  \param host_ptr Storage to be used if the CL_MEM_USE_HOST_PTR flag was
+     *                  specified.  Note alignment & exclusivity requirements.
+     *
+     *  \see Context::getDefault()
+     */
+    Buffer(
+         cl_mem_flags flags,
+        size_type size,
+        void* host_ptr = NULL,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+
+        Context context = Context::getDefault(err);
+
+        object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error);
+
+        detail::errHandler(error, __CREATE_BUFFER_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    /*!
+     * \brief Construct a Buffer from a host container via iterators.
+     * IteratorType must be random access.
+     * If useHostPtr is specified iterators must represent contiguous data.
+     */
+    template< typename IteratorType >
+    Buffer(
+        IteratorType startIterator,
+        IteratorType endIterator,
+        bool readOnly,
+        bool useHostPtr = false,
+        cl_int* err = NULL)
+    {
+        typedef typename std::iterator_traits<IteratorType>::value_type DataType;
+        cl_int error;
+
+        cl_mem_flags flags = 0;
+        if( readOnly ) {
+            flags |= CL_MEM_READ_ONLY;
+        }
+        else {
+            flags |= CL_MEM_READ_WRITE;
+        }
+        if( useHostPtr ) {
+            flags |= CL_MEM_USE_HOST_PTR;
+        }
+        
+        size_type size = sizeof(DataType)*(endIterator - startIterator);
+
+        Context context = Context::getDefault(err);
+
+        if( useHostPtr ) {
+            object_ = ::clCreateBuffer(context(), flags, size, static_cast<DataType*>(&*startIterator), &error);
+        } else {
+            object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
+        }
+
+        detail::errHandler(error, __CREATE_BUFFER_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+
+        if( !useHostPtr ) {
+            error = cl::copy(startIterator, endIterator, *this);
+            detail::errHandler(error, __CREATE_BUFFER_ERR);
+            if (err != NULL) {
+                *err = error;
+            }
+        }
+    }
+
+    /*!
+     * \brief Construct a Buffer from a host container via iterators using a specified context.
+     * IteratorType must be random access.
+     * If useHostPtr is specified iterators must represent contiguous data.
+     */
+    template< typename IteratorType >
+    Buffer(const Context &context, IteratorType startIterator, IteratorType endIterator,
+        bool readOnly, bool useHostPtr = false, cl_int* err = NULL);
+    
+    /*!
+    * \brief Construct a Buffer from a host container via iterators using a specified queue.
+    * If useHostPtr is specified iterators must be random access.
+    */
+    template< typename IteratorType >
+    Buffer(const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator,
+        bool readOnly, bool useHostPtr = false, cl_int* err = NULL);
+
+    //! \brief Default constructor - initializes to NULL.
+    Buffer() : Memory() { }
+
+    /*! \brief Constructor from cl_mem - takes ownership.
+     *
+     * \param retainObject will cause the constructor to retain its cl object.
+     *                     Defaults to false to maintain compatibility with earlier versions.
+     *
+     *  See Memory for further details.
+     */
+    explicit Buffer(const cl_mem& buffer, bool retainObject = false) :
+        Memory(buffer, retainObject) { }
+
+    /*! \brief Assignment from cl_mem - performs shallow copy.
+    *
+    *  See Memory for further details.
+    */
+    Buffer& operator = (const cl_mem& rhs)
+    {
+        Memory::operator=(rhs);
+        return *this;
+    }
+
+    /*! \brief Copy constructor to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Buffer(const Buffer& buf) : Memory(buf) {}
+
+    /*! \brief Copy assignment to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Buffer& operator = (const Buffer &buf)
+    {
+        Memory::operator=(buf);
+        return *this;
+    }
+
+    /*! \brief Move constructor to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Buffer(Buffer&& buf) CL_HPP_NOEXCEPT_ : Memory(std::move(buf)) {}
+
+    /*! \brief Move assignment to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Buffer& operator = (Buffer &&buf)
+    {
+        Memory::operator=(std::move(buf));
+        return *this;
+    }
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 110
+    /*! \brief Creates a new buffer object from this.
+     *
+     *  Wraps clCreateSubBuffer().
+     */
+    Buffer createSubBuffer(
+        cl_mem_flags flags,
+        cl_buffer_create_type buffer_create_type,
+        const void * buffer_create_info,
+        cl_int * err = NULL)
+    {
+        Buffer result;
+        cl_int error;
+        result.object_ = ::clCreateSubBuffer(
+            object_, 
+            flags, 
+            buffer_create_type, 
+            buffer_create_info, 
+            &error);
+
+        detail::errHandler(error, __CREATE_SUBBUFFER_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+
+        return result;
+    }		
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
+};
+
+#if defined (CL_HPP_USE_DX_INTEROP)
+/*! \brief Class interface for creating OpenCL buffers from ID3D10Buffer's.
+ *
+ *  This is provided to facilitate interoperability with Direct3D.
+ * 
+ *  See Memory for details about copy semantics, etc.
+ *
+ *  \see Memory
+ */
+class BufferD3D10 : public Buffer
+{
+public:
+   
+
+    /*! \brief Constructs a BufferD3D10, in a specified context, from a
+     *         given ID3D10Buffer.
+     *
+     *  Wraps clCreateFromD3D10BufferKHR().
+     */
+    BufferD3D10(
+        const Context& context,
+        cl_mem_flags flags,
+        ID3D10Buffer* bufobj,
+        cl_int * err = NULL) : pfn_clCreateFromD3D10BufferKHR(nullptr)
+    {
+        typedef CL_API_ENTRY cl_mem (CL_API_CALL *PFN_clCreateFromD3D10BufferKHR)(
+            cl_context context, cl_mem_flags flags, ID3D10Buffer*  buffer,
+            cl_int* errcode_ret);
+        PFN_clCreateFromD3D10BufferKHR pfn_clCreateFromD3D10BufferKHR;
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+        vector<cl_context_properties> props = context.getInfo<CL_CONTEXT_PROPERTIES>();
+        cl_platform platform = -1;
+        for( int i = 0; i < props.size(); ++i ) {
+            if( props[i] == CL_CONTEXT_PLATFORM ) {
+                platform = props[i+1];
+            }
+        }
+        CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clCreateFromD3D10BufferKHR);
+#elif CL_HPP_TARGET_OPENCL_VERSION >= 110
+        CL_HPP_INIT_CL_EXT_FCN_PTR_(clCreateFromD3D10BufferKHR);
+#endif
+
+        cl_int error;
+        object_ = pfn_clCreateFromD3D10BufferKHR(
+            context(),
+            flags,
+            bufobj,
+            &error);
+
+        detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    //! \brief Default constructor - initializes to NULL.
+    BufferD3D10() : Buffer() { }
+
+    /*! \brief Constructor from cl_mem - takes ownership.
+     *
+     * \param retainObject will cause the constructor to retain its cl object.
+     *                     Defaults to false to maintain compatibility with 
+     *                     earlier versions.
+     *  See Memory for further details.
+     */
+    explicit BufferD3D10(const cl_mem& buffer, bool retainObject = false) : 
+        Buffer(buffer, retainObject) { }
+
+    /*! \brief Assignment from cl_mem - performs shallow copy.
+     *
+     *  See Memory for further details.
+     */
+    BufferD3D10& operator = (const cl_mem& rhs)
+    {
+        Buffer::operator=(rhs);
+        return *this;
+    }
+
+    /*! \brief Copy constructor to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    BufferD3D10(const BufferD3D10& buf) : 
+        Buffer(buf) {}
+
+    /*! \brief Copy assignment to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    BufferD3D10& operator = (const BufferD3D10 &buf)
+    {
+        Buffer::operator=(buf);
+        return *this;
+    }
+
+    /*! \brief Move constructor to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    BufferD3D10(BufferD3D10&& buf) CL_HPP_NOEXCEPT_ : Buffer(std::move(buf)) {}
+
+    /*! \brief Move assignment to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    BufferD3D10& operator = (BufferD3D10 &&buf)
+    {
+        Buffer::operator=(std::move(buf));
+        return *this;
+    }
+};
+#endif
+
+/*! \brief Class interface for GL Buffer Memory Objects.
+ *
+ *  This is provided to facilitate interoperability with OpenGL.
+ * 
+ *  See Memory for details about copy semantics, etc.
+ * 
+ *  \see Memory
+ */
+class BufferGL : public Buffer
+{
+public:
+    /*! \brief Constructs a BufferGL in a specified context, from a given
+     *         GL buffer.
+     *
+     *  Wraps clCreateFromGLBuffer().
+     */
+    BufferGL(
+        const Context& context,
+        cl_mem_flags flags,
+        cl_GLuint bufobj,
+        cl_int * err = NULL)
+    {
+        cl_int error;
+        object_ = ::clCreateFromGLBuffer(
+            context(),
+            flags,
+            bufobj,
+            &error);
+
+        detail::errHandler(error, __CREATE_GL_BUFFER_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    //! \brief Default constructor - initializes to NULL.
+    BufferGL() : Buffer() { }
+
+    /*! \brief Constructor from cl_mem - takes ownership.
+     *
+     * \param retainObject will cause the constructor to retain its cl object.
+     *                     Defaults to false to maintain compatibility with
+     *                     earlier versions.
+     *  See Memory for further details.
+     */
+    explicit BufferGL(const cl_mem& buffer, bool retainObject = false) :
+        Buffer(buffer, retainObject) { }
+
+    /*! \brief Assignment from cl_mem - performs shallow copy.
+     *
+     *  See Memory for further details.
+     */
+    BufferGL& operator = (const cl_mem& rhs)
+    {
+        Buffer::operator=(rhs);
+        return *this;
+    }
+
+    /*! \brief Copy constructor to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    BufferGL(const BufferGL& buf) : Buffer(buf) {}
+
+    /*! \brief Copy assignment to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    BufferGL& operator = (const BufferGL &buf)
+    {
+        Buffer::operator=(buf);
+        return *this;
+    }
+
+    /*! \brief Move constructor to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    BufferGL(BufferGL&& buf) CL_HPP_NOEXCEPT_ : Buffer(std::move(buf)) {}
+
+    /*! \brief Move assignment to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    BufferGL& operator = (BufferGL &&buf)
+    {
+        Buffer::operator=(std::move(buf));
+        return *this;
+    }
+
+    //! \brief Wrapper for clGetGLObjectInfo().
+    cl_int getObjectInfo(
+        cl_gl_object_type *type,
+        cl_GLuint * gl_object_name)
+    {
+        return detail::errHandler(
+            ::clGetGLObjectInfo(object_,type,gl_object_name),
+            __GET_GL_OBJECT_INFO_ERR);
+    }
+};
+
+/*! \brief Class interface for GL Render Buffer Memory Objects.
+ *
+ *  This is provided to facilitate interoperability with OpenGL.
+ * 
+ *  See Memory for details about copy semantics, etc.
+ * 
+ *  \see Memory
+ */
+class BufferRenderGL : public Buffer
+{
+public:
+    /*! \brief Constructs a BufferRenderGL in a specified context, from a given
+     *         GL Renderbuffer.
+     *
+     *  Wraps clCreateFromGLRenderbuffer().
+     */
+    BufferRenderGL(
+        const Context& context,
+        cl_mem_flags flags,
+        cl_GLuint bufobj,
+        cl_int * err = NULL)
+    {
+        cl_int error;
+        object_ = ::clCreateFromGLRenderbuffer(
+            context(),
+            flags,
+            bufobj,
+            &error);
+
+        detail::errHandler(error, __CREATE_GL_RENDER_BUFFER_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    //! \brief Default constructor - initializes to NULL.
+    BufferRenderGL() : Buffer() { }
+
+    /*! \brief Constructor from cl_mem - takes ownership.
+     *
+     * \param retainObject will cause the constructor to retain its cl object.
+     *                     Defaults to false to maintain compatibility with 
+     *                     earlier versions.
+     *  See Memory for further details.
+     */
+    explicit BufferRenderGL(const cl_mem& buffer, bool retainObject = false) :
+        Buffer(buffer, retainObject) { }
+
+    /*! \brief Assignment from cl_mem - performs shallow copy.
+     *
+     *  See Memory for further details.
+     */
+    BufferRenderGL& operator = (const cl_mem& rhs)
+    {
+        Buffer::operator=(rhs);
+        return *this;
+    }
+
+    /*! \brief Copy constructor to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    BufferRenderGL(const BufferRenderGL& buf) : Buffer(buf) {}
+
+    /*! \brief Copy assignment to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    BufferRenderGL& operator = (const BufferRenderGL &buf)
+    {
+        Buffer::operator=(buf);
+        return *this;
+    }
+
+    /*! \brief Move constructor to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    BufferRenderGL(BufferRenderGL&& buf) CL_HPP_NOEXCEPT_ : Buffer(std::move(buf)) {}
+
+    /*! \brief Move assignment to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    BufferRenderGL& operator = (BufferRenderGL &&buf)
+    {
+        Buffer::operator=(std::move(buf));
+        return *this;
+    }
+
+    //! \brief Wrapper for clGetGLObjectInfo().
+    cl_int getObjectInfo(
+        cl_gl_object_type *type,
+        cl_GLuint * gl_object_name)
+    {
+        return detail::errHandler(
+            ::clGetGLObjectInfo(object_,type,gl_object_name),
+            __GET_GL_OBJECT_INFO_ERR);
+    }
+};
+
+/*! \brief C++ base class for Image Memory objects.
+ *
+ *  See Memory for details about copy semantics, etc.
+ * 
+ *  \see Memory
+ */
+class Image : public Memory
+{
+protected:
+    //! \brief Default constructor - initializes to NULL.
+    Image() : Memory() { }
+
+    /*! \brief Constructor from cl_mem - takes ownership.
+     *
+     * \param retainObject will cause the constructor to retain its cl object.
+     *                     Defaults to false to maintain compatibility with
+     *                     earlier versions.
+     *  See Memory for further details.
+     */
+    explicit Image(const cl_mem& image, bool retainObject = false) :
+        Memory(image, retainObject) { }
+
+    /*! \brief Assignment from cl_mem - performs shallow copy.
+     *
+     *  See Memory for further details.
+     */
+    Image& operator = (const cl_mem& rhs)
+    {
+        Memory::operator=(rhs);
+        return *this;
+    }
+
+    /*! \brief Copy constructor to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image(const Image& img) : Memory(img) {}
+
+    /*! \brief Copy assignment to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image& operator = (const Image &img)
+    {
+        Memory::operator=(img);
+        return *this;
+    }
+
+    /*! \brief Move constructor to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image(Image&& img) CL_HPP_NOEXCEPT_ : Memory(std::move(img)) {}
+
+    /*! \brief Move assignment to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image& operator = (Image &&img)
+    {
+        Memory::operator=(std::move(img));
+        return *this;
+    }
+
+
+public:
+    //! \brief Wrapper for clGetImageInfo().
+    template <typename T>
+    cl_int getImageInfo(cl_image_info name, T* param) const
+    {
+        return detail::errHandler(
+            detail::getInfo(&::clGetImageInfo, object_, name, param),
+            __GET_IMAGE_INFO_ERR);
+    }
+    
+    //! \brief Wrapper for clGetImageInfo() that returns by value.
+    template <cl_int name> typename
+    detail::param_traits<detail::cl_image_info, name>::param_type
+    getImageInfo(cl_int* err = NULL) const
+    {
+        typename detail::param_traits<
+            detail::cl_image_info, name>::param_type param;
+        cl_int result = getImageInfo(name, &param);
+        if (err != NULL) {
+            *err = result;
+        }
+        return param;
+    }
+};
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+/*! \brief Class interface for 1D Image Memory objects.
+ *
+ *  See Memory for details about copy semantics, etc.
+ * 
+ *  \see Memory
+ */
+class Image1D : public Image
+{
+public:
+    /*! \brief Constructs a 1D Image in a specified context.
+     *
+     *  Wraps clCreateImage().
+     */
+    Image1D(
+        const Context& context,
+        cl_mem_flags flags,
+        ImageFormat format,
+        size_type width,
+        void* host_ptr = NULL,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+        cl_image_desc desc =
+        {
+            CL_MEM_OBJECT_IMAGE1D,
+            width,
+            0, 0, 0, 0, 0, 0, 0, 0
+        };
+        object_ = ::clCreateImage(
+            context(), 
+            flags, 
+            &format, 
+            &desc, 
+            host_ptr, 
+            &error);
+
+        detail::errHandler(error, __CREATE_IMAGE_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    //! \brief Default constructor - initializes to NULL.
+    Image1D() { }
+
+    /*! \brief Constructor from cl_mem - takes ownership.
+     *
+     * \param retainObject will cause the constructor to retain its cl object.
+     *                     Defaults to false to maintain compatibility with
+     *                     earlier versions.
+     *  See Memory for further details.
+     */
+    explicit Image1D(const cl_mem& image1D, bool retainObject = false) :
+        Image(image1D, retainObject) { }
+
+    /*! \brief Assignment from cl_mem - performs shallow copy.
+     *
+     *  See Memory for further details.
+     */
+    Image1D& operator = (const cl_mem& rhs)
+    {
+        Image::operator=(rhs);
+        return *this;
+    }
+
+    /*! \brief Copy constructor to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image1D(const Image1D& img) : Image(img) {}
+
+    /*! \brief Copy assignment to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image1D& operator = (const Image1D &img)
+    {
+        Image::operator=(img);
+        return *this;
+    }
+
+    /*! \brief Move constructor to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image1D(Image1D&& img) CL_HPP_NOEXCEPT_ : Image(std::move(img)) {}
+
+    /*! \brief Move assignment to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image1D& operator = (Image1D &&img)
+    {
+        Image::operator=(std::move(img));
+        return *this;
+    }
+
+};
+
+/*! \class Image1DBuffer
+ * \brief Image interface for 1D buffer images.
+ */
+class Image1DBuffer : public Image
+{
+public:
+    Image1DBuffer(
+        const Context& context,
+        cl_mem_flags flags,
+        ImageFormat format,
+        size_type width,
+        const Buffer &buffer,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+        cl_image_desc desc =
+        {
+            CL_MEM_OBJECT_IMAGE1D_BUFFER,
+            width,
+            0, 0, 0, 0, 0, 0, 0,
+            buffer()
+        };
+        object_ = ::clCreateImage(
+            context(), 
+            flags, 
+            &format, 
+            &desc, 
+            NULL, 
+            &error);
+
+        detail::errHandler(error, __CREATE_IMAGE_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    Image1DBuffer() { }
+
+    /*! \brief Constructor from cl_mem - takes ownership.
+     *
+     * \param retainObject will cause the constructor to retain its cl object.
+     *                     Defaults to false to maintain compatibility with
+     *                     earlier versions.
+     *  See Memory for further details.
+     */
+    explicit Image1DBuffer(const cl_mem& image1D, bool retainObject = false) :
+        Image(image1D, retainObject) { }
+
+    Image1DBuffer& operator = (const cl_mem& rhs)
+    {
+        Image::operator=(rhs);
+        return *this;
+    }
+
+    /*! \brief Copy constructor to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image1DBuffer(const Image1DBuffer& img) : Image(img) {}
+
+    /*! \brief Copy assignment to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image1DBuffer& operator = (const Image1DBuffer &img)
+    {
+        Image::operator=(img);
+        return *this;
+    }
+
+    /*! \brief Move constructor to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image1DBuffer(Image1DBuffer&& img) CL_HPP_NOEXCEPT_ : Image(std::move(img)) {}
+
+    /*! \brief Move assignment to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image1DBuffer& operator = (Image1DBuffer &&img)
+    {
+        Image::operator=(std::move(img));
+        return *this;
+    }
+
+};
+
+/*! \class Image1DArray
+ * \brief Image interface for arrays of 1D images.
+ */
+class Image1DArray : public Image
+{
+public:
+    Image1DArray(
+        const Context& context,
+        cl_mem_flags flags,
+        ImageFormat format,
+        size_type arraySize,
+        size_type width,
+        size_type rowPitch,
+        void* host_ptr = NULL,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+        cl_image_desc desc =
+        {
+            CL_MEM_OBJECT_IMAGE1D_ARRAY,
+            width,
+            0, 0,  // height, depth (unused)
+            arraySize,
+            rowPitch,
+            0, 0, 0, 0
+        };
+        object_ = ::clCreateImage(
+            context(), 
+            flags, 
+            &format, 
+            &desc, 
+            host_ptr, 
+            &error);
+
+        detail::errHandler(error, __CREATE_IMAGE_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    Image1DArray() { }
+  
+    /*! \brief Constructor from cl_mem - takes ownership.
+     *
+     * \param retainObject will cause the constructor to retain its cl object.
+     *                     Defaults to false to maintain compatibility with
+     *                     earlier versions.
+     *  See Memory for further details.
+     */
+    explicit Image1DArray(const cl_mem& imageArray, bool retainObject = false) :
+        Image(imageArray, retainObject) { }
+
+
+    Image1DArray& operator = (const cl_mem& rhs)
+    {
+        Image::operator=(rhs);
+        return *this;
+    }
+
+    /*! \brief Copy constructor to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image1DArray(const Image1DArray& img) : Image(img) {}
+
+    /*! \brief Copy assignment to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image1DArray& operator = (const Image1DArray &img)
+    {
+        Image::operator=(img);
+        return *this;
+    }
+
+    /*! \brief Move constructor to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image1DArray(Image1DArray&& img) CL_HPP_NOEXCEPT_ : Image(std::move(img)) {}
+
+    /*! \brief Move assignment to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image1DArray& operator = (Image1DArray &&img)
+    {
+        Image::operator=(std::move(img));
+        return *this;
+    }
+
+};
+#endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 120
+
+
+/*! \brief Class interface for 2D Image Memory objects.
+ *
+ *  See Memory for details about copy semantics, etc.
+ * 
+ *  \see Memory
+ */
+class Image2D : public Image
+{
+public:
+    /*! \brief Constructs a 2D Image in a specified context.
+     *
+     *  Wraps clCreateImage().
+     */
+    Image2D(
+        const Context& context,
+        cl_mem_flags flags,
+        ImageFormat format,
+        size_type width,
+        size_type height,
+        size_type row_pitch = 0,
+        void* host_ptr = NULL,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+        bool useCreateImage;
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
+        // Run-time decision based on the actual platform
+        {
+            cl_uint version = detail::getContextPlatformVersion(context());
+            useCreateImage = (version >= 0x10002); // OpenCL 1.2 or above
+        }
+#elif CL_HPP_TARGET_OPENCL_VERSION >= 120
+        useCreateImage = true;
+#else
+        useCreateImage = false;
+#endif
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+        if (useCreateImage)
+        {
+            cl_image_desc desc =
+            {
+                CL_MEM_OBJECT_IMAGE2D,
+                width,
+                height,
+                0, 0, // depth, array size (unused)
+                row_pitch,
+                0, 0, 0, 0
+            };
+            object_ = ::clCreateImage(
+                context(),
+                flags,
+                &format,
+                &desc,
+                host_ptr,
+                &error);
+
+            detail::errHandler(error, __CREATE_IMAGE_ERR);
+            if (err != NULL) {
+                *err = error;
+            }
+        }
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
+        if (!useCreateImage)
+        {
+            object_ = ::clCreateImage2D(
+                context(), flags,&format, width, height, row_pitch, host_ptr, &error);
+
+            detail::errHandler(error, __CREATE_IMAGE2D_ERR);
+            if (err != NULL) {
+                *err = error;
+            }
+        }
+#endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120
+    }
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+    /*! \brief Constructs a 2D Image from a buffer.
+    * \note This will share storage with the underlying buffer.
+    *
+    *  Wraps clCreateImage().
+    */
+    Image2D(
+        const Context& context,
+        ImageFormat format,
+        const Buffer &sourceBuffer,
+        size_type width,
+        size_type height,
+        size_type row_pitch = 0,
+        cl_int* err = nullptr)
+    {
+        cl_int error;
+
+        cl_image_desc desc =
+        {
+            CL_MEM_OBJECT_IMAGE2D,
+            width,
+            height,
+            0, 0, // depth, array size (unused)
+            row_pitch,
+            0, 0, 0,
+            // Use buffer as input to image
+            sourceBuffer()
+        };
+        object_ = ::clCreateImage(
+            context(),
+            0, // flags inherited from buffer
+            &format,
+            &desc,
+            nullptr,
+            &error);
+
+        detail::errHandler(error, __CREATE_IMAGE_ERR);
+        if (err != nullptr) {
+            *err = error;
+        }
+    }
+#endif //#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+    /*! \brief Constructs a 2D Image from an image.
+    * \note This will share storage with the underlying image but may
+    *       reinterpret the channel order and type.
+    *
+    * The image will be created matching with a descriptor matching the source. 
+    *
+    * \param order is the channel order to reinterpret the image data as.
+    *              The channel order may differ as described in the OpenCL 
+    *              2.0 API specification.
+    *
+    * Wraps clCreateImage().
+    */
+    Image2D(
+        const Context& context,
+        cl_channel_order order,
+        const Image &sourceImage,
+        cl_int* err = nullptr)
+    {
+        cl_int error;
+
+        // Descriptor fields have to match source image
+        size_type sourceWidth = 
+            sourceImage.getImageInfo<CL_IMAGE_WIDTH>();
+        size_type sourceHeight = 
+            sourceImage.getImageInfo<CL_IMAGE_HEIGHT>();
+        size_type sourceRowPitch =
+            sourceImage.getImageInfo<CL_IMAGE_ROW_PITCH>();
+        cl_uint sourceNumMIPLevels =
+            sourceImage.getImageInfo<CL_IMAGE_NUM_MIP_LEVELS>();
+        cl_uint sourceNumSamples =
+            sourceImage.getImageInfo<CL_IMAGE_NUM_SAMPLES>();
+        cl_image_format sourceFormat =
+            sourceImage.getImageInfo<CL_IMAGE_FORMAT>();
+
+        // Update only the channel order. 
+        // Channel format inherited from source.
+        sourceFormat.image_channel_order = order;
+        cl_image_desc desc =
+        {
+            CL_MEM_OBJECT_IMAGE2D,
+            sourceWidth,
+            sourceHeight,
+            0, 0, // depth (unused), array size (unused)
+            sourceRowPitch,
+            0, // slice pitch (unused)
+            sourceNumMIPLevels,
+            sourceNumSamples,
+            // Use buffer as input to image
+            sourceImage()
+        };
+        object_ = ::clCreateImage(
+            context(),
+            0, // flags should be inherited from mem_object
+            &sourceFormat,
+            &desc,
+            nullptr,
+            &error);
+
+        detail::errHandler(error, __CREATE_IMAGE_ERR);
+        if (err != nullptr) {
+            *err = error;
+        }
+    }
+#endif //#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+
+    //! \brief Default constructor - initializes to NULL.
+    Image2D() { }
+
+    /*! \brief Constructor from cl_mem - takes ownership.
+     *
+     * \param retainObject will cause the constructor to retain its cl object.
+     *                     Defaults to false to maintain compatibility with
+     *                     earlier versions.
+     *  See Memory for further details.
+     */
+    explicit Image2D(const cl_mem& image2D, bool retainObject = false) :
+        Image(image2D, retainObject) { }
+
+    /*! \brief Assignment from cl_mem - performs shallow copy.
+     *
+     *  See Memory for further details.
+     */
+    Image2D& operator = (const cl_mem& rhs)
+    {
+        Image::operator=(rhs);
+        return *this;
+    }
+
+    /*! \brief Copy constructor to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image2D(const Image2D& img) : Image(img) {}
+
+    /*! \brief Copy assignment to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image2D& operator = (const Image2D &img)
+    {
+        Image::operator=(img);
+        return *this;
+    }
+
+    /*! \brief Move constructor to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image2D(Image2D&& img) CL_HPP_NOEXCEPT_ : Image(std::move(img)) {}
+
+    /*! \brief Move assignment to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image2D& operator = (Image2D &&img)
+    {
+        Image::operator=(std::move(img));
+        return *this;
+    }
+
+};
+
+
+#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
+/*! \brief Class interface for GL 2D Image Memory objects.
+ *
+ *  This is provided to facilitate interoperability with OpenGL.
+ * 
+ *  See Memory for details about copy semantics, etc.
+ * 
+ *  \see Memory
+ *  \note Deprecated for OpenCL 1.2. Please use ImageGL instead.
+ */
+class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED Image2DGL : public Image2D 
+{
+public:
+    /*! \brief Constructs an Image2DGL in a specified context, from a given
+     *         GL Texture.
+     *
+     *  Wraps clCreateFromGLTexture2D().
+     */
+    Image2DGL(
+        const Context& context,
+        cl_mem_flags flags,
+        cl_GLenum target,
+        cl_GLint  miplevel,
+        cl_GLuint texobj,
+        cl_int * err = NULL)
+    {
+        cl_int error;
+        object_ = ::clCreateFromGLTexture2D(
+            context(),
+            flags,
+            target,
+            miplevel,
+            texobj,
+            &error);
+
+        detail::errHandler(error, __CREATE_GL_TEXTURE_2D_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+
+    }
+    
+    //! \brief Default constructor - initializes to NULL.
+    Image2DGL() : Image2D() { }
+
+    /*! \brief Constructor from cl_mem - takes ownership.
+     *
+     * \param retainObject will cause the constructor to retain its cl object.
+     *                     Defaults to false to maintain compatibility with
+     *                     earlier versions.
+     *  See Memory for further details.
+     */
+    explicit Image2DGL(const cl_mem& image, bool retainObject = false) : 
+        Image2D(image, retainObject) { }
+
+    /*! \brief Assignment from cl_mem - performs shallow copy.
+     *c
+     *  See Memory for further details.
+     */
+    Image2DGL& operator = (const cl_mem& rhs)
+    {
+        Image2D::operator=(rhs);
+        return *this;
+    }
+
+    /*! \brief Copy constructor to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image2DGL(const Image2DGL& img) : Image2D(img) {}
+
+    /*! \brief Copy assignment to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image2DGL& operator = (const Image2DGL &img)
+    {
+        Image2D::operator=(img);
+        return *this;
+    }
+
+    /*! \brief Move constructor to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image2DGL(Image2DGL&& img) CL_HPP_NOEXCEPT_ : Image2D(std::move(img)) {}
+
+    /*! \brief Move assignment to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image2DGL& operator = (Image2DGL &&img)
+    {
+        Image2D::operator=(std::move(img));
+        return *this;
+    }
+
+} CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
+#endif // CL_USE_DEPRECATED_OPENCL_1_1_APIS
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+/*! \class Image2DArray
+ * \brief Image interface for arrays of 2D images.
+ */
+class Image2DArray : public Image
+{
+public:
+    Image2DArray(
+        const Context& context,
+        cl_mem_flags flags,
+        ImageFormat format,
+        size_type arraySize,
+        size_type width,
+        size_type height,
+        size_type rowPitch,
+        size_type slicePitch,
+        void* host_ptr = NULL,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+        cl_image_desc desc =
+        {
+            CL_MEM_OBJECT_IMAGE2D_ARRAY,
+            width,
+            height,
+            0,       // depth (unused)
+            arraySize,
+            rowPitch,
+            slicePitch,
+            0, 0, 0
+        };
+        object_ = ::clCreateImage(
+            context(), 
+            flags, 
+            &format, 
+            &desc, 
+            host_ptr, 
+            &error);
+
+        detail::errHandler(error, __CREATE_IMAGE_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    Image2DArray() { }
+    
+    /*! \brief Constructor from cl_mem - takes ownership.
+     *
+     * \param retainObject will cause the constructor to retain its cl object.
+     *                     Defaults to false to maintain compatibility with
+     *                     earlier versions.
+     *  See Memory for further details.
+     */
+    explicit Image2DArray(const cl_mem& imageArray, bool retainObject = false) : Image(imageArray, retainObject) { }
+
+    Image2DArray& operator = (const cl_mem& rhs)
+    {
+        Image::operator=(rhs);
+        return *this;
+    }
+
+    /*! \brief Copy constructor to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image2DArray(const Image2DArray& img) : Image(img) {}
+
+    /*! \brief Copy assignment to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image2DArray& operator = (const Image2DArray &img)
+    {
+        Image::operator=(img);
+        return *this;
+    }
+
+    /*! \brief Move constructor to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image2DArray(Image2DArray&& img) CL_HPP_NOEXCEPT_ : Image(std::move(img)) {}
+
+    /*! \brief Move assignment to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image2DArray& operator = (Image2DArray &&img)
+    {
+        Image::operator=(std::move(img));
+        return *this;
+    }
+};
+#endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 120
+
+/*! \brief Class interface for 3D Image Memory objects.
+ *
+ *  See Memory for details about copy semantics, etc.
+ * 
+ *  \see Memory
+ */
+class Image3D : public Image
+{
+public:
+    /*! \brief Constructs a 3D Image in a specified context.
+     *
+     *  Wraps clCreateImage().
+     */
+    Image3D(
+        const Context& context,
+        cl_mem_flags flags,
+        ImageFormat format,
+        size_type width,
+        size_type height,
+        size_type depth,
+        size_type row_pitch = 0,
+        size_type slice_pitch = 0,
+        void* host_ptr = NULL,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+        bool useCreateImage;
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120 && CL_HPP_MINIMUM_OPENCL_VERSION < 120
+        // Run-time decision based on the actual platform
+        {
+            cl_uint version = detail::getContextPlatformVersion(context());
+            useCreateImage = (version >= 0x10002); // OpenCL 1.2 or above
+        }
+#elif CL_HPP_TARGET_OPENCL_VERSION >= 120
+        useCreateImage = true;
+#else
+        useCreateImage = false;
+#endif
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+        if (useCreateImage)
+        {
+            cl_image_desc desc =
+            {
+                CL_MEM_OBJECT_IMAGE3D,
+                width,
+                height,
+                depth,
+                0,      // array size (unused)
+                row_pitch,
+                slice_pitch,
+                0, 0, 0
+            };
+            object_ = ::clCreateImage(
+                context(), 
+                flags, 
+                &format, 
+                &desc, 
+                host_ptr, 
+                &error);
+
+            detail::errHandler(error, __CREATE_IMAGE_ERR);
+            if (err != NULL) {
+                *err = error;
+            }
+        }
+#endif  // CL_HPP_TARGET_OPENCL_VERSION >= 120
+#if CL_HPP_MINIMUM_OPENCL_VERSION < 120
+        if (!useCreateImage)
+        {
+            object_ = ::clCreateImage3D(
+                context(), flags, &format, width, height, depth, row_pitch,
+                slice_pitch, host_ptr, &error);
+
+            detail::errHandler(error, __CREATE_IMAGE3D_ERR);
+            if (err != NULL) {
+                *err = error;
+            }
+        }
+#endif // CL_HPP_MINIMUM_OPENCL_VERSION < 120
+    }
+
+    //! \brief Default constructor - initializes to NULL.
+    Image3D() : Image() { }
+
+    /*! \brief Constructor from cl_mem - takes ownership.
+     *
+     * \param retainObject will cause the constructor to retain its cl object.
+     *                     Defaults to false to maintain compatibility with
+     *                     earlier versions.
+     *  See Memory for further details.
+     */
+    explicit Image3D(const cl_mem& image3D, bool retainObject = false) : 
+        Image(image3D, retainObject) { }
+
+    /*! \brief Assignment from cl_mem - performs shallow copy.
+     *
+     *  See Memory for further details.
+     */
+    Image3D& operator = (const cl_mem& rhs)
+    {
+        Image::operator=(rhs);
+        return *this;
+    }
+
+    /*! \brief Copy constructor to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image3D(const Image3D& img) : Image(img) {}
+
+    /*! \brief Copy assignment to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image3D& operator = (const Image3D &img)
+    {
+        Image::operator=(img);
+        return *this;
+    }
+
+    /*! \brief Move constructor to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image3D(Image3D&& img) CL_HPP_NOEXCEPT_ : Image(std::move(img)) {}
+
+    /*! \brief Move assignment to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image3D& operator = (Image3D &&img)
+    {
+        Image::operator=(std::move(img));
+        return *this;
+    }
+};
+
+#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
+/*! \brief Class interface for GL 3D Image Memory objects.
+ *
+ *  This is provided to facilitate interoperability with OpenGL.
+ * 
+ *  See Memory for details about copy semantics, etc.
+ * 
+ *  \see Memory
+ */
+class Image3DGL : public Image3D
+{
+public:
+    /*! \brief Constructs an Image3DGL in a specified context, from a given
+     *         GL Texture.
+     *
+     *  Wraps clCreateFromGLTexture3D().
+     */
+    Image3DGL(
+        const Context& context,
+        cl_mem_flags flags,
+        cl_GLenum target,
+        cl_GLint  miplevel,
+        cl_GLuint texobj,
+        cl_int * err = NULL)
+    {
+        cl_int error;
+        object_ = ::clCreateFromGLTexture3D(
+            context(),
+            flags,
+            target,
+            miplevel,
+            texobj,
+            &error);
+
+        detail::errHandler(error, __CREATE_GL_TEXTURE_3D_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    //! \brief Default constructor - initializes to NULL.
+    Image3DGL() : Image3D() { }
+
+    /*! \brief Constructor from cl_mem - takes ownership.
+     *
+     * \param retainObject will cause the constructor to retain its cl object.
+     *                     Defaults to false to maintain compatibility with
+     *                     earlier versions.
+     *  See Memory for further details.
+     */
+    explicit Image3DGL(const cl_mem& image, bool retainObject = false) : 
+        Image3D(image, retainObject) { }
+
+    /*! \brief Assignment from cl_mem - performs shallow copy.
+     *
+     *  See Memory for further details.
+     */
+    Image3DGL& operator = (const cl_mem& rhs)
+    {
+        Image3D::operator=(rhs);
+        return *this;
+    }
+
+    /*! \brief Copy constructor to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image3DGL(const Image3DGL& img) : Image3D(img) {}
+
+    /*! \brief Copy assignment to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image3DGL& operator = (const Image3DGL &img)
+    {
+        Image3D::operator=(img);
+        return *this;
+    }
+
+    /*! \brief Move constructor to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image3DGL(Image3DGL&& img) CL_HPP_NOEXCEPT_ : Image3D(std::move(img)) {}
+
+    /*! \brief Move assignment to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Image3DGL& operator = (Image3DGL &&img)
+    {
+        Image3D::operator=(std::move(img));
+        return *this;
+    }
+};
+#endif // CL_USE_DEPRECATED_OPENCL_1_1_APIS
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+/*! \class ImageGL
+ * \brief general image interface for GL interop.
+ * We abstract the 2D and 3D GL images into a single instance here
+ * that wraps all GL sourced images on the grounds that setup information
+ * was performed by OpenCL anyway.
+ */
+class ImageGL : public Image
+{
+public:
+    ImageGL(
+        const Context& context,
+        cl_mem_flags flags,
+        cl_GLenum target,
+        cl_GLint  miplevel,
+        cl_GLuint texobj,
+        cl_int * err = NULL)
+    {
+        cl_int error;
+        object_ = ::clCreateFromGLTexture(
+            context(), 
+            flags, 
+            target,
+            miplevel,
+            texobj,
+            &error);
+
+        detail::errHandler(error, __CREATE_GL_TEXTURE_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    ImageGL() : Image() { }
+    
+    /*! \brief Constructor from cl_mem - takes ownership.
+     *
+     * \param retainObject will cause the constructor to retain its cl object.
+     *                     Defaults to false to maintain compatibility with
+     *                     earlier versions.
+     *  See Memory for further details.
+     */
+    explicit ImageGL(const cl_mem& image, bool retainObject = false) : 
+        Image(image, retainObject) { }
+
+    ImageGL& operator = (const cl_mem& rhs)
+    {
+        Image::operator=(rhs);
+        return *this;
+    }
+
+    /*! \brief Copy constructor to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    ImageGL(const ImageGL& img) : Image(img) {}
+
+    /*! \brief Copy assignment to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    ImageGL& operator = (const ImageGL &img)
+    {
+        Image::operator=(img);
+        return *this;
+    }
+
+    /*! \brief Move constructor to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    ImageGL(ImageGL&& img) CL_HPP_NOEXCEPT_ : Image(std::move(img)) {}
+
+    /*! \brief Move assignment to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    ImageGL& operator = (ImageGL &&img)
+    {
+        Image::operator=(std::move(img));
+        return *this;
+    }
+};
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+
+
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+/*! \brief Class interface for Pipe Memory Objects.
+*
+*  See Memory for details about copy semantics, etc.
+*
+*  \see Memory
+*/
+class Pipe : public Memory
+{
+public:
+
+    /*! \brief Constructs a Pipe in a specified context.
+     *
+     * Wraps clCreatePipe().
+     * @param context Context in which to create the pipe.
+     * @param flags Bitfield. Only CL_MEM_READ_WRITE and CL_MEM_HOST_NO_ACCESS are valid.
+     * @param packet_size Size in bytes of a single packet of the pipe.
+     * @param max_packets Number of packets that may be stored in the pipe.
+     *
+     */
+    Pipe(
+        const Context& context,
+        cl_uint packet_size,
+        cl_uint max_packets,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+
+        cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
+        object_ = ::clCreatePipe(context(), flags, packet_size, max_packets, nullptr, &error);
+
+        detail::errHandler(error, __CREATE_BUFFER_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    /*! \brief Constructs a Pipe in a the default context.
+     *
+     * Wraps clCreatePipe().
+     * @param flags Bitfield. Only CL_MEM_READ_WRITE and CL_MEM_HOST_NO_ACCESS are valid.
+     * @param packet_size Size in bytes of a single packet of the pipe.
+     * @param max_packets Number of packets that may be stored in the pipe.
+     *
+     */
+    Pipe(
+        cl_uint packet_size,
+        cl_uint max_packets,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+
+        Context context = Context::getDefault(err);
+
+        cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
+        object_ = ::clCreatePipe(context(), flags, packet_size, max_packets, nullptr, &error);
+
+        detail::errHandler(error, __CREATE_BUFFER_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    //! \brief Default constructor - initializes to NULL.
+    Pipe() : Memory() { }
+
+    /*! \brief Constructor from cl_mem - takes ownership.
+     *
+     * \param retainObject will cause the constructor to retain its cl object.
+     *                     Defaults to false to maintain compatibility with earlier versions.
+     *
+     *  See Memory for further details.
+     */
+    explicit Pipe(const cl_mem& pipe, bool retainObject = false) :
+        Memory(pipe, retainObject) { }
+
+    /*! \brief Assignment from cl_mem - performs shallow copy.
+     *
+     *  See Memory for further details.
+     */
+    Pipe& operator = (const cl_mem& rhs)
+    {
+        Memory::operator=(rhs);
+        return *this;
+    }
+
+    /*! \brief Copy constructor to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Pipe(const Pipe& pipe) : Memory(pipe) {}
+
+    /*! \brief Copy assignment to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Pipe& operator = (const Pipe &pipe)
+    {
+        Memory::operator=(pipe);
+        return *this;
+    }
+
+    /*! \brief Move constructor to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Pipe(Pipe&& pipe) CL_HPP_NOEXCEPT_ : Memory(std::move(pipe)) {}
+
+    /*! \brief Move assignment to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Pipe& operator = (Pipe &&pipe)
+    {
+        Memory::operator=(std::move(pipe));
+        return *this;
+    }
+
+    //! \brief Wrapper for clGetMemObjectInfo().
+    template <typename T>
+    cl_int getInfo(cl_pipe_info name, T* param) const
+    {
+        return detail::errHandler(
+            detail::getInfo(&::clGetPipeInfo, object_, name, param),
+            __GET_MEM_OBJECT_INFO_ERR);
+    }
+
+    //! \brief Wrapper for clGetMemObjectInfo() that returns by value.
+    template <cl_int name> typename
+        detail::param_traits<detail::cl_pipe_info, name>::param_type
+        getInfo(cl_int* err = NULL) const
+    {
+        typename detail::param_traits<
+            detail::cl_pipe_info, name>::param_type param;
+        cl_int result = getInfo(name, &param);
+        if (err != NULL) {
+            *err = result;
+        }
+        return param;
+    }
+}; // class Pipe
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
+
+
+/*! \brief Class interface for cl_sampler.
+ *
+ *  \note Copies of these objects are shallow, meaning that the copy will refer
+ *        to the same underlying cl_sampler as the original.  For details, see
+ *        clRetainSampler() and clReleaseSampler().
+ *
+ *  \see cl_sampler 
+ */
+class Sampler : public detail::Wrapper<cl_sampler>
+{
+public:
+    //! \brief Default constructor - initializes to NULL.
+    Sampler() { }
+
+    /*! \brief Constructs a Sampler in a specified context.
+     *
+     *  Wraps clCreateSampler().
+     */
+    Sampler(
+        const Context& context,
+        cl_bool normalized_coords,
+        cl_addressing_mode addressing_mode,
+        cl_filter_mode filter_mode,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+        cl_sampler_properties sampler_properties[] = {
+            CL_SAMPLER_NORMALIZED_COORDS, normalized_coords,
+            CL_SAMPLER_ADDRESSING_MODE, addressing_mode,
+            CL_SAMPLER_FILTER_MODE, filter_mode,
+            0 };
+        object_ = ::clCreateSamplerWithProperties(
+            context(),
+            sampler_properties,
+            &error);
+
+        detail::errHandler(error, __CREATE_SAMPLER_WITH_PROPERTIES_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+#else
+        object_ = ::clCreateSampler(
+            context(),
+            normalized_coords,
+            addressing_mode,
+            filter_mode,
+            &error);
+
+        detail::errHandler(error, __CREATE_SAMPLER_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+#endif        
+    }
+
+    /*! \brief Constructor from cl_sampler - takes ownership.
+     * 
+     * \param retainObject will cause the constructor to retain its cl object.
+     *                     Defaults to false to maintain compatibility with
+     *                     earlier versions.
+     *  This effectively transfers ownership of a refcount on the cl_sampler
+     *  into the new Sampler object.
+     */
+    explicit Sampler(const cl_sampler& sampler, bool retainObject = false) : 
+        detail::Wrapper<cl_type>(sampler, retainObject) { }
+
+    /*! \brief Assignment operator from cl_sampler - takes ownership.
+     *
+     *  This effectively transfers ownership of a refcount on the rhs and calls
+     *  clReleaseSampler() on the value previously held by this instance.
+     */
+    Sampler& operator = (const cl_sampler& rhs)
+    {
+        detail::Wrapper<cl_type>::operator=(rhs);
+        return *this;
+    }
+
+    /*! \brief Copy constructor to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Sampler(const Sampler& sam) : detail::Wrapper<cl_type>(sam) {}
+
+    /*! \brief Copy assignment to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Sampler& operator = (const Sampler &sam)
+    {
+        detail::Wrapper<cl_type>::operator=(sam);
+        return *this;
+    }
+
+    /*! \brief Move constructor to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Sampler(Sampler&& sam) CL_HPP_NOEXCEPT_ : detail::Wrapper<cl_type>(std::move(sam)) {}
+
+    /*! \brief Move assignment to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Sampler& operator = (Sampler &&sam)
+    {
+        detail::Wrapper<cl_type>::operator=(std::move(sam));
+        return *this;
+    }
+
+    //! \brief Wrapper for clGetSamplerInfo().
+    template <typename T>
+    cl_int getInfo(cl_sampler_info name, T* param) const
+    {
+        return detail::errHandler(
+            detail::getInfo(&::clGetSamplerInfo, object_, name, param),
+            __GET_SAMPLER_INFO_ERR);
+    }
+
+    //! \brief Wrapper for clGetSamplerInfo() that returns by value.
+    template <cl_int name> typename
+    detail::param_traits<detail::cl_sampler_info, name>::param_type
+    getInfo(cl_int* err = NULL) const
+    {
+        typename detail::param_traits<
+            detail::cl_sampler_info, name>::param_type param;
+        cl_int result = getInfo(name, &param);
+        if (err != NULL) {
+            *err = result;
+        }
+        return param;
+    }
+};
+
+class Program;
+class CommandQueue;
+class DeviceCommandQueue;
+class Kernel;
+
+//! \brief Class interface for specifying NDRange values.
+class NDRange
+{
+private:
+    size_type sizes_[3];
+    cl_uint dimensions_;
+
+public:
+    //! \brief Default constructor - resulting range has zero dimensions.
+    NDRange()
+        : dimensions_(0)
+    {
+        sizes_[0] = 0;
+        sizes_[1] = 0;
+        sizes_[2] = 0;
+    }
+
+    //! \brief Constructs one-dimensional range.
+    NDRange(size_type size0)
+        : dimensions_(1)
+    {
+        sizes_[0] = size0;
+        sizes_[1] = 1;
+        sizes_[2] = 1;
+    }
+
+    //! \brief Constructs two-dimensional range.
+    NDRange(size_type size0, size_type size1)
+        : dimensions_(2)
+    {
+        sizes_[0] = size0;
+        sizes_[1] = size1;
+        sizes_[2] = 1;
+    }
+
+    //! \brief Constructs three-dimensional range.
+    NDRange(size_type size0, size_type size1, size_type size2)
+        : dimensions_(3)
+    {
+        sizes_[0] = size0;
+        sizes_[1] = size1;
+        sizes_[2] = size2;
+    }
+
+    /*! \brief Conversion operator to const size_type *.
+     *  
+     *  \returns a pointer to the size of the first dimension.
+     */
+    operator const size_type*() const { 
+        return sizes_; 
+    }
+
+    //! \brief Queries the number of dimensions in the range.
+    size_type dimensions() const 
+    { 
+        return dimensions_; 
+    }
+
+    //! \brief Returns the size of the object in bytes based on the
+    // runtime number of dimensions
+    size_type size() const
+    {
+        return dimensions_*sizeof(size_type);
+    }
+
+    size_type* get()
+    {
+        return sizes_;
+    }
+    
+    const size_type* get() const
+    {
+        return sizes_;
+    }
+};
+
+//! \brief A zero-dimensional range.
+static const NDRange NullRange;
+
+//! \brief Local address wrapper for use with Kernel::setArg
+struct LocalSpaceArg
+{
+    size_type size_;
+};
+
+namespace detail {
+
+template <typename T, class Enable = void>
+struct KernelArgumentHandler;
+
+// Enable for objects that are not subclasses of memory
+// Pointers, constants etc
+template <typename T>
+struct KernelArgumentHandler<T, typename std::enable_if<!std::is_base_of<cl::Memory, T>::value>::type>
+{
+    static size_type size(const T&) { return sizeof(T); }
+    static const T* ptr(const T& value) { return &value; }
+};
+
+// Enable for subclasses of memory where we want to get a reference to the cl_mem out
+// and pass that in for safety
+template <typename T>
+struct KernelArgumentHandler<T, typename std::enable_if<std::is_base_of<cl::Memory, T>::value>::type>
+{
+    static size_type size(const T&) { return sizeof(cl_mem); }
+    static const cl_mem* ptr(const T& value) { return &(value()); }
+};
+
+// Specialization for DeviceCommandQueue defined later
+
+template <>
+struct KernelArgumentHandler<LocalSpaceArg, void>
+{
+    static size_type size(const LocalSpaceArg& value) { return value.size_; }
+    static const void* ptr(const LocalSpaceArg&) { return NULL; }
+};
+
+} 
+//! \endcond
+
+/*! Local
+ * \brief Helper function for generating LocalSpaceArg objects.
+ */
+inline LocalSpaceArg
+Local(size_type size)
+{
+    LocalSpaceArg ret = { size };
+    return ret;
+}
+
+/*! \brief Class interface for cl_kernel.
+ *
+ *  \note Copies of these objects are shallow, meaning that the copy will refer
+ *        to the same underlying cl_kernel as the original.  For details, see
+ *        clRetainKernel() and clReleaseKernel().
+ *
+ *  \see cl_kernel
+ */
+class Kernel : public detail::Wrapper<cl_kernel>
+{
+public:
+    inline Kernel(const Program& program, const char* name, cl_int* err = NULL);
+
+    //! \brief Default constructor - initializes to NULL.
+    Kernel() { }
+
+    /*! \brief Constructor from cl_kernel - takes ownership.
+     * 
+     * \param retainObject will cause the constructor to retain its cl object.
+     *                     Defaults to false to maintain compatibility with
+     *                     earlier versions.
+     *  This effectively transfers ownership of a refcount on the cl_kernel
+     *  into the new Kernel object.
+     */
+    explicit Kernel(const cl_kernel& kernel, bool retainObject = false) : 
+        detail::Wrapper<cl_type>(kernel, retainObject) { }
+
+    /*! \brief Assignment operator from cl_kernel - takes ownership.
+     *
+     *  This effectively transfers ownership of a refcount on the rhs and calls
+     *  clReleaseKernel() on the value previously held by this instance.
+     */
+    Kernel& operator = (const cl_kernel& rhs)
+    {
+        detail::Wrapper<cl_type>::operator=(rhs);
+        return *this;
+    }
+
+    /*! \brief Copy constructor to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Kernel(const Kernel& kernel) : detail::Wrapper<cl_type>(kernel) {}
+
+    /*! \brief Copy assignment to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Kernel& operator = (const Kernel &kernel)
+    {
+        detail::Wrapper<cl_type>::operator=(kernel);
+        return *this;
+    }
+
+    /*! \brief Move constructor to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Kernel(Kernel&& kernel) CL_HPP_NOEXCEPT_ : detail::Wrapper<cl_type>(std::move(kernel)) {}
+
+    /*! \brief Move assignment to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Kernel& operator = (Kernel &&kernel)
+    {
+        detail::Wrapper<cl_type>::operator=(std::move(kernel));
+        return *this;
+    }
+
+    template <typename T>
+    cl_int getInfo(cl_kernel_info name, T* param) const
+    {
+        return detail::errHandler(
+            detail::getInfo(&::clGetKernelInfo, object_, name, param),
+            __GET_KERNEL_INFO_ERR);
+    }
+
+    template <cl_int name> typename
+    detail::param_traits<detail::cl_kernel_info, name>::param_type
+    getInfo(cl_int* err = NULL) const
+    {
+        typename detail::param_traits<
+            detail::cl_kernel_info, name>::param_type param;
+        cl_int result = getInfo(name, &param);
+        if (err != NULL) {
+            *err = result;
+        }
+        return param;
+    }
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+    template <typename T>
+    cl_int getArgInfo(cl_uint argIndex, cl_kernel_arg_info name, T* param) const
+    {
+        return detail::errHandler(
+            detail::getInfo(&::clGetKernelArgInfo, object_, argIndex, name, param),
+            __GET_KERNEL_ARG_INFO_ERR);
+    }
+
+    template <cl_int name> typename
+    detail::param_traits<detail::cl_kernel_arg_info, name>::param_type
+    getArgInfo(cl_uint argIndex, cl_int* err = NULL) const
+    {
+        typename detail::param_traits<
+            detail::cl_kernel_arg_info, name>::param_type param;
+        cl_int result = getArgInfo(argIndex, name, &param);
+        if (err != NULL) {
+            *err = result;
+        }
+        return param;
+    }
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+
+    template <typename T>
+    cl_int getWorkGroupInfo(
+        const Device& device, cl_kernel_work_group_info name, T* param) const
+    {
+        return detail::errHandler(
+            detail::getInfo(
+                &::clGetKernelWorkGroupInfo, object_, device(), name, param),
+                __GET_KERNEL_WORK_GROUP_INFO_ERR);
+    }
+
+    template <cl_int name> typename
+    detail::param_traits<detail::cl_kernel_work_group_info, name>::param_type
+        getWorkGroupInfo(const Device& device, cl_int* err = NULL) const
+    {
+        typename detail::param_traits<
+        detail::cl_kernel_work_group_info, name>::param_type param;
+        cl_int result = getWorkGroupInfo(device, name, &param);
+        if (err != NULL) {
+            *err = result;
+        }
+        return param;
+    }
+    
+#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+#if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR)
+    cl_int getSubGroupInfo(const cl::Device &dev, cl_kernel_sub_group_info name, const cl::NDRange &range, size_type* param) const
+    {
+        typedef clGetKernelSubGroupInfoKHR_fn PFN_clGetKernelSubGroupInfoKHR;
+        static PFN_clGetKernelSubGroupInfoKHR pfn_clGetKernelSubGroupInfoKHR = NULL;
+        CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetKernelSubGroupInfoKHR);
+
+        return detail::errHandler(
+            pfn_clGetKernelSubGroupInfoKHR(object_, dev(), name, range.size(), range.get(), sizeof(size_type), param, nullptr),
+            __GET_KERNEL_ARG_INFO_ERR);
+    }
+
+    template <cl_int name>
+        size_type getSubGroupInfo(const cl::Device &dev, const cl::NDRange &range, cl_int* err = NULL) const
+    {
+        size_type param;
+        cl_int result = getSubGroupInfo(dev, name, range, &param);
+        if (err != NULL) {
+            *err = result;
+        }
+        return param;
+    }
+#endif // #if defined(CL_HPP_USE_CL_SUB_GROUPS_KHR)
+#endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+    /*! \brief setArg overload taking a shared_ptr type
+     */
+    template<typename T>
+    cl_int setArg(cl_uint index, const cl::pointer<T> argPtr)
+    {
+        return detail::errHandler(
+            ::clSetKernelArgSVMPointer(object_, index, argPtr.get()),
+            __SET_KERNEL_ARGS_ERR);
+    }
+
+    /*! \brief setArg overload taking a vector type.
+     */
+    template<typename T, class Alloc>
+    cl_int setArg(cl_uint index, const cl::vector<T, Alloc> &argPtr)
+    {
+        return detail::errHandler(
+            ::clSetKernelArgSVMPointer(object_, index, argPtr.data()),
+            __SET_KERNEL_ARGS_ERR);
+    }
+#endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
+   
+#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+    /*! \brief setArg overload taking a pointer type
+    */
+    template<typename T>
+    typename std::enable_if<std::is_pointer<T>::value, cl_int>::type
+        setArg(cl_uint index, const T argPtr)
+    {
+        return detail::errHandler(
+            ::clSetKernelArgSVMPointer(object_, index, argPtr),
+            __SET_KERNEL_ARGS_ERR);
+    }
+#endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
+
+    /*! \brief setArg overload taking a POD type
+     */
+    template <typename T>
+    typename std::enable_if<!std::is_pointer<T>::value, cl_int>::type
+        setArg(cl_uint index, const T &value)
+    {
+        return detail::errHandler(
+            ::clSetKernelArg(
+                object_,
+                index,
+                detail::KernelArgumentHandler<T>::size(value),
+                detail::KernelArgumentHandler<T>::ptr(value)),
+            __SET_KERNEL_ARGS_ERR);
+    }
+
+    cl_int setArg(cl_uint index, size_type size, const void* argPtr)
+    {
+        return detail::errHandler(
+            ::clSetKernelArg(object_, index, size, argPtr),
+            __SET_KERNEL_ARGS_ERR);
+    }
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+    /*!
+     * Specify a vector of SVM pointers that the kernel may access in 
+     * addition to its arguments.
+     */
+    cl_int setSVMPointers(const vector<void*> &pointerList)
+    {
+        return detail::errHandler(
+            ::clSetKernelExecInfo(
+                object_,
+                CL_KERNEL_EXEC_INFO_SVM_PTRS,
+                sizeof(void*)*pointerList.size(),
+                pointerList.data()));
+    }
+
+    /*!
+     * Specify a std::array of SVM pointers that the kernel may access in
+     * addition to its arguments.
+     */
+    template<int ArrayLength>
+    cl_int setSVMPointers(const std::array<void*, ArrayLength> &pointerList)
+    {
+        return detail::errHandler(
+            ::clSetKernelExecInfo(
+                object_,
+                CL_KERNEL_EXEC_INFO_SVM_PTRS,
+                sizeof(void*)*pointerList.size(),
+                pointerList.data()));
+    }
+
+    /*! \brief Enable fine-grained system SVM.
+     *
+     * \note It is only possible to enable fine-grained system SVM if all devices
+     *       in the context associated with kernel support it.
+     * 
+     * \param svmEnabled True if fine-grained system SVM is requested. False otherwise.
+     * \return CL_SUCCESS if the function was executed succesfully. CL_INVALID_OPERATION
+     *         if no devices in the context support fine-grained system SVM.
+     *
+     * \see clSetKernelExecInfo
+     */
+    cl_int enableFineGrainedSystemSVM(bool svmEnabled)
+    {
+        cl_bool svmEnabled_ = svmEnabled ? CL_TRUE : CL_FALSE;
+        return detail::errHandler(
+            ::clSetKernelExecInfo(
+                object_,
+                CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM,
+                sizeof(cl_bool),
+                &svmEnabled_
+                )
+            );
+    }
+    
+    template<int index, int ArrayLength, typename T0, typename... Ts>
+    void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, pointer<T0> &t0, Ts... ts)
+    {
+        pointerList[index] = static_cast<void*>(t0.get());
+        setSVMPointersHelper<index + 1, Ts...>(ts...);
+    }
+
+    template<int index, int ArrayLength, typename T0, typename... Ts>
+    typename std::enable_if<std::is_pointer<T0>::value, void>::type
+    setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0, Ts... ts)
+    {
+        pointerList[index] = static_cast<void*>(t0);
+        setSVMPointersHelper<index + 1, Ts...>(ts...);
+    }
+    
+    template<int index, int ArrayLength, typename T0>
+    void setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, pointer<T0> &t0)
+    {
+        pointerList[index] = static_cast<void*>(t0.get());
+    }
+
+    template<int index, int ArrayLength, typename T0>
+    typename std::enable_if<std::is_pointer<T0>::value, void>::type
+    setSVMPointersHelper(std::array<void*, ArrayLength> &pointerList, T0 t0)
+    {
+        pointerList[index] = static_cast<void*>(t0);
+    }
+
+    template<typename T0, typename... Ts>
+    cl_int setSVMPointers(T0 t0, Ts... ts)
+    {
+        std::array<void*, 1 + sizeof...(Ts)> pointerList;
+
+        setSVMPointersHelper<0, 1 + sizeof...(Ts)>(pointerList, t0, ts...);
+        return detail::errHandler(
+            ::clSetKernelExecInfo(
+            object_,
+            CL_KERNEL_EXEC_INFO_SVM_PTRS,
+            sizeof(void*)*(1 + sizeof...(Ts)),
+            pointerList.data()));
+    }
+#endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
+};
+
+/*! \class Program
+ * \brief Program interface that implements cl_program.
+ */
+class Program : public detail::Wrapper<cl_program>
+{
+public:
+#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
+    typedef vector<vector<unsigned char>> Binaries;
+    typedef vector<string> Sources;
+#else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
+    typedef vector<std::pair<const void*, size_type> > Binaries;
+    typedef vector<std::pair<const char*, size_type> > Sources;
+#endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
+    
+    Program(
+        const string& source,
+        bool build = false,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+
+        const char * strings = source.c_str();
+        const size_type length  = source.size();
+
+        Context context = Context::getDefault(err);
+
+        object_ = ::clCreateProgramWithSource(
+            context(), (cl_uint)1, &strings, &length, &error);
+
+        detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
+
+        if (error == CL_SUCCESS && build) {
+
+            error = ::clBuildProgram(
+                object_,
+                0,
+                NULL,
+#if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
+                "-cl-std=CL2.0",
+#else
+                "",
+#endif // #if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
+                NULL,
+                NULL);
+
+            detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
+        }
+
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    Program(
+        const Context& context,
+        const string& source,
+        bool build = false,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+
+        const char * strings = source.c_str();
+        const size_type length  = source.size();
+
+        object_ = ::clCreateProgramWithSource(
+            context(), (cl_uint)1, &strings, &length, &error);
+
+        detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
+
+        if (error == CL_SUCCESS && build) {
+            error = ::clBuildProgram(
+                object_,
+                0,
+                NULL,
+#if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
+                "-cl-std=CL2.0",
+#else
+                "",
+#endif // #if !defined(CL_HPP_CL_1_2_DEFAULT_BUILD)
+                NULL,
+                NULL);
+            
+            detail::buildErrHandler(error, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
+        }
+
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    /**
+     * Create a program from a vector of source strings and the default context.
+     * Does not compile or link the program.
+     */
+    Program(
+        const Sources& sources,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+        Context context = Context::getDefault(err);
+
+        const size_type n = (size_type)sources.size();
+
+        vector<size_type> lengths(n);
+        vector<const char*> strings(n);
+
+        for (size_type i = 0; i < n; ++i) {
+#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
+            strings[i] = sources[(int)i].data();
+            lengths[i] = sources[(int)i].length();
+#else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
+            strings[i] = sources[(int)i].first;
+            lengths[i] = sources[(int)i].second;
+#endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
+        }
+
+        object_ = ::clCreateProgramWithSource(
+            context(), (cl_uint)n, strings.data(), lengths.data(), &error);
+
+        detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    /**
+     * Create a program from a vector of source strings and a provided context.
+     * Does not compile or link the program.
+     */
+    Program(
+        const Context& context,
+        const Sources& sources,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+
+        const size_type n = (size_type)sources.size();
+
+        vector<size_type> lengths(n);
+        vector<const char*> strings(n);
+
+        for (size_type i = 0; i < n; ++i) {
+#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
+            strings[i] = sources[(int)i].data();
+            lengths[i] = sources[(int)i].length();
+#else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
+            strings[i] = sources[(int)i].first;
+            lengths[i] = sources[(int)i].second;
+#endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
+        }
+
+        object_ = ::clCreateProgramWithSource(
+            context(), (cl_uint)n, strings.data(), lengths.data(), &error);
+
+        detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    /**
+     * Construct a program object from a list of devices and a per-device list of binaries.
+     * \param context A valid OpenCL context in which to construct the program.
+     * \param devices A vector of OpenCL device objects for which the program will be created.
+     * \param binaries A vector of pairs of a pointer to a binary object and its length.
+     * \param binaryStatus An optional vector that on completion will be resized to
+     *   match the size of binaries and filled with values to specify if each binary
+     *   was successfully loaded.
+     *   Set to CL_SUCCESS if the binary was successfully loaded.
+     *   Set to CL_INVALID_VALUE if the length is 0 or the binary pointer is NULL.
+     *   Set to CL_INVALID_BINARY if the binary provided is not valid for the matching device.
+     * \param err if non-NULL will be set to CL_SUCCESS on successful operation or one of the following errors:
+     *   CL_INVALID_CONTEXT if context is not a valid context.
+     *   CL_INVALID_VALUE if the length of devices is zero; or if the length of binaries does not match the length of devices; 
+     *     or if any entry in binaries is NULL or has length 0.
+     *   CL_INVALID_DEVICE if OpenCL devices listed in devices are not in the list of devices associated with context.
+     *   CL_INVALID_BINARY if an invalid program binary was encountered for any device. binaryStatus will return specific status for each device.
+     *   CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.
+     */
+    Program(
+        const Context& context,
+        const vector<Device>& devices,
+        const Binaries& binaries,
+        vector<cl_int>* binaryStatus = NULL,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+        
+        const size_type numDevices = devices.size();
+        
+        // Catch size mismatch early and return
+        if(binaries.size() != numDevices) {
+            error = CL_INVALID_VALUE;
+            detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
+            if (err != NULL) {
+                *err = error;
+            }
+            return;
+        }
+
+
+        vector<size_type> lengths(numDevices);
+        vector<const unsigned char*> images(numDevices);
+#if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
+        for (size_type i = 0; i < numDevices; ++i) {
+            images[i] = binaries[i].data();
+            lengths[i] = binaries[(int)i].size();
+        }
+#else // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
+        for (size_type i = 0; i < numDevices; ++i) {
+            images[i] = (const unsigned char*)binaries[i].first;
+            lengths[i] = binaries[(int)i].second;
+        }
+#endif // #if !defined(CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY)
+        
+        vector<cl_device_id> deviceIDs(numDevices);
+        for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
+            deviceIDs[deviceIndex] = (devices[deviceIndex])();
+        }
+
+        if(binaryStatus) {
+            binaryStatus->resize(numDevices);
+        }
+        
+        object_ = ::clCreateProgramWithBinary(
+            context(), (cl_uint) devices.size(),
+            deviceIDs.data(),
+            lengths.data(), images.data(), (binaryStatus != NULL && numDevices > 0)
+               ? &binaryStatus->front()
+               : NULL, &error);
+
+        detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+    /**
+     * Create program using builtin kernels.
+     * \param kernelNames Semi-colon separated list of builtin kernel names
+     */
+    Program(
+        const Context& context,
+        const vector<Device>& devices,
+        const string& kernelNames,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+
+
+        size_type numDevices = devices.size();
+        vector<cl_device_id> deviceIDs(numDevices);
+        for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
+            deviceIDs[deviceIndex] = (devices[deviceIndex])();
+        }
+        
+        object_ = ::clCreateProgramWithBuiltInKernels(
+            context(), 
+            (cl_uint) devices.size(),
+            deviceIDs.data(),
+            kernelNames.c_str(), 
+            &error);
+
+        detail::errHandler(error, __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+
+    Program() { }
+    
+
+    /*! \brief Constructor from cl_mem - takes ownership.
+     *
+     * \param retainObject will cause the constructor to retain its cl object.
+     *                     Defaults to false to maintain compatibility with
+     *                     earlier versions.
+     */
+    explicit Program(const cl_program& program, bool retainObject = false) : 
+        detail::Wrapper<cl_type>(program, retainObject) { }
+
+    Program& operator = (const cl_program& rhs)
+    {
+        detail::Wrapper<cl_type>::operator=(rhs);
+        return *this;
+    }
+
+    /*! \brief Copy constructor to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Program(const Program& program) : detail::Wrapper<cl_type>(program) {}
+
+    /*! \brief Copy assignment to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    Program& operator = (const Program &program)
+    {
+        detail::Wrapper<cl_type>::operator=(program);
+        return *this;
+    }
+
+    /*! \brief Move constructor to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Program(Program&& program) CL_HPP_NOEXCEPT_ : detail::Wrapper<cl_type>(std::move(program)) {}
+
+    /*! \brief Move assignment to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    Program& operator = (Program &&program)
+    {
+        detail::Wrapper<cl_type>::operator=(std::move(program));
+        return *this;
+    }
+
+    cl_int build(
+        const vector<Device>& devices,
+        const char* options = NULL,
+        void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL,
+        void* data = NULL) const
+    {
+        size_type numDevices = devices.size();
+        vector<cl_device_id> deviceIDs(numDevices);
+        
+        for( size_type deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) {
+            deviceIDs[deviceIndex] = (devices[deviceIndex])();
+        }
+
+        cl_int buildError = ::clBuildProgram(
+            object_,
+            (cl_uint)
+            devices.size(),
+            deviceIDs.data(),
+            options,
+            notifyFptr,
+            data);
+
+        return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
+    }
+
+    cl_int build(
+        const char* options = NULL,
+        void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL,
+        void* data = NULL) const
+    {
+        cl_int buildError = ::clBuildProgram(
+            object_,
+            0,
+            NULL,
+            options,
+            notifyFptr,
+            data);
+
+
+        return detail::buildErrHandler(buildError, __BUILD_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
+    }
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+    cl_int compile(
+        const char* options = NULL,
+        void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL,
+        void* data = NULL) const
+    {
+        cl_int error = ::clCompileProgram(
+            object_,
+            0,
+            NULL,
+            options,
+            0,
+            NULL,
+            NULL,
+            notifyFptr,
+            data);
+        return detail::buildErrHandler(error, __COMPILE_PROGRAM_ERR, getBuildInfo<CL_PROGRAM_BUILD_LOG>());
+    }
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+
+    template <typename T>
+    cl_int getInfo(cl_program_info name, T* param) const
+    {
+        return detail::errHandler(
+            detail::getInfo(&::clGetProgramInfo, object_, name, param),
+            __GET_PROGRAM_INFO_ERR);
+    }
+
+    template <cl_int name> typename
+    detail::param_traits<detail::cl_program_info, name>::param_type
+    getInfo(cl_int* err = NULL) const
+    {
+        typename detail::param_traits<
+            detail::cl_program_info, name>::param_type param;
+        cl_int result = getInfo(name, &param);
+        if (err != NULL) {
+            *err = result;
+        }
+        return param;
+    }
+
+    template <typename T>
+    cl_int getBuildInfo(
+        const Device& device, cl_program_build_info name, T* param) const
+    {
+        return detail::errHandler(
+            detail::getInfo(
+                &::clGetProgramBuildInfo, object_, device(), name, param),
+                __GET_PROGRAM_BUILD_INFO_ERR);
+    }
+
+    template <cl_int name> typename
+    detail::param_traits<detail::cl_program_build_info, name>::param_type
+    getBuildInfo(const Device& device, cl_int* err = NULL) const
+    {
+        typename detail::param_traits<
+            detail::cl_program_build_info, name>::param_type param;
+        cl_int result = getBuildInfo(device, name, &param);
+        if (err != NULL) {
+            *err = result;
+        }
+        return param;
+    }
+    
+    /**
+     * Build info function that returns a vector of device/info pairs for the specified 
+     * info type and for all devices in the program.
+     * On an error reading the info for any device, an empty vector of info will be returned.
+     */
+    template <cl_int name>
+    vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
+        getBuildInfo(cl_int *err = NULL) const
+    {
+        cl_int result = CL_SUCCESS;
+
+        auto devs = getInfo<CL_PROGRAM_DEVICES>(&result);
+        vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>>
+            devInfo;
+
+        // If there was an initial error from getInfo return the error
+        if (result != CL_SUCCESS) {
+            if (err != NULL) {
+                *err = result;
+            }
+            return devInfo;
+        }
+
+        for (cl::Device d : devs) {
+            typename detail::param_traits<
+                detail::cl_program_build_info, name>::param_type param;
+            result = getBuildInfo(d, name, &param);
+            devInfo.push_back(
+                std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, name>::param_type>
+                (d, param));
+            if (result != CL_SUCCESS) {
+                // On error, leave the loop and return the error code
+                break;
+            }
+        }
+        if (err != NULL) {
+            *err = result;
+        }
+        if (result != CL_SUCCESS) {
+            devInfo.clear();
+        }
+        return devInfo;
+    }
+
+    cl_int createKernels(vector<Kernel>* kernels)
+    {
+        cl_uint numKernels;
+        cl_int err = ::clCreateKernelsInProgram(object_, 0, NULL, &numKernels);
+        if (err != CL_SUCCESS) {
+            return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
+        }
+
+        vector<cl_kernel> value(numKernels);
+        
+        err = ::clCreateKernelsInProgram(
+            object_, numKernels, value.data(), NULL);
+        if (err != CL_SUCCESS) {
+            return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR);
+        }
+
+        if (kernels) {
+            kernels->resize(value.size());
+
+            // Assign to param, constructing with retain behaviour
+            // to correctly capture each underlying CL object
+            for (size_type i = 0; i < value.size(); i++) {
+                // We do not need to retain because this kernel is being created 
+                // by the runtime
+                (*kernels)[i] = Kernel(value[i], false);
+            }
+        }
+        return CL_SUCCESS;
+    }
+};
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+inline Program linkProgram(
+    Program input1,
+    Program input2,
+    const char* options = NULL,
+    void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL,
+    void* data = NULL,
+    cl_int* err = NULL) 
+{
+    cl_int error_local = CL_SUCCESS;
+
+    cl_program programs[2] = { input1(), input2() };
+
+    Context ctx = input1.getInfo<CL_PROGRAM_CONTEXT>(&error_local);
+    if(error_local!=CL_SUCCESS) {
+        detail::errHandler(error_local, __LINK_PROGRAM_ERR);
+    }
+
+    cl_program prog = ::clLinkProgram(
+        ctx(),
+        0,
+        NULL,
+        options,
+        2,
+        programs,
+        notifyFptr,
+        data,
+        &error_local);
+
+    detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
+    if (err != NULL) {
+        *err = error_local;
+    }
+
+    return Program(prog);
+}
+
+inline Program linkProgram(
+    vector<Program> inputPrograms,
+    const char* options = NULL,
+    void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL,
+    void* data = NULL,
+    cl_int* err = NULL) 
+{
+    cl_int error_local = CL_SUCCESS;
+
+    vector<cl_program> programs(inputPrograms.size());
+
+    for (unsigned int i = 0; i < inputPrograms.size(); i++) {
+        programs[i] = inputPrograms[i]();
+    }
+    
+    Context ctx;
+    if(inputPrograms.size() > 0) {
+        ctx = inputPrograms[0].getInfo<CL_PROGRAM_CONTEXT>(&error_local);
+        if(error_local!=CL_SUCCESS) {
+            detail::errHandler(error_local, __LINK_PROGRAM_ERR);
+        }
+    }
+    cl_program prog = ::clLinkProgram(
+        ctx(),
+        0,
+        NULL,
+        options,
+        (cl_uint)inputPrograms.size(),
+        programs.data(),
+        notifyFptr,
+        data,
+        &error_local);
+
+    detail::errHandler(error_local,__COMPILE_PROGRAM_ERR);
+    if (err != NULL) {
+        *err = error_local;
+    }
+
+    return Program(prog, false);
+}
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+
+// Template specialization for CL_PROGRAM_BINARIES
+template <>
+inline cl_int cl::Program::getInfo(cl_program_info name, vector<vector<unsigned char>>* param) const
+{
+    if (name != CL_PROGRAM_BINARIES) {
+        return CL_INVALID_VALUE;
+    }
+    if (param) {
+        // Resize the parameter array appropriately for each allocation
+        // and pass down to the helper
+
+        vector<size_type> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>();
+        size_type numBinaries = sizes.size();
+
+        // Resize the parameter array and constituent arrays
+        param->resize(numBinaries);
+        for (int i = 0; i < numBinaries; ++i) {
+            (*param)[i].resize(sizes[i]);
+        }
+
+        return detail::errHandler(
+            detail::getInfo(&::clGetProgramInfo, object_, name, param),
+            __GET_PROGRAM_INFO_ERR);
+    }
+
+    return CL_SUCCESS;
+}
+
+template<>
+inline vector<vector<unsigned char>> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err) const
+{
+    vector<vector<unsigned char>> binariesVectors;
+
+    cl_int result = getInfo(CL_PROGRAM_BINARIES, &binariesVectors);
+    if (err != NULL) {
+        *err = result;
+    }
+    return binariesVectors;
+}
+
+inline Kernel::Kernel(const Program& program, const char* name, cl_int* err)
+{
+    cl_int error;
+
+    object_ = ::clCreateKernel(program(), name, &error);
+    detail::errHandler(error, __CREATE_KERNEL_ERR);
+
+    if (err != NULL) {
+        *err = error;
+    }
+
+}
+
+/*! \class CommandQueue
+ * \brief CommandQueue interface for cl_command_queue.
+ */
+class CommandQueue : public detail::Wrapper<cl_command_queue>
+{
+private:
+    static std::once_flag default_initialized_;
+    static CommandQueue default_;
+    static cl_int default_error_;
+
+    /*! \brief Create the default command queue returned by @ref getDefault.
+     *
+     * It sets default_error_ to indicate success or failure. It does not throw
+     * @c cl::Error.
+     */
+    static void makeDefault()
+    {
+        /* We don't want to throw an error from this function, so we have to
+         * catch and set the error flag.
+         */
+#if defined(CL_HPP_ENABLE_EXCEPTIONS)
+        try
+#endif
+        {
+            int error;
+            Context context = Context::getDefault(&error);
+
+            if (error != CL_SUCCESS) {
+                default_error_ = error;
+            }
+            else {
+                Device device = context.getInfo<CL_CONTEXT_DEVICES>()[0];
+                default_ = CommandQueue(context, device, 0, &default_error_);
+            }
+        }
+#if defined(CL_HPP_ENABLE_EXCEPTIONS)
+        catch (cl::Error &e) {
+            default_error_ = e.err();
+        }
+#endif
+    }
+
+    /*! \brief Create the default command queue.
+     *
+     * This sets @c default_. It does not throw
+     * @c cl::Error.
+     */
+    static void makeDefaultProvided(const CommandQueue &c) {
+        default_ = c;
+    }
+
+public:
+#ifdef CL_HPP_UNIT_TEST_ENABLE
+    /*! \brief Reset the default.
+    *
+    * This sets @c default_ to an empty value to support cleanup in
+    * the unit test framework.
+    * This function is not thread safe.
+    */
+    static void unitTestClearDefault() {
+        default_ = CommandQueue();
+    }
+#endif // #ifdef CL_HPP_UNIT_TEST_ENABLE
+
+    /*!
+     * \brief Constructs a CommandQueue based on passed properties.
+     * Will return an CL_INVALID_QUEUE_PROPERTIES error if CL_QUEUE_ON_DEVICE is specified.
+     */
+   CommandQueue(
+        cl_command_queue_properties properties,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+
+        Context context = Context::getDefault(&error);
+        detail::errHandler(error, __CREATE_CONTEXT_ERR);
+
+        if (error != CL_SUCCESS) {
+            if (err != NULL) {
+                *err = error;
+            }
+        }
+        else {
+            Device device = context.getInfo<CL_CONTEXT_DEVICES>()[0];
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+            cl_queue_properties queue_properties[] = {
+                CL_QUEUE_PROPERTIES, properties, 0 };
+            if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
+                object_ = ::clCreateCommandQueueWithProperties(
+                    context(), device(), queue_properties, &error);
+            }
+            else {
+                error = CL_INVALID_QUEUE_PROPERTIES;
+            }
+
+            detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
+            if (err != NULL) {
+                *err = error;
+            }
+#else
+            object_ = ::clCreateCommandQueue(
+                context(), device(), properties, &error);
+
+            detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
+            if (err != NULL) {
+                *err = error;
+            }
+#endif
+        }
+    }
+
+    /*!
+     * \brief Constructs a CommandQueue for an implementation defined device in the given context
+     * Will return an CL_INVALID_QUEUE_PROPERTIES error if CL_QUEUE_ON_DEVICE is specified.
+     */
+    explicit CommandQueue(
+        const Context& context,
+        cl_command_queue_properties properties = 0,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+        vector<cl::Device> devices;
+        error = context.getInfo(CL_CONTEXT_DEVICES, &devices);
+
+        detail::errHandler(error, __CREATE_CONTEXT_ERR);
+
+        if (error != CL_SUCCESS)
+        {
+            if (err != NULL) {
+                *err = error;
+            }
+            return;
+        }
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+        cl_queue_properties queue_properties[] = {
+            CL_QUEUE_PROPERTIES, properties, 0 };
+        if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
+            object_ = ::clCreateCommandQueueWithProperties(
+                context(), devices[0](), queue_properties, &error);
+        }
+        else {
+            error = CL_INVALID_QUEUE_PROPERTIES;
+        }
+
+        detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+#else
+        object_ = ::clCreateCommandQueue(
+            context(), devices[0](), properties, &error);
+
+        detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+#endif
+
+    }
+
+    /*!
+     * \brief Constructs a CommandQueue for a passed device and context
+     * Will return an CL_INVALID_QUEUE_PROPERTIES error if CL_QUEUE_ON_DEVICE is specified.
+     */
+    CommandQueue(
+        const Context& context,
+        const Device& device,
+        cl_command_queue_properties properties = 0,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+        cl_queue_properties queue_properties[] = {
+            CL_QUEUE_PROPERTIES, properties, 0 };
+        if ((properties & CL_QUEUE_ON_DEVICE) == 0) {
+            object_ = ::clCreateCommandQueueWithProperties(
+                context(), device(), queue_properties, &error);
+        }
+        else {
+            error = CL_INVALID_QUEUE_PROPERTIES;
+        }
+
+        detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+#else
+        object_ = ::clCreateCommandQueue(
+            context(), device(), properties, &error);
+
+        detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+#endif
+    }
+
+    static CommandQueue getDefault(cl_int * err = NULL) 
+    {
+        std::call_once(default_initialized_, makeDefault);
+#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+        detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
+#else // CL_HPP_TARGET_OPENCL_VERSION >= 200
+        detail::errHandler(default_error_, __CREATE_COMMAND_QUEUE_ERR);
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 200
+        if (err != NULL) {
+            *err = default_error_;
+        }
+        return default_;
+    }
+
+    /**
+     * Modify the default command queue to be used by
+     * subsequent operations.
+     * Will only set the default if no default was previously created.
+     * @return updated default platform.
+     *         Should be compared to the passed value to ensure that it was updated.
+     */
+    static CommandQueue setDefault(const CommandQueue &default_queue)
+    {
+        std::call_once(default_initialized_, makeDefaultProvided, std::cref(default_queue));
+        detail::errHandler(default_error_);
+        return default_;
+    }
+
+    CommandQueue() { }
+
+
+    /*! \brief Constructor from cl_mem - takes ownership.
+     *
+     * \param retainObject will cause the constructor to retain its cl object.
+     *                     Defaults to false to maintain compatibility with
+     *                     earlier versions.
+     */
+    explicit CommandQueue(const cl_command_queue& commandQueue, bool retainObject = false) : 
+        detail::Wrapper<cl_type>(commandQueue, retainObject) { }
+
+    CommandQueue& operator = (const cl_command_queue& rhs)
+    {
+        detail::Wrapper<cl_type>::operator=(rhs);
+        return *this;
+    }
+
+    /*! \brief Copy constructor to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    CommandQueue(const CommandQueue& queue) : detail::Wrapper<cl_type>(queue) {}
+
+    /*! \brief Copy assignment to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    CommandQueue& operator = (const CommandQueue &queue)
+    {
+        detail::Wrapper<cl_type>::operator=(queue);
+        return *this;
+    }
+
+    /*! \brief Move constructor to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    CommandQueue(CommandQueue&& queue) CL_HPP_NOEXCEPT_ : detail::Wrapper<cl_type>(std::move(queue)) {}
+
+    /*! \brief Move assignment to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    CommandQueue& operator = (CommandQueue &&queue)
+    {
+        detail::Wrapper<cl_type>::operator=(std::move(queue));
+        return *this;
+    }
+
+    template <typename T>
+    cl_int getInfo(cl_command_queue_info name, T* param) const
+    {
+        return detail::errHandler(
+            detail::getInfo(
+                &::clGetCommandQueueInfo, object_, name, param),
+                __GET_COMMAND_QUEUE_INFO_ERR);
+    }
+
+    template <cl_int name> typename
+    detail::param_traits<detail::cl_command_queue_info, name>::param_type
+    getInfo(cl_int* err = NULL) const
+    {
+        typename detail::param_traits<
+            detail::cl_command_queue_info, name>::param_type param;
+        cl_int result = getInfo(name, &param);
+        if (err != NULL) {
+            *err = result;
+        }
+        return param;
+    }
+
+    cl_int enqueueReadBuffer(
+        const Buffer& buffer,
+        cl_bool blocking,
+        size_type offset,
+        size_type size,
+        void* ptr,
+        const vector<Event>* events = NULL,
+        Event* event = NULL) const
+    {
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+            ::clEnqueueReadBuffer(
+                object_, buffer(), blocking, offset, size,
+                ptr,
+                (events != NULL) ? (cl_uint) events->size() : 0,
+                (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                (event != NULL) ? &tmp : NULL),
+            __ENQUEUE_READ_BUFFER_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+
+    cl_int enqueueWriteBuffer(
+        const Buffer& buffer,
+        cl_bool blocking,
+        size_type offset,
+        size_type size,
+        const void* ptr,
+        const vector<Event>* events = NULL,
+        Event* event = NULL) const
+    {
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+            ::clEnqueueWriteBuffer(
+                object_, buffer(), blocking, offset, size,
+                ptr,
+                (events != NULL) ? (cl_uint) events->size() : 0,
+                (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                (event != NULL) ? &tmp : NULL),
+                __ENQUEUE_WRITE_BUFFER_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+
+    cl_int enqueueCopyBuffer(
+        const Buffer& src,
+        const Buffer& dst,
+        size_type src_offset,
+        size_type dst_offset,
+        size_type size,
+        const vector<Event>* events = NULL,
+        Event* event = NULL) const
+    {
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+            ::clEnqueueCopyBuffer(
+                object_, src(), dst(), src_offset, dst_offset, size,
+                (events != NULL) ? (cl_uint) events->size() : 0,
+                (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                (event != NULL) ? &tmp : NULL),
+            __ENQEUE_COPY_BUFFER_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+
+    cl_int enqueueReadBufferRect(
+        const Buffer& buffer,
+        cl_bool blocking,
+        const array<size_type, 3>& buffer_offset,
+        const array<size_type, 3>& host_offset,
+        const array<size_type, 3>& region,
+        size_type buffer_row_pitch,
+        size_type buffer_slice_pitch,
+        size_type host_row_pitch,
+        size_type host_slice_pitch,
+        void *ptr,
+        const vector<Event>* events = NULL,
+        Event* event = NULL) const
+    {
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+            ::clEnqueueReadBufferRect(
+                object_, 
+                buffer(), 
+                blocking,
+                buffer_offset.data(),
+                host_offset.data(),
+                region.data(),
+                buffer_row_pitch,
+                buffer_slice_pitch,
+                host_row_pitch,
+                host_slice_pitch,
+                ptr,
+                (events != NULL) ? (cl_uint) events->size() : 0,
+                (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                (event != NULL) ? &tmp : NULL),
+                __ENQUEUE_READ_BUFFER_RECT_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+
+    cl_int enqueueWriteBufferRect(
+        const Buffer& buffer,
+        cl_bool blocking,
+        const array<size_type, 3>& buffer_offset,
+        const array<size_type, 3>& host_offset,
+        const array<size_type, 3>& region,
+        size_type buffer_row_pitch,
+        size_type buffer_slice_pitch,
+        size_type host_row_pitch,
+        size_type host_slice_pitch,
+        void *ptr,
+        const vector<Event>* events = NULL,
+        Event* event = NULL) const
+    {
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+            ::clEnqueueWriteBufferRect(
+                object_, 
+                buffer(), 
+                blocking,
+                buffer_offset.data(),
+                host_offset.data(),
+                region.data(),
+                buffer_row_pitch,
+                buffer_slice_pitch,
+                host_row_pitch,
+                host_slice_pitch,
+                ptr,
+                (events != NULL) ? (cl_uint) events->size() : 0,
+                (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                (event != NULL) ? &tmp : NULL),
+                __ENQUEUE_WRITE_BUFFER_RECT_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+
+    cl_int enqueueCopyBufferRect(
+        const Buffer& src,
+        const Buffer& dst,
+        const array<size_type, 3>& src_origin,
+        const array<size_type, 3>& dst_origin,
+        const array<size_type, 3>& region,
+        size_type src_row_pitch,
+        size_type src_slice_pitch,
+        size_type dst_row_pitch,
+        size_type dst_slice_pitch,
+        const vector<Event>* events = NULL,
+        Event* event = NULL) const
+    {
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+            ::clEnqueueCopyBufferRect(
+                object_, 
+                src(), 
+                dst(), 
+                src_origin.data(),
+                dst_origin.data(),
+                region.data(),
+                src_row_pitch,
+                src_slice_pitch,
+                dst_row_pitch,
+                dst_slice_pitch,
+                (events != NULL) ? (cl_uint) events->size() : 0,
+                (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                (event != NULL) ? &tmp : NULL),
+            __ENQEUE_COPY_BUFFER_RECT_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+    /**
+     * Enqueue a command to fill a buffer object with a pattern
+     * of a given size. The pattern is specified as a vector type.
+     * \tparam PatternType The datatype of the pattern field. 
+     *     The pattern type must be an accepted OpenCL data type.
+     * \tparam offset Is the offset in bytes into the buffer at 
+     *     which to start filling. This must be a multiple of 
+     *     the pattern size.
+     * \tparam size Is the size in bytes of the region to fill.
+     *     This must be a multiple of the pattern size.
+     */
+    template<typename PatternType>
+    cl_int enqueueFillBuffer(
+        const Buffer& buffer,
+        PatternType pattern,
+        size_type offset,
+        size_type size,
+        const vector<Event>* events = NULL,
+        Event* event = NULL) const
+    {
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+            ::clEnqueueFillBuffer(
+                object_, 
+                buffer(),
+                static_cast<void*>(&pattern),
+                sizeof(PatternType), 
+                offset, 
+                size,
+                (events != NULL) ? (cl_uint) events->size() : 0,
+                (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                (event != NULL) ? &tmp : NULL),
+                __ENQUEUE_FILL_BUFFER_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+
+    cl_int enqueueReadImage(
+        const Image& image,
+        cl_bool blocking,
+        const array<size_type, 3>& origin,
+        const array<size_type, 3>& region,
+        size_type row_pitch,
+        size_type slice_pitch,
+        void* ptr,
+        const vector<Event>* events = NULL,
+        Event* event = NULL) const
+    {
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+            ::clEnqueueReadImage(
+                object_, 
+                image(), 
+                blocking, 
+                origin.data(),
+                region.data(), 
+                row_pitch, 
+                slice_pitch, 
+                ptr,
+                (events != NULL) ? (cl_uint) events->size() : 0,
+                (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                (event != NULL) ? &tmp : NULL),
+            __ENQUEUE_READ_IMAGE_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+
+    cl_int enqueueWriteImage(
+        const Image& image,
+        cl_bool blocking,
+        const array<size_type, 3>& origin,
+        const array<size_type, 3>& region,
+        size_type row_pitch,
+        size_type slice_pitch,
+        void* ptr,
+        const vector<Event>* events = NULL,
+        Event* event = NULL) const
+    {
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+            ::clEnqueueWriteImage(
+                object_, 
+                image(), 
+                blocking, 
+                origin.data(),
+                region.data(), 
+                row_pitch, 
+                slice_pitch, 
+                ptr,
+                (events != NULL) ? (cl_uint) events->size() : 0,
+                (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                (event != NULL) ? &tmp : NULL),
+            __ENQUEUE_WRITE_IMAGE_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+
+    cl_int enqueueCopyImage(
+        const Image& src,
+        const Image& dst,
+        const array<size_type, 3>& src_origin,
+        const array<size_type, 3>& dst_origin,
+        const array<size_type, 3>& region,
+        const vector<Event>* events = NULL,
+        Event* event = NULL) const
+    {
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+            ::clEnqueueCopyImage(
+                object_, 
+                src(), 
+                dst(), 
+                src_origin.data(),
+                dst_origin.data(), 
+                region.data(),
+                (events != NULL) ? (cl_uint) events->size() : 0,
+                (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                (event != NULL) ? &tmp : NULL),
+            __ENQUEUE_COPY_IMAGE_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+    /**
+     * Enqueue a command to fill an image object with a specified color.
+     * \param fillColor is the color to use to fill the image.
+     *     This is a four component RGBA floating-point color value if
+     *     the image channel data type is not an unnormalized signed or
+     *     unsigned data type.
+     */
+    cl_int enqueueFillImage(
+        const Image& image,
+        cl_float4 fillColor,
+        const array<size_type, 3>& origin,
+        const array<size_type, 3>& region,
+        const vector<Event>* events = NULL,
+        Event* event = NULL) const
+    {
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+            ::clEnqueueFillImage(
+                object_, 
+                image(),
+                static_cast<void*>(&fillColor), 
+                origin.data(),
+                region.data(),
+                (events != NULL) ? (cl_uint) events->size() : 0,
+                (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                (event != NULL) ? &tmp : NULL),
+                __ENQUEUE_FILL_IMAGE_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+
+    /**
+     * Enqueue a command to fill an image object with a specified color.
+     * \param fillColor is the color to use to fill the image.
+     *     This is a four component RGBA signed integer color value if
+     *     the image channel data type is an unnormalized signed integer
+     *     type.
+     */
+    cl_int enqueueFillImage(
+        const Image& image,
+        cl_int4 fillColor,
+        const array<size_type, 3>& origin,
+        const array<size_type, 3>& region,
+        const vector<Event>* events = NULL,
+        Event* event = NULL) const
+    {
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+            ::clEnqueueFillImage(
+                object_, 
+                image(),
+                static_cast<void*>(&fillColor), 
+                origin.data(),
+                region.data(),
+                (events != NULL) ? (cl_uint) events->size() : 0,
+                (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                (event != NULL) ? &tmp : NULL),
+                __ENQUEUE_FILL_IMAGE_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+
+    /**
+     * Enqueue a command to fill an image object with a specified color.
+     * \param fillColor is the color to use to fill the image.
+     *     This is a four component RGBA unsigned integer color value if
+     *     the image channel data type is an unnormalized unsigned integer
+     *     type.
+     */
+    cl_int enqueueFillImage(
+        const Image& image,
+        cl_uint4 fillColor,
+        const array<size_type, 3>& origin,
+        const array<size_type, 3>& region,
+        const vector<Event>* events = NULL,
+        Event* event = NULL) const
+    {
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+            ::clEnqueueFillImage(
+                object_, 
+                image(),
+                static_cast<void*>(&fillColor), 
+                origin.data(),
+                region.data(),
+                (events != NULL) ? (cl_uint) events->size() : 0,
+                (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                (event != NULL) ? &tmp : NULL),
+                __ENQUEUE_FILL_IMAGE_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+
+    cl_int enqueueCopyImageToBuffer(
+        const Image& src,
+        const Buffer& dst,
+        const array<size_type, 3>& src_origin,
+        const array<size_type, 3>& region,
+        size_type dst_offset,
+        const vector<Event>* events = NULL,
+        Event* event = NULL) const
+    {
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+            ::clEnqueueCopyImageToBuffer(
+                object_, 
+                src(), 
+                dst(), 
+                src_origin.data(),
+                region.data(), 
+                dst_offset,
+                (events != NULL) ? (cl_uint) events->size() : 0,
+                (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                (event != NULL) ? &tmp : NULL),
+            __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+
+    cl_int enqueueCopyBufferToImage(
+        const Buffer& src,
+        const Image& dst,
+        size_type src_offset,
+        const array<size_type, 3>& dst_origin,
+        const array<size_type, 3>& region,
+        const vector<Event>* events = NULL,
+        Event* event = NULL) const
+    {
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+            ::clEnqueueCopyBufferToImage(
+                object_, 
+                src(), 
+                dst(), 
+                src_offset,
+                dst_origin.data(), 
+                region.data(),
+                (events != NULL) ? (cl_uint) events->size() : 0,
+                (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                (event != NULL) ? &tmp : NULL),
+            __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+
+    void* enqueueMapBuffer(
+        const Buffer& buffer,
+        cl_bool blocking,
+        cl_map_flags flags,
+        size_type offset,
+        size_type size,
+        const vector<Event>* events = NULL,
+        Event* event = NULL,
+        cl_int* err = NULL) const
+    {
+        cl_event tmp;
+        cl_int error;
+        void * result = ::clEnqueueMapBuffer(
+            object_, buffer(), blocking, flags, offset, size,
+            (events != NULL) ? (cl_uint) events->size() : 0,
+            (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+            (event != NULL) ? &tmp : NULL,
+            &error);
+
+        detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+        if (event != NULL && error == CL_SUCCESS)
+            *event = tmp;
+
+        return result;
+    }
+
+    void* enqueueMapImage(
+        const Image& buffer,
+        cl_bool blocking,
+        cl_map_flags flags,
+        const array<size_type, 3>& origin,
+        const array<size_type, 3>& region,
+        size_type * row_pitch,
+        size_type * slice_pitch,
+        const vector<Event>* events = NULL,
+        Event* event = NULL,
+        cl_int* err = NULL) const
+    {
+        cl_event tmp;
+        cl_int error;
+        void * result = ::clEnqueueMapImage(
+            object_, buffer(), blocking, flags,
+            origin.data(), 
+            region.data(),
+            row_pitch, slice_pitch,
+            (events != NULL) ? (cl_uint) events->size() : 0,
+            (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+            (event != NULL) ? &tmp : NULL,
+            &error);
+
+        detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR);
+        if (err != NULL) {
+              *err = error;
+        }
+        if (event != NULL && error == CL_SUCCESS)
+            *event = tmp;
+        return result;
+    }
+
+    cl_int enqueueUnmapMemObject(
+        const Memory& memory,
+        void* mapped_ptr,
+        const vector<Event>* events = NULL,
+        Event* event = NULL) const
+    {
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+            ::clEnqueueUnmapMemObject(
+                object_, memory(), mapped_ptr,
+                (events != NULL) ? (cl_uint) events->size() : 0,
+                (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                (event != NULL) ? &tmp : NULL),
+            __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+    /**
+     * Enqueues a marker command which waits for either a list of events to complete, 
+     * or all previously enqueued commands to complete.
+     *
+     * Enqueues a marker command which waits for either a list of events to complete, 
+     * or if the list is empty it waits for all commands previously enqueued in command_queue 
+     * to complete before it completes. This command returns an event which can be waited on, 
+     * i.e. this event can be waited on to insure that all events either in the event_wait_list 
+     * or all previously enqueued commands, queued before this command to command_queue, 
+     * have completed.
+     */
+    cl_int enqueueMarkerWithWaitList(
+        const vector<Event> *events = 0,
+        Event *event = 0)
+    {
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+            ::clEnqueueMarkerWithWaitList(
+                object_,
+                (events != NULL) ? (cl_uint) events->size() : 0,
+                (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                (event != NULL) ? &tmp : NULL),
+            __ENQUEUE_MARKER_WAIT_LIST_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+
+    /**
+     * A synchronization point that enqueues a barrier operation.
+     *
+     * Enqueues a barrier command which waits for either a list of events to complete, 
+     * or if the list is empty it waits for all commands previously enqueued in command_queue 
+     * to complete before it completes. This command blocks command execution, that is, any 
+     * following commands enqueued after it do not execute until it completes. This command 
+     * returns an event which can be waited on, i.e. this event can be waited on to insure that 
+     * all events either in the event_wait_list or all previously enqueued commands, queued 
+     * before this command to command_queue, have completed.
+     */
+    cl_int enqueueBarrierWithWaitList(
+        const vector<Event> *events = 0,
+        Event *event = 0)
+    {
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+            ::clEnqueueBarrierWithWaitList(
+                object_,
+                (events != NULL) ? (cl_uint) events->size() : 0,
+                (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                (event != NULL) ? &tmp : NULL),
+            __ENQUEUE_BARRIER_WAIT_LIST_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+    
+    /**
+     * Enqueues a command to indicate with which device a set of memory objects
+     * should be associated.
+     */
+    cl_int enqueueMigrateMemObjects(
+        const vector<Memory> &memObjects,
+        cl_mem_migration_flags flags,
+        const vector<Event>* events = NULL,
+        Event* event = NULL
+        )
+    {
+        cl_event tmp;
+        
+        vector<cl_mem> localMemObjects(memObjects.size());
+
+        for( int i = 0; i < (int)memObjects.size(); ++i ) {
+            localMemObjects[i] = memObjects[i]();
+        }
+
+
+        cl_int err = detail::errHandler(
+            ::clEnqueueMigrateMemObjects(
+                object_, 
+                (cl_uint)memObjects.size(), 
+                localMemObjects.data(),
+                flags,
+                (events != NULL) ? (cl_uint) events->size() : 0,
+                (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                (event != NULL) ? &tmp : NULL),
+            __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+
+    cl_int enqueueNDRangeKernel(
+        const Kernel& kernel,
+        const NDRange& offset,
+        const NDRange& global,
+        const NDRange& local = NullRange,
+        const vector<Event>* events = NULL,
+        Event* event = NULL) const
+    {
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+            ::clEnqueueNDRangeKernel(
+                object_, kernel(), (cl_uint) global.dimensions(),
+                offset.dimensions() != 0 ? (const size_type*) offset : NULL,
+                (const size_type*) global,
+                local.dimensions() != 0 ? (const size_type*) local : NULL,
+                (events != NULL) ? (cl_uint) events->size() : 0,
+                (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                (event != NULL) ? &tmp : NULL),
+            __ENQUEUE_NDRANGE_KERNEL_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+
+#if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
+    CL_EXT_PREFIX__VERSION_1_2_DEPRECATED cl_int enqueueTask(
+        const Kernel& kernel,
+        const vector<Event>* events = NULL,
+        Event* event = NULL) CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED const
+    {
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+            ::clEnqueueTask(
+                object_, kernel(),
+                (events != NULL) ? (cl_uint) events->size() : 0,
+                (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                (event != NULL) ? &tmp : NULL),
+            __ENQUEUE_TASK_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+#endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
+
+    cl_int enqueueNativeKernel(
+        void (CL_CALLBACK *userFptr)(void *),
+        std::pair<void*, size_type> args,
+        const vector<Memory>* mem_objects = NULL,
+        const vector<const void*>* mem_locs = NULL,
+        const vector<Event>* events = NULL,
+        Event* event = NULL) const
+    {
+        size_type elements = 0;
+        if (mem_objects != NULL) {
+            elements = mem_objects->size();
+        }
+        vector<cl_mem> mems(elements);
+        for (unsigned int i = 0; i < elements; i++) {
+            mems[i] = ((*mem_objects)[i])();
+        }
+        
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+            ::clEnqueueNativeKernel(
+                object_, userFptr, args.first, args.second,
+                (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
+                mems.data(),
+                (mem_locs != NULL && mem_locs->size() > 0) ? (const void **) &mem_locs->front() : NULL,
+                (events != NULL) ? (cl_uint) events->size() : 0,
+                (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                (event != NULL) ? &tmp : NULL),
+            __ENQUEUE_NATIVE_KERNEL);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+
+/**
+ * Deprecated APIs for 1.2
+ */
+#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
+    CL_EXT_PREFIX__VERSION_1_1_DEPRECATED 
+    cl_int enqueueMarker(Event* event = NULL) const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
+    {
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+            ::clEnqueueMarker(
+                object_, 
+                (event != NULL) ? &tmp : NULL),
+            __ENQUEUE_MARKER_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+
+    CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
+    cl_int enqueueWaitForEvents(const vector<Event>& events) const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
+    {
+        return detail::errHandler(
+            ::clEnqueueWaitForEvents(
+                object_,
+                (cl_uint) events.size(),
+                events.size() > 0 ? (const cl_event*) &events.front() : NULL),
+            __ENQUEUE_WAIT_FOR_EVENTS_ERR);
+    }
+#endif // defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
+
+    cl_int enqueueAcquireGLObjects(
+         const vector<Memory>* mem_objects = NULL,
+         const vector<Event>* events = NULL,
+         Event* event = NULL) const
+     {
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+             ::clEnqueueAcquireGLObjects(
+                 object_,
+                 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
+                 (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL,
+                 (events != NULL) ? (cl_uint) events->size() : 0,
+                 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                 (event != NULL) ? &tmp : NULL),
+             __ENQUEUE_ACQUIRE_GL_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+     }
+
+    cl_int enqueueReleaseGLObjects(
+         const vector<Memory>* mem_objects = NULL,
+         const vector<Event>* events = NULL,
+         Event* event = NULL) const
+     {
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+             ::clEnqueueReleaseGLObjects(
+                 object_,
+                 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
+                 (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL,
+                 (events != NULL) ? (cl_uint) events->size() : 0,
+                 (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                 (event != NULL) ? &tmp : NULL),
+             __ENQUEUE_RELEASE_GL_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+     }
+
+#if defined (CL_HPP_USE_DX_INTEROP)
+typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)(
+    cl_command_queue command_queue, cl_uint num_objects,
+    const cl_mem* mem_objects, cl_uint num_events_in_wait_list,
+    const cl_event* event_wait_list, cl_event* event);
+typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)(
+    cl_command_queue command_queue, cl_uint num_objects,
+    const cl_mem* mem_objects,  cl_uint num_events_in_wait_list,
+    const cl_event* event_wait_list, cl_event* event);
+
+    cl_int enqueueAcquireD3D10Objects(
+         const vector<Memory>* mem_objects = NULL,
+         const vector<Event>* events = NULL,
+         Event* event = NULL) const
+    {
+        static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR = NULL;
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+        cl_context context = getInfo<CL_QUEUE_CONTEXT>();
+        cl::Device device(getInfo<CL_QUEUE_DEVICE>());
+        cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
+        CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireD3D10ObjectsKHR);
+#endif
+#if CL_HPP_TARGET_OPENCL_VERSION >= 110
+        CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueAcquireD3D10ObjectsKHR);
+#endif
+        
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+             pfn_clEnqueueAcquireD3D10ObjectsKHR(
+                 object_,
+                 (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
+                 (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL,
+                 (events != NULL) ? (cl_uint) events->size() : 0,
+                 (events != NULL) ? (cl_event*) &events->front() : NULL,
+                 (event != NULL) ? &tmp : NULL),
+             __ENQUEUE_ACQUIRE_GL_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+     }
+
+    cl_int enqueueReleaseD3D10Objects(
+         const vector<Memory>* mem_objects = NULL,
+         const vector<Event>* events = NULL,
+         Event* event = NULL) const
+    {
+        static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR = NULL;
+#if CL_HPP_TARGET_OPENCL_VERSION >= 120
+        cl_context context = getInfo<CL_QUEUE_CONTEXT>();
+        cl::Device device(getInfo<CL_QUEUE_DEVICE>());
+        cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>();
+        CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseD3D10ObjectsKHR);
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 120
+#if CL_HPP_TARGET_OPENCL_VERSION >= 110
+        CL_HPP_INIT_CL_EXT_FCN_PTR_(clEnqueueReleaseD3D10ObjectsKHR);
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
+
+        cl_event tmp;
+        cl_int err = detail::errHandler(
+            pfn_clEnqueueReleaseD3D10ObjectsKHR(
+                object_,
+                (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0,
+                (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL,
+                (events != NULL) ? (cl_uint) events->size() : 0,
+                (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+                (event != NULL) ? &tmp : NULL),
+            __ENQUEUE_RELEASE_GL_ERR);
+
+        if (event != NULL && err == CL_SUCCESS)
+            *event = tmp;
+
+        return err;
+    }
+#endif
+
+/**
+ * Deprecated APIs for 1.2
+ */
+#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
+    CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
+    cl_int enqueueBarrier() const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
+    {
+        return detail::errHandler(
+            ::clEnqueueBarrier(object_),
+            __ENQUEUE_BARRIER_ERR);
+    }
+#endif // CL_USE_DEPRECATED_OPENCL_1_1_APIS
+
+    cl_int flush() const
+    {
+        return detail::errHandler(::clFlush(object_), __FLUSH_ERR);
+    }
+
+    cl_int finish() const
+    {
+        return detail::errHandler(::clFinish(object_), __FINISH_ERR);
+    }
+}; // CommandQueue
+
+CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag CommandQueue::default_initialized_;
+CL_HPP_DEFINE_STATIC_MEMBER_ CommandQueue CommandQueue::default_;
+CL_HPP_DEFINE_STATIC_MEMBER_ cl_int CommandQueue::default_error_ = CL_SUCCESS;
+
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+/*! \class DeviceCommandQueue
+ * \brief DeviceCommandQueue interface for device cl_command_queues.
+ */
+class DeviceCommandQueue : public detail::Wrapper<cl_command_queue>
+{
+public:
+    /*!
+    * Default construct device command queue on default context and device
+    */
+    DeviceCommandQueue(cl_int* err = NULL)
+    {
+        cl_int error;
+        cl::Context context = cl::Context::getDefault();
+        cl::Device device = cl::Device::getDefault();
+        
+        cl_command_queue_properties properties =
+            CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE;
+        cl_queue_properties queue_properties[] = {
+            CL_QUEUE_PROPERTIES, properties, 0 };
+        object_ = ::clCreateCommandQueueWithProperties(
+            context(), device(), queue_properties, &error);
+
+        detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    /*!
+     * Create a device command queue for a specified device in the passed context.
+     */
+    DeviceCommandQueue(
+        const Context& context,
+        const Device& device,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+
+        cl_command_queue_properties properties = 
+            CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE;
+        cl_queue_properties queue_properties[] = {
+            CL_QUEUE_PROPERTIES, properties, 0 };
+        object_ = ::clCreateCommandQueueWithProperties(
+            context(), device(), queue_properties, &error);
+
+        detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    /*!
+     * Create a device command queue for a specified device in the passed context.
+     */
+    DeviceCommandQueue(
+        const Context& context,
+        const Device& device,
+        cl_uint queueSize,
+        cl_int* err = NULL)
+    {
+        cl_int error;
+
+        cl_command_queue_properties properties =
+            CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE;
+        cl_queue_properties queue_properties[] = {
+            CL_QUEUE_PROPERTIES, properties, 
+            CL_QUEUE_SIZE, queueSize, 
+            0 };
+        object_ = ::clCreateCommandQueueWithProperties(
+            context(), device(), queue_properties, &error);
+
+        detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+
+    /*! \brief Constructor from cl_command_queue - takes ownership.
+    *
+    * \param retainObject will cause the constructor to retain its cl object.
+    *                     Defaults to false to maintain compatibility with
+    *                     earlier versions.
+    */
+    explicit DeviceCommandQueue(const cl_command_queue& commandQueue, bool retainObject = false) :
+        detail::Wrapper<cl_type>(commandQueue, retainObject) { }
+
+    DeviceCommandQueue& operator = (const cl_command_queue& rhs)
+    {
+        detail::Wrapper<cl_type>::operator=(rhs);
+        return *this;
+    }
+
+    /*! \brief Copy constructor to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    DeviceCommandQueue(const DeviceCommandQueue& queue) : detail::Wrapper<cl_type>(queue) {}
+
+    /*! \brief Copy assignment to forward copy to the superclass correctly.
+     * Required for MSVC.
+     */
+    DeviceCommandQueue& operator = (const DeviceCommandQueue &queue)
+    {
+        detail::Wrapper<cl_type>::operator=(queue);
+        return *this;
+    }
+
+    /*! \brief Move constructor to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    DeviceCommandQueue(DeviceCommandQueue&& queue) CL_HPP_NOEXCEPT_ : detail::Wrapper<cl_type>(std::move(queue)) {}
+
+    /*! \brief Move assignment to forward move to the superclass correctly.
+     * Required for MSVC.
+     */
+    DeviceCommandQueue& operator = (DeviceCommandQueue &&queue)
+    {
+        detail::Wrapper<cl_type>::operator=(std::move(queue));
+        return *this;
+    }
+
+    template <typename T>
+    cl_int getInfo(cl_command_queue_info name, T* param) const
+    {
+        return detail::errHandler(
+            detail::getInfo(
+            &::clGetCommandQueueInfo, object_, name, param),
+            __GET_COMMAND_QUEUE_INFO_ERR);
+    }
+
+    template <cl_int name> typename
+        detail::param_traits<detail::cl_command_queue_info, name>::param_type
+        getInfo(cl_int* err = NULL) const
+    {
+        typename detail::param_traits<
+            detail::cl_command_queue_info, name>::param_type param;
+        cl_int result = getInfo(name, &param);
+        if (err != NULL) {
+            *err = result;
+        }
+        return param;
+    }
+
+    /*!
+    * Create a new default device command queue for the default device,
+    * in the default context and of the default size.
+    * If there is already a default queue for the specified device this
+    * function will return the pre-existing queue.
+    */
+    static DeviceCommandQueue makeDefault(
+        cl_int *err = nullptr)
+    {
+        cl_int error;
+        cl::Context context = cl::Context::getDefault();
+        cl::Device device = cl::Device::getDefault();
+
+        cl_command_queue_properties properties =
+            CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
+        cl_queue_properties queue_properties[] = {
+            CL_QUEUE_PROPERTIES, properties,
+            0 };
+        DeviceCommandQueue deviceQueue(
+            ::clCreateCommandQueueWithProperties(
+            context(), device(), queue_properties, &error));
+
+        detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+
+        return deviceQueue;
+    }
+
+    /*!
+    * Create a new default device command queue for the specified device
+    * and of the default size.
+    * If there is already a default queue for the specified device this
+    * function will return the pre-existing queue.
+    */
+    static DeviceCommandQueue makeDefault(
+        const Context &context, const Device &device, cl_int *err = nullptr)
+    {
+        cl_int error;
+
+        cl_command_queue_properties properties =
+            CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
+        cl_queue_properties queue_properties[] = {
+            CL_QUEUE_PROPERTIES, properties,
+            0 };
+        DeviceCommandQueue deviceQueue(
+            ::clCreateCommandQueueWithProperties(
+            context(), device(), queue_properties, &error));
+
+        detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+
+        return deviceQueue;
+    }
+
+    /*!
+     * Create a new default device command queue for the specified device 
+     * and of the requested size in bytes.
+     * If there is already a default queue for the specified device this
+     * function will return the pre-existing queue.
+     */
+    static DeviceCommandQueue makeDefault(
+        const Context &context, const Device &device, cl_uint queueSize, cl_int *err = nullptr)
+    {
+        cl_int error;
+
+        cl_command_queue_properties properties =
+            CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | CL_QUEUE_ON_DEVICE_DEFAULT;
+        cl_queue_properties queue_properties[] = {
+            CL_QUEUE_PROPERTIES, properties,
+            CL_QUEUE_SIZE, queueSize,
+            0 };
+        DeviceCommandQueue deviceQueue(
+            ::clCreateCommandQueueWithProperties(
+                context(), device(), queue_properties, &error));
+
+        detail::errHandler(error, __CREATE_COMMAND_QUEUE_WITH_PROPERTIES_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+
+        return deviceQueue;
+    }
+}; // DeviceCommandQueue
+
+namespace detail
+{
+    // Specialization for device command queue
+    template <>
+    struct KernelArgumentHandler<cl::DeviceCommandQueue, void>
+    {
+        static size_type size(const cl::DeviceCommandQueue&) { return sizeof(cl_command_queue); }
+        static const cl_command_queue* ptr(const cl::DeviceCommandQueue& value) { return &(value()); }
+    };
+} // namespace detail
+
+#endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
+
+
+template< typename IteratorType >
+Buffer::Buffer(
+    const Context &context,
+    IteratorType startIterator,
+    IteratorType endIterator,
+    bool readOnly,
+    bool useHostPtr,
+    cl_int* err)
+{
+    typedef typename std::iterator_traits<IteratorType>::value_type DataType;
+    cl_int error;
+
+    cl_mem_flags flags = 0;
+    if( readOnly ) {
+        flags |= CL_MEM_READ_ONLY;
+    }
+    else {
+        flags |= CL_MEM_READ_WRITE;
+    }
+    if( useHostPtr ) {
+        flags |= CL_MEM_USE_HOST_PTR;
+    }
+    
+    size_type size = sizeof(DataType)*(endIterator - startIterator);
+
+    if( useHostPtr ) {
+        object_ = ::clCreateBuffer(context(), flags, size, static_cast<DataType*>(&*startIterator), &error);
+    } else {
+        object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
+    }
+
+    detail::errHandler(error, __CREATE_BUFFER_ERR);
+    if (err != NULL) {
+        *err = error;
+    }
+
+    if( !useHostPtr ) {
+        CommandQueue queue(context, 0, &error);
+        detail::errHandler(error, __CREATE_BUFFER_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+
+        error = cl::copy(queue, startIterator, endIterator, *this);
+        detail::errHandler(error, __CREATE_BUFFER_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+}
+
+template< typename IteratorType >
+Buffer::Buffer(
+    const CommandQueue &queue,
+    IteratorType startIterator,
+    IteratorType endIterator,
+    bool readOnly,
+    bool useHostPtr,
+    cl_int* err)
+{
+    typedef typename std::iterator_traits<IteratorType>::value_type DataType;
+    cl_int error;
+
+    cl_mem_flags flags = 0;
+    if (readOnly) {
+        flags |= CL_MEM_READ_ONLY;
+    }
+    else {
+        flags |= CL_MEM_READ_WRITE;
+    }
+    if (useHostPtr) {
+        flags |= CL_MEM_USE_HOST_PTR;
+    }
+
+    size_type size = sizeof(DataType)*(endIterator - startIterator);
+
+    Context context = queue.getInfo<CL_QUEUE_CONTEXT>();
+
+    if (useHostPtr) {
+        object_ = ::clCreateBuffer(context(), flags, size, static_cast<DataType*>(&*startIterator), &error);
+    }
+    else {
+        object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
+    }
+
+    detail::errHandler(error, __CREATE_BUFFER_ERR);
+    if (err != NULL) {
+        *err = error;
+    }
+
+    if (!useHostPtr) {
+        error = cl::copy(queue, startIterator, endIterator, *this);
+        detail::errHandler(error, __CREATE_BUFFER_ERR);
+        if (err != NULL) {
+            *err = error;
+        }
+    }
+}
+
+inline cl_int enqueueReadBuffer(
+    const Buffer& buffer,
+    cl_bool blocking,
+    size_type offset,
+    size_type size,
+    void* ptr,
+    const vector<Event>* events = NULL,
+    Event* event = NULL)
+{
+    cl_int error;
+    CommandQueue queue = CommandQueue::getDefault(&error);
+
+    if (error != CL_SUCCESS) {
+        return error;
+    }
+
+    return queue.enqueueReadBuffer(buffer, blocking, offset, size, ptr, events, event);
+}
+
+inline cl_int enqueueWriteBuffer(
+        const Buffer& buffer,
+        cl_bool blocking,
+        size_type offset,
+        size_type size,
+        const void* ptr,
+        const vector<Event>* events = NULL,
+        Event* event = NULL)
+{
+    cl_int error;
+    CommandQueue queue = CommandQueue::getDefault(&error);
+
+    if (error != CL_SUCCESS) {
+        return error;
+    }
+
+    return queue.enqueueWriteBuffer(buffer, blocking, offset, size, ptr, events, event);
+}
+
+inline void* enqueueMapBuffer(
+        const Buffer& buffer,
+        cl_bool blocking,
+        cl_map_flags flags,
+        size_type offset,
+        size_type size,
+        const vector<Event>* events = NULL,
+        Event* event = NULL,
+        cl_int* err = NULL)
+{
+    cl_int error;
+    CommandQueue queue = CommandQueue::getDefault(&error);
+    detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
+    if (err != NULL) {
+        *err = error;
+    }
+
+    void * result = ::clEnqueueMapBuffer(
+            queue(), buffer(), blocking, flags, offset, size,
+            (events != NULL) ? (cl_uint) events->size() : 0,
+            (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+            (cl_event*) event,
+            &error);
+
+    detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
+    if (err != NULL) {
+        *err = error;
+    }
+    return result;
+}
+
+inline cl_int enqueueUnmapMemObject(
+    const Memory& memory,
+    void* mapped_ptr,
+    const vector<Event>* events = NULL,
+    Event* event = NULL)
+{
+    cl_int error;
+    CommandQueue queue = CommandQueue::getDefault(&error);
+    detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR);
+    if (error != CL_SUCCESS) {
+        return error;
+    }
+
+    cl_event tmp;
+    cl_int err = detail::errHandler(
+        ::clEnqueueUnmapMemObject(
+            queue(), memory(), mapped_ptr,
+            (events != NULL) ? (cl_uint) events->size() : 0,
+            (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
+            (event != NULL) ? &tmp : NULL),
+        __ENQUEUE_UNMAP_MEM_OBJECT_ERR);
+
+    if (event != NULL && err == CL_SUCCESS)
+        *event = tmp;
+
+    return err;
+}
+
+inline cl_int enqueueCopyBuffer(
+        const Buffer& src,
+        const Buffer& dst,
+        size_type src_offset,
+        size_type dst_offset,
+        size_type size,
+        const vector<Event>* events = NULL,
+        Event* event = NULL)
+{
+    cl_int error;
+    CommandQueue queue = CommandQueue::getDefault(&error);
+
+    if (error != CL_SUCCESS) {
+        return error;
+    }
+
+    return queue.enqueueCopyBuffer(src, dst, src_offset, dst_offset, size, events, event);
+}
+
+/**
+ * Blocking copy operation between iterators and a buffer.
+ * Host to Device.
+ * Uses default command queue.
+ */
+template< typename IteratorType >
+inline cl_int copy( IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer )
+{
+    cl_int error;
+    CommandQueue queue = CommandQueue::getDefault(&error);
+    if (error != CL_SUCCESS)
+        return error;
+
+    return cl::copy(queue, startIterator, endIterator, buffer);
+}
+
+/**
+ * Blocking copy operation between iterators and a buffer.
+ * Device to Host.
+ * Uses default command queue.
+ */
+template< typename IteratorType >
+inline cl_int copy( const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
+{
+    cl_int error;
+    CommandQueue queue = CommandQueue::getDefault(&error);
+    if (error != CL_SUCCESS)
+        return error;
+
+    return cl::copy(queue, buffer, startIterator, endIterator);
+}
+
+/**
+ * Blocking copy operation between iterators and a buffer.
+ * Host to Device.
+ * Uses specified queue.
+ */
+template< typename IteratorType >
+inline cl_int copy( const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer )
+{
+    typedef typename std::iterator_traits<IteratorType>::value_type DataType;
+    cl_int error;
+    
+    size_type length = endIterator-startIterator;
+    size_type byteLength = length*sizeof(DataType);
+
+    DataType *pointer = 
+        static_cast<DataType*>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error));
+    // if exceptions enabled, enqueueMapBuffer will throw
+    if( error != CL_SUCCESS ) {
+        return error;
+    }
+#if defined(_MSC_VER)
+    std::copy(
+        startIterator, 
+        endIterator, 
+        stdext::checked_array_iterator<DataType*>(
+            pointer, length));
+#else
+    std::copy(startIterator, endIterator, pointer);
+#endif
+    Event endEvent;
+    error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
+    // if exceptions enabled, enqueueUnmapMemObject will throw
+    if( error != CL_SUCCESS ) { 
+        return error;
+    }
+    endEvent.wait();
+    return CL_SUCCESS;
+}
+
+/**
+ * Blocking copy operation between iterators and a buffer.
+ * Device to Host.
+ * Uses specified queue.
+ */
+template< typename IteratorType >
+inline cl_int copy( const CommandQueue &queue, const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator )
+{
+    typedef typename std::iterator_traits<IteratorType>::value_type DataType;
+    cl_int error;
+        
+    size_type length = endIterator-startIterator;
+    size_type byteLength = length*sizeof(DataType);
+
+    DataType *pointer = 
+        static_cast<DataType*>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error));
+    // if exceptions enabled, enqueueMapBuffer will throw
+    if( error != CL_SUCCESS ) {
+        return error;
+    }
+    std::copy(pointer, pointer + length, startIterator);
+    Event endEvent;
+    error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent);
+    // if exceptions enabled, enqueueUnmapMemObject will throw
+    if( error != CL_SUCCESS ) { 
+        return error;
+    }
+    endEvent.wait();
+    return CL_SUCCESS;
+}
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 110
+inline cl_int enqueueReadBufferRect(
+    const Buffer& buffer,
+    cl_bool blocking,
+    const array<size_type, 3>& buffer_offset,
+    const array<size_type, 3>& host_offset,
+    const array<size_type, 3>& region,
+    size_type buffer_row_pitch,
+    size_type buffer_slice_pitch,
+    size_type host_row_pitch,
+    size_type host_slice_pitch,
+    void *ptr,
+    const vector<Event>* events = NULL,
+    Event* event = NULL)
+{
+    cl_int error;
+    CommandQueue queue = CommandQueue::getDefault(&error);
+
+    if (error != CL_SUCCESS) {
+        return error;
+    }
+
+    return queue.enqueueReadBufferRect(
+        buffer, 
+        blocking, 
+        buffer_offset, 
+        host_offset,
+        region,
+        buffer_row_pitch,
+        buffer_slice_pitch,
+        host_row_pitch,
+        host_slice_pitch,
+        ptr, 
+        events, 
+        event);
+}
+
+inline cl_int enqueueWriteBufferRect(
+    const Buffer& buffer,
+    cl_bool blocking,
+    const array<size_type, 3>& buffer_offset,
+    const array<size_type, 3>& host_offset,
+    const array<size_type, 3>& region,
+    size_type buffer_row_pitch,
+    size_type buffer_slice_pitch,
+    size_type host_row_pitch,
+    size_type host_slice_pitch,
+    void *ptr,
+    const vector<Event>* events = NULL,
+    Event* event = NULL)
+{
+    cl_int error;
+    CommandQueue queue = CommandQueue::getDefault(&error);
+
+    if (error != CL_SUCCESS) {
+        return error;
+    }
+
+    return queue.enqueueWriteBufferRect(
+        buffer, 
+        blocking, 
+        buffer_offset, 
+        host_offset,
+        region,
+        buffer_row_pitch,
+        buffer_slice_pitch,
+        host_row_pitch,
+        host_slice_pitch,
+        ptr, 
+        events, 
+        event);
+}
+
+inline cl_int enqueueCopyBufferRect(
+    const Buffer& src,
+    const Buffer& dst,
+    const array<size_type, 3>& src_origin,
+    const array<size_type, 3>& dst_origin,
+    const array<size_type, 3>& region,
+    size_type src_row_pitch,
+    size_type src_slice_pitch,
+    size_type dst_row_pitch,
+    size_type dst_slice_pitch,
+    const vector<Event>* events = NULL,
+    Event* event = NULL)
+{
+    cl_int error;
+    CommandQueue queue = CommandQueue::getDefault(&error);
+
+    if (error != CL_SUCCESS) {
+        return error;
+    }
+
+    return queue.enqueueCopyBufferRect(
+        src,
+        dst,
+        src_origin,
+        dst_origin,
+        region,
+        src_row_pitch,
+        src_slice_pitch,
+        dst_row_pitch,
+        dst_slice_pitch,
+        events, 
+        event);
+}
+#endif // CL_HPP_TARGET_OPENCL_VERSION >= 110
+
+inline cl_int enqueueReadImage(
+    const Image& image,
+    cl_bool blocking,
+    const array<size_type, 3>& origin,
+    const array<size_type, 3>& region,
+    size_type row_pitch,
+    size_type slice_pitch,
+    void* ptr,
+    const vector<Event>* events = NULL,
+    Event* event = NULL) 
+{
+    cl_int error;
+    CommandQueue queue = CommandQueue::getDefault(&error);
+
+    if (error != CL_SUCCESS) {
+        return error;
+    }
+
+    return queue.enqueueReadImage(
+        image,
+        blocking,
+        origin,
+        region,
+        row_pitch,
+        slice_pitch,
+        ptr,
+        events, 
+        event);
+}
+
+inline cl_int enqueueWriteImage(
+    const Image& image,
+    cl_bool blocking,
+    const array<size_type, 3>& origin,
+    const array<size_type, 3>& region,
+    size_type row_pitch,
+    size_type slice_pitch,
+    void* ptr,
+    const vector<Event>* events = NULL,
+    Event* event = NULL)
+{
+    cl_int error;
+    CommandQueue queue = CommandQueue::getDefault(&error);
+
+    if (error != CL_SUCCESS) {
+        return error;
+    }
+
+    return queue.enqueueWriteImage(
+        image,
+        blocking,
+        origin,
+        region,
+        row_pitch,
+        slice_pitch,
+        ptr,
+        events, 
+        event);
+}
+
+inline cl_int enqueueCopyImage(
+    const Image& src,
+    const Image& dst,
+    const array<size_type, 3>& src_origin,
+    const array<size_type, 3>& dst_origin,
+    const array<size_type, 3>& region,
+    const vector<Event>* events = NULL,
+    Event* event = NULL)
+{
+    cl_int error;
+    CommandQueue queue = CommandQueue::getDefault(&error);
+
+    if (error != CL_SUCCESS) {
+        return error;
+    }
+
+    return queue.enqueueCopyImage(
+        src,
+        dst,
+        src_origin,
+        dst_origin,
+        region,
+        events,
+        event);
+}
+
+inline cl_int enqueueCopyImageToBuffer(
+    const Image& src,
+    const Buffer& dst,
+    const array<size_type, 3>& src_origin,
+    const array<size_type, 3>& region,
+    size_type dst_offset,
+    const vector<Event>* events = NULL,
+    Event* event = NULL)
+{
+    cl_int error;
+    CommandQueue queue = CommandQueue::getDefault(&error);
+
+    if (error != CL_SUCCESS) {
+        return error;
+    }
+
+    return queue.enqueueCopyImageToBuffer(
+        src,
+        dst,
+        src_origin,
+        region,
+        dst_offset,
+        events,
+        event);
+}
+
+inline cl_int enqueueCopyBufferToImage(
+    const Buffer& src,
+    const Image& dst,
+    size_type src_offset,
+    const array<size_type, 3>& dst_origin,
+    const array<size_type, 3>& region,
+    const vector<Event>* events = NULL,
+    Event* event = NULL)
+{
+    cl_int error;
+    CommandQueue queue = CommandQueue::getDefault(&error);
+
+    if (error != CL_SUCCESS) {
+        return error;
+    }
+
+    return queue.enqueueCopyBufferToImage(
+        src,
+        dst,
+        src_offset,
+        dst_origin,
+        region,
+        events,
+        event);
+}
+
+
+inline cl_int flush(void)
+{
+    cl_int error;
+    CommandQueue queue = CommandQueue::getDefault(&error);
+
+    if (error != CL_SUCCESS) {
+        return error;
+    }
+
+    return queue.flush();
+}
+
+inline cl_int finish(void)
+{
+    cl_int error;
+    CommandQueue queue = CommandQueue::getDefault(&error);
+
+    if (error != CL_SUCCESS) {
+        return error;
+    } 
+
+
+    return queue.finish();
+}
+
+class EnqueueArgs
+{
+private:
+    CommandQueue queue_;
+    const NDRange offset_;
+    const NDRange global_;
+    const NDRange local_;
+    vector<Event> events_;
+
+    template<typename... Ts>
+    friend class KernelFunctor;
+
+public:
+    EnqueueArgs(NDRange global) : 
+      queue_(CommandQueue::getDefault()),
+      offset_(NullRange), 
+      global_(global),
+      local_(NullRange)
+    {
+
+    }
+
+    EnqueueArgs(NDRange global, NDRange local) : 
+      queue_(CommandQueue::getDefault()),
+      offset_(NullRange), 
+      global_(global),
+      local_(local)
+    {
+
+    }
+
+    EnqueueArgs(NDRange offset, NDRange global, NDRange local) : 
+      queue_(CommandQueue::getDefault()),
+      offset_(offset), 
+      global_(global),
+      local_(local)
+    {
+
+    }
+
+    EnqueueArgs(Event e, NDRange global) : 
+      queue_(CommandQueue::getDefault()),
+      offset_(NullRange), 
+      global_(global),
+      local_(NullRange)
+    {
+        events_.push_back(e);
+    }
+
+    EnqueueArgs(Event e, NDRange global, NDRange local) : 
+      queue_(CommandQueue::getDefault()),
+      offset_(NullRange), 
+      global_(global),
+      local_(local)
+    {
+        events_.push_back(e);
+    }
+
+    EnqueueArgs(Event e, NDRange offset, NDRange global, NDRange local) : 
+      queue_(CommandQueue::getDefault()),
+      offset_(offset), 
+      global_(global),
+      local_(local)
+    {
+        events_.push_back(e);
+    }
+
+    EnqueueArgs(const vector<Event> &events, NDRange global) : 
+      queue_(CommandQueue::getDefault()),
+      offset_(NullRange), 
+      global_(global),
+      local_(NullRange),
+      events_(events)
+    {
+
+    }
+
+    EnqueueArgs(const vector<Event> &events, NDRange global, NDRange local) : 
+      queue_(CommandQueue::getDefault()),
+      offset_(NullRange), 
+      global_(global),
+      local_(local),
+      events_(events)
+    {
+
+    }
+
+    EnqueueArgs(const vector<Event> &events, NDRange offset, NDRange global, NDRange local) : 
+      queue_(CommandQueue::getDefault()),
+      offset_(offset), 
+      global_(global),
+      local_(local),
+      events_(events)
+    {
+
+    }
+
+    EnqueueArgs(CommandQueue &queue, NDRange global) : 
+      queue_(queue),
+      offset_(NullRange), 
+      global_(global),
+      local_(NullRange)
+    {
+
+    }
+
+    EnqueueArgs(CommandQueue &queue, NDRange global, NDRange local) : 
+      queue_(queue),
+      offset_(NullRange), 
+      global_(global),
+      local_(local)
+    {
+
+    }
+
+    EnqueueArgs(CommandQueue &queue, NDRange offset, NDRange global, NDRange local) : 
+      queue_(queue),
+      offset_(offset), 
+      global_(global),
+      local_(local)
+    {
+
+    }
+
+    EnqueueArgs(CommandQueue &queue, Event e, NDRange global) : 
+      queue_(queue),
+      offset_(NullRange), 
+      global_(global),
+      local_(NullRange)
+    {
+        events_.push_back(e);
+    }
+
+    EnqueueArgs(CommandQueue &queue, Event e, NDRange global, NDRange local) : 
+      queue_(queue),
+      offset_(NullRange), 
+      global_(global),
+      local_(local)
+    {
+        events_.push_back(e);
+    }
+
+    EnqueueArgs(CommandQueue &queue, Event e, NDRange offset, NDRange global, NDRange local) : 
+      queue_(queue),
+      offset_(offset), 
+      global_(global),
+      local_(local)
+    {
+        events_.push_back(e);
+    }
+
+    EnqueueArgs(CommandQueue &queue, const vector<Event> &events, NDRange global) : 
+      queue_(queue),
+      offset_(NullRange), 
+      global_(global),
+      local_(NullRange),
+      events_(events)
+    {
+
+    }
+
+    EnqueueArgs(CommandQueue &queue, const vector<Event> &events, NDRange global, NDRange local) : 
+      queue_(queue),
+      offset_(NullRange), 
+      global_(global),
+      local_(local),
+      events_(events)
+    {
+
+    }
+
+    EnqueueArgs(CommandQueue &queue, const vector<Event> &events, NDRange offset, NDRange global, NDRange local) : 
+      queue_(queue),
+      offset_(offset), 
+      global_(global),
+      local_(local),
+      events_(events)
+    {
+
+    }
+};
+
+
+//----------------------------------------------------------------------------------------------
+
+
+/**
+ * Type safe kernel functor.
+ * 
+ */
+template<typename... Ts>
+class KernelFunctor
+{
+private:
+    Kernel kernel_;
+
+    template<int index, typename T0, typename... T1s>
+    void setArgs(T0&& t0, T1s&&... t1s)
+    {
+        kernel_.setArg(index, t0);
+        setArgs<index + 1, T1s...>(std::forward<T1s>(t1s)...);
+    }
+
+    template<int index, typename T0>
+    void setArgs(T0&& t0)
+    {
+        kernel_.setArg(index, t0);
+    }
+
+    template<int index>
+    void setArgs()
+    {
+    }
+
+
+public:
+    KernelFunctor(Kernel kernel) : kernel_(kernel)
+    {}
+
+    KernelFunctor(
+        const Program& program,
+        const string name,
+        cl_int * err = NULL) :
+        kernel_(program, name.c_str(), err)
+    {}
+
+    //! \brief Return type of the functor
+    typedef Event result_type;
+
+    /**
+     * Enqueue kernel.
+     * @param args Launch parameters of the kernel.
+     * @param t0... List of kernel arguments based on the template type of the functor.
+     */
+    Event operator() (
+        const EnqueueArgs& args,
+        Ts... ts)
+    {
+        Event event;
+        setArgs<0>(std::forward<Ts>(ts)...);
+        
+        args.queue_.enqueueNDRangeKernel(
+            kernel_,
+            args.offset_,
+            args.global_,
+            args.local_,
+            &args.events_,
+            &event);
+
+        return event;
+    }
+
+    /**
+    * Enqueue kernel with support for error code.
+    * @param args Launch parameters of the kernel.
+    * @param t0... List of kernel arguments based on the template type of the functor.
+    * @param error Out parameter returning the error code from the execution.
+    */
+    Event operator() (
+        const EnqueueArgs& args,
+        Ts... ts,
+        cl_int &error)
+    {
+        Event event;
+        setArgs<0>(std::forward<Ts>(ts)...);
+
+        error = args.queue_.enqueueNDRangeKernel(
+            kernel_,
+            args.offset_,
+            args.global_,
+            args.local_,
+            &args.events_,
+            &event);
+        
+        return event;
+    }
+
+#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+    cl_int setSVMPointers(const vector<void*> &pointerList)
+    {
+        return kernel_.setSVMPointers(pointerList);
+    }
+
+    template<typename T0, typename... T1s>
+    cl_int setSVMPointers(T0 t0, T1s... ts)
+    {
+        return kernel_.setSVMPointers(t0, ts...);
+    }
+#endif // #if CL_HPP_TARGET_OPENCL_VERSION >= 200
+
+    Kernel getKernel()
+    {
+        return kernel_;
+    }
+};
+
+namespace compatibility {
+    /**
+     * Backward compatibility class to ensure that cl.hpp code works with cl2.hpp.
+     * Please use KernelFunctor directly.
+     */
+    template<typename... Ts>
+    struct make_kernel
+    {
+        typedef KernelFunctor<Ts...> FunctorType;
+
+        FunctorType functor_;
+
+        make_kernel(
+            const Program& program,
+            const string name,
+            cl_int * err = NULL) :
+            functor_(FunctorType(program, name, err))
+        {}
+
+        make_kernel(
+            const Kernel kernel) :
+            functor_(FunctorType(kernel))
+        {}
+
+        //! \brief Return type of the functor
+        typedef Event result_type;
+
+        //! \brief Function signature of kernel functor with no event dependency.
+        typedef Event type_(
+            const EnqueueArgs&,
+            Ts...);
+
+        Event operator()(
+            const EnqueueArgs& enqueueArgs,
+            Ts... args)
+        {
+            return functor_(
+                enqueueArgs, args...);
+        }
+    };
+} // namespace compatibility
+
+
+//----------------------------------------------------------------------------------------------------------------------
+
+#undef CL_HPP_ERR_STR_
+#if !defined(CL_HPP_USER_OVERRIDE_ERROR_STRINGS)
+#undef __GET_DEVICE_INFO_ERR
+#undef __GET_PLATFORM_INFO_ERR
+#undef __GET_DEVICE_IDS_ERR
+#undef __GET_CONTEXT_INFO_ERR
+#undef __GET_EVENT_INFO_ERR
+#undef __GET_EVENT_PROFILE_INFO_ERR
+#undef __GET_MEM_OBJECT_INFO_ERR
+#undef __GET_IMAGE_INFO_ERR
+#undef __GET_SAMPLER_INFO_ERR
+#undef __GET_KERNEL_INFO_ERR
+#undef __GET_KERNEL_ARG_INFO_ERR
+#undef __GET_KERNEL_WORK_GROUP_INFO_ERR
+#undef __GET_PROGRAM_INFO_ERR
+#undef __GET_PROGRAM_BUILD_INFO_ERR
+#undef __GET_COMMAND_QUEUE_INFO_ERR
+
+#undef __CREATE_CONTEXT_ERR
+#undef __CREATE_CONTEXT_FROM_TYPE_ERR
+#undef __GET_SUPPORTED_IMAGE_FORMATS_ERR
+
+#undef __CREATE_BUFFER_ERR
+#undef __CREATE_SUBBUFFER_ERR
+#undef __CREATE_IMAGE2D_ERR
+#undef __CREATE_IMAGE3D_ERR
+#undef __CREATE_SAMPLER_ERR
+#undef __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR
+
+#undef __CREATE_USER_EVENT_ERR
+#undef __SET_USER_EVENT_STATUS_ERR
+#undef __SET_EVENT_CALLBACK_ERR
+#undef __SET_PRINTF_CALLBACK_ERR
+
+#undef __WAIT_FOR_EVENTS_ERR
+
+#undef __CREATE_KERNEL_ERR
+#undef __SET_KERNEL_ARGS_ERR
+#undef __CREATE_PROGRAM_WITH_SOURCE_ERR
+#undef __CREATE_PROGRAM_WITH_BINARY_ERR
+#undef __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR
+#undef __BUILD_PROGRAM_ERR
+#undef __CREATE_KERNELS_IN_PROGRAM_ERR
+
+#undef __CREATE_COMMAND_QUEUE_ERR
+#undef __SET_COMMAND_QUEUE_PROPERTY_ERR
+#undef __ENQUEUE_READ_BUFFER_ERR
+#undef __ENQUEUE_WRITE_BUFFER_ERR
+#undef __ENQUEUE_READ_BUFFER_RECT_ERR
+#undef __ENQUEUE_WRITE_BUFFER_RECT_ERR
+#undef __ENQEUE_COPY_BUFFER_ERR
+#undef __ENQEUE_COPY_BUFFER_RECT_ERR
+#undef __ENQUEUE_READ_IMAGE_ERR
+#undef __ENQUEUE_WRITE_IMAGE_ERR
+#undef __ENQUEUE_COPY_IMAGE_ERR
+#undef __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR
+#undef __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR
+#undef __ENQUEUE_MAP_BUFFER_ERR
+#undef __ENQUEUE_MAP_IMAGE_ERR
+#undef __ENQUEUE_UNMAP_MEM_OBJECT_ERR
+#undef __ENQUEUE_NDRANGE_KERNEL_ERR
+#undef __ENQUEUE_TASK_ERR
+#undef __ENQUEUE_NATIVE_KERNEL
+
+#undef __UNLOAD_COMPILER_ERR
+#undef __CREATE_SUB_DEVICES_ERR
+#endif //CL_HPP_USER_OVERRIDE_ERROR_STRINGS
+
+// Extensions
+#undef CL_HPP_INIT_CL_EXT_FCN_PTR_
+#undef CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_
+
+#if defined(CL_HPP_USE_CL_DEVICE_FISSION)
+#undef CL_HPP_PARAM_NAME_DEVICE_FISSION_
+#endif // CL_HPP_USE_CL_DEVICE_FISSION
+
+#undef CL_HPP_NOEXCEPT_
+#undef CL_HPP_DEFINE_STATIC_MEMBER_
+
+} // namespace cl
+
+#endif // CL_HPP_
diff --git a/include/CL/cl_platform.h b/include/CL/cl_platform.h
index e53d8c8..191f057 100644
--- a/include/CL/cl_platform.h
+++ b/include/CL/cl_platform.h
@@ -213,16 +213,16 @@ typedef double                  cl_double;
 /* scalar types  */
 typedef int8_t          cl_char;
 typedef uint8_t         cl_uchar;
-typedef int16_t         cl_short    __attribute__((aligned(2)));
-typedef uint16_t        cl_ushort   __attribute__((aligned(2)));
-typedef int32_t         cl_int      __attribute__((aligned(4)));
-typedef uint32_t        cl_uint     __attribute__((aligned(4)));
-typedef int64_t         cl_long     __attribute__((aligned(8)));
-typedef uint64_t        cl_ulong    __attribute__((aligned(8)));
+typedef int16_t         cl_short    __attribute__((__aligned__(2)));
+typedef uint16_t        cl_ushort   __attribute__((__aligned__(2)));
+typedef int32_t         cl_int      __attribute__((__aligned__(4)));
+typedef uint32_t        cl_uint     __attribute__((__aligned__(4)));
+typedef int64_t         cl_long     __attribute__((__aligned__(8)));
+typedef uint64_t        cl_ulong    __attribute__((__aligned__(8)));
 
-typedef uint16_t        cl_half     __attribute__((aligned(2)));
-typedef float           cl_float    __attribute__((aligned(4)));
-typedef double          cl_double   __attribute__((aligned(8)));
+typedef uint16_t        cl_half     __attribute__((__aligned__(2)));
+typedef float           cl_float    __attribute__((__aligned__(4)));
+typedef double          cl_double   __attribute__((__aligned__(8)));
 
 /* Macro names and corresponding values defined by OpenCL */
 #define CL_CHAR_BIT         8
@@ -453,7 +453,7 @@ typedef unsigned int cl_GLenum;
 
 /* Define alignment keys */
 #if defined( __GNUC__ )
-    #define CL_ALIGNED(_x)          __attribute__ ((aligned(_x)))
+    #define CL_ALIGNED(_x)          __attribute__ ((__aligned__(_x)))
 #elif defined( _WIN32) && (_MSC_VER)
     /* Alignment keys neutered on windows because MSVC can't swallow function arguments with alignment requirements     */
     /* http://msdn.microsoft.com/en-us/library/373ak2y1%28VS.71%29.aspx                                                 */
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 32693e6..43ff228 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -25,7 +25,7 @@
 
 add_subdirectory("CL")
 
-set(PRIVATE_HEADERS  _kernel.h _kernel_c.h pocl_types.h pocl_features.h pocl_device.h pocl.h)
+set(PRIVATE_HEADERS  _kernel.h _kernel_c.h _kernel_constants.h pocl_types.h pocl_features.h pocl_device.h pocl.h)
 
 install(FILES ${PRIVATE_HEADERS}
         DESTINATION ${POCL_INSTALL_PRIVATE_HEADER_DIR})
diff --git a/include/Makefile.am b/include/Makefile.am
index eb63f08..e7d18f0 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -24,11 +24,11 @@
 
 # Directory containing "private" headers
 pkgdataincludedir = $(pkgdatadir)/include
-pkgdatainclude_HEADERS = _kernel.h _kernel_c.h pocl_types.h pocl_features.h pocl_device.h pocl.h pocl_tests.h
+pkgdatainclude_HEADERS = _kernel.h _kernel_c.h pocl_types.h pocl_features.h pocl_device.h pocl.h pocl_tests.h _kernel_constants.h
 
 # Public - and default - includes dir
-include_HEADERS = poclu.h utlist.h
+include_HEADERS = poclu.h
 
-EXTRA_DIST = vccompat.hpp CMakeLists.txt
+EXTRA_DIST = vccompat.hpp CMakeLists.txt pocl_cache.h pocl_file_util.h utlist.h
 
 SUBDIRS = CL OpenCL
diff --git a/include/Makefile.in b/include/Makefile.in
index 05f7ac8..98f1971 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -104,8 +114,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = include
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(include_HEADERS) $(pkgdatainclude_HEADERS)
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -114,6 +122,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(include_HEADERS) \
+	$(pkgdatainclude_HEADERS) $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -203,6 +213,7 @@ am__define_uniq_tagged_files = \
 ETAGS = etags
 CTAGS = ctags
 DIST_SUBDIRS = $(SUBDIRS)
+am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 am__relativize = \
   dir0=`pwd`; \
@@ -279,6 +290,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -315,6 +329,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -432,11 +447,11 @@ top_srcdir = @top_srcdir@
 
 # Directory containing "private" headers
 pkgdataincludedir = $(pkgdatadir)/include
-pkgdatainclude_HEADERS = _kernel.h _kernel_c.h pocl_types.h pocl_features.h pocl_device.h pocl.h pocl_tests.h
+pkgdatainclude_HEADERS = _kernel.h _kernel_c.h pocl_types.h pocl_features.h pocl_device.h pocl.h pocl_tests.h _kernel_constants.h
 
 # Public - and default - includes dir
-include_HEADERS = poclu.h utlist.h
-EXTRA_DIST = vccompat.hpp CMakeLists.txt
+include_HEADERS = poclu.h
+EXTRA_DIST = vccompat.hpp CMakeLists.txt pocl_cache.h pocl_file_util.h utlist.h
 SUBDIRS = CL OpenCL
 all: all-recursive
 
@@ -453,7 +468,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign include/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -795,6 +809,8 @@ uninstall-am: uninstall-includeHEADERS uninstall-pkgdataincludeHEADERS
 	ps ps-am tags tags-am uninstall uninstall-am \
 	uninstall-includeHEADERS uninstall-pkgdataincludeHEADERS
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/include/OpenCL/Makefile.in b/include/OpenCL/Makefile.in
index 607fea2..b24ee15 100644
--- a/include/OpenCL/Makefile.in
+++ b/include/OpenCL/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -104,8 +114,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = include/OpenCL
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(am__library_include_HEADERS_DIST)
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -114,6 +122,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am \
+	$(am__library_include_HEADERS_DIST) $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -187,6 +197,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -238,6 +249,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -274,6 +288,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -408,7 +423,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/OpenCL/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign include/OpenCL/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -655,6 +669,8 @@ uninstall-am: uninstall-library_includeHEADERS
 	ps ps-am tags tags-am uninstall uninstall-am \
 	uninstall-library_includeHEADERS
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/include/_kernel.h b/include/_kernel.h
index 5d05df0..54ea23d 100644
--- a/include/_kernel.h
+++ b/include/_kernel.h
@@ -74,9 +74,6 @@
 #  define _CL_STATIC_ASSERT(_t, _x) typedef int __cl_ai##_t[(x) ? 1 : -1];
 #endif
 
-#define CLK_LOCAL_MEM_FENCE 0x1
-#define CLK_GLOBAL_MEM_FENCE 0x2
-
 typedef uint cl_mem_fence_flags;
 
 

@@ -813,6 +810,67 @@ void _CL_OVERLOADABLE barrier (cl_mem_fence_flags flags);
   double4  _CL_OVERLOADABLE NAME(double4 , int);        \
   double8  _CL_OVERLOADABLE NAME(double8 , int);        \
   double16 _CL_OVERLOADABLE NAME(double16, int);)
+#define _CL_DECLARE_FUNC_V_VPK(NAME)                                    \
+  __IF_FP16(                                                            \
+  half     _CL_OVERLOADABLE NAME(half    , __global  int     *);        \
+  half2    _CL_OVERLOADABLE NAME(half2   , __global  int2    *);        \
+  half3    _CL_OVERLOADABLE NAME(half3   , __global  int3    *);        \
+  half4    _CL_OVERLOADABLE NAME(half4   , __global  int4    *);        \
+  half8    _CL_OVERLOADABLE NAME(half8   , __global  int8    *);        \
+  half16   _CL_OVERLOADABLE NAME(half16  , __global  int16   *);)       \
+  float    _CL_OVERLOADABLE NAME(float   , __global  int     *);        \
+  float2   _CL_OVERLOADABLE NAME(float2  , __global  int2    *);        \
+  float3   _CL_OVERLOADABLE NAME(float3  , __global  int3    *);        \
+  float4   _CL_OVERLOADABLE NAME(float4  , __global  int4    *);        \
+  float8   _CL_OVERLOADABLE NAME(float8  , __global  int8    *);        \
+  float16  _CL_OVERLOADABLE NAME(float16 , __global  int16   *);        \
+  __IF_FP64(                                                            \
+  double   _CL_OVERLOADABLE NAME(double  , __global  int     *);        \
+  double2  _CL_OVERLOADABLE NAME(double2 , __global  int2    *);        \
+  double3  _CL_OVERLOADABLE NAME(double3 , __global  int3    *);        \
+  double4  _CL_OVERLOADABLE NAME(double4 , __global  int4    *);        \
+  double8  _CL_OVERLOADABLE NAME(double8 , __global  int8    *);        \
+  double16 _CL_OVERLOADABLE NAME(double16, __global  int16   *);)       \
+  __IF_FP16(                                                            \
+  half     _CL_OVERLOADABLE NAME(half    , __local   int     *);        \
+  half2    _CL_OVERLOADABLE NAME(half2   , __local   int2    *);        \
+  half3    _CL_OVERLOADABLE NAME(half3   , __local   int3    *);        \
+  half4    _CL_OVERLOADABLE NAME(half4   , __local   int4    *);        \
+  half8    _CL_OVERLOADABLE NAME(half8   , __local   int8    *);        \
+  half16   _CL_OVERLOADABLE NAME(half16  , __local   int16   *);)       \
+  float    _CL_OVERLOADABLE NAME(float   , __local   int     *);        \
+  float2   _CL_OVERLOADABLE NAME(float2  , __local   int2    *);        \
+  float3   _CL_OVERLOADABLE NAME(float3  , __local   int3    *);        \
+  float4   _CL_OVERLOADABLE NAME(float4  , __local   int4    *);        \
+  float8   _CL_OVERLOADABLE NAME(float8  , __local   int8    *);        \
+  float16  _CL_OVERLOADABLE NAME(float16 , __local   int16   *);        \
+  __IF_FP64(                                                            \
+  double   _CL_OVERLOADABLE NAME(double  , __local   int     *);        \
+  double2  _CL_OVERLOADABLE NAME(double2 , __local   int2    *);        \
+  double3  _CL_OVERLOADABLE NAME(double3 , __local   int3    *);        \
+  double4  _CL_OVERLOADABLE NAME(double4 , __local   int4    *);        \
+  double8  _CL_OVERLOADABLE NAME(double8 , __local   int8    *);        \
+  double16 _CL_OVERLOADABLE NAME(double16, __local   int16   *);)       \
+  __IF_FP16(                                                            \
+  half     _CL_OVERLOADABLE NAME(half    , __private int     *);        \
+  half2    _CL_OVERLOADABLE NAME(half2   , __private int2    *);        \
+  half3    _CL_OVERLOADABLE NAME(half3   , __private int3    *);        \
+  half4    _CL_OVERLOADABLE NAME(half4   , __private int4    *);        \
+  half8    _CL_OVERLOADABLE NAME(half8   , __private int8    *);        \
+  half16   _CL_OVERLOADABLE NAME(half16  , __private int16   *);)       \
+  float    _CL_OVERLOADABLE NAME(float   , __private int     *);        \
+  float2   _CL_OVERLOADABLE NAME(float2  , __private int2    *);        \
+  float3   _CL_OVERLOADABLE NAME(float3  , __private int3    *);        \
+  float4   _CL_OVERLOADABLE NAME(float4  , __private int4    *);        \
+  float8   _CL_OVERLOADABLE NAME(float8  , __private int8    *);        \
+  float16  _CL_OVERLOADABLE NAME(float16 , __private int16   *);        \
+  __IF_FP64(                                                            \
+  double   _CL_OVERLOADABLE NAME(double  , __private int     *);        \
+  double2  _CL_OVERLOADABLE NAME(double2 , __private int2    *);        \
+  double3  _CL_OVERLOADABLE NAME(double3 , __private int3    *);        \
+  double4  _CL_OVERLOADABLE NAME(double4 , __private int4    *);        \
+  double8  _CL_OVERLOADABLE NAME(double8 , __private int8    *);        \
+  double16 _CL_OVERLOADABLE NAME(double16, __private int16   *);)
 #define _CL_DECLARE_FUNC_V_VPV(NAME)                                    \
   __IF_FP16(                                                            \
   half     _CL_OVERLOADABLE NAME(half    , __global  half    *);        \
@@ -1189,7 +1247,7 @@ _CL_DECLARE_FUNC_V_VS(fmin)
 #endif
 _CL_DECLARE_FUNC_V_VV(fmod)
 _CL_DECLARE_FUNC_V_VPV(fract)
-// frexp
+_CL_DECLARE_FUNC_V_VPK(frexp)
 _CL_DECLARE_FUNC_V_VV(hypot)
 _CL_DECLARE_FUNC_K_V(ilogb)
 _CL_DECLARE_FUNC_V_VJ(ldexp)
@@ -1204,7 +1262,7 @@ _CL_DECLARE_FUNC_V_V(logb)
 _CL_DECLARE_FUNC_V_VVV(mad)
 _CL_DECLARE_FUNC_V_VV(maxmag)
 _CL_DECLARE_FUNC_V_VV(minmag)
-// modf
+_CL_DECLARE_FUNC_V_VPV(modf)
 _CL_DECLARE_FUNC_V_U(nan)
 _CL_DECLARE_FUNC_V_VV(nextafter)
 _CL_DECLARE_FUNC_V_VV(pow)
@@ -1243,22 +1301,21 @@ _CL_DECLARE_FUNC_F_F(half_rsqrt)
 _CL_DECLARE_FUNC_F_F(half_sin)
 _CL_DECLARE_FUNC_F_F(half_sqrt)
 _CL_DECLARE_FUNC_F_F(half_tan)
-_CL_DECLARE_FUNC_F_F(native_cos)
-_CL_DECLARE_FUNC_F_FF(native_divide)
-_CL_DECLARE_FUNC_F_F(native_exp)
-_CL_DECLARE_FUNC_F_F(native_exp2)
-_CL_DECLARE_FUNC_F_F(native_exp10)
-_CL_DECLARE_FUNC_F_F(native_log)
-_CL_DECLARE_FUNC_F_F(native_log2)
-_CL_DECLARE_FUNC_F_F(native_log10)
-_CL_DECLARE_FUNC_F_FF(native_powr)
-_CL_DECLARE_FUNC_F_F(native_recip)
-_CL_DECLARE_FUNC_F_F(native_rsqrt)
-_CL_DECLARE_FUNC_F_F(native_sin)
-_CL_DECLARE_FUNC_F_F(native_sqrt)
-_CL_DECLARE_FUNC_F_F(native_tan)
+_CL_DECLARE_FUNC_V_V(_cl_native_cos)
+_CL_DECLARE_FUNC_V_VV(_cl_native_divide)
+_CL_DECLARE_FUNC_V_V(_cl_native_exp)
+_CL_DECLARE_FUNC_V_V(_cl_native_exp2)
+_CL_DECLARE_FUNC_V_V(_cl_native_exp10)
+_CL_DECLARE_FUNC_V_V(_cl_native_log)
+_CL_DECLARE_FUNC_V_V(_cl_native_log2)
+_CL_DECLARE_FUNC_V_V(_cl_native_log10)
+_CL_DECLARE_FUNC_V_VV(_cl_native_powr)
+_CL_DECLARE_FUNC_V_V(_cl_native_recip)
+_CL_DECLARE_FUNC_V_V(_cl_native_rsqrt)
+_CL_DECLARE_FUNC_V_V(_cl_native_sin)
+_CL_DECLARE_FUNC_V_V(_cl_native_sqrt)
+_CL_DECLARE_FUNC_V_V(_cl_native_tan)
 
-

 /* Integer Constants */
 
 #define CHAR_BIT  8
diff --git a/include/_kernel_c.h b/include/_kernel_c.h
index 77633b5..be6732b 100644
--- a/include/_kernel_c.h
+++ b/include/_kernel_c.h
@@ -33,6 +33,8 @@
 
 #include "pocl_types.h"
 
+#include "_kernel_constants.h"
+
 /* Function/type attributes supported by Clang/SPIR */
 #if __has_attribute(__always_inline__)
 #  define _CL_ALWAYSINLINE __attribute__((__always_inline__))
@@ -159,64 +161,23 @@ typedef ulong ulong16 __attribute__((__ext_vector_type__(16)));
    by the frontend. */
 #if !defined(_CL_HAS_IMAGE_ACCESS)
 typedef int sampler_t;
-typedef struct dev_image_t* image2d_t;
-typedef struct dev_image_t* image3d_t;
-typedef struct dev_image_t* image1d_t;
-typedef struct dev_image_t* image1d_buffer_t;
-typedef struct dev_image_t* image2d_array_t;
-typedef struct dev_image_t* image1d_array_t;
-#endif
 
+/* Since some built-ins have different return types
+ * (e.g. get_image_dim returns an int2 for 2D images and arrays,
+ *  but an int4 for 3D images) we want each image type to
+ * point to a different type which is actually always the same.
+ * We do this by making it pointer to structs whose only element is a
+ * dev_image_t. The structs are not anonymous to allow identification
+ * by name.
+ */
+typedef struct _pocl_image2d_t { dev_image_t base; }* image2d_t;
+typedef struct _pocl_image3d_t { dev_image_t base; }* image3d_t;
+typedef struct _pocl_image1d_t { dev_image_t base; }* image1d_t;
+typedef struct _pocl_image1d_buffer_t { dev_image_t base; }* image1d_buffer_t;
+typedef struct _pocl_image2d_array_t { dev_image_t base; }* image2d_array_t;
+typedef struct _pocl_image1d_array_t { dev_image_t base; }* image1d_array_t;
+#endif
 
-/* cl_channel_order */
-#define CL_R                                        0x10B0
-#define CL_A                                        0x10B1
-#define CL_RG                                       0x10B2
-#define CL_RA                                       0x10B3
-#define CL_RGB                                      0x10B4
-#define CL_RGBA                                     0x10B5
-#define CL_BGRA                                     0x10B6
-#define CL_ARGB                                     0x10B7
-#define CL_INTENSITY                                0x10B8
-#define CL_LUMINANCE                                0x10B9
-#define CL_Rx                                       0x10BA
-#define CL_RGx                                      0x10BB
-#define CL_RGBx                                     0x10BC
-#define CL_DEPTH                                    0x10BD
-#define CL_DEPTH_STENCIL                            0x10BE
-
-/* cl_channel_type */
-#define CL_SNORM_INT8                               0x10D0
-#define CL_SNORM_INT16                              0x10D1
-#define CL_UNORM_INT8                               0x10D2
-#define CL_UNORM_INT16                              0x10D3
-#define CL_UNORM_SHORT_565                          0x10D4
-#define CL_UNORM_SHORT_555                          0x10D5
-#define CL_UNORM_INT_101010                         0x10D6
-#define CL_SIGNED_INT8                              0x10D7
-#define CL_SIGNED_INT16                             0x10D8
-#define CL_SIGNED_INT32                             0x10D9
-#define CL_UNSIGNED_INT8                            0x10DA
-#define CL_UNSIGNED_INT16                           0x10DB
-#define CL_UNSIGNED_INT32                           0x10DC
-#define CL_HALF_FLOAT                               0x10DD
-#define CL_FLOAT                                    0x10DE
-#define CL_UNORM_INT24                              0x10DF
-
-/* cl_addressing _mode */
-#define CLK_ADDRESS_NONE                            0x00
-#define CLK_ADDRESS_MIRRORED_REPEAT                 0x01
-#define CLK_ADDRESS_REPEAT                          0x02
-#define CLK_ADDRESS_CLAMP_TO_EDGE                   0x03
-#define CLK_ADDRESS_CLAMP                           0x04
-
-/* cl_sampler_info */
-#define CLK_NORMALIZED_COORDS_FALSE                 0x00
-#define CLK_NORMALIZED_COORDS_TRUE                  0x08
-
-/* filter_mode */
-#define CLK_FILTER_NEAREST                          0x00
-#define CLK_FILTER_LINEAR                           0x10
 
 //#ifdef _CL_HAS_IMAGE_ACCESS
 
@@ -298,4 +259,9 @@ int _CL_OVERLOADABLE get_image_height (image3d_t image);
 int _CL_OVERLOADABLE get_image_depth (image1d_t image);
 int _CL_OVERLOADABLE get_image_depth (image2d_t image);
 int _CL_OVERLOADABLE get_image_depth (image3d_t image);
+
+int2 _CL_OVERLOADABLE get_image_dim (image2d_t image);
+int2 _CL_OVERLOADABLE get_image_dim (image2d_array_t image);
+int4 _CL_OVERLOADABLE get_image_dim (image3d_t image);
+
 #endif
diff --git a/include/_kernel_constants.h b/include/_kernel_constants.h
new file mode 100644
index 0000000..ab11ea9
--- /dev/null
+++ b/include/_kernel_constants.h
@@ -0,0 +1,88 @@
+/* pocl/_kernel_constants.h - C compatible OpenCL types and runtime library
+   constants declarations.
+
+   Copyright (c) 2011 Universidad Rey Juan Carlos
+   Copyright (c) 2011-2013 Pekka Jääskeläinen / TUT
+   Copyright (c) 2011-2013 Erik Schnetter <eschnetter at perimeterinstitute.ca>
+                           Perimeter Institute for Theoretical Physics
+   
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+   
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+   
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+*/
+/**
+ * Header that can be implemented in C compiled implementations of
+ * built-in functions to introduce the OpenCL C compatible constants.
+ */
+#ifndef _KERNEL_CONSTANTS_H
+#define _KERNEL_CONSTANTS_H
+
+/* cl_channel_order */
+#define CL_R                                        0x10B0
+#define CL_A                                        0x10B1
+#define CL_RG                                       0x10B2
+#define CL_RA                                       0x10B3
+#define CL_RGB                                      0x10B4
+#define CL_RGBA                                     0x10B5
+#define CL_BGRA                                     0x10B6
+#define CL_ARGB                                     0x10B7
+#define CL_INTENSITY                                0x10B8
+#define CL_LUMINANCE                                0x10B9
+#define CL_Rx                                       0x10BA
+#define CL_RGx                                      0x10BB
+#define CL_RGBx                                     0x10BC
+#define CL_DEPTH                                    0x10BD
+#define CL_DEPTH_STENCIL                            0x10BE
+
+/* cl_channel_type */
+#define CL_SNORM_INT8                               0x10D0
+#define CL_SNORM_INT16                              0x10D1
+#define CL_UNORM_INT8                               0x10D2
+#define CL_UNORM_INT16                              0x10D3
+#define CL_UNORM_SHORT_565                          0x10D4
+#define CL_UNORM_SHORT_555                          0x10D5
+#define CL_UNORM_INT_101010                         0x10D6
+#define CL_SIGNED_INT8                              0x10D7
+#define CL_SIGNED_INT16                             0x10D8
+#define CL_SIGNED_INT32                             0x10D9
+#define CL_UNSIGNED_INT8                            0x10DA
+#define CL_UNSIGNED_INT16                           0x10DB
+#define CL_UNSIGNED_INT32                           0x10DC
+#define CL_HALF_FLOAT                               0x10DD
+#define CL_FLOAT                                    0x10DE
+#define CL_UNORM_INT24                              0x10DF
+
+/* cl_addressing _mode */
+#define CLK_ADDRESS_NONE                            0x00
+#define CLK_ADDRESS_MIRRORED_REPEAT                 0x01
+#define CLK_ADDRESS_REPEAT                          0x02
+#define CLK_ADDRESS_CLAMP_TO_EDGE                   0x03
+#define CLK_ADDRESS_CLAMP                           0x04
+
+/* cl_sampler_info */
+#define CLK_NORMALIZED_COORDS_FALSE                 0x00
+#define CLK_NORMALIZED_COORDS_TRUE                  0x08
+
+/* filter_mode */
+#define CLK_FILTER_NEAREST                          0x00
+#define CLK_FILTER_LINEAR                           0x10
+
+/* barrier() flags */
+#define CLK_LOCAL_MEM_FENCE                         0x01
+#define CLK_GLOBAL_MEM_FENCE                        0x02
+
+#endif
diff --git a/include/pocl.h b/include/pocl.h
index d13c37e..6eec4a0 100644
--- a/include/pocl.h
+++ b/include/pocl.h
@@ -50,6 +50,8 @@
 #define POCL_ADDRESS_SPACE_LOCAL 2
 #define POCL_ADDRESS_SPACE_CONSTANT 3
 
+#define POCL_FILENAME_LENGTH 1024
+
 typedef struct _mem_mapping mem_mapping_t;
 /* represents a single buffer to host memory mapping */
 struct _mem_mapping {
@@ -71,12 +73,14 @@ typedef struct
   /* A list of argument buffers to free after the command has 
      been executed. */
   cl_mem *arg_buffers;
-  int arg_buffer_count;
+  unsigned arg_buffer_count;
   size_t local_x;
   size_t local_y;
   size_t local_z;
   struct pocl_context pc;
   struct pocl_argument *arguments;
+  /* Can be used to store/cache device-specific data. */
+  void **device_data;
 } _cl_command_run;
 
 // clEnqueueNativeKernel
@@ -87,7 +91,7 @@ typedef struct
   size_t cb_args;
   void (*user_func)(void *);
   cl_mem *mem_list;
-  int num_mem_objects;
+  unsigned num_mem_objects;
 } _cl_command_native;
 
 // clEnqueueReadBuffer
@@ -191,16 +195,24 @@ typedef struct _cl_command_node_struct
   struct _cl_command_node_struct *next; // for linked-list storage
   cl_event event;
   const cl_event *event_wait_list;
-  cl_int num_events_in_wait_list;
+  cl_uint num_events_in_wait_list;
   cl_device_id device;
 } _cl_command_node;
 
 /* Additional LLVM version macros to simplify ifdefs */
 
+#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4)
+#define LLVM_OLDER_THAN_3_5 1
+#endif
+
 #if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || \
     defined(LLVM_3_5)
 
 # define LLVM_OLDER_THAN_3_6 1
+# define LLVM_OLDER_THAN_3_7 1
+#elif (defined LLVM_3_6)
+
+# define LLVM_OLDER_THAN_3_7 1
 
 #endif
 
diff --git a/include/pocl_cache.h b/include/pocl_cache.h
new file mode 100644
index 0000000..23fc694
--- /dev/null
+++ b/include/pocl_cache.h
@@ -0,0 +1,132 @@
+/* pocl_cache.h: global declarations of caching functions used mostly in runtime
+
+   Copyright (c) 2015 pocl developers
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+*/
+
+#ifndef POCL_CACHE_H
+#define POCL_CACHE_H
+
+/* The filename in which the work group (parallelizable) kernel LLVM bc is stored in
+   the kernel's temp dir. */
+#define POCL_PARALLEL_BC_FILENAME   "/parallel.bc"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CL_USE_DEPRECATED_OPENCL_1_1_APIS
+#include <CL/cl.h>
+
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
+void pocl_cache_init_topdir();
+
+int
+pocl_cache_create_program_cachedir(cl_program program, unsigned device_i,
+                                   const char* preprocessed_source, size_t source_len,
+                                   char *program_bc_path, void **cache_lock);
+
+void pocl_cache_cleanup_cachedir(cl_program program);
+
+void* pocl_cache_acquire_writer_lock_i(cl_program program, unsigned device_i);
+
+void* pocl_cache_acquire_writer_lock(cl_program program, cl_device_id device);
+
+void pocl_cache_release_lock(void* lock);
+
+int pocl_cl_device_to_index(cl_program   program,
+                            cl_device_id device);
+
+void pocl_cache_mk_temp_name(char* path);
+
+int pocl_cache_write_program_source(char *program_cl_path,
+                                    cl_program program);
+
+int pocl_cache_update_program_last_access(cl_program program,
+                                          unsigned device_i);
+
+
+
+char* pocl_cache_read_buildlog(cl_program program, unsigned device_i);
+
+int pocl_cache_append_to_buildlog(cl_program  program,
+                                  unsigned    device_i,
+                                  const char *content,
+                                  size_t      size);
+
+
+int pocl_cache_device_cachedir_exists(cl_program   program,
+                                      unsigned device_i);
+
+int pocl_cache_write_descriptor(cl_program   program,
+                                unsigned     device_i,
+                                const char*  kernel_name,
+                                const char*  content,
+                                size_t       size);
+
+int pocl_cache_make_kernel_cachedir_path(char*        kernel_cachedir_path,
+                                         cl_program   program,
+                                         cl_device_id device,
+                                         cl_kernel    kernel,
+                                         size_t       local_x,
+                                         size_t       local_y,
+                                         size_t       local_z);
+
+
+
+int pocl_cache_write_kernel_parallel_bc(void*        bc,
+                                        cl_program   program,
+                                        unsigned     device_i,
+                                        cl_kernel    kernel,
+                                        size_t       local_x,
+                                        size_t       local_y,
+                                        size_t       local_z);
+
+
+
+// these two required by llvm API
+
+void pocl_cache_program_bc_path(char*       program_bc_path,
+                               cl_program   program,
+                               unsigned     device_i);
+
+void pocl_cache_work_group_function_path(char* parallel_bc_path, cl_program program,
+                              unsigned device_i, cl_kernel kernel,
+                              size_t local_x, size_t local_y, size_t local_z);
+
+void pocl_cache_final_binary_path(char* final_binary_path, cl_program program,
+                               unsigned device_i, cl_kernel kernel,
+                               size_t local_x, size_t local_y,
+                               size_t local_z);
+
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --git a/include/pocl_features.h b/include/pocl_features.h
index 55569a4..7486366 100644
--- a/include/pocl_features.h
+++ b/include/pocl_features.h
@@ -21,7 +21,9 @@
 
 // Is double supported?
 #if defined cl_khr_int64 && __SIZEOF_DOUBLE__ == 8
-#  define cl_khr_fp64
+#  if !defined(cl_khr_fp64)
+#    define cl_khr_fp64
+#  endif
 #else
 #  undef cl_khr_fp64
 #endif
diff --git a/include/pocl_file_util.h b/include/pocl_file_util.h
new file mode 100644
index 0000000..d9b523b
--- /dev/null
+++ b/include/pocl_file_util.h
@@ -0,0 +1,85 @@
+/* pocl_file_util.h: global declarations of portable file utility functions
+   defined in lib/llvmopencl, due to using llvm::sys::fs & other llvm APIs
+
+   Copyright (c) 2015 pocl developers
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+*/
+
+
+#ifndef POCL_FILE_UTIL_H
+#define POCL_FILE_UTIL_H
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
+#define LOCK_ACQUIRE_FAIL 3210
+
+void* acquire_lock(const char* path, int shared);
+
+void release_lock(void* lock);
+
+
+
+/* Remove a directory, recursively */
+int pocl_rm_rf(const char* path);
+
+/* Make a directory, including all directories along path */
+int pocl_mkdir_p(const char* path);
+
+/* Remove a file or empty directory */
+int pocl_remove(const char* path);
+
+int pocl_exists(const char* path);
+
+int pocl_filesize(const char* path, uint64_t* res);
+
+/* Touch file to change last modified time. For portability, this
+ * removes & creates the file. */
+int pocl_touch_file(const char* path);
+
+/* Writes or appends data to a file.  */
+int pocl_write_file(const char* path, const char* content,
+                    uint64_t count, int append, int dont_rewrite);
+
+/* Allocates memory and places file contents in it.
+ * Returns negative errno on error, zero otherwise. */
+int pocl_read_file(const char* path, char** content, uint64_t *filesize);
+
+
+int pocl_write_module(void *module, const char* path, int dont_rewrite);
+
+int pocl_remove_locked(const char* path);
+
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --git a/include/poclu.h b/include/poclu.h
index 9fa9fc0..4c4acb6 100644
--- a/include/poclu.h
+++ b/include/poclu.h
@@ -99,6 +99,10 @@ poclu_cl_half_to_float(cl_half value);
 POCLU_API char * POCLU_CALL
 poclu_read_file(char* filemane);
 
+POCLU_API int POCLU_CALL
+poclu_write_file(char* filemane, char* content, size_t size);
+
+
 /* In case cl_err != CL_SUCCESS, prints out the error + function : line to stderr,
  * and returns 1, otherwise returns 0
  */
diff --git a/include/vccompat.hpp b/include/vccompat.hpp
index 9e93889..f931fd4 100644
--- a/include/vccompat.hpp
+++ b/include/vccompat.hpp
@@ -98,6 +98,7 @@ static inline void lt_dlinit(void) {
  * TODO: test these implementations...
  */
 
+/* Commented out: unused, and actually incorrect/unsafe.
 static inline void gen_random(char *s, const int len) {
   static const char alphanum[] =
     "0123456789"
@@ -115,6 +116,7 @@ static inline void mkdtemp(char *temp) {
   gen_random(&temp[rnd_start], 6);
   mkdir(temp);
 }
+*/
 
 /**
  * Memory allocation functions
diff --git a/lib/CL/CMakeLists.txt b/lib/CL/CMakeLists.txt
index 517e01a..7631a32 100644
--- a/lib/CL/CMakeLists.txt
+++ b/lib/CL/CMakeLists.txt
@@ -113,11 +113,13 @@ set(POCL_LIB_SOURCES  "clCreateContextFromType.c"
                    "clRetainDevice.c"
                    "clCreateSubDevices.c"
                    "pocl_cl.h" "pocl_util.h" "pocl_util.c"
+                   "pocl_queue_util.h" "pocl_queue_util.c"
                    "pocl_image_util.c" "pocl_image_util.h"
-                   "pocl_icd.h" "pocl_llvm.h"
+                   "pocl_icd.h" "pocl_llvm.h" "pocl_cache.c"
                    "pocl_runtime_config.c" "pocl_runtime_config.h"
                    "pocl_mem_management.c"  "pocl_mem_management.h"
-                   "pocl_llvm_api.cc" "pocl_hash.c")
+                   "pocl_llvm_api.cc" "pocl_hash.c"
+                   "pocl_debug.h" "pocl_debug.c")
 
 set(LIBPOCL_OBJS "$<TARGET_OBJECTS:llvmpasses>;$<TARGET_OBJECTS:libpocl_unlinked_objs>;${POCL_DEVICES_OBJS}")
 
@@ -135,6 +137,8 @@ endif(MSVC)
 # this is so that we don't compile twice when building both libpocl and libOpenCL
 add_library("libpocl_unlinked_objs" OBJECT ${POCL_LIB_SOURCES})
 
+# pocl_cache.c depends on a SHA1 hash of the built kernel-<machine>.bc
+add_dependencies("libpocl_unlinked_objs" "kernel_host")
 #################################################################
 
 if (MSVC)
@@ -146,7 +150,7 @@ endif()
 set(POCL_PRIVATE_LINK_LIST ${CLANG_LIBFILES} ${POCL_LLVM_LIBS} ${LLVM_SYSLIBS})
 
 # -lrt is required for glibc < 2.17
-if(HAVE_CLOCK_GETTIME)
+if(HAVE_CLOCK_GETTIME AND (NOT WIN32))
   list(APPEND POCL_PUBLIC_LINK_LIST "rt")
 endif()
 
diff --git a/lib/CL/Makefile.am b/lib/CL/Makefile.am
index 3aa0365..3d91f8d 100644
--- a/lib/CL/Makefile.am
+++ b/lib/CL/Makefile.am
@@ -124,13 +124,15 @@ libpocl_la_SOURCES = clCreateContextFromType.c	\
                    clRetainDevice.c \
                    pocl_cl.h \
                    pocl_util.c pocl_util.h \
+                   pocl_queue_util.c pocl_queue_util.h \
                    pocl_image_util.c pocl_image_util.h \
                    pocl_icd.h \
                    pocl_intfn.h \
                    pocl_llvm.h \
                    pocl_runtime_config.c pocl_runtime_config.h \
                    pocl_mem_management.c pocl_mem_management.h \
-                   pocl_hash.c pocl_hash.h
+                   pocl_hash.c pocl_hash.h pocl_cache.c \
+                   pocl_debug.c pocl_debug.h
 
 
 libpocl_la_CPPFLAGS = -I$(top_srcdir)/fix-include -I$(top_srcdir)/fix-include/OpenCL -I$(top_srcdir)/include -I$(top_srcdir)/lib/CL/devices $(OCL_ICD_CFLAGS)
@@ -143,6 +145,10 @@ if TCE_AVAILABLE
 libpocl_la_LDFLAGS += -lstdc++ `@TCE_CONFIG@ --libs`
 endif
 
+if BUILD_HSA
+libpocl_la_LDFLAGS += -lhsa-runtime64
+endif
+
 libpocl_la_LIBADD = devices/libpocl-devices.la
 libpocl_la_LIBADD += ${LTDL_LIBS}
 
@@ -193,6 +199,14 @@ libOpenCL_la_LDFLAGS = ${libpocl_la_LDFLAGS}
 libOpenCL_la_LIBADD = ${libpocl_la_LIBADD}
 endif
 
-CLEANFILES = libOpenCL.la
+CLEANFILES = libpocl.la libOpenCL.la kernellib_hash.h
 
 EXTRA_DIST = CMakeLists.txt
+
+BUILT_SOURCES = kernellib_hash.h
+
+FORCE:
+
+kernellib_hash.h: FORCE
+	echo '#define POCL_KERNELLIB_SHA1 "'`sha1sum ../../include/_kernel.h ../../include/_kernel_c.h ../../include/pocl_types.h ../../include/pocl_features.h ../kernel/*.cl ../kernel/*.c ../kernel/vecmathlib-pocl/*.cl ../kernel/vecmathlib-pocl/*.cc | sha1sum -`'"' > kernellib_hash.new
+	cmp kernellib_hash.new kernellib_hash.h || mv kernellib_hash.new kernellib_hash.h
diff --git a/lib/CL/Makefile.in b/lib/CL/Makefile.in
index 84d4d52..9572e6c 100644
--- a/lib/CL/Makefile.in
+++ b/lib/CL/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -40,7 +40,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -115,16 +125,15 @@ target_triplet = @target@
 # The ttasim device is written in C++ as it accesses the ttasim library of TCE
 # directly.
 @TCE_AVAILABLE_TRUE at am__append_2 = -lstdc++ `@TCE_CONFIG@ --libs`
+ at BUILD_HSA_TRUE@am__append_3 = -lhsa-runtime64
 
 # The POCL_DEBUG output requires the clock_gettime and older glibs
 # have it in a separate lib.
 # Mac doesnt have lrt, or clock_gettime
- at HAVE_CLOCK_GETTIME_TRUE@am__append_3 = -lrt
- at BUILD_SPU_TRUE@am__append_4 = -lspe2
- at LLVM_3_6_TRUE@am__append_5 = -lclangToolingCore 
+ at HAVE_CLOCK_GETTIME_TRUE@am__append_4 = -lrt
+ at BUILD_SPU_TRUE@am__append_5 = -lspe2
+ at LLVM_3_6_TRUE@am__append_6 = -lclangToolingCore 
 subdir = lib/CL
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -133,6 +142,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -207,10 +217,11 @@ am__libOpenCL_la_SOURCES_DIST = clCreateContextFromType.c \
 	clGetSupportedImageFormats.c clGetExtensionFunctionAddress.c \
 	clIcdGetPlatformIDsKHR.c clCreateSubDevices.c \
 	clReleaseDevice.c clRetainDevice.c pocl_cl.h pocl_util.c \
-	pocl_util.h pocl_image_util.c pocl_image_util.h pocl_icd.h \
-	pocl_intfn.h pocl_llvm.h pocl_runtime_config.c \
-	pocl_runtime_config.h pocl_mem_management.c \
-	pocl_mem_management.h pocl_hash.c pocl_hash.h
+	pocl_util.h pocl_queue_util.c pocl_queue_util.h \
+	pocl_image_util.c pocl_image_util.h pocl_icd.h pocl_intfn.h \
+	pocl_llvm.h pocl_runtime_config.c pocl_runtime_config.h \
+	pocl_mem_management.c pocl_mem_management.h pocl_hash.c \
+	pocl_hash.h pocl_cache.c pocl_debug.c pocl_debug.h
 am__objects_1 = libOpenCL_la-clCreateContextFromType.lo \
 	libOpenCL_la-clReleaseContext.lo \
 	libOpenCL_la-clRetainContext.lo \
@@ -286,9 +297,11 @@ am__objects_1 = libOpenCL_la-clCreateContextFromType.lo \
 	libOpenCL_la-clIcdGetPlatformIDsKHR.lo \
 	libOpenCL_la-clCreateSubDevices.lo \
 	libOpenCL_la-clReleaseDevice.lo libOpenCL_la-clRetainDevice.lo \
-	libOpenCL_la-pocl_util.lo libOpenCL_la-pocl_image_util.lo \
+	libOpenCL_la-pocl_util.lo libOpenCL_la-pocl_queue_util.lo \
+	libOpenCL_la-pocl_image_util.lo \
 	libOpenCL_la-pocl_runtime_config.lo \
-	libOpenCL_la-pocl_mem_management.lo libOpenCL_la-pocl_hash.lo
+	libOpenCL_la-pocl_mem_management.lo libOpenCL_la-pocl_hash.lo \
+	libOpenCL_la-pocl_cache.lo libOpenCL_la-pocl_debug.lo
 @BUILD_ICD_FALSE at am_libOpenCL_la_OBJECTS = $(am__objects_1)
 libOpenCL_la_OBJECTS = $(am_libOpenCL_la_OBJECTS)
 AM_V_lt = $(am__v_lt_ at AM_V@)
@@ -368,9 +381,10 @@ am_libpocl_la_OBJECTS = libpocl_la-clCreateContextFromType.lo \
 	libpocl_la-clIcdGetPlatformIDsKHR.lo \
 	libpocl_la-clCreateSubDevices.lo libpocl_la-clReleaseDevice.lo \
 	libpocl_la-clRetainDevice.lo libpocl_la-pocl_util.lo \
-	libpocl_la-pocl_image_util.lo \
+	libpocl_la-pocl_queue_util.lo libpocl_la-pocl_image_util.lo \
 	libpocl_la-pocl_runtime_config.lo \
-	libpocl_la-pocl_mem_management.lo libpocl_la-pocl_hash.lo
+	libpocl_la-pocl_mem_management.lo libpocl_la-pocl_hash.lo \
+	libpocl_la-pocl_cache.lo libpocl_la-pocl_debug.lo
 libpocl_la_OBJECTS = $(am_libpocl_la_OBJECTS)
 libpocl_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
@@ -479,6 +493,7 @@ am__define_uniq_tagged_files = \
 ETAGS = etags
 CTAGS = ctags
 DIST_SUBDIRS = $(SUBDIRS)
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 am__relativize = \
   dir0=`pwd`; \
@@ -555,6 +570,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -591,6 +609,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -793,27 +812,29 @@ libpocl_la_SOURCES = clCreateContextFromType.c	\
                    clRetainDevice.c \
                    pocl_cl.h \
                    pocl_util.c pocl_util.h \
+                   pocl_queue_util.c pocl_queue_util.h \
                    pocl_image_util.c pocl_image_util.h \
                    pocl_icd.h \
                    pocl_intfn.h \
                    pocl_llvm.h \
                    pocl_runtime_config.c pocl_runtime_config.h \
                    pocl_mem_management.c pocl_mem_management.h \
-                   pocl_hash.c pocl_hash.h
+                   pocl_hash.c pocl_hash.h pocl_cache.c \
+                   pocl_debug.c pocl_debug.h
 
 libpocl_la_CPPFLAGS = -I$(top_srcdir)/fix-include -I$(top_srcdir)/fix-include/OpenCL -I$(top_srcdir)/include -I$(top_srcdir)/lib/CL/devices $(OCL_ICD_CFLAGS)
 libpocl_la_LDFLAGS = -lltdl @PTHREAD_CFLAGS@ -version-info \
-	${LIB_VERSION} $(am__append_2) @LLVM_LDFLAGS@ \
+	${LIB_VERSION} $(am__append_2) $(am__append_3) @LLVM_LDFLAGS@ \
 	-L${top_builddir}/lib/CL/ @ICD_LD_FLAGS@
 libpocl_la_LIBADD = devices/libpocl-devices.la ${LTDL_LIBS} \
-	$(am__append_3) $(am__append_4) libpoclllvm.la \
+	$(am__append_4) $(am__append_5) libpoclllvm.la \
 	${top_builddir}/lib/llvmopencl/libllvmpasses.la \
 	-lclangFrontend -lclangDriver -lclangParse -lclangSema \
 	-lclangEdit -lclangLex -lclangSerialization -lclangAST \
 	-lclangBasic -lclangFrontendTool -lclangRewriteFrontend \
 	-lclangStaticAnalyzerFrontend -lclangStaticAnalyzerCore \
 	-lclangAnalysis -lclangCodeGen -lclangAST -lstdc++ -lm \
-	@LLVM_LIBS@ $(am__append_5) -lclangASTMatchers -lclangBasic
+	@LLVM_LIBS@ $(am__append_6) -lclangASTMatchers -lclangBasic
 
 #Kludge: compile pocl_llvm_api.cc into a library of its own.
 #The source file is necessarely a C++ file, and having a C++ file
@@ -829,9 +850,11 @@ AM_CXXFLAGS = @PTHREAD_CFLAGS@ @LLVM_CXX_FLAGS@
 @BUILD_ICD_FALSE at libOpenCL_la_CPPFLAGS = ${libpocl_la_CPPFLAGS}
 @BUILD_ICD_FALSE at libOpenCL_la_LDFLAGS = ${libpocl_la_LDFLAGS}
 @BUILD_ICD_FALSE at libOpenCL_la_LIBADD = ${libpocl_la_LIBADD}
-CLEANFILES = libOpenCL.la
+CLEANFILES = libpocl.la libOpenCL.la kernellib_hash.h
 EXTRA_DIST = CMakeLists.txt
-all: all-recursive
+BUILT_SOURCES = kernellib_hash.h
+all: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) all-recursive
 
 .SUFFIXES:
 .SUFFIXES: .c .cc .lo .o .obj
@@ -847,7 +870,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/CL/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign lib/CL/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -1010,9 +1032,12 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libOpenCL_la-clSetUserEventStatus.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libOpenCL_la-clUnloadCompiler.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libOpenCL_la-clWaitForEvents.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libOpenCL_la-pocl_cache.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libOpenCL_la-pocl_debug.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libOpenCL_la-pocl_hash.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libOpenCL_la-pocl_image_util.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libOpenCL_la-pocl_mem_management.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libOpenCL_la-pocl_queue_util.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libOpenCL_la-pocl_runtime_config.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libOpenCL_la-pocl_util.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libpocl_la-clBuildProgram.Plo at am__quote@
@@ -1098,9 +1123,12 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libpocl_la-clSetUserEventStatus.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libpocl_la-clUnloadCompiler.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libpocl_la-clWaitForEvents.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libpocl_la-pocl_cache.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libpocl_la-pocl_debug.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libpocl_la-pocl_hash.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libpocl_la-pocl_image_util.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libpocl_la-pocl_mem_management.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libpocl_la-pocl_queue_util.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libpocl_la-pocl_runtime_config.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libpocl_la-pocl_util.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libpoclllvm_la-pocl_llvm_api.Plo at am__quote@
@@ -1714,6 +1742,13 @@ libOpenCL_la-pocl_util.lo: pocl_util.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libOpenCL_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libOpenCL_la-pocl_util.lo `test -f 'pocl_util.c' || echo '$(srcdir)/'`pocl_util.c
 
+libOpenCL_la-pocl_queue_util.lo: pocl_queue_util.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libOpenCL_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libOpenCL_la-pocl_queue_util.lo -MD -MP -MF $(DEPDIR)/libOpenCL_la-pocl_queue_util.Tpo -c -o libOpenCL_la-pocl_queue_util.lo `test -f 'pocl_queue_util.c' || echo '$(srcdir)/'`pocl_queue_util.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libOpenCL_la-pocl_queue_util.Tpo $(DEPDIR)/libOpenCL_la-pocl_queue_util.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='pocl_queue_util.c' object='libOpenCL_la-pocl_queue_util.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libOpenCL_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libOpenCL_la-pocl_queue_util.lo `test -f 'pocl_queue_util.c' || echo '$(srcdir)/'`pocl_queue_util.c
+
 libOpenCL_la-pocl_image_util.lo: pocl_image_util.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libOpenCL_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libOpenCL_la-pocl_image_util.lo -MD -MP -MF $(DEPDIR)/libOpenCL_la-pocl_image_util.Tpo -c -o libOpenCL_la-pocl_image_util.lo `test -f 'pocl_image_util.c' || echo '$(srcdir)/'`pocl_image_util.c
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libOpenCL_la-pocl_image_util.Tpo $(DEPDIR)/libOpenCL_la-pocl_image_util.Plo
@@ -1742,6 +1777,20 @@ libOpenCL_la-pocl_hash.lo: pocl_hash.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libOpenCL_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libOpenCL_la-pocl_hash.lo `test -f 'pocl_hash.c' || echo '$(srcdir)/'`pocl_hash.c
 
+libOpenCL_la-pocl_cache.lo: pocl_cache.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libOpenCL_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libOpenCL_la-pocl_cache.lo -MD -MP -MF $(DEPDIR)/libOpenCL_la-pocl_cache.Tpo -c -o libOpenCL_la-pocl_cache.lo `test -f 'pocl_cache.c' || echo '$(srcdir)/'`pocl_cache.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libOpenCL_la-pocl_cache.Tpo $(DEPDIR)/libOpenCL_la-pocl_cache.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='pocl_cache.c' object='libOpenCL_la-pocl_cache.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libOpenCL_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libOpenCL_la-pocl_cache.lo `test -f 'pocl_cache.c' || echo '$(srcdir)/'`pocl_cache.c
+
+libOpenCL_la-pocl_debug.lo: pocl_debug.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libOpenCL_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libOpenCL_la-pocl_debug.lo -MD -MP -MF $(DEPDIR)/libOpenCL_la-pocl_debug.Tpo -c -o libOpenCL_la-pocl_debug.lo `test -f 'pocl_debug.c' || echo '$(srcdir)/'`pocl_debug.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libOpenCL_la-pocl_debug.Tpo $(DEPDIR)/libOpenCL_la-pocl_debug.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='pocl_debug.c' object='libOpenCL_la-pocl_debug.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libOpenCL_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libOpenCL_la-pocl_debug.lo `test -f 'pocl_debug.c' || echo '$(srcdir)/'`pocl_debug.c
+
 libpocl_la-clCreateContextFromType.lo: clCreateContextFromType.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpocl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpocl_la-clCreateContextFromType.lo -MD -MP -MF $(DEPDIR)/libpocl_la-clCreateContextFromType.Tpo -c -o libpocl_la-clCreateContextFromType.lo `test -f 'clCreateContextFromType.c' || echo '$(srcdir)/'`clCreateContextFromType.c
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libpocl_la-clCreateContextFromType.Tpo $(DEPDIR)/libpocl_la-clCreateContextFromType.Plo
@@ -2330,6 +2379,13 @@ libpocl_la-pocl_util.lo: pocl_util.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpocl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpocl_la-pocl_util.lo `test -f 'pocl_util.c' || echo '$(srcdir)/'`pocl_util.c
 
+libpocl_la-pocl_queue_util.lo: pocl_queue_util.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpocl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpocl_la-pocl_queue_util.lo -MD -MP -MF $(DEPDIR)/libpocl_la-pocl_queue_util.Tpo -c -o libpocl_la-pocl_queue_util.lo `test -f 'pocl_queue_util.c' || echo '$(srcdir)/'`pocl_queue_util.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libpocl_la-pocl_queue_util.Tpo $(DEPDIR)/libpocl_la-pocl_queue_util.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='pocl_queue_util.c' object='libpocl_la-pocl_queue_util.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpocl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpocl_la-pocl_queue_util.lo `test -f 'pocl_queue_util.c' || echo '$(srcdir)/'`pocl_queue_util.c
+
 libpocl_la-pocl_image_util.lo: pocl_image_util.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpocl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpocl_la-pocl_image_util.lo -MD -MP -MF $(DEPDIR)/libpocl_la-pocl_image_util.Tpo -c -o libpocl_la-pocl_image_util.lo `test -f 'pocl_image_util.c' || echo '$(srcdir)/'`pocl_image_util.c
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libpocl_la-pocl_image_util.Tpo $(DEPDIR)/libpocl_la-pocl_image_util.Plo
@@ -2358,6 +2414,20 @@ libpocl_la-pocl_hash.lo: pocl_hash.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpocl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpocl_la-pocl_hash.lo `test -f 'pocl_hash.c' || echo '$(srcdir)/'`pocl_hash.c
 
+libpocl_la-pocl_cache.lo: pocl_cache.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpocl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpocl_la-pocl_cache.lo -MD -MP -MF $(DEPDIR)/libpocl_la-pocl_cache.Tpo -c -o libpocl_la-pocl_cache.lo `test -f 'pocl_cache.c' || echo '$(srcdir)/'`pocl_cache.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libpocl_la-pocl_cache.Tpo $(DEPDIR)/libpocl_la-pocl_cache.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='pocl_cache.c' object='libpocl_la-pocl_cache.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpocl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpocl_la-pocl_cache.lo `test -f 'pocl_cache.c' || echo '$(srcdir)/'`pocl_cache.c
+
+libpocl_la-pocl_debug.lo: pocl_debug.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpocl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpocl_la-pocl_debug.lo -MD -MP -MF $(DEPDIR)/libpocl_la-pocl_debug.Tpo -c -o libpocl_la-pocl_debug.lo `test -f 'pocl_debug.c' || echo '$(srcdir)/'`pocl_debug.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libpocl_la-pocl_debug.Tpo $(DEPDIR)/libpocl_la-pocl_debug.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='pocl_debug.c' object='libpocl_la-pocl_debug.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpocl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpocl_la-pocl_debug.lo `test -f 'pocl_debug.c' || echo '$(srcdir)/'`pocl_debug.c
+
 .cc.o:
 @am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
 @am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@@ -2547,14 +2617,16 @@ distdir: $(DISTFILES)
 	  fi; \
 	done
 check-am: all-am
-check: check-recursive
+check: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) check-recursive
 all-am: Makefile $(LTLIBRARIES)
 installdirs: installdirs-recursive
 installdirs-am:
 	for dir in "$(DESTDIR)$(libdir)"; do \
 	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
 	done
-install: install-recursive
+install: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) install-recursive
 install-exec: install-exec-recursive
 install-data: install-data-recursive
 uninstall: uninstall-recursive
@@ -2585,6 +2657,7 @@ distclean-generic:
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
 	@echo "it deletes files that may require special tools to rebuild."
+	-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
 clean: clean-recursive
 
 clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
@@ -2656,7 +2729,8 @@ ps-am:
 
 uninstall-am: uninstall-libLTLIBRARIES
 
-.MAKE: $(am__recursive_targets) install-am install-strip
+.MAKE: $(am__recursive_targets) all check install install-am \
+	install-strip
 
 .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \
 	check-am clean clean-generic clean-libLTLIBRARIES \
@@ -2674,6 +2748,14 @@ uninstall-am: uninstall-libLTLIBRARIES
 	pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \
 	uninstall-libLTLIBRARIES
 
+.PRECIOUS: Makefile
+
+
+FORCE:
+
+kernellib_hash.h: FORCE
+	echo '#define POCL_KERNELLIB_SHA1 "'`sha1sum ../../include/_kernel.h ../../include/_kernel_c.h ../../include/pocl_types.h ../../include/pocl_features.h ../kernel/*.cl ../kernel/*.c ../kernel/vecmathlib-pocl/*.cl ../kernel/vecmathlib-pocl/*.cc | sha1sum -`'"' > kernellib_hash.new
+	cmp kernellib_hash.new kernellib_hash.h || mv kernellib_hash.new kernellib_hash.h
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/lib/CL/clBuildProgram.c b/lib/CL/clBuildProgram.c
index 00c2e2b..1c79974 100644
--- a/lib/CL/clBuildProgram.c
+++ b/lib/CL/clBuildProgram.c
@@ -34,14 +34,15 @@
 #  include "vccompat.hpp"
 #endif
 #include "pocl_llvm.h"
-#include "pocl_hash.h"
 #include "pocl_util.h"
+#include "pocl_file_util.h"
+#include "pocl_cache.h"
 #include "config.h"
 #include "pocl_runtime_config.h"
 
 /* supported compiler parameters which should pass to the frontend directly
    by using -Xclang */
-static char cl_parameters[] = 
+static const char cl_parameters[] =
   "-cl-single-precision-constant "
   "-cl-fp32-correctly-rounded-divide-sqrt "
   "-cl-opt-disable "
@@ -53,64 +54,41 @@ static char cl_parameters[] =
   "-cl-std=CL1.1 "
   "-cl-kernel-arg-info "
   "-w "
-  "-g ";
+  "-g "
+  "-Werror ";
 
-static char cl_parameters_not_yet_supported_by_clang[] = 
+static const char cl_parameters_not_yet_supported_by_clang[] =
   "-cl-strict-aliasing "
   "-cl-denorms-are-zero "
   "-cl-no-signed-zeros ";
 
 #define MEM_ASSERT(x, err_jmp) do{ if (x){errcode = CL_OUT_OF_HOST_MEMORY;goto err_jmp;}} while(0)
-#define COMMAND_LENGTH 4096
 
-static inline void
-build_program_compute_hash(cl_program program)
-{
-  SHA1_CTX hash_ctx;
-  int total_binary_size, i;
-
-  pocl_SHA1_Init(&hash_ctx);
-
-  if (program->source)
-    {
-      pocl_SHA1_Update(&hash_ctx, (uint8_t*) program->source, strlen(program->source));
-    }
-  else  /* Program was created with clCreateProgramWithBinary() */
-    {
-      total_binary_size = 0;
-      for (i = 0; i < program->num_devices; ++i)
-        total_binary_size += program->binary_sizes[i];
-
-      /* Binaries are stored in continuous chunk of memory starting from binaries[0] */
-      pocl_SHA1_Update(&hash_ctx, (uint8_t*) program->binaries[0], total_binary_size);
-    }
-
-  if (program->compiler_options)
-    pocl_SHA1_Update(&hash_ctx, (uint8_t*) program->compiler_options, 
-                     strlen(program->compiler_options));
-
-  /* The kernel compiler work-group function method affects the
-     produced binary heavily. */
-  const char *wg_method = 
-    pocl_get_string_option ("POCL_WORK_GROUP_METHOD", "");
-
-  pocl_SHA1_Update (&hash_ctx, (uint8_t*) wg_method, strlen (wg_method));
-  pocl_SHA1_Update (&hash_ctx, (uint8_t*) PACKAGE_VERSION, 
-                    strlen (PACKAGE_VERSION));
-  pocl_SHA1_Update (&hash_ctx, (uint8_t*) LLVM_VERSION, 
-                    strlen (LLVM_VERSION));
-  pocl_SHA1_Update (&hash_ctx, (uint8_t*) POCL_BUILD_TIMESTAMP, 
-                    strlen (POCL_BUILD_TIMESTAMP));
-  /*devices may include their own information to hash */
-  for (i = 0; i < program->num_devices; ++i)
-    {
-      if (program->devices[i]->ops->build_hash)
-        program->devices[i]->ops->build_hash (program->devices[i]->data, 
-                                              &hash_ctx);
-    }
-  
-  pocl_SHA1_Final(&hash_ctx, program->build_hash);
-}
+// append token, growing modded_options, if necessary, by max(strlen(token)+1, 256)
+#define APPEND_TOKEN() do { \
+  size_t needed = strlen(token) + 1; \
+  if (size <= (i + needed)) { \
+    size_t grow_by = needed > 256 ? needed : 256; \
+    char *grown_ptr = (char *)realloc(modded_options, size + grow_by); \
+    if (grown_ptr == NULL) { \
+      /* realloc failed, free modded_options and return */ \
+      errcode = CL_OUT_OF_HOST_MEMORY; \
+      goto ERROR_CLEAN_OPTIONS; \
+    } \
+    modded_options = grown_ptr; \
+    size += grow_by; \
+  } \
+  i += needed; \
+  strcat (modded_options, token); \
+  strcat (modded_options, " "); \
+} while (0)
+
+#define APPEND_TO_MAIN_BUILD_LOG(...)  \
+  POCL_MSG_ERR(__VA_ARGS__);   \
+  {                            \
+    size_t l = strlen(program->main_build_log); \
+    snprintf(program->main_build_log + l, (640 - l), __VA_ARGS__); \
+  }
 
 CL_API_ENTRY cl_int CL_API_CALL
 POname(clBuildProgram)(cl_program program,
@@ -122,41 +100,42 @@ POname(clBuildProgram)(cl_program program,
                        void *user_data) 
 CL_API_SUFFIX__VERSION_1_0
 {
-  char device_cachedir[POCL_FILENAME_LENGTH];
-  char binary_file_name[POCL_FILENAME_LENGTH];
-  char filename_str[POCL_FILENAME_LENGTH];
-  FILE *binary_file;
-  int fd;
-  size_t n;
+  char program_bc_path[POCL_FILENAME_LENGTH];
   int errcode;
-  int i;
+  size_t i;
   int error;
-  size_t length;
-  unsigned char *binary;
-  unsigned real_num_devices;
-  const cl_device_id *real_device_list;
-  /* The default build script for .cl files. */
-  int device_i = 0;
+  uint64_t fsize;
+  cl_device_id * unique_devlist = NULL;
+  char *binary = NULL;
+  unsigned device_i = 0, actually_built = 0;
   const char *user_options = "";
-  char *temp_options;
+  char *temp_options = NULL;
   char *modded_options = NULL;
-  char *token;
-  char *saveptr;
-  char *str = NULL;
+  char *token = NULL;
+  char *saveptr = NULL;
+  void* cache_lock = NULL;
+
+  POCL_RETURN_ERROR_COND((program == NULL), CL_INVALID_PROGRAM);
 
-  POCL_GOTO_ERROR_COND((program == NULL), CL_INVALID_PROGRAM);
+  POCL_GOTO_ERROR_COND((num_devices > 0 && device_list == NULL), CL_INVALID_VALUE);
+  POCL_GOTO_ERROR_COND((num_devices == 0 && device_list != NULL), CL_INVALID_VALUE);
 
   POCL_GOTO_ERROR_COND((pfn_notify == NULL && user_data != NULL), CL_INVALID_VALUE);
 
   POCL_LOCK_OBJ(program);
 
   POCL_GOTO_ERROR_ON(program->kernels, CL_INVALID_OPERATION, "Program already has kernels\n");
-  
+
+  POCL_GOTO_ERROR_ON((program->source == NULL && program->binaries == NULL),
+    CL_INVALID_PROGRAM, "Program doesn't have sources or binaries! You need "
+                        "to call clCreateProgramWith{Binary|Source} first\n");
+
+  program->main_build_log[0] = 0;
+
   if (options != NULL)
     {
-      int size = 512; 
-      int i = 1; /* terminating char */
-      char *swap_tmp;
+      size_t size = 512;
+      size_t i = 1; /* terminating char */
       modded_options = (char*) calloc (size, 1);
       temp_options = strdup (options);
       token = strtok_r (temp_options, " ", &saveptr);
@@ -164,7 +143,7 @@ CL_API_SUFFIX__VERSION_1_0
         {
           /* check if parameter is supported compiler parameter */
           if (memcmp (token, "-cl", 3) == 0 || memcmp (token, "-w", 2) == 0 
-              || memcmp(token, "-g", 2) == 0)
+              || memcmp(token, "-g", 2) == 0 || memcmp(token, "-Werror", 7) == 0)
             {
               if (strstr (cl_parameters, token))
                 {
@@ -173,32 +152,20 @@ CL_API_SUFFIX__VERSION_1_0
                 }
               else if (strstr (cl_parameters_not_yet_supported_by_clang, token))
                 {
-                  POCL_MSG_ERR("Build option isnt yet supported by clang: %s\n", token);
+                  APPEND_TO_MAIN_BUILD_LOG("Build option isnt yet supported by clang: %s\n", token);
                   token = strtok_r (NULL, " ", &saveptr);  
                   continue;
                 }
               else
                 {
-                  POCL_MSG_ERR("Invalid build option: %s\n", token);
+                  APPEND_TO_MAIN_BUILD_LOG("Invalid build option: %s\n", token);
                   errcode = CL_INVALID_BUILD_OPTIONS;
                   goto ERROR_CLEAN_OPTIONS;
                 }
             }
           else if (memcmp (token, "-D", 2) == 0 || memcmp (token, "-I", 2) == 0)
             {
-              if (size <= (i + strlen (token) + 1))
-                {
-                  swap_tmp = modded_options;
-                  modded_options = (char*) malloc (size + 256);
-                  if (modded_options == NULL)
-                    return CL_OUT_OF_HOST_MEMORY;
-                  memcpy (modded_options, swap_tmp, size);
-                  POCL_MEM_FREE(swap_tmp);
-                  size += 256;
-                }
-              i += strlen (token) + 1;
-              strcat (modded_options, token);
-              strcat (modded_options, " ");
+              APPEND_TOKEN();
               /* if there is a space in between, then next token is part 
                  of the option */
               if (strlen (token) == 2)
@@ -211,24 +178,12 @@ CL_API_SUFFIX__VERSION_1_0
             }
           else
             {
-              POCL_MSG_ERR("Invalid build option: %s\n", token);
+              APPEND_TO_MAIN_BUILD_LOG("Invalid build option: %s\n", token);
               errcode = CL_INVALID_BUILD_OPTIONS;
               goto ERROR_CLEAN_OPTIONS;
             }
-          if (size <= (i + strlen (token) + 1))
-            {
-              swap_tmp = modded_options;
-              modded_options = (char*) malloc (size + 256);
-              if (modded_options == NULL)
-                return CL_OUT_OF_HOST_MEMORY;
-              memcpy (modded_options, swap_tmp, size); 
-              POCL_MEM_FREE(swap_tmp);
-              size += 256;
-            }
-          i += strlen (token) + 1;
-          strcat (modded_options, token);
-          strcat (modded_options, " ");
-          token = strtok_r (NULL, " ", &saveptr);  
+          APPEND_TOKEN();
+          token = strtok_r (NULL, " ", &saveptr);
         }
       POCL_MEM_FREE(temp_options);
       user_options = modded_options;
@@ -237,48 +192,20 @@ CL_API_SUFFIX__VERSION_1_0
   else
     {
       POCL_MEM_FREE(program->compiler_options);
-    }  
-
-  POCL_GOTO_ERROR_ON((program->source == NULL && program->binaries == NULL),
-    CL_INVALID_PROGRAM, "Program doesn't have sources or binaries! You need "
-                        "to call clCreateProgramWith{Binary|Source} first\n");
+    }
 
-  POCL_GOTO_ERROR_COND((num_devices > 0 && device_list == NULL), CL_INVALID_VALUE);
-  POCL_GOTO_ERROR_COND((num_devices == 0 && device_list != NULL), CL_INVALID_VALUE);
-      
   if (num_devices == 0)
     {
-      real_num_devices = program->num_devices;
-      real_device_list = program->devices;
-    } else
-    {
-      real_num_devices = num_devices;
-      real_device_list = device_list;
+      num_devices = program->num_devices;
+      device_list = program->devices;
     }
-
-  build_program_compute_hash(program);
-  program->cache_dir = pocl_create_program_cache_dir(program);
-
-  if (program->source)
+  else
     {
-      /* Realloc for every clBuildProgram call
-       * since clBuildProgram can be called multiple times
-       * with different options and device count
-       */
-      length = sizeof(size_t) * real_num_devices;
-      program->binary_sizes = (size_t *) realloc(program->binary_sizes, length);
-      MEM_ASSERT(program->binary_sizes == NULL, ERROR_CLEAN_PROGRAM);
-      memset(program->binary_sizes, 0, length);
-
-      length = sizeof(unsigned char*) * real_num_devices;
-      program->binaries = (unsigned char**) realloc(program->binaries, length);
-      MEM_ASSERT(program->binaries == NULL, ERROR_CLEAN_PROGRAM);
-      memset(program->binaries, 0, length);
-
-      length = sizeof(void*) * real_num_devices;
-      program->llvm_irs = (void**) realloc (program->llvm_irs, length);
-      MEM_ASSERT(program->llvm_irs == NULL, ERROR_CLEAN_PROGRAM);
-      memset(program->llvm_irs, 0, length);
+      // convert subdevices to devices and remove duplicates
+      cl_uint real_num_devices = 0;
+      unique_devlist = pocl_unique_device_list(device_list, num_devices, &real_num_devices);
+      num_devices = real_num_devices;
+      device_list = unique_devlist;
     }
 
   POCL_MSG_PRINT_INFO("building program with options %s\n",
@@ -286,82 +213,76 @@ CL_API_SUFFIX__VERSION_1_0
 
   /* Build the fully linked non-parallel bitcode for all
          devices. */
-  for (device_i = 0; device_i < real_num_devices; ++device_i)
+  for (device_i = 0; device_i < program->num_devices; ++device_i)
     {
-      cl_device_id device = real_device_list[device_i];
-      snprintf(device_cachedir, POCL_FILENAME_LENGTH, "%s/%s",
-               program->cache_dir, device->cache_dir_name);
-
-      if (access (device_cachedir, F_OK) != 0)
-        mkdir(device_cachedir, S_IRWXU);
+      cl_device_id device = program->devices[device_i];
 
-      pocl_check_and_invalidate_cache(program, device_i, device_cachedir);
+      /* find the device in the supplied devices-to-build-for list */
+      int found = 0;
+      for (i = 0; i < num_devices; ++i)
+          if (device_list[i] == device) found = 1;
+      if (!found) continue;
 
-      snprintf(binary_file_name, POCL_FILENAME_LENGTH, "%s/%s",
-               device_cachedir, POCL_PROGRAM_BC_FILENAME);
-      snprintf(filename_str, POCL_FILENAME_LENGTH, "%s/%s",
-               program->cache_dir, POCL_BUILDLOG_FILENAME);
+      actually_built++;
 
-      /* First call to clBuildProgram. Cache not filled yet */
-      if ((fd = open(binary_file_name, (O_CREAT | O_EXCL | O_WRONLY),
-          (S_IRUSR | S_IWUSR))) >= 0)
+      /* clCreateProgramWithSource */
+      if (program->source)
         {
-          if (program->source)
+          error = pocl_llvm_build_program(program, device_i, user_options,
+                                          &cache_lock, program_bc_path);
+          if (error != 0)
             {
-              error = pocl_llvm_build_program(program, device, device_i,
-                        program->cache_dir, binary_file_name, device_cachedir, user_options, fd);
-              if (error != 0)
-                {
-                  unlink(binary_file_name);
-                  errcode = CL_BUILD_PROGRAM_FAILURE;
-                  goto ERROR_CLEAN_BINARIES;
-                }
+              errcode = CL_BUILD_PROGRAM_FAILURE;
+              goto ERROR_CLEAN_BINARIES;
             }
-          else if (program->binaries[device_i])
-            write(fd, program->binaries[device_i],
-                  program->binary_sizes[device_i]);
-          close(fd);
+          assert(cache_lock);
         }
-      else if (pocl_read_text_file(filename_str, &str))
-        {
-          fputs(str, stderr);
-          POCL_MEM_FREE(str);
+      /* clCreateProgramWithBinaries */
+      else if (program->binaries[device_i]) {
+            pocl_cache_create_program_cachedir(program, device_i, NULL, 0,
+                                               program_bc_path, &cache_lock);
+            assert(cache_lock);
+            errcode = pocl_write_file(program_bc_path, (char*)program->binaries[device_i],
+                          (uint64_t)program->binary_sizes[device_i], 0, 0);
+            POCL_GOTO_ERROR_ON(errcode, CL_BUILD_PROGRAM_FAILURE,
+                               "Failed to write binaries to program.bc\n");
         }
+      /* fail */
+      else
+        POCL_GOTO_ERROR_ON(1, CL_INVALID_BINARY, "Don't have sources and also no "
+                           "binaries for device %s - can't build the program\n",
+                           device->short_name);
 
       /* Read binaries from program.bc to memory */
       if (program->binaries[device_i] == NULL)
         {
-          binary_file = fopen(binary_file_name, "r");
-          MEM_ASSERT(binary_file == NULL, ERROR_CLEAN_PROGRAM);
+          errcode = pocl_read_file(program_bc_path, &binary, &fsize);
+          POCL_GOTO_ERROR_ON(errcode, CL_BUILD_ERROR, "Failed to read binaries from program.bc to memory: %s\n", program_bc_path);
 
-          fseek(binary_file, 0, SEEK_END);
-          program->binary_sizes[device_i] = ftell(binary_file);
-          fseek(binary_file, 0, SEEK_SET);
+          program->binary_sizes[device_i] = (size_t)fsize;
+          program->binaries[device_i] = (unsigned char *)binary;
+        }
 
-          binary = (unsigned char *) malloc(program->binary_sizes[device_i]);
-          MEM_ASSERT(binary == NULL, ERROR_CLEAN_PROGRAM);
+      if (program->llvm_irs[device_i] == NULL)
+          pocl_update_program_llvm_irs(program, device_i, device);
 
-          n = fread(binary, 1, program->binary_sizes[device_i], binary_file);
-          MEM_ASSERT((n < program->binary_sizes[device_i]), ERROR_CLEAN_PROGRAM);
-          program->binaries[device_i] = binary;
-        }
+      pocl_cache_update_program_last_access(program, device_i);
 
-      if (program->llvm_irs[device->dev_id] == NULL)
-        {
-          pocl_update_program_llvm_irs(program,
-                                       device, binary_file_name);
-        }
+      pocl_cache_release_lock(cache_lock);
+      cache_lock = NULL;
     }
 
+  POCL_GOTO_ERROR_ON((actually_built < num_devices), CL_BUILD_PROGRAM_FAILURE,
+                     "Some of the devices on the argument-supplied list are"
+                     "not available for the program, or do not exist\n")
+
   /* Maintain a 'last_accessed' file in every program's
    * cache directory. Will be useful for cache pruning script
    * that flushes old directories based on LRU */
-  snprintf(filename_str, POCL_FILENAME_LENGTH, "%s/%s",
-           program->cache_dir, POCL_LAST_ACCESSED_FILENAME);
-  pocl_touch_file(filename_str);
 
   program->build_status = CL_BUILD_SUCCESS;
   POCL_UNLOCK_OBJ(program);
+  POCL_MEM_FREE(unique_devlist);
   return CL_SUCCESS;
 
   /* Set pointers to NULL during cleanup so that clProgramRelease won't
@@ -372,13 +293,14 @@ ERROR_CLEAN_BINARIES:
   {
     POCL_MEM_FREE(program->binaries[i]);
   }
-ERROR_CLEAN_PROGRAM:
   POCL_MEM_FREE(program->binaries);
   POCL_MEM_FREE(program->binary_sizes);
 ERROR_CLEAN_OPTIONS:
   POCL_MEM_FREE(modded_options);
 ERROR:
+  POCL_MEM_FREE(unique_devlist);
   program->build_status = CL_BUILD_ERROR;
+  pocl_cache_release_lock(cache_lock);
   POCL_UNLOCK_OBJ(program);
   return errcode;
 }
diff --git a/lib/CL/clCreateBuffer.c b/lib/CL/clCreateBuffer.c
index dbd31ed..6c94124 100644
--- a/lib/CL/clCreateBuffer.c
+++ b/lib/CL/clCreateBuffer.c
@@ -115,7 +115,7 @@ POname(clCreateBuffer)(cl_context context,
   /* Store the per device buffer pointers always to a known
      location in the buffer (dev_id), even though the context
      might not contain all the devices. */
-  mem->device_ptrs = 
+  mem->device_ptrs =
     (pocl_mem_identifier*) malloc(pocl_num_devices * sizeof(pocl_mem_identifier));
   if (mem->device_ptrs == NULL)
     {
diff --git a/lib/CL/clCreateCommandQueue.c b/lib/CL/clCreateCommandQueue.c
index 5c59892..ae3011f 100644
--- a/lib/CL/clCreateCommandQueue.c
+++ b/lib/CL/clCreateCommandQueue.c
@@ -23,6 +23,7 @@
 
 #include "pocl_cl.h"
 #include "pocl_util.h"
+#include "pocl_queue_util.h"
 
 CL_API_ENTRY cl_command_queue CL_API_CALL
 POname(clCreateCommandQueue)(cl_context context, 
@@ -30,7 +31,7 @@ POname(clCreateCommandQueue)(cl_context context,
                      cl_command_queue_properties properties,
                      cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0
 {
-  int i;
+  unsigned i;
   int errcode;
   cl_bool found = CL_FALSE;
 
@@ -44,12 +45,12 @@ POname(clCreateCommandQueue)(cl_context context,
 
   for (i=0; i<context->num_devices; i++)
     {
-      if (context->devices[i] == device)
+      if (context->devices[i] == POCL_REAL_DEV(device))
         found = CL_TRUE;
     }
 
   POCL_GOTO_ERROR_ON((found == CL_FALSE), CL_INVALID_DEVICE,
-                                "Could not find device i2An the context\n");
+                                "Could not find device in the context\n");
 
   cl_command_queue command_queue = (cl_command_queue) malloc(sizeof(struct _cl_command_queue));
   if (command_queue == NULL)
@@ -67,6 +68,8 @@ POname(clCreateCommandQueue)(cl_context context,
 
   if (errcode_ret != NULL)
     *errcode_ret = CL_SUCCESS;
+
+  pocl_queue_list_insert(command_queue);
   return command_queue;
 
 ERROR:
diff --git a/lib/CL/clCreateContext.c b/lib/CL/clCreateContext.c
index 7091b9b..4a1f38b 100644
--- a/lib/CL/clCreateContext.c
+++ b/lib/CL/clCreateContext.c
@@ -23,6 +23,7 @@
 
 #include "devices/devices.h"
 #include "pocl_cl.h"
+#include "pocl_util.h"
 #include "pocl_mem_management.h"
 #include <stdlib.h>
 #include <string.h>
@@ -31,7 +32,7 @@ int context_set_properties(cl_context                    context,
                            const cl_context_properties * properties,
                            cl_int *                      errcode)
 {
-  int i;
+  unsigned i;
   int num_properties = 0;
   
   context->properties = NULL;
@@ -122,7 +123,7 @@ POname(clCreateContext)(const cl_context_properties * properties,
                 void *                        user_data,
                 cl_int *                      errcode_ret) CL_API_SUFFIX__VERSION_1_0
 {
-  int i, j;
+  unsigned i;
   cl_device_id device_ptr;
   int errcode = 0;
   cl_context context = NULL;
@@ -149,19 +150,19 @@ POname(clCreateContext)(const cl_context_properties * properties,
     {
       goto ERROR;
     }
-  
-  context->num_devices = num_devices;
-  context->devices = (cl_device_id *) malloc(num_devices * sizeof(cl_device_id));
+
+  context->devices = pocl_unique_device_list(devices, num_devices,
+                                             &context->num_devices);
   if (context->devices == NULL)
     {
       errcode = CL_OUT_OF_HOST_MEMORY;
       goto ERROR;
     }
   
-  j = 0;
-  for (i = 0; i < num_devices; ++i)
+  i = 0;
+  while (i < context->num_devices)
     {
-      device_ptr = devices[i];
+      device_ptr = context->devices[i++];
       if (device_ptr == NULL)
         {
           POCL_MSG_ERR("one of the devices in device list is NULL\n");
@@ -169,14 +170,20 @@ POname(clCreateContext)(const cl_context_properties * properties,
           goto ERROR_CLEAN_CONTEXT_AND_DEVICES;
         }
       
-      if (device_ptr->available == CL_TRUE) 
+      if (device_ptr->available != CL_TRUE)
         {
-          context->devices[j] = device_ptr;
-          ++j;
+          POCL_MSG_WARN("Dropping unavailable device: %s\n", device_ptr->long_name);
+          context->devices[i] = context->devices[--context->num_devices];
         }
       else
-        POCL_MSG_WARN("device not available: %s\n", device_ptr->long_name);
-      POname(clRetainDevice)(device_ptr);
+        POname(clRetainDevice)(device_ptr);
+    }
+
+  if (context->num_devices == 0)
+    {
+      POCL_MSG_PRINT_INFO("Zero devices after dropping the unavailable ones\n");
+      errcode = CL_INVALID_DEVICE;
+      goto ERROR_CLEAN_CONTEXT_AND_DEVICES;
     }
 
   pocl_init_mem_manager ();
diff --git a/lib/CL/clCreateContextFromType.c b/lib/CL/clCreateContextFromType.c
index 5af84d4..8e9494c 100644
--- a/lib/CL/clCreateContextFromType.c
+++ b/lib/CL/clCreateContextFromType.c
@@ -44,6 +44,8 @@ POname(clCreateContextFromType)(const cl_context_properties *properties,
   int i;
   cl_device_id device_ptr;
 
+  POCL_GOTO_ERROR_COND((pfn_notify == NULL && user_data != NULL), CL_INVALID_VALUE);
+
   /* initialize libtool here, LT will be needed when loading the kernels */     
   lt_dlinit();
   pocl_init_devices();
@@ -55,8 +57,6 @@ POname(clCreateContextFromType)(const cl_context_properties *properties,
     goto ERROR;
   }
 
-  POCL_GOTO_ERROR_COND((pfn_notify == NULL && user_data != NULL), CL_INVALID_VALUE);
-
   POCL_INIT_OBJECT(context);
   context->valid = 0;
 
@@ -76,8 +76,8 @@ POname(clCreateContextFromType)(const cl_context_properties *properties,
         } 
       /* Return a dummy context so icd call to clReleaseContext() still
          works. This fixes AMD SDK OpenCL samples to work (as of 2012-12-05). */
-      POCL_MSG_WARN("Couldn't find any device of type %lu; returning \
-                          a dummy context with 0 devices\n", (unsigned long)device_type);
+      POCL_MSG_WARN("Couldn't find any device of type %lu; returning "
+                          "a dummy context with 0 devices\n", (unsigned long)device_type);
       return context;
     }
 
diff --git a/lib/CL/clCreateImage.c b/lib/CL/clCreateImage.c
index d16ba55..e0998df 100644
--- a/lib/CL/clCreateImage.c
+++ b/lib/CL/clCreateImage.c
@@ -36,10 +36,10 @@ CL_API_SUFFIX__VERSION_1_2
     unsigned i;
     cl_uint num_entries = 0;
     cl_image_format *supported_image_formats;
-    int size;
+    size_t size;
     int errcode;
-    int row_pitch;
-    int slice_pitch;
+    size_t row_pitch;
+    size_t slice_pitch;
     int elem_size;
     int channels;
 
diff --git a/lib/CL/clCreateKernel.c b/lib/CL/clCreateKernel.c
index 786ee73..98ddd0b 100644
--- a/lib/CL/clCreateKernel.c
+++ b/lib/CL/clCreateKernel.c
@@ -23,6 +23,8 @@
 */
 
 #include "pocl_cl.h"
+#include "pocl_file_util.h"
+#include "pocl_cache.h"
 #include "pocl_llvm.h"
 #include <string.h>
 #include <sys/stat.h>
@@ -40,22 +42,28 @@ POname(clCreateKernel)(cl_program program,
                cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0
 {
   cl_kernel kernel = NULL;
-  char device_cachedir[POCL_FILENAME_LENGTH];
-  char descriptor_filename[POCL_FILENAME_LENGTH];
   int errcode;
   int error;
-  int device_i;
+  unsigned device_i;
+  void* cache_lock = NULL;
 
   POCL_GOTO_ERROR_COND((kernel_name == NULL), CL_INVALID_VALUE);
 
-  POCL_GOTO_ERROR_COND((program == NULL), CL_INVALID_VALUE);
+  POCL_GOTO_ERROR_COND((program == NULL), CL_INVALID_PROGRAM);
   
   POCL_GOTO_ERROR_ON((program->num_devices == 0),
     CL_INVALID_PROGRAM, "Invalid program (has no devices assigned)\n");
 
-  POCL_GOTO_ERROR_ON((program->binaries == NULL || program->binary_sizes == NULL),
-    CL_INVALID_PROGRAM_EXECUTABLE, "No binaries in program (perhaps you forgot "
-    "to call clBuildProgram first ?\n");
+  POCL_GOTO_ERROR_ON((program->build_status == CL_BUILD_NONE),
+    CL_INVALID_PROGRAM_EXECUTABLE, "You must call clBuildProgram first!"
+      " (even for programs created with binaries)\n");
+
+  POCL_GOTO_ERROR_ON((program->build_status != CL_BUILD_SUCCESS),
+    CL_INVALID_PROGRAM_EXECUTABLE, "Last BuildProgram() was not successful\n")
+
+  POCL_GOTO_ERROR_ON((program->llvm_irs == NULL),
+    CL_INVALID_PROGRAM_EXECUTABLE, "No built binaries in program "
+    "(this shouldn't happen...)\n");
 
   kernel = (cl_kernel) malloc(sizeof(struct _cl_kernel));
   if (kernel == NULL)
@@ -71,17 +79,19 @@ POname(clCreateKernel)(cl_program program,
       if (device_i > 0)
         POname(clRetainKernel) (kernel);
 
-      snprintf (device_cachedir, POCL_FILENAME_LENGTH, "%s/%s",
-                program->cache_dir, program->devices[device_i]->cache_dir_name);
-
       /* If there is no device dir for this device, the program was
          not built for that device in clBuildProgram. This seems to
          be OK by the standard. */
-      if (access (device_cachedir, F_OK) != 0) continue;
- 
-      error = pocl_llvm_get_kernel_metadata 
-          (program, kernel, program->devices[device_i]->dev_id, kernel_name,
-           device_cachedir, descriptor_filename, &errcode);
+      if (!pocl_cache_device_cachedir_exists(program, device_i))
+          continue;
+
+      cache_lock = pocl_cache_acquire_writer_lock_i(program, device_i);
+      assert(cache_lock);
+
+      error = pocl_llvm_get_kernel_metadata(program,
+                      kernel, device_i, kernel_name, &errcode);
+
+      pocl_cache_release_lock(cache_lock);
 
       if (error)
         {
@@ -91,12 +101,11 @@ POname(clCreateKernel)(cl_program program,
           goto ERROR;
         } 
 
-      /* when using the API, there is no descriptor file */
     }
 
-  /* TODO: one of these two could be eliminated?  */
-  kernel->function_name = strdup(kernel_name);
   kernel->name = strdup(kernel_name);
+  POCL_GOTO_ERROR_ON((kernel->name == NULL), CL_OUT_OF_HOST_MEMORY,
+                     "clCreateKernel couldn't allocate memory");
 
   kernel->context = program->context;
   kernel->program = program;
@@ -110,16 +119,18 @@ POname(clCreateKernel)(cl_program program,
 
   POCL_RETAIN_OBJECT(program);
 
-  if (errcode_ret != NULL)
-    *errcode_ret = CL_SUCCESS;
-  return kernel;
+  errcode = CL_SUCCESS;
+  goto SUCCESS;
 
 ERROR:
   POCL_MEM_FREE(kernel);
+  kernel = NULL;
+
+SUCCESS:
   if(errcode_ret != NULL)
   {
     *errcode_ret = errcode;
   }
-  return NULL;
+  return kernel;
 }
 POsym(clCreateKernel)
diff --git a/lib/CL/clCreateKernelsInProgram.c b/lib/CL/clCreateKernelsInProgram.c
index ebb36c1..f4c41d9 100644
--- a/lib/CL/clCreateKernelsInProgram.c
+++ b/lib/CL/clCreateKernelsInProgram.c
@@ -15,57 +15,75 @@ POname(clCreateKernelsInProgram)(cl_program      program ,
                          cl_kernel *     kernels ,
                          cl_uint *       num_kernels_ret ) CL_API_SUFFIX__VERSION_1_0
 {
-  int idx;
-  int num_kern_found;
-  
-  /* Get list of kernel names in program */
-  const char** knames = (const char**)malloc( num_kernels*sizeof(const char *) ); 
-  if (knames == NULL) 
-    return CL_OUT_OF_HOST_MEMORY;
-  num_kern_found = pocl_llvm_get_kernel_names (program, knames, num_kernels);
+  unsigned idx;
+  unsigned num_kern_found;
 
-  /* Sanity & quick return checks that the specs define */
-  if (num_kernels_ret != NULL)
-    *num_kernels_ret = num_kern_found;
-  if (kernels ==  NULL) 
-    {
-      POCL_MEM_FREE(knames);
-      return CL_SUCCESS;
-    }
+  POCL_RETURN_ERROR_COND((program == NULL), CL_INVALID_PROGRAM);
+
+  POCL_RETURN_ERROR_ON((program->num_devices == 0),
+    CL_INVALID_PROGRAM, "Invalid program (has no devices assigned)\n");
+
+  POCL_RETURN_ERROR_ON((program->build_status == CL_BUILD_NONE),
+    CL_INVALID_PROGRAM_EXECUTABLE, "You must call clBuildProgram first!"
+      " (even for programs created with binaries)\n");
+
+  POCL_RETURN_ERROR_ON((program->build_status != CL_BUILD_SUCCESS),
+    CL_INVALID_PROGRAM_EXECUTABLE, "Last BuildProgram() was not successful\n")
+
+  POCL_RETURN_ERROR_ON((program->llvm_irs == NULL),
+    CL_INVALID_PROGRAM_EXECUTABLE, "No built binaries in program "
+    "(this shouldn't happen...)\n");
 
-  POCL_RETURN_ERROR_ON((num_kernels < num_kern_found), CL_INVALID_VALUE,
+  num_kern_found = pocl_llvm_get_kernel_count(program);
+
+  POCL_RETURN_ERROR_ON((kernels && num_kernels < num_kern_found), CL_INVALID_VALUE,
       "kernels is not NULL and num_kernels "
       "is less than the number of kernels in program");
 
-  /* Create the kernels in the 'knames' list */ 
-  for (idx = 0; idx < num_kern_found; idx++) 
+  if (num_kern_found > 0 && kernels != NULL)
     {
-  
-      cl_int error_ret; 
-      kernels[idx] = clCreateKernel (program, knames[idx], &error_ret);
+      /* Get list of kernel names in program */
+      const char** knames = (const char**)calloc( num_kernels, sizeof(const char *) );
+      if (knames == NULL)
+        return CL_OUT_OF_HOST_MEMORY;
+      pocl_llvm_get_kernel_names (program, knames, num_kernels);
 
-      /* Check for errors, clean up & bail.
-       * If we happened to pass a invalid kernel name after all
-       * that should be treated as a pocl bug, not user error.
-       * TODO: what happens if the program is not valid?*/
-      assert(error_ret != CL_INVALID_KERNEL_NAME);  
-      assert(error_ret != CL_INVALID_VALUE);  
-      if (error_ret != CL_SUCCESS)
+      /* Create the kernels in the 'knames' list */
+      for (idx = 0; idx < num_kern_found; idx++)
         {
-          for (; idx>0; idx--) 
+          cl_int error_ret;
+          kernels[idx] = clCreateKernel (program, knames[idx], &error_ret);
+
+          /* Check for errors, clean up & bail.
+           * If we happened to pass a invalid kernel name after all
+           * that should be treated as a pocl bug, not user error.
+           * TODO: what happens if the program is not valid?*/
+          assert(error_ret != CL_INVALID_KERNEL_NAME);
+          assert(error_ret != CL_INVALID_VALUE);
+          if (error_ret != CL_SUCCESS)
             {
-              clReleaseKernel (kernels[idx-1]);
+              for (; idx>0; idx--)
+                {
+                  clReleaseKernel (kernels[idx-1]);
+                }
               POCL_MEM_FREE(knames);
               /* If error_ret is INVALID_KERNEL_DEFINITION, returning it here
-               * is against the specification. But the specs doesn't say what to 
-               * do in such a case, and just returning it is the sanest thing 
+               * is against the specification. But the specs doesn't say what to
+               * do in such a case, and just returning it is the sanest thing
                * to do. */
-              return error_ret; 
+              return error_ret;
             }
         }
+      for (idx = num_kern_found ; idx < num_kernels; idx++)
+        {
+          kernels[idx] = NULL;
+        }
+      POCL_MEM_FREE(knames);
     }
-  
-  POCL_MEM_FREE(knames);
+
+  if (num_kernels_ret)
+    *num_kernels_ret = num_kern_found;
+
   return CL_SUCCESS;
 }
 POsym(clCreateKernelsInProgram)
diff --git a/lib/CL/clCreateProgramWithBinary.c b/lib/CL/clCreateProgramWithBinary.c
index fe55d27..6f61d98 100644
--- a/lib/CL/clCreateProgramWithBinary.c
+++ b/lib/CL/clCreateProgramWithBinary.c
@@ -23,7 +23,6 @@
 
 #include "pocl_cl.h"
 #include "pocl_util.h"
-#include "devices.h"
 #include <string.h>
 
 CL_API_ENTRY cl_program CL_API_CALL
@@ -37,11 +36,9 @@ POname(clCreateProgramWithBinary)(cl_context                     context,
   CL_API_SUFFIX__VERSION_1_0
 {
   cl_program program;
-  unsigned total_binary_size;
-  unsigned char *pos;
-  int i;
-  int j;
+  unsigned i,j;
   int errcode;
+  cl_device_id * unique_devlist = NULL;
 
   POCL_GOTO_ERROR_COND((context == NULL), CL_INVALID_CONTEXT);
 
@@ -51,26 +48,12 @@ POname(clCreateProgramWithBinary)(cl_context                     context,
 
   POCL_GOTO_ERROR_COND((lengths == NULL), CL_INVALID_VALUE);
 
-  total_binary_size = 0;
   for (i = 0; i < num_devices; ++i)
     {
       POCL_GOTO_ERROR_ON((lengths[i] == 0 || binaries[i] == NULL), CL_INVALID_VALUE,
         "%i-th binary is NULL or its length==0\n", i);
-      total_binary_size += lengths[i];
     }
 
-  // check for invalid devices in device_list[].
-  for (i = 0; i < num_devices; i++)
-    {
-      int found = 0;
-      for (j = 0; j < context->num_devices; j++)
-        {
-          found |= context->devices[j] == device_list[i];
-        }
-      POCL_GOTO_ERROR_ON((!found), CL_INVALID_DEVICE,
-        "device not found in the device list of the context\n");
-    }
-  
   // check for duplicates in device_list[].
   for (i = 0; i < context->num_devices; i++)
     {
@@ -83,6 +66,24 @@ POname(clCreateProgramWithBinary)(cl_context                     context,
       POCL_GOTO_ERROR_ON((count > 1), CL_INVALID_DEVICE,
         "device %s specified multiple times\n", context->devices[i]->long_name);
     }
+
+  // convert subdevices to devices and remove duplicates
+  cl_uint real_num_devices = 0;
+  unique_devlist = pocl_unique_device_list(device_list, num_devices, &real_num_devices);
+  num_devices = real_num_devices;
+  device_list = unique_devlist;
+
+  // check for invalid devices in device_list[].
+  for (i = 0; i < num_devices; i++)
+    {
+      int found = 0;
+      for (j = 0; j < context->num_devices; j++)
+        {
+          found |= context->devices[j] == device_list[i];
+        }
+      POCL_GOTO_ERROR_ON((!found), CL_INVALID_DEVICE,
+        "device not found in the device list of the context\n");
+    }
   
   if ((program = (cl_program) malloc (sizeof (struct _cl_program))) == NULL)
     {
@@ -95,38 +96,35 @@ POname(clCreateProgramWithBinary)(cl_context                     context,
   program->binaries = NULL;
   program->compiler_options = NULL;
   program->llvm_irs = NULL;
-  program->cache_dir = NULL;
 
-  /* Allocate a continuous chunk of memory for all the binaries. */
   if ((program->binary_sizes =
-       (size_t*) malloc (sizeof (size_t) * num_devices)) == NULL ||
+       (size_t*) calloc (num_devices, sizeof(size_t))) == NULL ||
       (program->binaries = (unsigned char**)
-       malloc (sizeof (unsigned char*) * num_devices)) == NULL ||
-      (program->binaries[0] = (unsigned char*)
-       malloc (sizeof (unsigned char) * total_binary_size)) == NULL ||
+       calloc (num_devices, sizeof(unsigned char*))) == NULL ||
+      (program->build_log = (char**)
+       calloc (num_devices, sizeof(char*))) == NULL ||
       ((program->llvm_irs =
-        (void**) calloc (pocl_num_devices, sizeof (void*))) == NULL))
+        (void**) calloc (num_devices, sizeof(void*))) == NULL) ||
+      ((program->build_hash = (SHA1_digest_t*)
+        calloc (num_devices, sizeof(SHA1_digest_t))) == NULL))
     {
       errcode = CL_OUT_OF_HOST_MEMORY;
       goto ERROR_CLEAN_PROGRAM_AND_BINARIES;
     }
 
+  program->main_build_log[0] = 0;
   program->context = context;
   program->num_devices = num_devices;
-  program->devices = (cl_device_id*) malloc (sizeof(cl_device_id) * num_devices);
+  program->devices = unique_devlist;
   program->source = NULL;
   program->kernels = NULL;
   program->build_status = CL_BUILD_NONE;
 
-  pos = program->binaries[0];
   for (i = 0; i < num_devices; ++i)
     {
-      program->devices[i] = device_list[i];
       program->binary_sizes[i] = lengths[i];
-      program->llvm_irs[i] = NULL;
-      memcpy (pos, binaries[i], lengths[i]);
-      program->binaries[i] = pos;
-      pos += lengths[i];
+      program->binaries[i] = (unsigned char*) malloc (lengths[i]);
+      memcpy (program->binaries[i], binaries[i], lengths[i]);
       if (binary_status != NULL) /* TODO: validate the binary */
         binary_status[i] = CL_SUCCESS;
     }
@@ -142,12 +140,15 @@ ERROR_CLEAN_PROGRAM_BINARIES_AND_DEVICES:
   POCL_MEM_FREE(program->devices);
 #endif
 ERROR_CLEAN_PROGRAM_AND_BINARIES:
-  POCL_MEM_FREE(program->binaries[0]);
+  if (program->binaries)
+    for (i = 0; i < num_devices; ++i)
+      POCL_MEM_FREE(program->binaries[i]);
   POCL_MEM_FREE(program->binaries);
   POCL_MEM_FREE(program->binary_sizes);
 /*ERROR_CLEAN_PROGRAM:*/
   POCL_MEM_FREE(program);
 ERROR:
+  POCL_MEM_FREE(unique_devlist);
     if(errcode_ret != NULL)
       {
         *errcode_ret = errcode;
diff --git a/lib/CL/clCreateProgramWithSource.c b/lib/CL/clCreateProgramWithSource.c
index efc4824..5ea062a 100644
--- a/lib/CL/clCreateProgramWithSource.c
+++ b/lib/CL/clCreateProgramWithSource.c
@@ -34,14 +34,14 @@ POname(clCreateProgramWithSource)(cl_context context,
                           cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0
 {
   cl_program program = NULL;
-  unsigned size;
-  char *source;
+  size_t size = 0;
+  char *source = NULL;
   unsigned i;
   int errcode;
 
   POCL_GOTO_ERROR_COND((count == 0), CL_INVALID_VALUE);
 
-  program = (cl_program) malloc(sizeof(struct _cl_program));
+  program = (cl_program) calloc(1, sizeof(struct _cl_program));
   if (program == NULL)
   {
     errcode = CL_OUT_OF_HOST_MEMORY;
@@ -50,7 +50,6 @@ POname(clCreateProgramWithSource)(cl_context context,
 
   POCL_INIT_OBJECT(program);
 
-  size = 0;
   for (i = 0; i < count; ++i)
     {
       POCL_GOTO_ERROR_ON((strings[i] == NULL), CL_INVALID_VALUE,
@@ -63,7 +62,7 @@ POname(clCreateProgramWithSource)(cl_context context,
       else
         size += lengths[i];
     }
-  
+
   source = (char *) malloc(size + 1);
   if (source == NULL)
   {
@@ -95,16 +94,29 @@ POname(clCreateProgramWithSource)(cl_context context,
 
   *source = '\0';
 
+  program->main_build_log[0] = 0;
   program->context = context;
   program->num_devices = context->num_devices;
   program->devices = context->devices;
-  program->binary_sizes = NULL;
-  program->binaries = NULL;
   program->kernels = NULL;
-  program->llvm_irs = NULL;
-  program->cache_dir = NULL;
   program->build_status = CL_BUILD_NONE;
 
+  if ((program->binary_sizes =
+       (size_t*) calloc (program->num_devices, sizeof(size_t))) == NULL ||
+      (program->binaries = (unsigned char**)
+       calloc (program->num_devices, sizeof(unsigned char*))) == NULL ||
+      (program->build_log = (char**)
+       calloc (program->num_devices, sizeof(char*))) == NULL ||
+      ((program->llvm_irs =
+        (void**) calloc (program->num_devices, sizeof(void*))) == NULL) ||
+      ((program->build_hash = (SHA1_digest_t*)
+        calloc (program->num_devices, sizeof(SHA1_digest_t))) == NULL))
+    {
+      errcode = CL_OUT_OF_HOST_MEMORY;
+      goto ERROR;
+    }
+
+
   POCL_RETAIN_OBJECT(context);
 
   if (errcode_ret != NULL)
@@ -112,6 +124,14 @@ POname(clCreateProgramWithSource)(cl_context context,
   return program;
 
 ERROR:
+  if (program) {
+    POCL_MEM_FREE(program->build_hash);
+    POCL_MEM_FREE(program->llvm_irs);
+    POCL_MEM_FREE(program->build_log);
+    POCL_MEM_FREE(program->binaries);
+    POCL_MEM_FREE(program->binary_sizes);
+    POCL_MEM_FREE(program->source);
+  }
   POCL_MEM_FREE(program);
   if(errcode_ret)
   {
diff --git a/lib/CL/clCreateSubBuffer.c b/lib/CL/clCreateSubBuffer.c
index 28998dd..288671a 100644
--- a/lib/CL/clCreateSubBuffer.c
+++ b/lib/CL/clCreateSubBuffer.c
@@ -35,7 +35,7 @@ POname(clCreateSubBuffer)(cl_mem                   buffer,
   cl_device_id device;
   cl_mem mem = NULL;
   int errcode;
-  int i;
+  unsigned i;
 
   POCL_GOTO_ERROR_COND((buffer == NULL), CL_INVALID_MEM_OBJECT);
 
@@ -128,7 +128,7 @@ POname(clCreateSubBuffer)(cl_mem                   buffer,
     }
 
   mem->device_ptrs = (pocl_mem_identifier*)
-    malloc(pocl_num_devices * sizeof(pocl_mem_identifier *));
+    malloc(pocl_num_devices * sizeof(pocl_mem_identifier));
   if (mem->device_ptrs == NULL)
     {
         errcode = CL_OUT_OF_HOST_MEMORY;
diff --git a/lib/CL/clCreateSubDevices.c b/lib/CL/clCreateSubDevices.c
index 31b88f3..f0b0154 100644
--- a/lib/CL/clCreateSubDevices.c
+++ b/lib/CL/clCreateSubDevices.c
@@ -1,17 +1,18 @@
 /* OpenCL runtime library: clCreateSubDevices()
 
    Copyright (c) 2014 Lassi Koskinen
-   
+                 2015 Giuseppe Bilotta
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,15 +23,17 @@
 */
 
 #include "pocl_util.h"
+#include "pocl_debug.h"
 #include "pocl_cl.h"
 
 
-/* Creates an array of sub-devices that each reference a non-intersecting 
-   set of compute units within in_device, according to a partition scheme 
-   given by properties. */
-    
+/* Creates an array of sub-devices that each reference a non-intersecting
+   set of compute units within in_device, according to a partition scheme
+   given by properties.
+   TODO we should actually pin the subdevices to specific cores,
+   and possibly correct the cache information accordingly.
+   */
 
-  
 CL_API_ENTRY cl_int CL_API_CALL
 POname(clCreateSubDevices)(cl_device_id in_device,
                            const cl_device_partition_property *properties,
@@ -38,37 +41,122 @@ POname(clCreateSubDevices)(cl_device_id in_device,
                            cl_device_id *out_devices,
                            cl_uint *num_devices_ret) CL_API_SUFFIX__VERSION_1_2
 {
-   int errcode;
-   cl_device_id sub1 = in_device;
-   cl_device_id sub2 = in_device;
+   cl_int errcode = CL_SUCCESS;
+   cl_uint count_devices = 0;
+   cl_device_id *new_devs = NULL;
+   // number of elements in (copies of) properties, including terminating null
+   cl_uint num_props = 0;
+   uint i;
 
    POCL_GOTO_ERROR_COND((in_device == NULL), CL_INVALID_DEVICE);
+   POCL_GOTO_ERROR_COND((properties == NULL), CL_INVALID_VALUE);
+   POCL_GOTO_ERROR_COND((num_devices && !out_devices), CL_INVALID_VALUE);
+   POCL_GOTO_ERROR_COND((!num_devices && out_devices), CL_INVALID_VALUE);
+
+   /* check that the partition property is supported by the device */
+   errcode = CL_INVALID_VALUE;
+   for (i = 0; i < in_device->num_partition_properties; ++i) {
+     if (properties[0] == in_device->partition_properties[i]) {
+       errcode = CL_SUCCESS;
+       break;
+     }
+   }
+   if (errcode != CL_SUCCESS)
+     goto ERROR;
 
-   POCL_INIT_OBJECT(sub1);
-   sub1->parent_device = in_device;
-
-   POCL_INIT_OBJECT(sub2);
-   sub2->parent_device = in_device;
-   
-   out_devices[0] = sub1;
-   out_devices[1] = sub2;
-
-   POCL_RETAIN_OBJECT(in_device);
-   POCL_RETAIN_OBJECT(in_device);
-   
-   return CL_SUCCESS;
-    
-ERROR: 
-   if (&sub1 == &sub2) 
-     {
-        POCL_MEM_FREE(sub1);
-     } 
-   else 
-     {
-        POCL_MEM_FREE(sub1);
-        POCL_MEM_FREE(sub2);
+   /* Ok, it's a supported partition property, count the number of devices; currently,
+    * we only support EQUALLY and BY_COUNTS, which enumerate the number of devices
+    * differently */
+   if (properties[0] == CL_DEVICE_PARTITION_EQUALLY) {
+     // error out if the number of CUs per device is 0 or bigger than the number of
+     // CUs of in_device
+     POCL_GOTO_ERROR_COND(
+       (properties[1] == 0 || properties[1] > in_device->max_compute_units),
+       CL_INVALID_VALUE);
+     // error out if properties isn't zero-terminated
+     POCL_GOTO_ERROR_COND(properties[2] != 0, CL_INVALID_VALUE);
+
+     count_devices = in_device->max_compute_units / properties[1];
+     num_props = 3; // partition type, CUs per device, terminating 0
+   } else if (properties[0] == CL_DEVICE_PARTITION_BY_COUNTS) {
+     cl_uint total_cus = 0;
+     i = 1;
+     while (properties[i] != 0) {
+       count_devices++;
+       total_cus += properties[i];
+       ++i;
      }
+     // error out if the total number of CUs surpasses the number of device CUs,
+     // or if we have to many subdevices
+     POCL_GOTO_ERROR_COND(
+       (total_cus == 0 || total_cus > in_device->max_compute_units ||
+        count_devices > in_device->max_sub_devices),
+       CL_INVALID_DEVICE_PARTITION_COUNT);
+     num_props = count_devices + 2; // partition type, one spec per device, terminating 0
+   } else {
+     // we end here if some of our devices claim to support a different
+     // partition type, but this function was not updated accordingly
+
+     char what[1024];
+     snprintf(what, 1024, "Device-reported partition type 0x%x", (unsigned int)properties[0]);
+     POCL_ABORT_UNIMPLEMENTED(what);
+   }
+
+   // num_devices must match count_devices if non-zero
+   POCL_GOTO_ERROR_COND((num_devices && count_devices != num_devices), CL_INVALID_VALUE);
+
+   if (out_devices) {
+     // we allocate our own array of devices to simplify management
+     new_devs = calloc(count_devices, sizeof(cl_device_id));
+     POCL_GOTO_ERROR_COND((!new_devs), CL_OUT_OF_HOST_MEMORY);
+
+     for (i = 0; i < count_devices; ++i) {
+       new_devs[i] = calloc(1, sizeof(struct _cl_device_id));
+       POCL_GOTO_ERROR_COND((new_devs[i] == NULL), CL_OUT_OF_HOST_MEMORY);
+       POCL_INIT_OBJECT(new_devs[i]);
+
+       // clone in_device
+       memcpy(new_devs[i], in_device, sizeof(struct _cl_device_id));
+
+       // override the fields: partition type, parent, max_compute_units,
+       // max_sub_devices
+       new_devs[i]->partition_type = calloc(num_props, sizeof(*properties));
+       POCL_GOTO_ERROR_COND((new_devs[i]->partition_type == NULL),
+         CL_OUT_OF_HOST_MEMORY);
+       memcpy(new_devs[i]->partition_type, properties, num_props*sizeof(*properties));
+       new_devs[i]->num_partition_types = num_props;
+
+       new_devs[i]->parent_device = in_device;
+       new_devs[i]->max_sub_devices = new_devs[i]->max_compute_units =
+         (properties[0] == CL_DEVICE_PARTITION_EQUALLY ? properties[1] :
+          properties[i+1]);
+     }
+
+     memcpy(out_devices, new_devs, count_devices*sizeof(cl_device_id));
+     POCL_MEM_FREE(new_devs);
+   }
+
+   if (num_devices_ret)
+     *num_devices_ret = count_devices;
+
    return errcode;
 
+ERROR:
+  if (new_devs) {
+    // release all objects
+    for (i = 0; i < count_devices; ++i) {
+      int new_refcount = 0;
+      // the first NULL new_devs indicates we're done
+      // with the ones we actually managed to allocate
+      if (new_devs[i] == NULL)
+        break;
+      POCL_RELEASE_OBJECT(new_devs[i], new_refcount);
+      POCL_MEM_FREE(new_devs[i]);
+    }
+
+    free(new_devs);
+  }
+  return errcode;
+
 }
 POsym(clCreateSubDevices)
diff --git a/lib/CL/clCreateUserEvent.c b/lib/CL/clCreateUserEvent.c
index 2c33741..2572793 100644
--- a/lib/CL/clCreateUserEvent.c
+++ b/lib/CL/clCreateUserEvent.c
@@ -1,25 +1,28 @@
 #include "pocl_cl.h"
+#include "pocl_util.h"
 
 
 CL_API_ENTRY cl_event CL_API_CALL
 POname(clCreateUserEvent)(cl_context     context ,
-                  cl_int *       errcode_ret ) CL_API_SUFFIX__VERSION_1_1 
+                  cl_int *       errcode_ret ) CL_API_SUFFIX__VERSION_1_1
 {
-  int error; 
-  
-  cl_event event;
-  error = pocl_create_event (&event, 0, CL_COMMAND_USER);
+  int error;
+  cl_event event = NULL;
 
-  event->status = CL_QUEUED;
+  error = pocl_create_event (&event, context, NULL, CL_COMMAND_USER);
 
   if (error != CL_SUCCESS)
     {
-      if (errcode_ret)
-        *errcode_ret = error;
-
-      return NULL;
+      POCL_MEM_FREE(event);
+    }
+  else
+    {
+      event->status = CL_SUBMITTED;
     }
-  
+
+  if (errcode_ret)
+    *errcode_ret = error;
+
   return event;
 }
 POsym(clCreateUserEvent)
diff --git a/lib/CL/clEnqueueCopyBuffer.c b/lib/CL/clEnqueueCopyBuffer.c
index 8eaf2ea..e89365e 100644
--- a/lib/CL/clEnqueueCopyBuffer.c
+++ b/lib/CL/clEnqueueCopyBuffer.c
@@ -38,7 +38,7 @@ POname(clEnqueueCopyBuffer)(cl_command_queue command_queue,
                             cl_event *event) 
 CL_API_SUFFIX__VERSION_1_0
 {
-  cl_device_id device_id;
+  cl_device_id device;
   unsigned i;
   _cl_command_node *cmd = NULL;
   int errcode;
@@ -72,14 +72,7 @@ CL_API_SUFFIX__VERSION_1_0
   if (pocl_buffers_overlap(src_buffer, dst_buffer, src_offset,
         dst_offset, size) != CL_SUCCESS) return CL_MEM_COPY_OVERLAP;
 
-  device_id = command_queue->device;
-
-  for (i = 0; i < command_queue->context->num_devices; ++i)
-    {
-      if (command_queue->context->devices[i] == device_id)
-        break;
-    }
-  assert(i < command_queue->context->num_devices);
+  POCL_CHECK_DEV_IN_CMDQ
 
   errcode = pocl_create_command (&cmd, command_queue, CL_COMMAND_COPY_BUFFER, 
                                  event, num_events_in_wait_list, 
@@ -93,15 +86,15 @@ CL_API_SUFFIX__VERSION_1_0
   POname(clRetainMemObject)(src_buffer);
   POname(clRetainMemObject)(dst_buffer);
 
-  cmd->command.copy.data = device_id->data;
+  cmd->command.copy.data = device->data;
   /* TODO: call device->buf_offset() or similar as device_ptrs might not be
      actual buffer pointers but pointers to a book keeping structure. */
   cmd->command.copy.src_ptr = 
-    (char*)src_buffer->device_ptrs[device_id->dev_id].mem_ptr;
+    (char*)src_buffer->device_ptrs[device->dev_id].mem_ptr;
   cmd->command.copy.src_offset = src_offset;
 
   cmd->command.copy.dst_ptr = 
-    (char*)dst_buffer->device_ptrs[device_id->dev_id].mem_ptr;
+    (char*)dst_buffer->device_ptrs[device->dev_id].mem_ptr;
   cmd->command.copy.dst_offset = dst_offset;
   cmd->command.copy.cb = size;
 
diff --git a/lib/CL/clEnqueueCopyBufferRect.c b/lib/CL/clEnqueueCopyBufferRect.c
index e25ab00..a3737f2 100644
--- a/lib/CL/clEnqueueCopyBufferRect.c
+++ b/lib/CL/clEnqueueCopyBufferRect.c
@@ -40,7 +40,7 @@ POname(clEnqueueCopyBufferRect)(cl_command_queue command_queue,
                                 const cl_event *event_wait_list,
                                 cl_event *event) CL_API_SUFFIX__VERSION_1_1
 {
-  cl_device_id device_id;
+  cl_device_id device;
   unsigned i;
 
   POCL_RETURN_ERROR_COND((command_queue == NULL), CL_INVALID_COMMAND_QUEUE);
@@ -95,14 +95,7 @@ POname(clEnqueueCopyBufferRect)(cl_command_queue command_queue,
 
   }
 
-  device_id = command_queue->device;
-
-  for (i = 0; i < command_queue->context->num_devices; ++i)
-    {
-      if (command_queue->context->devices[i] == device_id)
-        break;
-    }
-  assert(i < command_queue->context->num_devices);
+  POCL_CHECK_DEV_IN_CMDQ
 
   /* execute directly */
   /* TODO: enqueue the read_rect if this is a non-blocking read (see
@@ -121,19 +114,19 @@ POname(clEnqueueCopyBufferRect)(cl_command_queue command_queue,
       POname(clRetainMemObject) (dst_buffer);
       POname(clFinish)(command_queue);
     }
-  POCL_UPDATE_EVENT_SUBMITTED(event, command_queue);
-  POCL_UPDATE_EVENT_RUNNING(event, command_queue);
+  POCL_UPDATE_EVENT_SUBMITTED(event);
+  POCL_UPDATE_EVENT_RUNNING(event);
 
   /* TODO: offset computation doesn't work in case the ptr is not 
      a direct pointer */
-  device_id->ops->copy_rect(device_id->data,
-                       src_buffer->device_ptrs[device_id->dev_id].mem_ptr, 
-                       dst_buffer->device_ptrs[device_id->dev_id].mem_ptr,
+  device->ops->copy_rect(device->data,
+                       src_buffer->device_ptrs[device->dev_id].mem_ptr,
+                       dst_buffer->device_ptrs[device->dev_id].mem_ptr,
                        src_origin, dst_origin, region,
                        src_row_pitch, src_slice_pitch,
                        dst_row_pitch, dst_slice_pitch);
 
-  POCL_UPDATE_EVENT_COMPLETE(event, command_queue);
+  POCL_UPDATE_EVENT_COMPLETE(event);
 
   POname(clReleaseMemObject) (src_buffer);
   POname(clReleaseMemObject) (dst_buffer);
diff --git a/lib/CL/clEnqueueCopyBufferToImage.c b/lib/CL/clEnqueueCopyBufferToImage.c
index 1bbee66..92f971d 100644
--- a/lib/CL/clEnqueueCopyBufferToImage.c
+++ b/lib/CL/clEnqueueCopyBufferToImage.c
@@ -71,7 +71,7 @@ CL_API_SUFFIX__VERSION_1_0
                                       region, 0, 0, temp+src_offset);
     
   POCL_MEM_FREE(temp);
-  POCL_UPDATE_EVENT_COMPLETE(event, command_queue);
+  POCL_UPDATE_EVENT_COMPLETE(event);
   return ret_code;
 }
 POsym(clEnqueueCopyBufferToImage) 
diff --git a/lib/CL/clEnqueueFillImage.c b/lib/CL/clEnqueueFillImage.c
index 26939e4..53e3151 100644
--- a/lib/CL/clEnqueueFillImage.c
+++ b/lib/CL/clEnqueueFillImage.c
@@ -131,7 +131,6 @@ CL_API_SUFFIX__VERSION_1_2
   
  ERROR_CLEAN:
   POCL_MEM_FREE(supported_image_formats);
-  POCL_MEM_FREE(*event);
   POCL_MEM_FREE(fill_pixel);
   return errcode;
 }
diff --git a/lib/CL/clEnqueueMapBuffer.c b/lib/CL/clEnqueueMapBuffer.c
index 6bcd7d5..68e4187 100644
--- a/lib/CL/clEnqueueMapBuffer.c
+++ b/lib/CL/clEnqueueMapBuffer.c
@@ -42,8 +42,10 @@ POname(clEnqueueMapBuffer)(cl_command_queue command_queue,
   cl_device_id device;
   void *host_ptr = NULL;
   mem_mapping_t *mapping_info = NULL;
-  int errcode;
+  int errcode; unsigned i;
   _cl_command_node *cmd = NULL;
+  /* need to release the memobject before returning? */
+  int must_release = 0;
 
   POCL_GOTO_ERROR_COND((command_queue == NULL), CL_INVALID_COMMAND_QUEUE);
 
@@ -75,10 +77,11 @@ POname(clEnqueueMapBuffer)(cl_command_queue command_queue,
       "buffer has been created with CL_MEM_HOST_READ_ONL or CL_MEM_HOST_NO_ACCESS "
       "and CL_MAP_WRITE or CL_MAP_WRITE_INVALIDATE_REGION is set in map_flags\n")
 
-  device = command_queue->device;
+  POCL_CHECK_DEV_IN_CMDQ
  
   /* Ensure the parent buffer is not freed prematurely. */
   POname(clRetainMemObject) (buffer);
+  must_release = 1;
 
   mapping_info = (mem_mapping_t*) calloc (1, sizeof (mem_mapping_t));
   if (mapping_info == NULL)
@@ -109,21 +112,20 @@ POname(clEnqueueMapBuffer)(cl_command_queue command_queue,
 
   if (host_ptr == NULL)
     {
-      POCL_UPDATE_EVENT_COMPLETE(event, command_queue);
       errcode = CL_MAP_FAILURE;
       goto ERROR;
     }
 
-  errcode = pocl_create_command (&cmd, command_queue, CL_COMMAND_MAP_BUFFER, 
-                                 event, num_events_in_wait_list, 
+  errcode = pocl_create_command (&cmd, command_queue, CL_COMMAND_MAP_BUFFER,
+                                 event, num_events_in_wait_list,
                                  event_wait_list);
-  
+
   if (errcode != CL_SUCCESS)
       goto ERROR;
-  
+
   cmd->command.map.buffer = buffer;
   cmd->command.map.mapping = mapping_info;
-    
+
   mapping_info->host_ptr = host_ptr;
   mapping_info->offset = offset;
   mapping_info->size = size;
@@ -142,16 +144,14 @@ POname(clEnqueueMapBuffer)(cl_command_queue command_queue,
 
   if (errcode_ret)
     *errcode_ret = errcode;
-  
 
   POCL_SUCCESS ();
   return host_ptr;
 
- ERROR:
-  if (event)
-    POCL_MEM_FREE(*event);
+ERROR:
+  if (must_release)
+    POname(clReleaseMemObject)(buffer);
   POCL_MEM_FREE(cmd);
-  POCL_MEM_FREE(event);
   POCL_MEM_FREE(mapping_info);
   if (errcode_ret)
     *errcode_ret = errcode;
diff --git a/lib/CL/clEnqueueMapImage.c b/lib/CL/clEnqueueMapImage.c
index 19a9765..5915ccf 100644
--- a/lib/CL/clEnqueueMapImage.c
+++ b/lib/CL/clEnqueueMapImage.c
@@ -39,14 +39,15 @@ POname(clEnqueueMapImage)(cl_command_queue   command_queue,
                           size_t *           image_slice_pitch,
                           cl_uint            num_events_in_wait_list,
                           const cl_event *   event_wait_list,
-                          cl_event *         event,
-                          cl_int *           errcode_ret ) 
+                          cl_event *         event_ret,
+                          cl_int *           errcode_ret )
 CL_API_SUFFIX__VERSION_1_0
 {
   cl_int errcode;
-  int offset;
+  size_t offset;
   void *map = NULL;
   cl_device_id device;
+  cl_event event = NULL;
   _cl_command_node *cmd = NULL;
   mem_mapping_t *mapping_info = NULL;
 
@@ -99,18 +100,24 @@ CL_API_SUFFIX__VERSION_1_0
       goto ERROR;
     }
 
+  errcode = pocl_create_command (&cmd, command_queue, CL_COMMAND_MAP_IMAGE,
+                                 &event, num_events_in_wait_list,
+                                 event_wait_list);
+  if (errcode != CL_SUCCESS)
+    goto ERROR;
+
   if (image->flags & CL_MEM_USE_HOST_PTR)
     {
       /* In this case it should use the given host_ptr + offset as
-         the mapping area in the host memory. */   
+         the mapping area in the host memory. */
       assert (image->mem_host_ptr != NULL);
       map = (char*)image->mem_host_ptr + offset;
-      device->ops->read_rect (device->data, map, 
+      device->ops->read_rect (device->data, map,
                               image->device_ptrs[device->dev_id].mem_ptr,
-                              origin, origin, region, 
-                              image->image_row_pitch, image->image_slice_pitch, 
+                              origin, origin, region,
+                              image->image_row_pitch, image->image_slice_pitch,
                               image->image_row_pitch, image->image_slice_pitch);
-      POCL_UPDATE_EVENT_COMPLETE(event, command_queue);
+      POCL_UPDATE_EVENT_COMPLETE(&event);
     }
   else
     {
@@ -127,7 +134,6 @@ CL_API_SUFFIX__VERSION_1_0
 
   if (map == NULL)
     {
-      POCL_UPDATE_EVENT_COMPLETE(event, command_queue);
       errcode = CL_MAP_FAILURE;
       goto ERROR;
     }
@@ -139,40 +145,34 @@ CL_API_SUFFIX__VERSION_1_0
   DL_APPEND (image->mappings, mapping_info);
   POCL_UNLOCK_OBJ (image);
 
-  errcode = pocl_create_command (&cmd, command_queue, CL_COMMAND_MAP_IMAGE, 
-                                 event, num_events_in_wait_list, 
-                                 event_wait_list);
-  if (errcode != CL_SUCCESS)
-    goto ERROR;
-      
-  
   cmd->command.map.buffer = image;
   cmd->command.map.mapping = mapping_info;
   pocl_command_enqueue(command_queue, cmd);
-  
+
+  *image_row_pitch = image->image_row_pitch;
+  if (image_slice_pitch)
+    *image_slice_pitch = image->image_slice_pitch;
+
   if (blocking_map)
     {
       POname(clFinish) (command_queue);
     }
-  
-  *image_row_pitch = image->image_row_pitch;
-  if (image_slice_pitch)
-    *image_slice_pitch = image->image_slice_pitch;
 
+  if (event_ret)
+    *event_ret = event;
   if (errcode_ret != NULL)
     (*errcode_ret) = CL_SUCCESS;
 
   return map;
- 
- ERROR:
-  POCL_MEM_FREE(map);
+
+ERROR:
+  POCL_MEM_FREE(event);
+  assert(map == NULL);
   POCL_MEM_FREE(cmd);
   POCL_MEM_FREE(mapping_info);
-  if (event != NULL)
-    POCL_MEM_FREE(*event);
   if(errcode_ret != NULL)
     (*errcode_ret) = errcode;
-      
+
   return NULL;
 }
 POsym(clEnqueueMapImage)
diff --git a/lib/CL/clEnqueueMarkerWithWaitList.c b/lib/CL/clEnqueueMarkerWithWaitList.c
index 28ad5b4..d954dc5 100644
--- a/lib/CL/clEnqueueMarkerWithWaitList.c
+++ b/lib/CL/clEnqueueMarkerWithWaitList.c
@@ -34,10 +34,10 @@ POname(clEnqueueMarkerWithWaitList) (cl_command_queue   command_queue,
 CL_API_SUFFIX__VERSION_1_2
 {
   int errcode;
-  _cl_command_node *cmd;
-  
+  _cl_command_node *cmd = NULL;
+
   POCL_RETURN_ERROR_COND((command_queue == NULL), CL_INVALID_COMMAND_QUEUE);
-  
+
   errcode = pocl_create_command (&cmd, command_queue, CL_COMMAND_MARKER, 
                                  event, num_events_in_wait_list, 
                                  event_wait_list);
@@ -46,11 +46,10 @@ CL_API_SUFFIX__VERSION_1_2
 
   cmd->command.marker.data = command_queue->device->data;
   pocl_command_enqueue (command_queue, cmd);
-  
+
   return CL_SUCCESS;
 
  ERROR:
-  POCL_MEM_FREE(event);
   POCL_MEM_FREE(cmd);
   return errcode;
 
diff --git a/lib/CL/clEnqueueNDRangeKernel.c b/lib/CL/clEnqueueNDRangeKernel.c
index edaf137..873074b 100644
--- a/lib/CL/clEnqueueNDRangeKernel.c
+++ b/lib/CL/clEnqueueNDRangeKernel.c
@@ -26,6 +26,7 @@
 #include "pocl_cl.h"
 #include "pocl_llvm.h"
 #include "pocl_util.h"
+#include "pocl_cache.h"
 #include "utlist.h"
 #ifndef _MSC_VER
 #  include <unistd.h>
@@ -56,14 +57,12 @@ POname(clEnqueueNDRangeKernel)(cl_command_queue command_queue,
   size_t offset_x, offset_y, offset_z;
   size_t global_x, global_y, global_z;
   size_t local_x, local_y, local_z;
-  char cachedir[POCL_FILENAME_LENGTH];
-  char kernel_filename[POCL_FILENAME_LENGTH];
-  char parallel_filename[POCL_FILENAME_LENGTH];
-  char so_filename[POCL_FILENAME_LENGTH];
-  int i, count;
+  unsigned i, count;
   int error;
+  cl_device_id realdev = NULL;
   struct pocl_context pc;
   _cl_command_node *command_node;
+  void* cache_lock;
 
   POCL_RETURN_ERROR_COND((command_queue == NULL), CL_INVALID_COMMAND_QUEUE);
   
@@ -78,6 +77,8 @@ POname(clEnqueueNDRangeKernel)(cl_command_queue command_queue,
 
   assert(command_queue->device->max_work_item_dimensions <= 3);
 
+  realdev = POCL_REAL_DEV(command_queue->device);
+
   if (global_work_offset != NULL)
     {
       offset_x = global_work_offset[0];
@@ -198,9 +199,9 @@ POname(clEnqueueNDRangeKernel)(cl_command_queue command_queue,
              command_queue->device->max_work_group_size);
     }
 
-  POCL_MSG_PRINT_INFO("Qeueing kernel %s with local size %u x %u x %u group "
+  POCL_MSG_PRINT_INFO("Queueing kernel %s with local size %u x %u x %u group "
                       "sizes %u x %u x %u...\n",
-                      kernel->function_name, 
+                      kernel->name,
                       (unsigned)local_x, (unsigned)local_y, (unsigned)local_z,
                       (unsigned)(global_x / local_x), 
                       (unsigned)(global_y / local_y), 
@@ -230,50 +231,25 @@ POname(clEnqueueNDRangeKernel)(cl_command_queue command_queue,
   POCL_RETURN_ERROR_COND((event_wait_list != NULL && num_events_in_wait_list == 0),
     CL_INVALID_EVENT_WAIT_LIST);
 
+  cache_lock = pocl_cache_acquire_writer_lock(kernel->program,
+                                              realdev);
+  assert(cache_lock);
 
-  snprintf (cachedir, POCL_FILENAME_LENGTH, "%s/%s/%s/%zu-%zu-%zu",
-            kernel->program->cache_dir, command_queue->device->cache_dir_name,
-            kernel->name,
-            local_x, local_y, local_z);
-
-  if (access (cachedir, F_OK) != 0)
-    mkdir (cachedir, S_IRWXU);
-  
-  error = snprintf
-          (parallel_filename, POCL_FILENAME_LENGTH,
-          "%s/%s", cachedir, POCL_PARALLEL_BC_FILENAME);
-  if (error < 0)
-    return CL_OUT_OF_HOST_MEMORY;
-
-  error = snprintf
-          (so_filename, POCL_FILENAME_LENGTH,
-          "%s/%s.so", cachedir, kernel->name);
-  if (error < 0)
-    return CL_OUT_OF_HOST_MEMORY;
-
-  error = snprintf
-          (kernel_filename, POCL_FILENAME_LENGTH,
-           "%s/%s/%s", kernel->program->cache_dir,
-           command_queue->device->cache_dir_name, POCL_PROGRAM_BC_FILENAME);
-  if (error < 0)
-    return CL_OUT_OF_HOST_MEMORY;
-
-  if (access(so_filename, F_OK) != 0)
-    {
-      error = pocl_llvm_generate_workgroup_function
-          (command_queue->device,
-           kernel, local_x, local_y, local_z,
-           parallel_filename, kernel_filename);
+  char cachedir[POCL_FILENAME_LENGTH];
+  pocl_cache_make_kernel_cachedir_path(cachedir, kernel->program,
+                                  realdev, kernel,
+                                  local_x, local_y, local_z);
 
-      if (error)  return error;
-    }
+  error = pocl_llvm_generate_workgroup_function(realdev,
+                                kernel, local_x, local_y, local_z);
+  if (error) goto ERROR;
 
   error = pocl_create_command (&command_node, command_queue,
                                CL_COMMAND_NDRANGE_KERNEL,
                                event, num_events_in_wait_list,
                                event_wait_list);
   if (error != CL_SUCCESS)
-    return error;
+    goto ERROR;
 
   pc.work_dim = work_dim;
   pc.num_groups[0] = global_x / local_x;
@@ -294,7 +270,7 @@ POname(clEnqueueNDRangeKernel)(cl_command_queue command_queue,
 
   /* Copy the currently set kernel arguments because the same kernel 
      object can be reused for new launches with different arguments. */
-  command_node->command.run.arguments = 
+  command_node->command.run.arguments =
     (struct pocl_argument *) malloc ((kernel->num_args + kernel->num_locals) *
                                      sizeof (struct pocl_argument));
 
@@ -338,8 +314,8 @@ POname(clEnqueueNDRangeKernel)(cl_command_queue command_queue,
   }
   
   /* Copy the argument buffers just so we can free them after execution. */
-  command_node->command.run.arg_buffers = 
-    (cl_mem *) malloc (sizeof (struct _cl_mem) * command_node->command.run.arg_buffer_count);
+  command_node->command.run.arg_buffers =
+    (cl_mem *) malloc (sizeof (cl_mem) * command_node->command.run.arg_buffer_count);
   count = 0;
   for (i = 0; i < kernel->num_args; ++i)
   {
@@ -361,7 +337,11 @@ POname(clEnqueueNDRangeKernel)(cl_command_queue command_queue,
   }
 
   pocl_command_enqueue (command_queue, command_node);
+  error = CL_SUCCESS;
+
+ERROR:
+  pocl_cache_release_lock(cache_lock);
+  return error;
 
-  return CL_SUCCESS;
 }
 POsym(clEnqueueNDRangeKernel)
diff --git a/lib/CL/clEnqueueNativeKernel.c b/lib/CL/clEnqueueNativeKernel.c
index bb573a3..61af742 100644
--- a/lib/CL/clEnqueueNativeKernel.c
+++ b/lib/CL/clEnqueueNativeKernel.c
@@ -20,10 +20,10 @@ POname(clEnqueueNativeKernel)(cl_command_queue   command_queue ,
                       cl_event *         event ) CL_API_SUFFIX__VERSION_1_0
 {
   cl_uint i = 0;
-  _cl_command_node *command_node;
-  cl_mem *mem_list_copy;
-  void *args_copy;
-  int error;
+  _cl_command_node *command_node = NULL;
+  cl_mem *mem_list_copy = NULL;
+  void *args_copy = NULL;
+  cl_int error;
 
   POCL_RETURN_ERROR_COND((command_queue == NULL), CL_INVALID_COMMAND_QUEUE);
 
@@ -63,23 +63,29 @@ POname(clEnqueueNativeKernel)(cl_command_queue   command_queue ,
 
   /* Specification specifies that args passed to user_func is a copy of the
    * one passed to this function */
-  args_copy = malloc (cb_args);
-  if (args_copy == NULL)
+  if (cb_args)
     {
-      POCL_MEM_FREE(command_node);
-      return CL_OUT_OF_HOST_MEMORY;
+      args_copy = malloc (cb_args);
+      if (args_copy == NULL)
+      {
+        POCL_MEM_FREE(command_node);
+        return CL_OUT_OF_HOST_MEMORY;
+      }
+      memcpy (args_copy, args, cb_args);
     }
-  memcpy (args_copy, args, cb_args);
 
   /* recopy the cl_mem object list to free them easily after run */
-  mem_list_copy = (cl_mem*) malloc(num_mem_objects * sizeof(cl_mem));
-  if (mem_list_copy == NULL)
+  if (num_mem_objects)
     {
-      POCL_MEM_FREE(args_copy);
-      POCL_MEM_FREE(command_node);
-      return CL_OUT_OF_HOST_MEMORY;
+      mem_list_copy = (cl_mem*) malloc(num_mem_objects * sizeof(cl_mem));
+      if (mem_list_copy == NULL)
+      {
+        POCL_MEM_FREE(args_copy);
+        POCL_MEM_FREE(command_node);
+        return CL_OUT_OF_HOST_MEMORY;
+      }
+      memcpy (mem_list_copy, mem_list, num_mem_objects * sizeof(cl_mem));
     }
-  memcpy (mem_list_copy, mem_list, num_mem_objects * sizeof(cl_mem));
   command_node->command.native.mem_list = mem_list_copy;
 
   for (i = 0; i < num_mem_objects; i++)
diff --git a/lib/CL/clEnqueueReadBuffer.c b/lib/CL/clEnqueueReadBuffer.c
index 79f61f5..420d840 100644
--- a/lib/CL/clEnqueueReadBuffer.c
+++ b/lib/CL/clEnqueueReadBuffer.c
@@ -62,7 +62,7 @@ POname(clEnqueueReadBuffer)(cl_command_queue command_queue,
   for(i=0; i<num_events_in_wait_list; i++)
     POCL_RETURN_ERROR_COND((event_wait_list[i] == NULL), CL_INVALID_EVENT_WAIT_LIST);
 
-  device = command_queue->device;
+  device = POCL_REAL_DEV(command_queue->device);
 
   errcode = pocl_create_command (&cmd, command_queue, CL_COMMAND_READ_BUFFER, 
                                  event, num_events_in_wait_list, 
diff --git a/lib/CL/clEnqueueReadBufferRect.c b/lib/CL/clEnqueueReadBufferRect.c
index 1b2de28..0e3f15b 100644
--- a/lib/CL/clEnqueueReadBufferRect.c
+++ b/lib/CL/clEnqueueReadBufferRect.c
@@ -80,16 +80,7 @@ POname(clEnqueueReadBufferRect)(cl_command_queue command_queue,
       &host_slice_pitch, "") != CL_SUCCESS) return CL_INVALID_VALUE;
 
 
-
-
-  device = command_queue->device;
-
-  for (i = 0; i < command_queue->context->num_devices; ++i)
-    {
-        if (command_queue->context->devices[i] == device)
-            break;
-    }
-  assert(i < command_queue->context->num_devices);
+  POCL_CHECK_DEV_IN_CMDQ
 
   /* execute directly */
   /* TODO: enqueue the read_rect if this is a non-blocking read (see
@@ -107,8 +98,8 @@ POname(clEnqueueReadBufferRect)(cl_command_queue command_queue,
       POname(clRetainMemObject) (buffer);
       POname(clFinish)(command_queue);
     }
-  POCL_UPDATE_EVENT_SUBMITTED(event, command_queue);
-  POCL_UPDATE_EVENT_RUNNING(event, command_queue);
+  POCL_UPDATE_EVENT_SUBMITTED(event);
+  POCL_UPDATE_EVENT_RUNNING(event);
 
   /* TODO: offset computation doesn't work in case the ptr is not 
      a direct pointer */
@@ -118,7 +109,7 @@ POname(clEnqueueReadBufferRect)(cl_command_queue command_queue,
                     buffer_row_pitch, buffer_slice_pitch,
                     host_row_pitch, host_slice_pitch);
 
-  POCL_UPDATE_EVENT_COMPLETE(event, command_queue);
+  POCL_UPDATE_EVENT_COMPLETE(event);
 
   POname(clReleaseMemObject) (buffer);
 
diff --git a/lib/CL/clEnqueueReadImage.c b/lib/CL/clEnqueueReadImage.c
index 7d7f8c3..d4797cb 100644
--- a/lib/CL/clEnqueueReadImage.c
+++ b/lib/CL/clEnqueueReadImage.c
@@ -41,7 +41,7 @@ POname(clEnqueueReadImage)(cl_command_queue     command_queue,
 CL_API_SUFFIX__VERSION_1_0 
 {
   cl_int errcode;
-  _cl_command_node *cmd;
+  _cl_command_node *cmd = NULL;
 
   POCL_RETURN_ERROR_COND((command_queue == NULL), CL_INVALID_COMMAND_QUEUE);
 
@@ -76,8 +76,8 @@ CL_API_SUFFIX__VERSION_1_0
                                 event_wait_list);
   if (errcode != CL_SUCCESS)
     {
-      if (event)
-        POCL_MEM_FREE(*event);
+      POCL_MEM_FREE(cmd);
+      return errcode;
     }
 
   cmd->command.rw_image.device_ptr = 
diff --git a/lib/CL/clEnqueueUnmapMemObject.c b/lib/CL/clEnqueueUnmapMemObject.c
index 0d7bd40..ef312b8 100644
--- a/lib/CL/clEnqueueUnmapMemObject.c
+++ b/lib/CL/clEnqueueUnmapMemObject.c
@@ -35,10 +35,10 @@ POname(clEnqueueUnmapMemObject)(cl_command_queue command_queue,
                         cl_event *       event) CL_API_SUFFIX__VERSION_1_0
 {
   int errcode;
-  cl_device_id device_id;
+  cl_device_id device;
   unsigned i;
   mem_mapping_t *mapping = NULL;
-  _cl_command_node *cmd;
+  _cl_command_node *cmd = NULL;
 
   POCL_RETURN_ERROR_COND((memobj == NULL), CL_INVALID_MEM_OBJECT);
 
@@ -64,22 +64,15 @@ POname(clEnqueueUnmapMemObject)(cl_command_queue command_queue,
       "Could not find mapping of this memobj\n");
 
   /* find the index of the device's ptr in the buffer */
-  device_id = command_queue->device;
-  for (i = 0; i < command_queue->context->num_devices; ++i)
-    {
-      if (command_queue->context->devices[i] == device_id)
-        break;
-    }
+  POCL_CHECK_DEV_IN_CMDQ
 
-  assert(i < command_queue->context->num_devices);
-
-  errcode = pocl_create_command (&cmd, command_queue, 
-                                 CL_COMMAND_UNMAP_MEM_OBJECT, 
-                                 event, num_events_in_wait_list, 
+  errcode = pocl_create_command (&cmd, command_queue,
+                                 CL_COMMAND_UNMAP_MEM_OBJECT,
+                                 event, num_events_in_wait_list,
                                  event_wait_list);
   if (errcode != CL_SUCCESS)
     goto ERROR;
-  
+
   cmd->command.unmap.data = command_queue->device->data;
   cmd->command.unmap.memobj = memobj;
   cmd->command.unmap.mapping = mapping;
@@ -87,8 +80,7 @@ POname(clEnqueueUnmapMemObject)(cl_command_queue command_queue,
 
   return CL_SUCCESS;
 
- ERROR:
-  POCL_MEM_FREE(*event);
+ERROR:
   POCL_MEM_FREE(cmd);
   return errcode;
 }
diff --git a/lib/CL/clEnqueueWriteBuffer.c b/lib/CL/clEnqueueWriteBuffer.c
index 68df325..631e4e1 100644
--- a/lib/CL/clEnqueueWriteBuffer.c
+++ b/lib/CL/clEnqueueWriteBuffer.c
@@ -62,7 +62,7 @@ POname(clEnqueueWriteBuffer)(cl_command_queue command_queue,
   for(i=0; i<num_events_in_wait_list; i++)
     POCL_RETURN_ERROR_COND((event_wait_list[i] == NULL), CL_INVALID_EVENT_WAIT_LIST);
 
-  device = command_queue->device;
+  device = POCL_REAL_DEV(command_queue->device);
 
   for (i = 0; i < command_queue->context->num_devices; ++i)
     {
diff --git a/lib/CL/clEnqueueWriteBufferRect.c b/lib/CL/clEnqueueWriteBufferRect.c
index 59324d0..1cf7ab7 100644
--- a/lib/CL/clEnqueueWriteBufferRect.c
+++ b/lib/CL/clEnqueueWriteBufferRect.c
@@ -81,7 +81,7 @@ POname(clEnqueueWriteBufferRect)(cl_command_queue command_queue,
 
 
 
-  device = command_queue->device;
+  device = POCL_REAL_DEV(command_queue->device);
 
   for (i = 0; i < command_queue->context->num_devices; ++i)
     {
@@ -108,7 +108,7 @@ POname(clEnqueueWriteBufferRect)(cl_command_queue command_queue,
       POname(clFinish)(command_queue);
     }
 
-  POCL_UPDATE_EVENT_RUNNING(event, command_queue);
+  POCL_UPDATE_EVENT_RUNNING(event);
 
   /* TODO: offset computation doesn't work in case the ptr is not 
      a direct pointer */
@@ -118,7 +118,7 @@ POname(clEnqueueWriteBufferRect)(cl_command_queue command_queue,
                            buffer_row_pitch, buffer_slice_pitch,
                            host_row_pitch, host_slice_pitch);
 
-  POCL_UPDATE_EVENT_COMPLETE(event, command_queue);
+  POCL_UPDATE_EVENT_COMPLETE(event);
 
   POname(clReleaseMemObject) (buffer);
 
diff --git a/lib/CL/clEnqueueWriteImage.c b/lib/CL/clEnqueueWriteImage.c
index 7cd8bab..2b65051 100644
--- a/lib/CL/clEnqueueWriteImage.c
+++ b/lib/CL/clEnqueueWriteImage.c
@@ -49,8 +49,6 @@ POname(clEnqueueWriteImage)(cl_command_queue    command_queue,
                                 event_wait_list);
   if (errcode != CL_SUCCESS)
     {
-      if (event)
-        POCL_MEM_FREE(*event);
       return errcode;
     }  
 
diff --git a/lib/CL/clFinish.c b/lib/CL/clFinish.c
index 03605e9..92e6161 100644
--- a/lib/CL/clFinish.c
+++ b/lib/CL/clFinish.c
@@ -1,17 +1,17 @@
 /* OpenCL runtime library: clFinish()
 
    Copyright (c) 2011 Erik Schnetter
-   
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -33,19 +33,21 @@ static void exec_commands (_cl_command_node *node_list);
 CL_API_ENTRY cl_int CL_API_CALL
 POname(clFinish)(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0
 {
-  int i;
+  unsigned i;
   _cl_command_node *node;
   cl_command_queue queue_at_hand;
   _cl_command_node *ready_list = NULL;
   cl_bool command_ready;
   cl_event *event;
-  
+
+  POCL_RETURN_ERROR_COND((command_queue == NULL), CL_INVALID_COMMAND_QUEUE);
+
   if (command_queue->properties & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE)
     POCL_ABORT_UNIMPLEMENTED("clFinish: Out-of-order queue");
 
   POCL_LOCK_OBJ (command_queue);
-  /* loop until queue given as parameter is empty. If command in queue has 
-     unsubmitted/uncomplete event move on to command_queue assosiated with that
+  /* loop until queue given as parameter is empty. If command in queue has
+     unsubmitted/incomplete event move on to command_queue associated with that
      event */
   queue_at_hand = command_queue;
   while (command_queue->root != NULL)
@@ -67,7 +69,7 @@ POname(clFinish)(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0
                   node->event_wait_list[i]->status != CL_SUBMITTED)
                 {
                   /* move to handle command queue with unqueued/unfinished
-                     prequisite event. Current node cannot be added to ready 
+                     prerequisite event. Current node cannot be added to ready
                      list */
                   queue_at_hand = node->event_wait_list[i]->queue;
                   command_ready = CL_FALSE;
@@ -79,7 +81,7 @@ POname(clFinish)(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0
           if (node->event)
             {
               event = &(node->event);
-              POCL_UPDATE_EVENT_SUBMITTED(event, command_queue);
+              POCL_UPDATE_EVENT_SUBMITTED(event);
             }
           /* remove command from queue and add to ready_list */
           LL_DELETE (queue_at_hand->root, node);
@@ -89,25 +91,21 @@ POname(clFinish)(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0
   POCL_UNLOCK_OBJ (command_queue);
 
   exec_commands(ready_list);
-  
+
   return CL_SUCCESS;
 }
 POsym(clFinish)
 
 static void exec_commands (_cl_command_node *node_list)
 {
-  int i;
+  unsigned i;
   cl_event *event = NULL;
   _cl_command_node *node;
-  cl_command_queue command_queue = NULL;
   event_callback_item* cb_ptr;
-  
+
   LL_FOREACH (node_list, node)
     {
       event = &(node->event);
-      /* Command queue is needed for POCL_UPDATE_EVENT macros */
-      if (node->event)
-        command_queue = node->event->queue;
 
       if (node->device->ops->compile_submitted_kernels)
         node->device->ops->compile_submitted_kernels (node);
@@ -115,74 +113,74 @@ static void exec_commands (_cl_command_node *node_list)
       switch (node->type)
         {
         case CL_COMMAND_READ_BUFFER:
-          POCL_UPDATE_EVENT_RUNNING(event, command_queue);
+          POCL_UPDATE_EVENT_RUNNING(event);
           node->device->ops->read
-            (node->device->data, 
-             node->command.read.host_ptr, 
+            (node->device->data,
+             node->command.read.host_ptr,
              node->command.read.device_ptr,
              node->command.read.offset,
-             node->command.read.cb); 
-          POCL_UPDATE_EVENT_COMPLETE(event, command_queue);
+             node->command.read.cb);
+          POCL_UPDATE_EVENT_COMPLETE(event);
           POname(clReleaseMemObject) (node->command.read.buffer);
           break;
         case CL_COMMAND_WRITE_BUFFER:
-          POCL_UPDATE_EVENT_RUNNING(event, command_queue);
+          POCL_UPDATE_EVENT_RUNNING(event);
           node->device->ops->write
-            (node->device->data, 
-             node->command.write.host_ptr, 
+            (node->device->data,
+             node->command.write.host_ptr,
              node->command.write.device_ptr,
              node->command.write.offset,
              node->command.write.cb);
-          POCL_UPDATE_EVENT_COMPLETE(event, command_queue);
+          POCL_UPDATE_EVENT_COMPLETE(event);
           POname(clReleaseMemObject) (node->command.write.buffer);
           break;
         case CL_COMMAND_COPY_BUFFER:
-          POCL_UPDATE_EVENT_RUNNING(event, command_queue);
+          POCL_UPDATE_EVENT_RUNNING(event);
           node->device->ops->copy
-            (node->command.copy.data, 
+            (node->command.copy.data,
              node->command.copy.src_ptr,
              node->command.copy.src_offset,
              node->command.copy.dst_ptr,
              node->command.copy.dst_offset,
              node->command.copy.cb);
-          POCL_UPDATE_EVENT_COMPLETE(event, command_queue);
+          POCL_UPDATE_EVENT_COMPLETE(event);
           POname(clReleaseMemObject) (node->command.copy.src_buffer);
           POname(clReleaseMemObject) (node->command.copy.dst_buffer);
           break;
         case CL_COMMAND_MAP_IMAGE:
-        case CL_COMMAND_MAP_BUFFER: 
-          POCL_UPDATE_EVENT_RUNNING(event, command_queue);            
-          pocl_map_mem_cmd (node->device, node->command.map.buffer, 
+        case CL_COMMAND_MAP_BUFFER:
+          POCL_UPDATE_EVENT_RUNNING(event);
+          pocl_map_mem_cmd (node->device, node->command.map.buffer,
                             node->command.map.mapping);
-          POCL_UPDATE_EVENT_COMPLETE(event, command_queue);
+          POCL_UPDATE_EVENT_COMPLETE(event);
           break;
         case CL_COMMAND_WRITE_IMAGE:
-          POCL_UPDATE_EVENT_RUNNING(event, command_queue); 
-          node->device->ops->write_rect 
+          POCL_UPDATE_EVENT_RUNNING(event);
+          node->device->ops->write_rect
             (node->device->data, node->command.rw_image.host_ptr,
              node->command.rw_image.device_ptr, node->command.rw_image.origin,
-             node->command.rw_image.origin, node->command.rw_image.region, 
-             node->command.rw_image.rowpitch, 
+             node->command.rw_image.origin, node->command.rw_image.region,
+             node->command.rw_image.rowpitch,
              node->command.rw_image.slicepitch,
              node->command.rw_image.rowpitch,
              node->command.rw_image.slicepitch);
-          POCL_UPDATE_EVENT_COMPLETE(event, command_queue);
+          POCL_UPDATE_EVENT_COMPLETE(event);
           break;
         case CL_COMMAND_READ_IMAGE:
-          POCL_UPDATE_EVENT_RUNNING(event, command_queue); 
-          node->device->ops->read_rect 
+          POCL_UPDATE_EVENT_RUNNING(event);
+          node->device->ops->read_rect
             (node->device->data, node->command.rw_image.host_ptr,
              node->command.rw_image.device_ptr, node->command.rw_image.origin,
-             node->command.rw_image.origin, node->command.rw_image.region, 
-             node->command.rw_image.rowpitch, 
+             node->command.rw_image.origin, node->command.rw_image.region,
+             node->command.rw_image.rowpitch,
              node->command.rw_image.slicepitch,
              node->command.rw_image.rowpitch,
              node->command.rw_image.slicepitch);
-          POCL_UPDATE_EVENT_COMPLETE(event, command_queue);
+          POCL_UPDATE_EVENT_COMPLETE(event);
           break;
         case CL_COMMAND_UNMAP_MEM_OBJECT:
-          POCL_UPDATE_EVENT_RUNNING(event, command_queue);
-          if ((node->command.unmap.memobj)->flags & 
+          POCL_UPDATE_EVENT_RUNNING(event);
+          if ((node->command.unmap.memobj)->flags &
               (CL_MEM_USE_HOST_PTR | CL_MEM_ALLOC_HOST_PTR))
             {
               /* TODO: should we ensure the device global region is updated from
@@ -191,51 +189,51 @@ static void exec_commands (_cl_command_node *node_list)
                  device accessible memory or just point there until the
                  kernel(s) get executed or similar? */
               /* Assume the region is automatically up to date. */
-            } else 
+            } else
             {
-              /* TODO: fixme. The offset computation must be done at the device 
+              /* TODO: fixme. The offset computation must be done at the device
                  driver. */
-              if (node->device->ops->unmap_mem != NULL)        
+              if (node->device->ops->unmap_mem != NULL)
                 node->device->ops->unmap_mem
-                  (node->device->data, 
-                   (node->command.unmap.mapping)->host_ptr, 
-                   (node->command.unmap.memobj)->device_ptrs[node->device->dev_id].mem_ptr, 
+                  (node->device->data,
+                   (node->command.unmap.mapping)->host_ptr,
+                   (node->command.unmap.memobj)->device_ptrs[node->device->dev_id].mem_ptr,
                    (node->command.unmap.mapping)->size);
             }
-          DL_DELETE((node->command.unmap.memobj)->mappings, 
+          DL_DELETE((node->command.unmap.memobj)->mappings,
                     node->command.unmap.mapping);
           (node->command.unmap.memobj)->map_count--;
-          POCL_UPDATE_EVENT_COMPLETE(event, command_queue);
+          POCL_UPDATE_EVENT_COMPLETE(event);
           break;
         case CL_COMMAND_NDRANGE_KERNEL:
           assert (*event == node->event);
-          POCL_UPDATE_EVENT_RUNNING(event, command_queue);
+          POCL_UPDATE_EVENT_RUNNING(event);
           node->device->ops->run(node->command.run.data, node);
-          POCL_UPDATE_EVENT_COMPLETE(event, command_queue);
+          POCL_UPDATE_EVENT_COMPLETE(event);
           for (i = 0; i < node->command.run.arg_buffer_count; ++i)
             {
               cl_mem buf = node->command.run.arg_buffers[i];
               if (buf == NULL) continue;
-              /*printf ("### releasing arg %d - the buffer %x of kernel %s\n", i, 
+              /*printf ("### releasing arg %d - the buffer %x of kernel %s\n", i,
                 buf,  node->command.run.kernel->function_name); */
               POname(clReleaseMemObject) (buf);
             }
           POCL_MEM_FREE(node->command.run.arg_buffers);
           POCL_MEM_FREE(node->command.run.tmp_dir);
-          for (i = 0; i < node->command.run.kernel->num_args + 
+          for (i = 0; i < node->command.run.kernel->num_args +
                  node->command.run.kernel->num_locals; ++i)
             {
               pocl_aligned_free (node->command.run.arguments[i].value);
               node->command.run.arguments[i].value = NULL;
             }
           POCL_MEM_FREE(node->command.run.arguments);
-      
+
           POname(clReleaseKernel)(node->command.run.kernel);
           break;
         case CL_COMMAND_NATIVE_KERNEL:
-          POCL_UPDATE_EVENT_RUNNING(event, command_queue);
+          POCL_UPDATE_EVENT_RUNNING(event);
           node->device->ops->run_native(node->command.native.data, node);
-          POCL_UPDATE_EVENT_COMPLETE(event, command_queue);
+          POCL_UPDATE_EVENT_COMPLETE(event);
           for (i = 0; i < node->command.native.num_mem_objects; ++i)
             {
               cl_mem buf = node->command.native.mem_list[i];
@@ -246,35 +244,35 @@ static void exec_commands (_cl_command_node *node_list)
           POCL_MEM_FREE(node->command.native.args);
 	      break;
         case CL_COMMAND_FILL_IMAGE:
-          POCL_UPDATE_EVENT_RUNNING(event, command_queue);
-          node->device->ops->fill_rect 
-            (node->command.fill_image.data, 
+          POCL_UPDATE_EVENT_RUNNING(event);
+          node->device->ops->fill_rect
+            (node->command.fill_image.data,
              node->command.fill_image.device_ptr,
              node->command.fill_image.buffer_origin,
              node->command.fill_image.region,
-             node->command.fill_image.rowpitch, 
+             node->command.fill_image.rowpitch,
              node->command.fill_image.slicepitch,
              node->command.fill_image.fill_pixel,
              node->command.fill_image.pixel_size);
           POCL_MEM_FREE(node->command.fill_image.fill_pixel);
-          POCL_UPDATE_EVENT_COMPLETE(event, command_queue);
+          POCL_UPDATE_EVENT_COMPLETE(event);
           break;
         case CL_COMMAND_MARKER:
-          POCL_UPDATE_EVENT_RUNNING(event, command_queue);
-          POCL_UPDATE_EVENT_COMPLETE(event, command_queue);
+          POCL_UPDATE_EVENT_RUNNING(event);
+          POCL_UPDATE_EVENT_COMPLETE(event);
           break;
         default:
           POCL_ABORT_UNIMPLEMENTED("clFinish: Unknown command");
           break;
-        }   
+        }
 
-        if (event)
+        if (*event)
           {
-            /* event callback handling 
+            /* event callback handling
                just call functions in the same order they were added */
             for (cb_ptr = (*event)->callback_list; cb_ptr; cb_ptr = cb_ptr->next)
               {
-                cb_ptr->callback_function ((*event), cb_ptr->trigger_status, 
+                cb_ptr->callback_function ((*event), cb_ptr->trigger_status,
                                            cb_ptr->user_data);
               }
             if ((*event)->implicit_event)
@@ -283,7 +281,7 @@ static void exec_commands (_cl_command_node *node_list)
     }
 
 
-  
+
   // free the queue contents
   node = node_list;
   node_list = NULL;
diff --git a/lib/CL/clGetDeviceIDs.c b/lib/CL/clGetDeviceIDs.c
index 07c918f..9a39cab 100644
--- a/lib/CL/clGetDeviceIDs.c
+++ b/lib/CL/clGetDeviceIDs.c
@@ -1,17 +1,17 @@
 /* OpenCL runtime library: clGetDeviceIDs()
 
-   Copyright (c) 2011 Kalle Raiskila 
-   
+   Copyright (c) 2011 Kalle Raiskila
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -26,10 +26,10 @@
 #include <string.h>
 
 CL_API_ENTRY cl_int CL_API_CALL
-POname(clGetDeviceIDs)(cl_platform_id   platform, 
-               cl_device_type   device_type, 
-               cl_uint          num_entries, 
-               cl_device_id *   devices, 
+POname(clGetDeviceIDs)(cl_platform_id   platform,
+               cl_device_type   device_type,
+               cl_uint          num_entries,
+               cl_device_id *   devices,
                cl_uint *        num_devices) CL_API_SUFFIX__VERSION_1_0
 {
   int total_num = 0;
@@ -45,12 +45,15 @@ POname(clGetDeviceIDs)(cl_platform_id   platform,
 
   total_num = pocl_get_device_type_count(device_type);
 
+  if (total_num == 0)
+      return CL_DEVICE_NOT_FOUND;
+
   if (devices != NULL)
     devices_added = pocl_get_devices(device_type, devices, num_entries);
- 
+
   if (num_devices != NULL)
     *num_devices = total_num;
-  
+
   if (devices_added > 0 || num_entries == 0)
     return CL_SUCCESS;
   else
diff --git a/lib/CL/clGetDeviceInfo.c b/lib/CL/clGetDeviceInfo.c
index b4b124b..b6d1c2c 100644
--- a/lib/CL/clGetDeviceInfo.c
+++ b/lib/CL/clGetDeviceInfo.c
@@ -236,18 +236,15 @@ POname(clGetDeviceInfo)(cl_device_id   device,
    * the values returned only serve the purpose of indicating
    * that it is not actually supported */
   case CL_DEVICE_PARENT_DEVICE                     :
-    POCL_RETURN_GETINFO(cl_device_id, NULL);
+    POCL_RETURN_GETINFO(cl_device_id, device->parent_device);
   case CL_DEVICE_PARTITION_MAX_SUB_DEVICES         :
-    POCL_RETURN_GETINFO(cl_uint, 2);
+    POCL_RETURN_GETINFO(cl_uint, device->max_sub_devices);
   case CL_DEVICE_PARTITION_PROPERTIES              :
+    POCL_RETURN_GETINFO_ARRAY(cl_device_partition_property,
+      device->num_partition_properties, device->partition_properties);
   case CL_DEVICE_PARTITION_TYPE                    :
-    {
-      /* since we don't support sub-devices, querying the partition type
-       * presently returns the same thing as querying the available partition
-       * properties, i.e. { 0} */
-      typedef struct { cl_device_partition_property prop[1]; } dev_pp_1;
-      POCL_RETURN_GETINFO(dev_pp_1, *(const dev_pp_1*)device->device_partition_properties);
-    }
+    POCL_RETURN_GETINFO_ARRAY(cl_device_partition_property,
+      device->num_partition_types, device->partition_type);
   case CL_DEVICE_PARTITION_AFFINITY_DOMAIN         :
     POCL_RETURN_GETINFO(cl_device_affinity_domain, 0);
 
diff --git a/lib/CL/clGetEventInfo.c b/lib/CL/clGetEventInfo.c
index ed1575d..5ab504b 100644
--- a/lib/CL/clGetEventInfo.c
+++ b/lib/CL/clGetEventInfo.c
@@ -21,7 +21,7 @@ CL_API_SUFFIX__VERSION_1_0
     case CL_EVENT_REFERENCE_COUNT:
       POCL_RETURN_GETINFO(cl_uint, event->pocl_refcount);
     case CL_EVENT_CONTEXT:
-      POCL_RETURN_GETINFO(cl_context, event->queue->context);
+      POCL_RETURN_GETINFO(cl_context, event->context);
     default:
       break;
     }
diff --git a/lib/CL/clGetKernelWorkGroupInfo.c b/lib/CL/clGetKernelWorkGroupInfo.c
index 6503781..42221a4 100644
--- a/lib/CL/clGetKernelWorkGroupInfo.c
+++ b/lib/CL/clGetKernelWorkGroupInfo.c
@@ -21,10 +21,10 @@ POname(clGetKernelWorkGroupInfo)
   /* check that kernel is associated with device, or that there is no risk of confusion */
   if (device != NULL)
     {
-      int i;
+      unsigned i;
       int found_it = 0;
       for (i = 0; i < kernel->context->num_devices; i++)
-        if (device == kernel->context->devices[i])
+        if (POCL_REAL_DEV(device) == kernel->context->devices[i])
         {
           found_it = 1;
           break;
diff --git a/lib/CL/clGetPlatformIDs.c b/lib/CL/clGetPlatformIDs.c
index 916e61c..309baf3 100644
--- a/lib/CL/clGetPlatformIDs.c
+++ b/lib/CL/clGetPlatformIDs.c
@@ -25,14 +25,20 @@
 #include <string.h>
 #include "pocl_cl.h"
 
+#ifdef __GNUC__
 #pragma GCC visibility push(hidden)
+#endif
+
 #ifdef BUILD_ICD
 struct _cl_icd_dispatch pocl_dispatch = POCL_ICD_DISPATCH;
 struct _cl_platform_id _platforms[1]  = {{&pocl_dispatch}};
 #else
 struct _cl_platform_id _platforms[1]  = {};
 #endif
+
+#ifdef __GNUC__
 #pragma GCC visibility pop
+#endif
 
 /*
  * Get the number of supported platforms on this system. 
@@ -43,8 +49,8 @@ POname(clGetPlatformIDs)(cl_uint           num_entries,
                  cl_platform_id *  platforms,
                  cl_uint *         num_platforms) CL_API_SUFFIX__VERSION_1_0
 {	
-  int const num = 1;
-  int i;
+  const unsigned num = 1;
+  unsigned i;
   
   if (platforms != NULL) {
     if (num_entries < num)
diff --git a/lib/CL/clGetPlatformInfo.c b/lib/CL/clGetPlatformInfo.c
index 205a903..36bf1d6 100644
--- a/lib/CL/clGetPlatformInfo.c
+++ b/lib/CL/clGetPlatformInfo.c
@@ -32,7 +32,7 @@ POname(clGetPlatformInfo)(cl_platform_id   platform,
                   size_t *         param_value_size_ret) CL_API_SUFFIX__VERSION_1_0
 {
   const char *ret;
-  int retlen;
+  size_t retlen;
   cl_platform_id tmp_platform;
 
   // TODO: if we don't have ICD in use, platform==NULL should be valid & point to pocl
diff --git a/lib/CL/clGetProgramBuildInfo.c b/lib/CL/clGetProgramBuildInfo.c
index 39b9d14..e4ef947 100644
--- a/lib/CL/clGetProgramBuildInfo.c
+++ b/lib/CL/clGetProgramBuildInfo.c
@@ -23,6 +23,8 @@
 
 #include "pocl_cl.h"
 #include "pocl_util.h"
+#include "pocl_file_util.h"
+#include "pocl_cache.h"
 #include <string.h>
 
 CL_API_ENTRY cl_int CL_API_CALL
@@ -33,19 +35,12 @@ POname(clGetProgramBuildInfo)(cl_program            program,
                       void *                param_value,
                       size_t *              param_value_size_ret) CL_API_SUFFIX__VERSION_1_0
 {
-  const char *empty_str = "";      /* dummy return value */
   const char *str;
 
-  int i;
-  cl_bool found;
-
   POCL_RETURN_ERROR_COND((program == NULL), CL_INVALID_PROGRAM);
 
-  found = CL_FALSE;
-  for (i = 0; i < program->num_devices; i++)
-    if (device == program->devices[i]) found = CL_TRUE;
-
-  POCL_RETURN_ERROR_ON((found == CL_FALSE), CL_INVALID_DEVICE, "Program was not "
+  int device_i = pocl_cl_device_to_index(program, device);
+  POCL_RETURN_ERROR_ON((device_i < 0), CL_INVALID_DEVICE, "Program was not "
     "built for this device\n")
 
   switch (param_name) {
@@ -56,25 +51,32 @@ POname(clGetProgramBuildInfo)(cl_program            program,
     
   case CL_PROGRAM_BUILD_OPTIONS:
     {
-      str = (program->compiler_options)? program->compiler_options: empty_str;
+      str = (program->compiler_options)? program->compiler_options: "";
       POCL_RETURN_GETINFO_STR(str);
     }
     
   case CL_PROGRAM_BUILD_LOG:
     {
-      char *build_log = NULL;
-      char buildlog_file_name[POCL_FILENAME_LENGTH];
-      snprintf(buildlog_file_name, POCL_FILENAME_LENGTH, "%s/%s",
-               program->cache_dir, POCL_BUILDLOG_FILENAME);
-
-      str = (pocl_read_text_file(buildlog_file_name, &build_log))?
-                        build_log: empty_str;
+      char *build_log;
+      if (program->main_build_log[0])
+          build_log = strdup(program->main_build_log);
+      else if (program->build_log[device_i])
+          build_log = strdup(program->build_log[device_i]);
+      else
+          build_log = pocl_cache_read_buildlog(program, device_i);
+      if (program->build_status == CL_BUILD_NONE)
+          build_log = "";
+      POCL_RETURN_ERROR_ON((build_log==NULL), CL_OUT_OF_HOST_MEMORY, "failed to read build log");
 
-      size_t const value_size = strlen(str) + 1;
+      size_t const value_size = strlen(build_log) + 1;
       if (param_value)
       {
-        if (param_value_size < value_size) return CL_INVALID_VALUE;
-        memcpy(param_value, str, value_size);
+        if (param_value_size < value_size)
+        {
+            POCL_MEM_FREE(build_log);
+            return CL_INVALID_VALUE;
+        }
+        memcpy(param_value, build_log, value_size);
       }
       POCL_MEM_FREE(build_log);
       if (param_value_size_ret)
diff --git a/lib/CL/clGetProgramInfo.c b/lib/CL/clGetProgramInfo.c
index 6974535..b1ac8ee 100644
--- a/lib/CL/clGetProgramInfo.c
+++ b/lib/CL/clGetProgramInfo.c
@@ -21,8 +21,10 @@
    THE SOFTWARE.
 */
 
+#include <string.h>
 #include "pocl_llvm.h"
 #include "pocl_util.h"
+#include "pocl_cache.h"
 
 CL_API_ENTRY cl_int CL_API_CALL
 POname(clGetProgramInfo)(cl_program program,
@@ -31,7 +33,7 @@ POname(clGetProgramInfo)(cl_program program,
                  void *param_value,
                  size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0
 {
-  int i;
+  unsigned i;
 
   POCL_RETURN_ERROR_COND((program == NULL), CL_INVALID_PROGRAM);
 
@@ -56,6 +58,7 @@ POname(clGetProgramInfo)(cl_program program,
       size_t const value_size = sizeof(size_t) * program->num_devices;
       if (param_value)
         pocl_llvm_update_binaries (program);
+
       POCL_RETURN_GETINFO_SIZE(value_size, program->binary_sizes);
     }
 
@@ -65,9 +68,9 @@ POname(clGetProgramInfo)(cl_program program,
       if (param_value)
       {
         if (param_value_size < value_size) return CL_INVALID_VALUE;
+        unsigned char **target = (unsigned char**) param_value;
         for (i = 0; i < program->num_devices; ++i)
           {
-            unsigned char **target = (unsigned char**) param_value;
             if (target[i] == NULL) continue;
             memcpy (target[i], program->binaries[i], program->binary_sizes[i]);
           }
@@ -85,20 +88,48 @@ POname(clGetProgramInfo)(cl_program program,
       if (param_value)
       {
         if (param_value_size < value_size) return CL_INVALID_VALUE;
-        for (i = 0; i < program->num_devices; ++i)
-          {           
-            cl_device_id *devices = (cl_device_id*) param_value;
-            devices[i] = program->context->devices[i];
-          }
+        memcpy(param_value, (void*)program->devices, value_size);
       }
       if (param_value_size_ret)
         *param_value_size_ret = value_size;
       return CL_SUCCESS;
     }
+  case CL_PROGRAM_NUM_KERNELS:
+    {
+      size_t num_kernels = pocl_llvm_get_kernel_count(program);
+      POCL_RETURN_GETINFO(size_t, num_kernels);
+    }
+  case CL_PROGRAM_KERNEL_NAMES:
+    {
+      const char *kernel_names[32];
+      unsigned num_kernels = 0;
+      size_t size = 0;
+      num_kernels = pocl_llvm_get_kernel_names(program, kernel_names, 32);
+      for (i = 0; i < num_kernels; ++i)
+        {
+          if (size + strlen (kernel_names[i]) + 1 >= param_value_size)
+            break;
+          size += strlen (kernel_names[i]) + 1;
+          
+          if (i == 0)
+            memcpy (param_value, kernel_names[i], strlen(kernel_names[i])+1);
+          else
+            strcat((char*)param_value, kernel_names[i]);
+          if (i != num_kernels - 1)
+            strcat ((char*)param_value, ";");
+        }
+
+      if (param_value_size_ret)
+        *param_value_size_ret = size;      
+      return CL_SUCCESS;
+    }
   default:
     break;
   }
-  POCL_ABORT_UNIMPLEMENTED("clGetProgramInfo: unknown param_name");
+  
+  char error_str[64];
+  sprintf(error_str, "clGetProgramInfo: %X", param_name);
+  POCL_ABORT_UNIMPLEMENTED(error_str);
   return CL_INVALID_VALUE;
 }
 POsym(clGetProgramInfo)
diff --git a/lib/CL/clGetSupportedImageFormats.c b/lib/CL/clGetSupportedImageFormats.c
index f4c2275..f9178d5 100644
--- a/lib/CL/clGetSupportedImageFormats.c
+++ b/lib/CL/clGetSupportedImageFormats.c
@@ -35,15 +35,15 @@ POname(clGetSupportedImageFormats) (cl_context           context,
                                     cl_uint *            num_image_formats) 
 CL_API_SUFFIX__VERSION_1_0
 {
-  int i, j;
+  unsigned i, j;
   cl_device_id device_id;
   const cl_image_format **dev_image_formats = 0;
-  int *dev_num_image_formats = 0;
+  unsigned *dev_num_image_formats = 0;
   int errcode = 0;
   
   cl_image_format reff;
   int reff_found;
-  int formatCount = 0;
+  unsigned formatCount = 0;
   
   POCL_RETURN_ERROR_COND((context == NULL), CL_INVALID_CONTEXT);
 
@@ -52,17 +52,22 @@ CL_API_SUFFIX__VERSION_1_0
   POCL_RETURN_ERROR_COND((num_entries == 0 && image_formats != NULL), CL_INVALID_VALUE);
   
   dev_image_formats = (const cl_image_format**) calloc (context->num_devices, sizeof(cl_image_format*));
-  dev_num_image_formats = (int*) calloc (context->num_devices, sizeof(int));
-  
+  dev_num_image_formats = (unsigned*) calloc (context->num_devices, sizeof(unsigned));
+
   if (dev_image_formats == NULL || dev_num_image_formats == NULL)
-    return CL_OUT_OF_HOST_MEMORY;
-  
+    {
+      /* one might have been allocated, but the other not */
+      free(dev_image_formats);
+      free(dev_num_image_formats);
+      return CL_OUT_OF_HOST_MEMORY;
+    }
+
   /* get supported image formats from devices */
   for (i = 0; i < context->num_devices; ++i)
     {    
       device_id = context->devices[i];
       errcode = device_id->ops->get_supported_image_formats 
-        (flags, dev_image_formats+i, dev_num_image_formats + i);
+        (flags, dev_image_formats+i, (cl_uint*)(dev_num_image_formats + i));
       
       if (errcode != CL_SUCCESS)
         goto CLEAN_MEM_AND_RETURN;
diff --git a/lib/CL/clReleaseCommandQueue.c b/lib/CL/clReleaseCommandQueue.c
index de363dc..c79465c 100644
--- a/lib/CL/clReleaseCommandQueue.c
+++ b/lib/CL/clReleaseCommandQueue.c
@@ -23,6 +23,7 @@
 
 #include "pocl_cl.h"
 #include "pocl_util.h"
+#include "pocl_queue_util.h"
 
 CL_API_ENTRY cl_int CL_API_CALL
 POname(clReleaseCommandQueue)(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0
@@ -34,6 +35,7 @@ POname(clReleaseCommandQueue)(cl_command_queue command_queue) CL_API_SUFFIX__VER
   POCL_RELEASE_OBJECT(command_queue, new_refcount);
   if (new_refcount == 0)
     {
+      pocl_queue_list_delete(command_queue);
       POCL_MEM_FREE(command_queue);
       /* TODO: should clReleaseContext()? */
     }
diff --git a/lib/CL/clReleaseContext.c b/lib/CL/clReleaseContext.c
index b59f034..77d43d1 100644
--- a/lib/CL/clReleaseContext.c
+++ b/lib/CL/clReleaseContext.c
@@ -37,7 +37,7 @@ POname(clReleaseContext)(cl_context context) CL_API_SUFFIX__VERSION_1_0
          references and let the objects to get freed. */
       /* TODO: call the corresponding clRelease* functions
          for all the referred objects. */
-      int i;
+      unsigned i;
       for (i = 0; i < context->num_devices; ++i) 
         {
           POname(clReleaseDevice) (context->devices[i]);
diff --git a/lib/CL/clReleaseDevice.c b/lib/CL/clReleaseDevice.c
index 42afbee..b48b29e 100644
--- a/lib/CL/clReleaseDevice.c
+++ b/lib/CL/clReleaseDevice.c
@@ -26,15 +26,14 @@
 CL_API_ENTRY cl_int CL_API_CALL
 POname(clReleaseDevice)(cl_device_id device) CL_API_SUFFIX__VERSION_1_2 
 {
+  if (device->parent_device == NULL)
+    return CL_SUCCESS;
+
   int new_refcount;
   POCL_RELEASE_OBJECT (device, new_refcount);
-  (void)new_refcount;
 
-  /* Cannot free() the device driver objects because they
-     can be in use in other contexts and might be needed
-     later on. The device driver table initialized in devices.c
-     is reused across many contexts.
-  */
+  if (new_refcount == 0)
+    POCL_MEM_FREE(device);
 
   return CL_SUCCESS;
 }
diff --git a/lib/CL/clReleaseEvent.c b/lib/CL/clReleaseEvent.c
index 436f568..6f94ea4 100644
--- a/lib/CL/clReleaseEvent.c
+++ b/lib/CL/clReleaseEvent.c
@@ -30,13 +30,15 @@ POname(clReleaseEvent)(cl_event event) CL_API_SUFFIX__VERSION_1_0
   int new_refcount;
   POCL_RETURN_ERROR_COND((event == NULL), CL_INVALID_EVENT);
 
-  POCL_RETURN_ERROR_COND((event->queue == NULL), CL_INVALID_EVENT);
+  POCL_RETURN_ERROR_COND((event->context == NULL), CL_INVALID_EVENT);
 
   POCL_RELEASE_OBJECT (event, new_refcount);
 
   if (new_refcount == 0)
     {
-      POname(clReleaseCommandQueue) (event->queue);
+      POname(clReleaseContext) (event->context);
+      if (event->queue)
+        POname(clReleaseCommandQueue) (event->queue);
       pocl_mem_manager_free_event (event);
     }
 
diff --git a/lib/CL/clReleaseKernel.c b/lib/CL/clReleaseKernel.c
index 8f26acb..c0bd62a 100644
--- a/lib/CL/clReleaseKernel.c
+++ b/lib/CL/clReleaseKernel.c
@@ -29,7 +29,7 @@ POname(clReleaseKernel)(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0
 {
   int new_refcount;
   cl_kernel *pk;
-  int i;
+  unsigned i;
 
   POCL_RETURN_ERROR_COND((kernel == NULL), CL_INVALID_KERNEL);
 
@@ -58,7 +58,6 @@ POname(clReleaseKernel)(cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0
           POname(clReleaseProgram) (kernel->program);
         }
       
-      POCL_MEM_FREE(kernel->function_name);
       POCL_MEM_FREE(kernel->name);
 
       for (i = 0; i < kernel->num_args; i++)
diff --git a/lib/CL/clReleaseProgram.c b/lib/CL/clReleaseProgram.c
index 4cfe8a5..c003ef7 100644
--- a/lib/CL/clReleaseProgram.c
+++ b/lib/CL/clReleaseProgram.c
@@ -32,13 +32,15 @@
 
 #include "pocl_cl.h"
 #include "pocl_util.h"
-#include "pocl_runtime_config.h"
+#include "pocl_cache.h"
+#include "devices.h"
 
 CL_API_ENTRY cl_int CL_API_CALL
 POname(clReleaseProgram)(cl_program program) CL_API_SUFFIX__VERSION_1_0
 {
   int new_refcount;
   cl_kernel k;
+  unsigned i;
 
   POCL_RETURN_ERROR_COND((program == NULL), CL_INVALID_PROGRAM);
 
@@ -61,23 +63,22 @@ POname(clReleaseProgram)(cl_program program) CL_API_SUFFIX__VERSION_1_0
 
       POCL_RELEASE_OBJECT (program->context, new_refcount);
       POCL_MEM_FREE(program->source);
-      
-      if (program->binaries != NULL)
-        {
-          POCL_MEM_FREE(program->binaries[0]);
-          POCL_MEM_FREE(program->binaries);
-        }
+
       POCL_MEM_FREE(program->binary_sizes);
+      if (program->binaries)
+        for (i = 0; i < program->num_devices; ++i)
+          POCL_MEM_FREE(program->binaries[i]);
+      POCL_MEM_FREE(program->binaries);
 
-      if ((!pocl_get_bool_option("POCL_KERNEL_CACHE", POCL_BUILD_KERNEL_CACHE)) &&
-            (!pocl_get_bool_option("POCL_LEAVE_KERNEL_COMPILER_TEMP_FILES", 0)) &&
-            program->cache_dir)
-        {
-          pocl_remove_directory (program->cache_dir);
-        }
+      pocl_cache_cleanup_cachedir(program);
+
+      if (program->build_log)
+        for (i = 0; i < program->num_devices; ++i)
+          POCL_MEM_FREE(program->build_log[i]);
+      POCL_MEM_FREE(program->build_log);
 
+      POCL_MEM_FREE(program->build_hash);
       POCL_MEM_FREE(program->llvm_irs);
-      POCL_MEM_FREE(program->cache_dir);
       POCL_MEM_FREE(program);
     }
 
diff --git a/lib/CL/clRetainDevice.c b/lib/CL/clRetainDevice.c
index f9c9a88..5f7e10a 100644
--- a/lib/CL/clRetainDevice.c
+++ b/lib/CL/clRetainDevice.c
@@ -25,6 +25,9 @@
 CL_API_ENTRY cl_int CL_API_CALL
 POname(clRetainDevice)(cl_device_id device) CL_API_SUFFIX__VERSION_1_2
 {
+  if (device->parent_device == NULL)
+    return CL_SUCCESS;
+
   POCL_RETAIN_OBJECT (device);
   return CL_SUCCESS;
 }
diff --git a/lib/CL/clRetainEvent.c b/lib/CL/clRetainEvent.c
index c3823b0..b73e9df 100644
--- a/lib/CL/clRetainEvent.c
+++ b/lib/CL/clRetainEvent.c
@@ -5,8 +5,6 @@ POname(clRetainEvent)(cl_event  event ) CL_API_SUFFIX__VERSION_1_0
 {
   POCL_RETURN_ERROR_COND((event == NULL), CL_INVALID_EVENT);
 
-  POCL_RETURN_ERROR_COND((event->queue == NULL), CL_INVALID_EVENT);
-
   POCL_RETAIN_OBJECT(event);
 
   return CL_SUCCESS;
diff --git a/lib/CL/clSetKernelArg.c b/lib/CL/clSetKernelArg.c
index 51dcdb4..086bbc1 100644
--- a/lib/CL/clSetKernelArg.c
+++ b/lib/CL/clSetKernelArg.c
@@ -61,6 +61,11 @@ POname(clSetKernelArg)(cl_kernel kernel,
     CL_INVALID_ARG_SIZE, "Arg %u is pointer/buffer/image, but arg_size is "
     "not sizeof(cl_mem)", arg_index);
 
+  POCL_RETURN_ERROR_ON((pi->type == POCL_ARG_TYPE_SAMPLER
+    && (arg_size != sizeof(cl_sampler_t))),
+    CL_INVALID_ARG_SIZE, "Arg %u is sampler, but arg_size is "
+    "not sizeof(cl_sampler_t)", arg_index);
+
   p = &(kernel->dyn_arguments[arg_index]); 
   POCL_LOCK_OBJ (kernel);
   pi->is_set = 0;
diff --git a/lib/CL/clSetUserEventStatus.c b/lib/CL/clSetUserEventStatus.c
index 006ec5a..b753d90 100644
--- a/lib/CL/clSetUserEventStatus.c
+++ b/lib/CL/clSetUserEventStatus.c
@@ -3,11 +3,18 @@ CL_API_ENTRY cl_int CL_API_CALL
 POname(clSetUserEventStatus)(cl_event    event ,
                      cl_int      execution_status ) CL_API_SUFFIX__VERSION_1_1
 {
-  if(event == NULL)
+  /* Must be a valid user event */
+  if (event == NULL || event->command_type != CL_COMMAND_USER)
     return CL_INVALID_EVENT;
+  /* Can only be set to CL_COMPLETE (0) or negative values */
+  if (execution_status > CL_COMPLETE)
+    return CL_INVALID_VALUE;
+  /* Can only be done once */
+  if (event->status <= CL_COMPLETE)
+    return CL_INVALID_OPERATION;
 
   event->status = execution_status;
-  
+
   return CL_SUCCESS;
 }
 POsym(clSetUserEventStatus)
diff --git a/lib/CL/clWaitForEvents.c b/lib/CL/clWaitForEvents.c
index db0310a..eabc13e 100644
--- a/lib/CL/clWaitForEvents.c
+++ b/lib/CL/clWaitForEvents.c
@@ -27,7 +27,19 @@ CL_API_ENTRY cl_int CL_API_CALL
 POname(clWaitForEvents)(cl_uint              num_events ,
                   const cl_event *     event_list ) CL_API_SUFFIX__VERSION_1_0
 {
-  int event_i;
+  unsigned event_i;
+
+  POCL_RETURN_ERROR_COND((num_events == 0 || event_list == NULL), CL_INVALID_VALUE);
+
+  for (event_i = 0; event_i < num_events; ++event_i)
+    {
+      POCL_RETURN_ERROR_COND((event_list[event_i] == NULL), CL_INVALID_EVENT);
+      if (event_i > 0)
+        {
+          POCL_RETURN_ERROR_COND((event_list[event_i]->context != event_list[event_i - 1]->context), CL_INVALID_CONTEXT);
+        }
+    }
+
   // dummy implementation, waits until *all* events have completed.
   for (event_i = 0; event_i < num_events; ++event_i)
     {
diff --git a/lib/CL/devices/CMakeLists.txt b/lib/CL/devices/CMakeLists.txt
index f4868e5..5c017e7 100644
--- a/lib/CL/devices/CMakeLists.txt
+++ b/lib/CL/devices/CMakeLists.txt
@@ -34,8 +34,8 @@ set(POCL_DEVICES_OBJS "$<TARGET_OBJECTS:pocl-devices>"
       "$<TARGET_OBJECTS:pocl-devices-topology>")
 
 if(ENABLE_TCE)
-  add_subdirectory("tce")
   include_directories(AFTER "tce")
+  add_subdirectory("tce")
   list(APPEND POCL_DEVICES_LINK_LIST ${TCE_LIBS})
   list(APPEND POCL_DEVICES_OBJS "$<TARGET_OBJECTS:pocl-devices-tce-ttasim>")
 endif()
@@ -45,6 +45,13 @@ if(ENABLE_SPU)
   list(APPEND POCL_DEVICES_LINK_LIST "spe2")
 endif()
 
+if(ENABLE_HSA)
+  include_directories(AFTER "${HSA_INCLUDES}")
+  add_subdirectory("hsa")
+  list(APPEND POCL_DEVICES_LINK_LIST ${HSALIB})
+  list(APPEND POCL_DEVICES_OBJS "$<TARGET_OBJECTS:pocl-devices-hsa>")
+endif()
+
 set(POCL_DEVICES_SOURCES 
   devices.h  devices.c
   bufalloc.c  dev_image.h
diff --git a/lib/CL/devices/Makefile.am b/lib/CL/devices/Makefile.am
index 7b6e8e8..e7f9fee 100644
--- a/lib/CL/devices/Makefile.am
+++ b/lib/CL/devices/Makefile.am
@@ -50,4 +50,9 @@ SUBDIRS += cellspu
 libpocl_devices_la_LIBADD += cellspu/libpocl-devices-cellspu.la
 endif
 
+if BUILD_HSA
+SUBDIRS += hsa
+libpocl_devices_la_LIBADD += hsa/libpocl-devices-hsa.la
+endif
+
 EXTRA_DIST = CMakeLists.txt
diff --git a/lib/CL/devices/Makefile.in b/lib/CL/devices/Makefile.in
index f7c4477..8257161 100644
--- a/lib/CL/devices/Makefile.in
+++ b/lib/CL/devices/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -40,7 +40,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -108,9 +118,9 @@ target_triplet = @target@
 @TCE_AVAILABLE_TRUE at am__append_2 = tce/libpocl-devices-tce.la
 @BUILD_SPU_TRUE at am__append_3 = cellspu
 @BUILD_SPU_TRUE at am__append_4 = cellspu/libpocl-devices-cellspu.la
+ at BUILD_HSA_TRUE@am__append_5 = hsa
+ at BUILD_HSA_TRUE@am__append_6 = hsa/libpocl-devices-hsa.la
 subdir = lib/CL/devices
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -119,6 +129,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -127,7 +138,7 @@ LTLIBRARIES = $(noinst_LTLIBRARIES)
 libpocl_devices_la_DEPENDENCIES = pthread/libpocl-devices-pthread.la \
 	basic/libpocl-devices-basic.la \
 	topology/libpocl-devices-topology.la $(am__append_2) \
-	$(am__append_4)
+	$(am__append_4) $(am__append_6)
 am_libpocl_devices_la_OBJECTS = libpocl_devices_la-devices.lo \
 	libpocl_devices_la-bufalloc.lo libpocl_devices_la-common.lo \
 	libpocl_devices_la-cpuinfo.lo
@@ -212,7 +223,8 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
-DIST_SUBDIRS = topology pthread basic tce cellspu
+DIST_SUBDIRS = topology pthread basic tce cellspu hsa
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 am__relativize = \
   dir0=`pwd`; \
@@ -289,6 +301,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -325,6 +340,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -439,7 +455,8 @@ target_vendor = @target_vendor@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-SUBDIRS = topology pthread basic $(am__append_1) $(am__append_3)
+SUBDIRS = topology pthread basic $(am__append_1) $(am__append_3) \
+	$(am__append_5)
 noinst_LTLIBRARIES = libpocl-devices.la
 libpocl_devices_la_SOURCES = devices.h devices.c bufalloc.c dev_image.h \
 	prototypes.inc common.h common.c bufalloc.h cpuinfo.c cpuinfo.h
@@ -447,7 +464,7 @@ libpocl_devices_la_SOURCES = devices.h devices.c bufalloc.c dev_image.h \
 libpocl_devices_la_LIBADD = pthread/libpocl-devices-pthread.la \
 	basic/libpocl-devices-basic.la \
 	topology/libpocl-devices-topology.la $(am__append_2) \
-	$(am__append_4)
+	$(am__append_4) $(am__append_6)
 libpocl_devices_la_CPPFLAGS = \
   -I$(top_srcdir)/fix-include \
   -I$(top_srcdir)/include \
@@ -473,7 +490,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/CL/devices/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign lib/CL/devices/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -849,6 +865,8 @@ uninstall-am:
 	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
 	uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/lib/CL/devices/basic/Makefile.in b/lib/CL/devices/basic/Makefile.in
index d7b039b..2365960 100644
--- a/lib/CL/devices/basic/Makefile.in
+++ b/lib/CL/devices/basic/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -104,8 +114,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = lib/CL/devices/basic
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -114,6 +122,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -192,6 +201,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -243,6 +253,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -279,6 +292,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -416,7 +430,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/CL/devices/basic/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign lib/CL/devices/basic/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -694,6 +707,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/lib/CL/devices/basic/basic.c b/lib/CL/devices/basic/basic.c
index 300a1be..a1a500e 100644
--- a/lib/CL/devices/basic/basic.c
+++ b/lib/CL/devices/basic/basic.c
@@ -32,19 +32,21 @@
 #include <assert.h>
 #include <string.h>
 #include <stdlib.h>
-#include <dev_image.h>
 
 #ifndef _MSC_VER
 #  include <sys/time.h>
+#  include <sys/resource.h>
 #  include <unistd.h>
 #else
 #  include "vccompat.hpp"
 #endif
 
+#include "pocl_cache.h"
+
 #define max(a,b) (((a) > (b)) ? (a) : (b))
 
 #define COMMAND_LENGTH 2048
-#define WORKGROUP_STRING_LENGTH 128
+#define WORKGROUP_STRING_LENGTH 1024
 
 struct data {
   /* Currently loaded kernel. */
@@ -53,7 +55,7 @@ struct data {
   lt_dlhandle current_dlhandle;
 };
 
-const cl_image_format supported_image_formats[] = {
+static const cl_image_format supported_image_formats[] = {
     { CL_R, CL_SNORM_INT8 },
     { CL_R, CL_SNORM_INT16 },
     { CL_R, CL_UNORM_INT8 },
@@ -221,9 +223,7 @@ pocl_basic_init_device_infos(struct _cl_device_id* dev)
   dev->vendor_id = 0;
   dev->max_compute_units = 0;
   dev->max_work_item_dimensions = 3;
-  dev->max_work_item_sizes[0] = SIZE_MAX;
-  dev->max_work_item_sizes[1] = SIZE_MAX;
-  dev->max_work_item_sizes[2] = SIZE_MAX;
+
   /*
     The hard restriction will be the context data which is
     stored in stack that can be as small as 8K in Linux.
@@ -231,7 +231,9 @@ pocl_basic_init_device_infos(struct _cl_device_id* dev)
     the SIMD lanes times the vector units, but not more than
     that to avoid stack overflow and cache trashing.
   */
-  dev->max_work_group_size = 1024*4;
+  dev->max_work_item_sizes[0] = dev->max_work_item_sizes[1] =
+	  dev->max_work_item_sizes[2] = dev->max_work_group_size = 1024*4;
+
   dev->preferred_wg_size_multiple = 8;
   dev->preferred_vector_width_char = POCL_DEVICES_PREFERRED_VECTOR_WIDTH_CHAR;
   dev->preferred_vector_width_short = POCL_DEVICES_PREFERRED_VECTOR_WIDTH_SHORT;
@@ -251,20 +253,22 @@ pocl_basic_init_device_infos(struct _cl_device_id* dev)
   dev->max_clock_frequency = 0;
   dev->address_bits = POCL_DEVICE_ADDRESS_BITS;
 
+  dev->image_support = CL_TRUE;
   /* Use the minimum values until we get a more sensible
      upper limit from somewhere. */
   dev->max_read_image_args = dev->max_write_image_args = 128;
   dev->image2d_max_width = dev->image2d_max_height = 8192;
   dev->image3d_max_width = dev->image3d_max_height = dev->image3d_max_depth = 2048;
+  dev->image_max_buffer_size = 65536;
+  dev->image_max_array_size = 2048;
   dev->max_samplers = 16;
   dev->max_constant_args = 8;
 
   dev->max_mem_alloc_size = 0;
-  dev->image_support = CL_TRUE;
-  dev->image_max_buffer_size = 0;
-  dev->image_max_array_size = 0;
+
   dev->max_parameter_size = 1024;
-  dev->min_data_type_align_size = dev->mem_base_addr_align = MAX_EXTENDED_ALIGNMENT;
+  dev->min_data_type_align_size = MAX_EXTENDED_ALIGNMENT; // this is in bytes
+  dev->mem_base_addr_align = MAX_EXTENDED_ALIGNMENT*8; // this is in bits
   dev->half_fp_config = 0;
   dev->single_fp_config = CL_FP_ROUND_TO_NEAREST | CL_FP_INF_NAN;
   dev->double_fp_config = CL_FP_ROUND_TO_NEAREST | CL_FP_INF_NAN;
@@ -281,11 +285,24 @@ pocl_basic_init_device_infos(struct _cl_device_id* dev)
   dev->endian_little = !(WORDS_BIGENDIAN);
   dev->available = CL_TRUE;
   dev->compiler_available = CL_TRUE;
+  dev->spmd = CL_FALSE;
   dev->execution_capabilities = CL_EXEC_KERNEL | CL_EXEC_NATIVE_KERNEL;
   dev->queue_properties = CL_QUEUE_PROFILING_ENABLE;
   dev->platform = 0;
-  dev->device_partition_properties[0] = 0;
-  dev->printf_buffer_size = 0;
+
+  dev->parent_device = NULL;
+  // basic does not support partitioning
+  dev->max_sub_devices = 1;
+  dev->num_partition_properties = 1;
+  dev->partition_properties = calloc(dev->num_partition_properties,
+    sizeof(cl_device_partition_property));
+  dev->num_partition_types = 0;
+  dev->partition_type = NULL;
+
+  /* printf buffer size is meaningless for pocl, so just set it to
+   * the minimum value required by the spec
+   */
+  dev->printf_buffer_size = 1024*1024 ;
   dev->vendor = "pocl";
   dev->profile = "FULL_PROFILE";
   /* Note: The specification describes identifiers being delimited by
@@ -306,11 +323,15 @@ pocl_basic_init_device_infos(struct _cl_device_id* dev)
 #define HALF_EXT
 #endif
 
-  dev->extensions = DOUBLE_EXT HALF_EXT "cl_khr_byte_addressable_store";
+  dev->extensions = DOUBLE_EXT HALF_EXT "cl_khr_byte_addressable_store "
+      "cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics "
+      "cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics "
+      "cl_khr_int64_base_atomics cl_khr_int64_extended_atomics";
 
   dev->llvm_target_triplet = OCL_KERNEL_TARGET;
   dev->llvm_cpu = OCL_KERNEL_TARGET_CPU;
   dev->has_64bit_long = 1;
+  dev->autolocals_to_args = 1;
 }
 
 unsigned int
@@ -325,12 +346,79 @@ pocl_basic_probe(struct pocl_device_ops *ops)
   return env_count;
 }
 
+#define MIN_MAX_MEM_ALLOC_SIZE (128*1024*1024)
+
+/* set maximum allocation sizes for buffers and images */
+void
+pocl_basic_set_buffer_image_limits(cl_device_id device)
+{
+  /* Maximum allocation size: we don't have hardware limits, so we
+   * can potentially allocate the whole memory for a single buffer, unless
+   * of course there are limits set at the operating system level. Of course
+   * we still have to respect the OpenCL-commanded minimum */
+  size_t alloc_limit = SIZE_MAX;
+
+#ifndef _MSC_VER
+  // TODO getrlimit equivalent under Windows
+  struct rlimit limits;
+  int ret = getrlimit(RLIMIT_DATA, &limits);
+  if (ret == 0)
+    alloc_limit = limits.rlim_cur;
+#endif
+  if (alloc_limit > device->global_mem_size)
+    alloc_limit = device->global_mem_size;
+  else if (alloc_limit < MIN_MAX_MEM_ALLOC_SIZE)
+    alloc_limit = MIN_MAX_MEM_ALLOC_SIZE;
+  // TODO in theory now if alloc_limit was > rlim_cur and < rlim_max
+  // we should try and setrlimit to alloc_limit, or allocations might fail
+
+  device->local_mem_size = device->max_constant_buffer_size =
+    device->max_mem_alloc_size = alloc_limit;
+
+  /* We don't have hardware limitations on the buffer-backed image sizes,
+   * so we set the maximum size in terms of the maximum amount of pixels
+   * that fix in max_mem_alloc_size. A single pixel can take up to 4 32-bit channels,
+   * i.e. 16 bytes.
+   */
+  size_t max_pixels = device->max_mem_alloc_size/16;
+  if (max_pixels > device->image_max_buffer_size)
+    device->image_max_buffer_size = max_pixels;
+
+  /* Similarly, we can take the 2D image size limit to be the largest power of 2
+   * whose square fits in image_max_buffer_size; since the 2D image size limit
+   * starts at a power of 2, it's a simple matter of doubling.
+   * This is actually completely arbitrary, another equally valid option
+   * would be to have each maximum dimension match the image_max_buffer_size.
+   */
+  max_pixels = device->image2d_max_width;
+  // keep doubing until we go over
+  while (max_pixels <= device->image_max_buffer_size/max_pixels)
+    max_pixels *= 2;
+  // halve before assignment
+  max_pixels /= 2;
+  if (max_pixels > device->image2d_max_width)
+    device->image2d_max_width = device->image2d_max_height = max_pixels;
+
+  /* Same thing for 3D images, of course with cubes. Again, totally arbitrary. */
+  max_pixels = device->image3d_max_width;
+  // keep doubing until we go over
+  while (max_pixels*max_pixels <= device->image_max_buffer_size/max_pixels)
+    max_pixels *= 2;
+  // halve before assignment
+  max_pixels /= 2;
+  if (max_pixels > device->image3d_max_width)
+  device->image3d_max_width = device->image3d_max_height =
+    device->image3d_max_depth = max_pixels;
+
+}
+
 void
 pocl_basic_init (cl_device_id device, const char* parameters)
 {
   struct data *d;
   static int global_mem_id;
   static int first_basic_init = 1;
+  static int device_number = 0;
   
   if (first_basic_init)
     {
@@ -344,8 +432,25 @@ pocl_basic_init (cl_device_id device, const char* parameters)
   d->current_kernel = NULL;
   d->current_dlhandle = 0;
   device->data = d;
+  /* hwloc probes OpenCL device info at its initialization in case
+     the OpenCL extension is enabled. This causes to printout 
+     an unimplemented property error because hwloc is used to
+     initialize global_mem_size which it is not yet. Just put 
+     a nonzero there for now. */
+  device->global_mem_size = 1;
   pocl_topology_detect_device_info(device);
   pocl_cpuinfo_detect_device_info(device);
+  pocl_basic_set_buffer_image_limits(device);
+
+  /* in case hwloc doesn't provide a PCI ID, let's generate
+     a vendor id that hopefully is unique across vendors. */
+  const char *magic = "pocl";
+  if (device->vendor_id == 0)
+    device->vendor_id =
+      magic[0] | magic[1] << 8 | magic[2] << 16 | magic[3] << 24;
+
+  device->vendor_id += device_number;
+  device_number++;
 
   /* The basic driver represents only one "compute unit" as
      it doesn't exploit multiple hardware threads. Multiple
@@ -362,7 +467,7 @@ pocl_basic_init (cl_device_id device, const char* parameters)
   #endif
 }
 
-void *
+static void *
 pocl_basic_malloc (void *device_data, cl_mem_flags flags,
 		    size_t size, void *host_ptr)
 {
@@ -395,13 +500,15 @@ cl_int
 pocl_basic_alloc_mem_obj (cl_device_id device, cl_mem mem_obj)
 {
   void *b = NULL;
-  cl_int flags = mem_obj->flags;
+  cl_mem_flags flags = mem_obj->flags;
 
   /* if memory for this global memory is not yet allocated -> do it */
   if (mem_obj->device_ptrs[device->global_mem_id].mem_ptr == NULL)
     {
-      if (flags & CL_MEM_USE_HOST_PTR && mem_obj->mem_host_ptr != NULL)
+      if (flags & CL_MEM_USE_HOST_PTR)
         {
+          // mem_host_ptr must be non-NULL
+          assert(mem_obj->mem_host_ptr != NULL);
           b = mem_obj->mem_host_ptr;
         }
       else
@@ -412,8 +519,12 @@ pocl_basic_alloc_mem_obj (cl_device_id device, cl_mem mem_obj)
         }
 
       if (flags & CL_MEM_COPY_HOST_PTR)
-        memcpy (b, mem_obj->mem_host_ptr, mem_obj->size);
-    
+        {
+          // mem_host_ptr must be non-NULL
+          assert(mem_obj->mem_host_ptr != NULL);
+          memcpy (b, mem_obj->mem_host_ptr, mem_obj->size);
+        }
+
       mem_obj->device_ptrs[device->global_mem_id].mem_ptr = b;
       mem_obj->device_ptrs[device->global_mem_id].global_mem_id = 
         device->global_mem_id;
@@ -421,7 +532,7 @@ pocl_basic_alloc_mem_obj (cl_device_id device, cl_mem mem_obj)
   /* copy already allocated global mem info to devices own slot */
   mem_obj->device_ptrs[device->dev_id] = 
     mem_obj->device_ptrs[device->global_mem_id];
-    
+
   return CL_SUCCESS;
 }
 
@@ -441,7 +552,7 @@ pocl_basic_read (void *data, void *host_ptr, const void *device_ptr,
   if (host_ptr == device_ptr)
     return;
 
-  memcpy (host_ptr, device_ptr + offset, cb);
+  memcpy (host_ptr, (char*)device_ptr + offset, cb);
 }
 
 void
@@ -451,7 +562,7 @@ pocl_basic_write (void *data, const void *host_ptr, void *device_ptr,
   if (host_ptr == device_ptr)
     return;
 
-  memcpy (device_ptr + offset, host_ptr, cb);
+  memcpy ((char*)device_ptr + offset, host_ptr, cb);
 }
 
 
@@ -514,12 +625,12 @@ pocl_basic_run
       else if (kernel->arg_info[i].type == POCL_ARG_TYPE_SAMPLER)
         {
           dev_sampler_t ds;
+          fill_dev_sampler_t(&ds, al);
           
+          void* devptr = pocl_basic_malloc (data, 0, sizeof(dev_sampler_t), NULL);
           arguments[i] = malloc (sizeof (void *));
-          *(void **)(arguments[i]) = pocl_basic_malloc 
-            (data, 0, sizeof(dev_sampler_t), NULL);
-          pocl_basic_write (data, &ds, *(void**)arguments[i], 0, 
-                            sizeof(dev_sampler_t));
+          *(void **)(arguments[i]) = devptr;
+          pocl_basic_write (data, &ds, devptr, 0, sizeof(dev_sampler_t));
         }
       else
         {
@@ -557,13 +668,13 @@ pocl_basic_run
           pocl_basic_free (data, 0, *(void **)(arguments[i]));
           POCL_MEM_FREE(arguments[i]);
         }
-      else if (kernel->arg_info[i].type == POCL_ARG_TYPE_IMAGE)
+      else if (kernel->arg_info[i].type == POCL_ARG_TYPE_IMAGE ||
+                kernel->arg_info[i].type == POCL_ARG_TYPE_SAMPLER)
         {
           pocl_basic_free (data, 0, *(void **)(arguments[i]));
           POCL_MEM_FREE(arguments[i]);
         }
-      else if (kernel->arg_info[i].type == POCL_ARG_TYPE_SAMPLER || 
-               (kernel->arg_info[i].type == POCL_ARG_TYPE_POINTER && *(void**)arguments[i] == NULL))
+      else if (kernel->arg_info[i].type == POCL_ARG_TYPE_POINTER && *(void**)arguments[i] == NULL)
         {
           POCL_MEM_FREE(arguments[i]);
         }
@@ -593,7 +704,7 @@ pocl_basic_copy (void *data, const void *src_ptr, size_t src_offset,
   if (src_ptr == dst_ptr)
     return;
   
-  memcpy (dst_ptr + dst_offset, src_ptr + src_offset, cb);
+  memcpy ((char*)dst_ptr + dst_offset, (char*)src_ptr + src_offset, cb);
 }
 
 void
@@ -755,7 +866,7 @@ pocl_basic_get_timer_value (void *data)
 cl_int 
 pocl_basic_get_supported_image_formats (cl_mem_flags flags,
                                         const cl_image_format **image_formats,
-                                        cl_int *num_img_formats)
+                                        cl_uint *num_img_formats)
 {
     if (num_img_formats == NULL || image_formats == NULL)
       return CL_INVALID_VALUE;
@@ -792,17 +903,22 @@ void check_compiler_cache (_cl_command_node *cmd)
     {
       if (strcmp (ci->tmp_dir, cmd->command.run.tmp_dir) == 0 &&
           strcmp (ci->function_name, 
-                  cmd->command.run.kernel->function_name) == 0)
+                  cmd->command.run.kernel->name) == 0)
         {
           POCL_UNLOCK (compiler_cache_lock);
           cmd->command.run.wg = ci->wg;
           return;
         }
     }
+  cl_program program = cmd->command.run.kernel->program;
+
+  void* cache_lock = pocl_cache_acquire_writer_lock(program, cmd->device);
+  assert(cache_lock);
+
   ci = (compiler_cache_item*) malloc (sizeof (compiler_cache_item));
   ci->next = NULL;
   ci->tmp_dir = strdup(cmd->command.run.tmp_dir);
-  ci->function_name = strdup (cmd->command.run.kernel->function_name);
+  ci->function_name = strdup (cmd->command.run.kernel->name);
   const char* module_fn = llvm_codegen (cmd->command.run.tmp_dir,
                                         cmd->command.run.kernel,
                                         cmd->device);
@@ -816,10 +932,11 @@ void check_compiler_cache (_cl_command_node *cmd)
       abort();
     }
   snprintf (workgroup_string, WORKGROUP_STRING_LENGTH,
-            "_%s_workgroup", cmd->command.run.kernel->function_name);
+            "_pocl_launcher_%s_workgroup", cmd->command.run.kernel->name);
   cmd->command.run.wg = ci->wg = 
     (pocl_workgroup) lt_dlsym (dlhandle, workgroup_string);
 
+  pocl_cache_release_lock(cache_lock);
   LL_APPEND (compiler_cache, ci);
   POCL_UNLOCK (compiler_cache_lock);
 
diff --git a/lib/CL/devices/bufalloc.h b/lib/CL/devices/bufalloc.h
index f1bba1a..6312148 100644
--- a/lib/CL/devices/bufalloc.h
+++ b/lib/CL/devices/bufalloc.h
@@ -132,11 +132,14 @@ struct memory_region
   memory_region_t *next;
   memory_region_t *prev;
   enum allocation_strategy strategy; 
-  short alignment; /* alignment of the returned chunks in a 2's exponent byte count */
+  unsigned short alignment; /* alignment of the returned chunks in a 2's exponent byte count */
   ba_lock_t lock;
 };
 
+#ifdef __GNUC__
 #pragma GCC visibility push(hidden)
+#endif
+
 chunk_info_t *alloc_buffer_from_region(memory_region_t *region, size_t size);
 chunk_info_t *alloc_buffer(memory_region_t *regions, size_t size);
 
@@ -153,7 +156,10 @@ print_chunk (chunk_info_t *chunk);
 
 void
 print_chunks (chunk_info_t *first);
+
+#ifdef __GNUC__
 #pragma GCC visibility pop 
+#endif
 
 #ifdef __cplusplus
 }
diff --git a/lib/CL/devices/cellspu/Makefile.in b/lib/CL/devices/cellspu/Makefile.in
index 98776d6..7ee7e58 100644
--- a/lib/CL/devices/cellspu/Makefile.in
+++ b/lib/CL/devices/cellspu/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -104,8 +114,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = lib/CL/devices/cellspu
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -114,6 +122,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -192,6 +201,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -243,6 +253,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -279,6 +292,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -414,7 +428,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/CL/devices/cellspu/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign lib/CL/devices/cellspu/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -692,6 +705,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/lib/CL/devices/cellspu/cellspu.c b/lib/CL/devices/cellspu/cellspu.c
index e06f96b..cbb82c2 100644
--- a/lib/CL/devices/cellspu/cellspu.c
+++ b/lib/CL/devices/cellspu/cellspu.c
@@ -37,7 +37,7 @@
 #define max(a,b) (((a) > (b)) ? (a) : (b))
 
 #define COMMAND_LENGTH 2048
-#define WORKGROUP_STRING_LENGTH 128
+#define WORKGROUP_STRING_LENGTH 1024
 
 //#define DEBUG_CELLSPU_DRIVER
 
@@ -86,10 +86,8 @@ pocl_cellspu_init_device_infos(struct _cl_device_id* dev)
   dev->type = CL_DEVICE_TYPE_ACCELERATOR;
   dev->max_compute_units = 1;
   dev->max_work_item_dimensions = 3;
-  dev->max_work_item_sizes[0] = CL_INT_MAX;
-  dev->max_work_item_sizes[1] = CL_INT_MAX;
-  dev->max_work_item_sizes[2] = CL_INT_MAX;
-  dev->max_work_group_size = 1024;
+  dev->max_work_item_sizes[0] = dev->max_work_item_sizes[1] =
+	  dev->max_work_item_sizes[2] = dev->max_work_group_size = 8192;
   dev->preferred_wg_size_multiple = 8;
   dev->preferred_vector_width_char = POCL_DEVICES_PREFERRED_VECTOR_WIDTH_CHAR;
   dev->preferred_vector_width_short = POCL_DEVICES_PREFERRED_VECTOR_WIDTH_SHORT;
@@ -125,6 +123,16 @@ pocl_cellspu_init_device_infos(struct _cl_device_id* dev)
   dev->extensions = "";
   dev->llvm_target_triplet = "cellspu-v0";
   dev->llvm_cpu = "cellspu";
+
+  dev->parent_device = NULL;
+  // cellspu does not support partitioning
+  dev->max_sub_devices = 1;
+  dev->num_partition_properties = 1;
+  dev->partition_properties = calloc(dev->num_partition_properties,
+    sizeof(cl_device_partition_property));
+  dev->num_partition_types = 0;
+  dev->partition_type = NULL;
+
 }
 
 void
@@ -270,7 +278,7 @@ pocl_cellspu_run
   // SPU image.
   // TODO: figure out which function to call given what conditions
   snprintf (workgroup_string, WORKGROUP_STRING_LENGTH,
-            "_%s_workgroup_fast", kernel->function_name);
+            "_pocl_launcher_%s_workgroup_fast", kernel->function_name);
 
 
   if ( access (module, F_OK) != 0)
diff --git a/lib/CL/devices/common.c b/lib/CL/devices/common.c
index 31442b8..c598b09 100644
--- a/lib/CL/devices/common.c
+++ b/lib/CL/devices/common.c
@@ -36,12 +36,15 @@
 #include "config.h"
 
 #include "pocl_image_util.h"
-#include "pocl_util.h"
+#include "pocl_file_util.h"
+#include "pocl_cache.h"
 #include "devices.h"
 #include "pocl_mem_management.h"
 #include "pocl_runtime_config.h"
 #include "pocl_llvm.h"
 
+#include "_kernel_constants.h"
+
 #define COMMAND_LENGTH 2048
 
 /**
@@ -56,35 +59,29 @@
 const char*
 llvm_codegen (const char* tmpdir, cl_kernel kernel, cl_device_id device) {
 
-  const char* pocl_verbose_ptr = 
-    pocl_get_string_option("POCL_VERBOSE", (char*)NULL);
-  int pocl_verbose = pocl_verbose_ptr && *pocl_verbose_ptr;
-
   char command[COMMAND_LENGTH];
   char bytecode[POCL_FILENAME_LENGTH];
   char objfile[POCL_FILENAME_LENGTH];
 
-  char* module = (char*) malloc(min(POCL_FILENAME_LENGTH, 
-	   strlen(tmpdir) + strlen(kernel->function_name) + 5)); // strlen of / .so 4+1
+  char* module = malloc(strlen(tmpdir) + strlen(kernel->name) +
+                        strlen("/.so") + 1);
 
   int error;
 
-  error = snprintf 
-    (module, POCL_FILENAME_LENGTH,
-     "%s/%s.so", tmpdir, kernel->function_name);
+  error = snprintf(module, POCL_FILENAME_LENGTH,
+                   "%s/%s.so", tmpdir, kernel->name);
 
   assert (error >= 0);
 
-  error = snprintf
-    (objfile, POCL_FILENAME_LENGTH,
-     "%s/%s.so.o", tmpdir, kernel->function_name);
+  error = snprintf(objfile, POCL_FILENAME_LENGTH,
+                   "%s/%s.so.o", tmpdir, kernel->name);
   assert (error >= 0);
 
+  if (pocl_exists(module))
+    return module;
 
-  if (access (module, F_OK) != 0)
-    {
       error = snprintf (bytecode, POCL_FILENAME_LENGTH,
-                        "%s/%s", tmpdir, POCL_PARALLEL_BC_FILENAME);
+                        "%s%s", tmpdir, POCL_PARALLEL_BC_FILENAME);
       assert (error >= 0);
       
       error = pocl_llvm_codegen( kernel, device, bytecode, objfile);
@@ -100,20 +97,17 @@ llvm_codegen (const char* tmpdir, cl_kernel kernel, cl_device_id device) {
             module, objfile);
       assert (error >= 0);
 
-      if (pocl_verbose) {
-        fprintf(stderr, "[pocl] executing [%s]\n", command);
-        fflush(stderr);
-      }
+      POCL_MSG_PRINT_INFO ("executing [%s]\n", command);
       error = system (command);
       assert (error == 0);
 
       /* Save space in kernel cache */
       if (!pocl_get_bool_option("POCL_LEAVE_KERNEL_COMPILER_TEMP_FILES", 0))
         {
-          pocl_remove_file(objfile);
-          pocl_remove_file(bytecode);
+          pocl_remove(objfile);
+          pocl_remove(bytecode);
         }
-    }
+
   return module;
 }
 
@@ -138,6 +132,39 @@ void fill_dev_image_t (dev_image_t* di, struct pocl_argument* parg,
                               &(di->elem_size));
 }
 
+/**
+ * Populates the device specific sampler data structure used by kernel
+ * from given kernel sampler argument
+ */
+void fill_dev_sampler_t (dev_sampler_t *ds, struct pocl_argument *parg)
+{
+  cl_sampler_t sampler = *(cl_sampler_t *)parg->value;
+
+  *ds = 0;
+  *ds |= sampler.normalized_coords == CL_TRUE ? CLK_NORMALIZED_COORDS_TRUE :
+      CLK_NORMALIZED_COORDS_FALSE;
+
+  switch (sampler.addressing_mode) {
+    case CL_ADDRESS_NONE:
+      *ds |= CLK_ADDRESS_NONE; break;
+    case CL_ADDRESS_CLAMP_TO_EDGE:
+      *ds |= CLK_ADDRESS_CLAMP_TO_EDGE; break;
+    case CL_ADDRESS_CLAMP:
+      *ds |= CLK_ADDRESS_CLAMP; break;
+    case CL_ADDRESS_REPEAT:
+      *ds |= CLK_ADDRESS_REPEAT; break;
+    case CL_ADDRESS_MIRRORED_REPEAT:
+      *ds |= CLK_ADDRESS_MIRRORED_REPEAT; break;
+  }
+
+  switch (sampler.filter_mode) {
+    case CL_FILTER_NEAREST:
+      *ds |= CLK_FILTER_NEAREST; break;
+    case CL_FILTER_LINEAR :
+      *ds |= CLK_FILTER_LINEAR; break;
+  }
+}
+
 void*
 pocl_memalign_alloc(size_t align_width, size_t size)
 {
diff --git a/lib/CL/devices/common.h b/lib/CL/devices/common.h
index 51b4af0..02bd7a6 100644
--- a/lib/CL/devices/common.h
+++ b/lib/CL/devices/common.h
@@ -80,6 +80,8 @@ const char* llvm_codegen (const char* tmpdir,
 void fill_dev_image_t (dev_image_t* di, struct pocl_argument* parg, 
                        cl_device_id device);
 
+void fill_dev_sampler_t (dev_sampler_t *ds, struct pocl_argument *parg);
+
 void* pocl_memalign_alloc(size_t align_width, size_t size);
 
 #endif
diff --git a/lib/CL/devices/cpuinfo.c b/lib/CL/devices/cpuinfo.c
index 3a3a253..f7010e5 100644
--- a/lib/CL/devices/cpuinfo.c
+++ b/lib/CL/devices/cpuinfo.c
@@ -45,17 +45,30 @@ const char* cpufreq_file="/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"
 #if   defined  __powerpc__
  #define FREQSTRING "clock"
  #define MODELSTRING "cpu\t"
+ #define DEFAULTVENDOR "AIM" // Apple-IBM-Motorola
+ #define DEFAULTVENDORID 0x1014 // IBM
+ #define VENDORSTRING "vendor"
 #elif defined __arm__
  #define FREQSTRING " "
  #define MODELSTRING "Processor"
+ #define DEFAULTVENDOR "ARM"
+ #define DEFAULTVENDORID 0x13b5 // ARM
+ #define VENDORSTRING "CPU implementer"
 #elif defined __mips
  #define FREQSTRING "BogoMIPS\t"
  #define MODELSTRING "cpu model\t"
+ #define DEFAULTVENDORID 0x153f // MIPS
+ #define DEFAULTVENDOR "MIPS"
 #else
  #define FREQSTRING "cpu MHz"
  #define MODELSTRING "model name"
+ #define DEFAULTVENDOR "Unknown x86"
+ #define DEFAULTVENDORID 0x0
+ #define VENDORSTRING "vendor_id"
 #endif
 
+static const char *cpuvendor_default = DEFAULTVENDOR;
+
 /** 
  * Read the CPU maximum frequency from the Linux cpufreq interface.
  * If cpufreq is not available on current host processor, returns -1.
@@ -219,6 +232,7 @@ pocl_cpuinfo_detect_compute_unit_count()
   return -1;  
 }
 
+#ifdef POCL_ANDROID
 
 #define SYSFS_CPU_NUM_CORES_NODE    "/sys/devices/system/cpu/possible"
 
@@ -246,32 +260,58 @@ pocl_sysfs_detect_compute_unit_count()
 
   return cores;
 }
-
+#endif
 
 void
-pocl_cpuinfo_append_cpu_name(cl_device_id device)
+pocl_cpuinfo_get_cpu_name_and_vendor(cl_device_id device)
 {
   /* If something fails here, have this as backup solution.
    * short_name is in the .data anyways.*/
   device->long_name = device->short_name;
-  
+
+  /* default vendor and vendor_id, in case it cannot be found by other means */
+  device->vendor = cpuvendor_default;
+  if (device->vendor_id == 0)
+    device->vendor_id = DEFAULTVENDORID;
+
   /* read contents of /proc/cpuinfo */
-  if (access (cpuinfo, R_OK) != 0) 
+  if (access (cpuinfo, R_OK) != 0)
     return;
   FILE *f = fopen (cpuinfo, "r");
   char contents[MAX_CPUINFO_SIZE];
   int num_read = fread (contents, 1, MAX_CPUINFO_SIZE - 1, f);            
+  fclose(f);
   contents[num_read]='\0';
 
+  char *start, *end;
+  /* find the vendor_id string an put */
+#ifdef VENDORSTRING
+  do {
+    start = strstr(contents, VENDORSTRING"\t: ");
+    if (!start)
+      break;
+    start += strlen(VENDORSTRING"\t: ");
+    end = strchr(start, '\n');
+    if (!end)
+      break;
+    char *_vendor = malloc(end-start + 1);
+    if (!_vendor)
+      break;
+    memcpy(_vendor, start, end-start);
+    _vendor[end-start] = '\0';
+    device->vendor = _vendor;
+  } while (0);
+#endif
+
   /* find the cpu description */
-  char *start=strstr (contents, MODELSTRING"\t: ");
-  if (start == NULL) 
+  start=strstr (contents, MODELSTRING"\t: ");
+  if (start == NULL)
     return;
   start += strlen (MODELSTRING"\t: ");
-  char *end = strchr (start, '\n'); 
-  if (end == NULL) 
+  end = strchr (start, '\n');
+  if (end == NULL)
     return;
-  
+
   /* create the descriptive long_name for device */
   int len = strlen (device->short_name) + (end-start) + 2;
   char *new_name = (char*)malloc (len);
@@ -283,20 +323,21 @@ pocl_cpuinfo_append_cpu_name(cl_device_id device)
 void
 pocl_cpuinfo_detect_device_info(cl_device_id device) 
 {
+  int res;
 #ifdef POCL_ANDROID
   /* sysfs node seems more suitable for android kernels
      override the value provided by hwloc
    */
   device->max_compute_units = pocl_sysfs_detect_compute_unit_count();
-#endif
-
+#else
   if (device->max_compute_units == 0) {
-    if ((device->max_compute_units = pocl_cpuinfo_detect_compute_unit_count()) == -1)
-      device->max_compute_units = 0;
+    res = pocl_cpuinfo_detect_compute_unit_count();
+    device->max_compute_units = (res > 0) ? (cl_uint)res : 0;
   }
+#endif
 
-  if ((device->max_clock_frequency = pocl_cpuinfo_detect_max_clock_frequency()) == -1)
-    device->max_clock_frequency = 0;
+  res = pocl_cpuinfo_detect_max_clock_frequency();
+  device->max_clock_frequency = (res > 0) ? (cl_uint)res : 0;
 
-  pocl_cpuinfo_append_cpu_name(device);
+  pocl_cpuinfo_get_cpu_name_and_vendor(device);
 }
diff --git a/lib/CL/devices/dev_image.h b/lib/CL/devices/dev_image.h
index 6079102..772726f 100644
--- a/lib/CL/devices/dev_image.h
+++ b/lib/CL/devices/dev_image.h
@@ -26,8 +26,7 @@
 
 #include "pocl_cl.h"
 
-//Definition of the image datatype used on basic and pthread (and probably tce?)
-
+//Definition of the image and sampler datatype used on basic and pthread (and probably tce?)
 typedef cl_int dev_sampler_t;
 
 typedef struct dev_image_t {
diff --git a/lib/CL/devices/devices.c b/lib/CL/devices/devices.c
index 971af20..9e902a2 100644
--- a/lib/CL/devices/devices.c
+++ b/lib/CL/devices/devices.c
@@ -1,7 +1,7 @@
 /* Definition of available OpenCL devices.
 
    Copyright (c) 2011 Universidad Rey Juan Carlos and
-                 2012 Pekka Jääskeläinen / Tampere University of Technology
+                 2012-2015 Pekka Jääskeläinen / Tampere University of Technology
    
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
@@ -36,6 +36,9 @@
 #include "pocl_runtime_config.h"
 #include "basic/basic.h"
 #include "pthread/pocl-pthread.h"
+#include "pocl_debug.h"
+#include "pocl_cache.h"
+#include "pocl_queue_util.h"
 
 #if defined(BUILD_SPU)
 #include "cellspu/cellspu.h"
@@ -45,18 +48,14 @@
 #include "tce/ttasim/ttasim.h"
 #endif
 
+#include "hsa/pocl-hsa.h"
+
 #define MAX_DEV_NAME_LEN 64
 
 /* the enabled devices */
 static struct _cl_device_id* pocl_devices = NULL;
 unsigned int pocl_num_devices = 0;
 
-#ifdef POCL_DEBUG_MESSAGES
-int pocl_debug_messages;
-#ifdef HAVE_CLOCK_GETTIME
-struct timespec pocl_debug_timespec;
-#endif
-#endif
 
 /* Init function prototype */
 typedef void (*init_device_ops)(struct pocl_device_ops*);
@@ -71,11 +70,14 @@ static init_device_ops pocl_devices_init_ops[] = {
 #if defined(TCE_AVAILABLE)
   pocl_ttasim_init_device_ops,
 #endif
+#if defined(BUILD_HSA)
+  pocl_hsa_init_device_ops,
+#endif
 };
 
 #define POCL_NUM_DEVICE_TYPES (sizeof(pocl_devices_init_ops) / sizeof((pocl_devices_init_ops)[0]))
 
-static struct pocl_device_ops pocl_device_ops[POCL_NUM_DEVICE_TYPES] = {0};
+static struct pocl_device_ops pocl_device_ops[POCL_NUM_DEVICE_TYPES];
 
 /**
  * Get the number of specified devices from environnement
@@ -83,7 +85,7 @@ static struct pocl_device_ops pocl_device_ops[POCL_NUM_DEVICE_TYPES] = {0};
 int pocl_device_get_env_count(const char *dev_type)
 {
   const char *dev_env = getenv(POCL_DEVICES_ENV);
-  char *ptr, *saveptr, *tofree, *token;
+  char *ptr, *saveptr = NULL, *tofree, *token;
   unsigned int dev_count = 0;
   if (dev_env == NULL) 
     {
@@ -184,13 +186,24 @@ void
 pocl_init_devices()
 {
   static unsigned int init_done = 0;
+  static unsigned int init_in_progress = 0;
   static pocl_lock_t pocl_init_lock = POCL_LOCK_INITIALIZER;
 
-  int i, j, dev_index;
+  unsigned i, j, dev_index;
   char env_name[1024];
   char dev_name[MAX_DEV_NAME_LEN] = {0};
   unsigned int device_count[POCL_NUM_DEVICE_TYPES];
 
+  /* This is a workaround to a nasty problem with libhwloc: When
+     initializing basic, it calls libhwloc to query device info.
+     In case libhwloc has the OpenCL plugin installed, it initializes
+     it and it leads to initializing pocl again which leads to an
+     infinite loop. */
+
+  if (init_in_progress)
+      return;
+  init_in_progress = 1;
+
   if (init_done == 0)
     POCL_INIT_LOCK(pocl_init_lock);
   POCL_LOCK(pocl_init_lock);
@@ -206,6 +219,10 @@ pocl_init_devices()
   pocl_debug_messages = pocl_get_bool_option("POCL_DEBUG", 0);
 #endif
 
+  pocl_cache_init_topdir();
+
+  pocl_init_queue_list();
+
   /* Init operations */
   for (i = 0; i < POCL_NUM_DEVICE_TYPES; ++i)
     {
@@ -224,7 +241,7 @@ pocl_init_devices()
     POCL_ABORT("Can not allocate memory for devices\n");
 
   dev_index = 0;
-  /* Init infos for each probbed devices */
+  /* Init infos for each probed devices */
   for (i = 0; i < POCL_NUM_DEVICE_TYPES; ++i)
     {
       assert(pocl_device_ops[i].init);
diff --git a/lib/CL/devices/devices.h b/lib/CL/devices/devices.h
index 989e31e..abda021 100644
--- a/lib/CL/devices/devices.h
+++ b/lib/CL/devices/devices.h
@@ -27,7 +27,9 @@
 
 #include "../pocl_cl.h"
 
+#ifdef __GNUC__
 #pragma GCC visibility push(hidden)
+#endif
 
 #ifdef __cplusplus
 extern "C" {
@@ -69,7 +71,9 @@ unsigned int pocl_get_devices(cl_device_type device_type, struct _cl_device_id *
  */
 int pocl_device_get_env_count(const char *dev_type);
 
+#ifdef __GNUC__
 #pragma GCC visibility pop
+#endif
 
 /* the environment variable that lists the enabled devices */
 #define POCL_DEVICES_ENV "POCL_DEVICES"
diff --git a/include/CMakeLists.txt b/lib/CL/devices/hsa/CMakeLists.txt
similarity index 79%
copy from include/CMakeLists.txt
copy to lib/CL/devices/hsa/CMakeLists.txt
index 32693e6..1926d9e 100644
--- a/include/CMakeLists.txt
+++ b/lib/CL/devices/hsa/CMakeLists.txt
@@ -1,7 +1,7 @@
 #=============================================================================
 #   CMake build system files
 #
-#   Copyright (c) 2014 pocl developers
+#   Copyright (c) 2015 pocl developers
 #
 #   Permission is hereby granted, free of charge, to any person obtaining a copy
 #   of this software and associated documentation files (the "Software"), to deal
@@ -23,12 +23,8 @@
 #
 #=============================================================================
 
-add_subdirectory("CL")
-
-set(PRIVATE_HEADERS  _kernel.h _kernel_c.h pocl_types.h pocl_features.h pocl_device.h pocl.h)
-
-install(FILES ${PRIVATE_HEADERS}
-        DESTINATION ${POCL_INSTALL_PRIVATE_HEADER_DIR})
-
-install(FILES "poclu.h"
-        DESTINATION ${POCL_INSTALL_PUBLIC_HEADER_DIR})
+if(MSVC)
+  set_source_files_properties( pocl-hsa.c pocl-hsa.h PROPERTIES LANGUAGE CXX )
+endif(MSVC)
+add_library("pocl-devices-hsa" OBJECT pocl-hsa.c pocl-hsa.h)
+set(POCL_DEVICES_OBJS "${POCL_DEVICES_OBJS};$<TARGET_OBJECTS:pocl-devices-hsa>" PARENT_SCOPE)
diff --git a/lib/CL/devices/tce/ttasim/Makefile.am b/lib/CL/devices/hsa/Makefile.am
similarity index 65%
copy from lib/CL/devices/tce/ttasim/Makefile.am
copy to lib/CL/devices/hsa/Makefile.am
index c01462d..1a61eab 100644
--- a/lib/CL/devices/tce/ttasim/Makefile.am
+++ b/lib/CL/devices/hsa/Makefile.am
@@ -1,19 +1,19 @@
 # Process this file with automake to produce Makefile.in (in this,
 # and all subdirectories).
-# Makefile.am for pocl/lib/CL/devices/ttasim.
-# 
-# Copyright (c) 2012 Pekka Jääskeläinen / Tampere University of Technology
-# 
+# Makefile.am for pocl/lib/CL/devices/hsa.
+#
+# Copyright (c) 2015 Pekka Jääskeläinen / Tampere University of Technology
+#
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
 # in the Software without restriction, including without limitation the rights
 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 # copies of the Software, and to permit persons to whom the Software is
 # furnished to do so, subject to the following conditions:
-# 
+#
 # The above copyright notice and this permission notice shall be included in
 # all copies or substantial portions of the Software.
-# 
+#
 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,14 +22,17 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 
-noinst_LTLIBRARIES = libpocl-devices-tce-ttasim.la
+noinst_LTLIBRARIES = libpocl-devices-hsa.la
 
-libpocl_devices_tce_ttasim_la_SOURCES = ttasim.h ttasim.cc
-libpocl_devices_tce_ttasim_ladir = ${datadir}
+libpocl_devices_hsa_la_SOURCES = pocl-hsa.h pocl-hsa.c
 
-libpocl_devices_tce_ttasim_la_CPPFLAGS = `@TCE_CONFIG@ --includes` -I$(top_srcdir)/include \
--I$(top_srcdir)/lib/CL/devices -I$(top_srcdir)/lib/CL/devices/tce \
--I$(top_srcdir)/lib/CL $(OCL_ICD_CFLAGS)
-libpocl_devices_tce_ttasim_la_LDFLAGS = -lltdl @PTHREAD_CFLAGS@ --version-info ${LIB_VERSION}
+libpocl_devices_hsa_la_CFLAGS = -std=c99
+
+# TODO: find out the HSA include dir at configure time.
+libpocl_devices_hsa_la_CPPFLAGS = -I$(top_srcdir)/fix-include -I$(top_srcdir)/include -I$(top_srcdir)/lib/CL/devices \
+	-I$(top_srcdir)/lib/CL $(OCL_ICD_CFLAGS) @HSA_INCLUDES@
+#  -I$(HOME)/src/HSA-Runtime-Reference-Source/inc
+
+libpocl_devices_hsa_la_LDFLAGS = ${HSA_LIBS} -lltdl @PTHREAD_CFLAGS@ --version-info ${LIB_VERSION}
 
 EXTRA_DIST = CMakeLists.txt
diff --git a/lib/CL/devices/basic/Makefile.in b/lib/CL/devices/hsa/Makefile.in
similarity index 87%
copy from lib/CL/devices/basic/Makefile.in
copy to lib/CL/devices/hsa/Makefile.in
index d7b039b..6f5b285 100644
--- a/lib/CL/devices/basic/Makefile.in
+++ b/lib/CL/devices/hsa/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -16,20 +16,20 @@
 
 # Process this file with automake to produce Makefile.in (in this,
 # and all subdirectories).
-# Makefile.am for pocl/lib/CL/devices/basic.
-# 
-# Copyright (c) 2012 Pekka Jääskeläinen / Tampere University of Technology
-# 
+# Makefile.am for pocl/lib/CL/devices/hsa.
+#
+# Copyright (c) 2015 Pekka Jääskeläinen / Tampere University of Technology
+#
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
 # in the Software without restriction, including without limitation the rights
 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 # copies of the Software, and to permit persons to whom the Software is
 # furnished to do so, subject to the following conditions:
-# 
+#
 # The above copyright notice and this permission notice shall be included in
 # all copies or substantial portions of the Software.
-# 
+#
 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -39,7 +39,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -103,9 +113,7 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-subdir = lib/CL/devices/basic
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
+subdir = lib/CL/devices/hsa
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -114,24 +122,24 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 LTLIBRARIES = $(noinst_LTLIBRARIES)
-libpocl_devices_basic_la_LIBADD =
-am_libpocl_devices_basic_la_OBJECTS =  \
-	libpocl_devices_basic_la-basic.lo
-libpocl_devices_basic_la_OBJECTS =  \
-	$(am_libpocl_devices_basic_la_OBJECTS)
+libpocl_devices_hsa_la_LIBADD =
+am_libpocl_devices_hsa_la_OBJECTS =  \
+	libpocl_devices_hsa_la-pocl-hsa.lo
+libpocl_devices_hsa_la_OBJECTS = $(am_libpocl_devices_hsa_la_OBJECTS)
 AM_V_lt = $(am__v_lt_ at AM_V@)
 am__v_lt_ = $(am__v_lt_ at AM_DEFAULT_V@)
 am__v_lt_0 = --silent
 am__v_lt_1 = 
-libpocl_devices_basic_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
+libpocl_devices_hsa_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
-	$(AM_CFLAGS) $(CFLAGS) $(libpocl_devices_basic_la_LDFLAGS) \
-	$(LDFLAGS) -o $@
+	$(libpocl_devices_hsa_la_CFLAGS) $(CFLAGS) \
+	$(libpocl_devices_hsa_la_LDFLAGS) $(LDFLAGS) -o $@
 AM_V_P = $(am__v_P_ at AM_V@)
 am__v_P_ = $(am__v_P_ at AM_DEFAULT_V@)
 am__v_P_0 = false
@@ -166,8 +174,8 @@ AM_V_CCLD = $(am__v_CCLD_ at AM_V@)
 am__v_CCLD_ = $(am__v_CCLD_ at AM_DEFAULT_V@)
 am__v_CCLD_0 = @echo "  CCLD    " $@;
 am__v_CCLD_1 = 
-SOURCES = $(libpocl_devices_basic_la_SOURCES)
-DIST_SOURCES = $(libpocl_devices_basic_la_SOURCES)
+SOURCES = $(libpocl_devices_hsa_la_SOURCES)
+DIST_SOURCES = $(libpocl_devices_hsa_la_SOURCES)
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
     n|no|NO) false;; \
@@ -192,6 +200,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -243,6 +252,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -279,6 +291,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -393,12 +406,16 @@ target_vendor = @target_vendor@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-noinst_LTLIBRARIES = libpocl-devices-basic.la
-libpocl_devices_basic_la_SOURCES = basic.h basic.c
-libpocl_devices_basic_la_CPPFLAGS = -I$(top_srcdir)/fix-include -I$(top_srcdir)/include \
--I$(top_srcdir)/lib/CL/devices -I$(top_srcdir)/lib/CL $(OCL_ICD_CFLAGS)
+noinst_LTLIBRARIES = libpocl-devices-hsa.la
+libpocl_devices_hsa_la_SOURCES = pocl-hsa.h pocl-hsa.c
+libpocl_devices_hsa_la_CFLAGS = -std=c99
+
+# TODO: find out the HSA include dir at configure time.
+libpocl_devices_hsa_la_CPPFLAGS = -I$(top_srcdir)/fix-include -I$(top_srcdir)/include -I$(top_srcdir)/lib/CL/devices \
+	-I$(top_srcdir)/lib/CL $(OCL_ICD_CFLAGS) @HSA_INCLUDES@
 
-libpocl_devices_basic_la_LDFLAGS = -lltdl @PTHREAD_CFLAGS@ --version-info ${LIB_VERSION}
+#  -I$(HOME)/src/HSA-Runtime-Reference-Source/inc
+libpocl_devices_hsa_la_LDFLAGS = ${HSA_LIBS} -lltdl @PTHREAD_CFLAGS@ --version-info ${LIB_VERSION}
 EXTRA_DIST = CMakeLists.txt
 all: all-am
 
@@ -413,10 +430,9 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/CL/devices/basic/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/CL/devices/hsa/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign lib/CL/devices/basic/Makefile
-.PRECIOUS: Makefile
+	  $(AUTOMAKE) --foreign lib/CL/devices/hsa/Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -446,8 +462,8 @@ clean-noinstLTLIBRARIES:
 	  rm -f $${locs}; \
 	}
 
-libpocl-devices-basic.la: $(libpocl_devices_basic_la_OBJECTS) $(libpocl_devices_basic_la_DEPENDENCIES) $(EXTRA_libpocl_devices_basic_la_DEPENDENCIES) 
-	$(AM_V_CCLD)$(libpocl_devices_basic_la_LINK)  $(libpocl_devices_basic_la_OBJECTS) $(libpocl_devices_basic_la_LIBADD) $(LIBS)
+libpocl-devices-hsa.la: $(libpocl_devices_hsa_la_OBJECTS) $(libpocl_devices_hsa_la_DEPENDENCIES) $(EXTRA_libpocl_devices_hsa_la_DEPENDENCIES) 
+	$(AM_V_CCLD)$(libpocl_devices_hsa_la_LINK)  $(libpocl_devices_hsa_la_OBJECTS) $(libpocl_devices_hsa_la_LIBADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -455,7 +471,7 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libpocl_devices_basic_la-basic.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libpocl_devices_hsa_la-pocl-hsa.Plo at am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -478,12 +494,12 @@ distclean-compile:
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LTCOMPILE) -c -o $@ $<
 
-libpocl_devices_basic_la-basic.lo: basic.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpocl_devices_basic_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpocl_devices_basic_la-basic.lo -MD -MP -MF $(DEPDIR)/libpocl_devices_basic_la-basic.Tpo -c -o libpocl_devices_basic_la-basic.lo `test -f 'basic.c' || echo '$(srcdir)/'`basic.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libpocl_devices_basic_la-basic.Tpo $(DEPDIR)/libpocl_devices_basic_la-basic.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='basic.c' object='libpocl_devices_basic_la-basic.lo' libtool=yes @AMDEPBACKSLASH@
+libpocl_devices_hsa_la-pocl-hsa.lo: pocl-hsa.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpocl_devices_hsa_la_CPPFLAGS) $(CPPFLAGS) $(libpocl_devices_hsa_la_CFLAGS) $(CFLAGS) -MT libpocl_devices_hsa_la-pocl-hsa.lo -MD -MP -MF $(DEPDIR)/libpocl_devices_hsa_la-pocl-hsa.Tpo -c -o libpocl_devices_hsa_la-pocl-hsa.lo `test -f 'pocl-hsa.c' || echo '$(srcdir)/'`pocl-hsa.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libpocl_devices_hsa_la-pocl-hsa.Tpo $(DEPDIR)/libpocl_devices_hsa_la-pocl-hsa.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='pocl-hsa.c' object='libpocl_devices_hsa_la-pocl-hsa.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpocl_devices_basic_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpocl_devices_basic_la-basic.lo `test -f 'basic.c' || echo '$(srcdir)/'`basic.c
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpocl_devices_hsa_la_CPPFLAGS) $(CPPFLAGS) $(libpocl_devices_hsa_la_CFLAGS) $(CFLAGS) -c -o libpocl_devices_hsa_la-pocl-hsa.lo `test -f 'pocl-hsa.c' || echo '$(srcdir)/'`pocl-hsa.c
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -694,6 +710,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/lib/CL/devices/hsa/pocl-hsa.c b/lib/CL/devices/hsa/pocl-hsa.c
new file mode 100644
index 0000000..f6173ca
--- /dev/null
+++ b/lib/CL/devices/hsa/pocl-hsa.c
@@ -0,0 +1,990 @@
+/* pocl-hsa.c - driver for HSA supported devices. Currently only AMDGCN.
+
+   Copyright (c) 2015 Pekka Jääskeläinen <pekka.jaaskelainen at tut.fi>
+                 2015 Charles Chen <ccchen at pllab.cs.nthu.edu.tw>
+                      Shao-chung Wang <scwang at pllab.cs.nthu.edu.tw>
+                 2015 Michal Babej <michal.babej at tut.fi>
+
+   Short snippets borrowed from the MatrixMultiplication example in
+   the HSA runtime library sources (c) 2014 HSA Foundation Inc.
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+*/
+/* Some example code snippets copied verbatim from vector_copy.c of HSA-Runtime-AMD: */
+/* Copyright 2014 HSA Foundation Inc.  All Rights Reserved.
+ *
+ * HSAF is granting you permission to use this software and documentation (if
+ * any) (collectively, the "Materials") pursuant to the terms and conditions
+ * of the Software License Agreement included with the Materials.  If you do
+ * not have a copy of the Software License Agreement, contact the  HSA Foundation for a copy.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ * CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
+ */
+
+#include "hsa.h"
+#include "hsa_ext_finalize.h"
+#include "hsa_ext_amd.h"
+#include "hsa_ext_image.h"
+
+#include "pocl-hsa.h"
+#include "common.h"
+#include "devices.h"
+#include "pocl_file_util.h"
+#include "pocl_cache.h"
+#include "pocl_llvm.h"
+#include "pocl_util.h"
+
+#include <assert.h>
+#include <string.h>
+#include <stdlib.h>
+
+#ifndef _MSC_VER
+#  include <sys/wait.h>
+#  include <sys/time.h>
+#  include <unistd.h>
+#else
+#  include "vccompat.hpp"
+#endif
+
+#define max(a,b) (((a) > (b)) ? (a) : (b))
+
+/* TODO:
+   - track hsa_memory_register() calls and deregister the memory
+     at free() calls
+   - fix pocl_llvm_generate_workgroup_function() to
+     generate the entire linked program.bc for HSA, not just a single kernel.
+   - AMD SDK samples. Requires work mainly in these areas:
+      - atomics support
+      - image support
+      - CL C++
+   - OpenCL printf() support
+   - get_global_offset() and global_work_offset param of clEnqueNDRker -
+     HSA kernel dispatch packet has no offset fields -
+     we must take care of it somewhere
+   - clinfo of Ubuntu crashes
+   - etc. etc.
+*/
+
+#define HSA_KERNEL_CACHE_SIZE 64
+
+/* Simple statically-sized kernel data cache */
+/* for caching kernel dispatch data, binaries etc */
+typedef struct pocl_hsa_kernel_cache_s {
+  cl_kernel kernel;
+  hsa_executable_t hsa_exe;
+  uint64_t code_handle;
+  uint32_t private_size;
+  uint32_t static_group_size;
+  hsa_signal_t kernel_completion_signal;
+  void* kernargs;
+  uint32_t args_segment_size;
+} pocl_hsa_kernel_cache_t;
+
+typedef struct pocl_hsa_device_data_s {
+  /* Currently loaded kernel. */
+  cl_kernel current_kernel;
+  /* The HSA kernel agent controlled by the device driver instance. */
+  hsa_agent_t *agent;
+  hsa_profile_t agent_profile;
+  /* mem regions */
+  hsa_region_t global_region, kernarg_region, group_region;
+  /* Queue for pushing work to the agent. */
+  hsa_queue_t *queue;
+  /* Per-program data cache to simplify program compiling stage */
+  pocl_hsa_kernel_cache_t kernel_cache[HSA_KERNEL_CACHE_SIZE];
+  unsigned kernel_cache_lastptr;
+} pocl_hsa_device_data_t;
+
+struct pocl_supported_hsa_device_properties
+{
+  char *dev_name;
+  const char *llvm_cpu;
+  const char *llvm_target_triplet;
+  int has_64bit_long;
+  cl_ulong max_mem_alloc_size;
+  cl_ulong global_mem_size;
+  cl_uint vendor_id;
+  cl_device_mem_cache_type global_mem_cache_type;
+  cl_uint global_mem_cacheline_size;
+  cl_uint max_compute_units;
+  cl_uint max_clock_frequency;
+  cl_ulong max_constant_buffer_size;
+  cl_ulong local_mem_size;
+};
+
+void
+pocl_hsa_init_device_ops(struct pocl_device_ops *ops)
+{
+  pocl_basic_init_device_ops (ops);
+
+  /* TODO: more descriptive name from HSA probing the device */
+  ops->device_name = "hsa";
+  ops->init_device_infos = pocl_hsa_init_device_infos;
+  ops->probe = pocl_hsa_probe;
+  ops->uninit = pocl_hsa_uninit;
+  ops->init = pocl_hsa_init;
+  ops->alloc_mem_obj = pocl_hsa_alloc_mem_obj;
+  ops->free = pocl_hsa_free;
+  ops->compile_submitted_kernels = pocl_hsa_compile_submitted_kernels;
+  ops->run = pocl_hsa_run;
+  ops->read = pocl_basic_read;
+  ops->read_rect = pocl_basic_read_rect;
+  ops->write = pocl_basic_write;
+  ops->write_rect = pocl_basic_write_rect;
+  ops->copy = pocl_basic_copy;
+  ops->copy_rect = pocl_basic_copy_rect;
+  ops->get_timer_value = pocl_basic_get_timer_value;
+}
+
+#define MAX_HSA_AGENTS 16
+
+static void pocl_hsa_abort_on_error(hsa_status_t status,
+                                    unsigned line,
+                                    const char* func,
+                                    const char* code)
+{
+  const char* str;
+  if (status != HSA_STATUS_SUCCESS)
+    {
+      hsa_status_string(status, &str);
+      POCL_MSG_PRINT2(func, line, "Error from HSA Runtime call:\n");
+      POCL_ABORT(str);
+    }
+}
+
+
+#define HSA_CHECK(code) pocl_hsa_abort_on_error(code, __LINE__, __FUNCTION__, #code);
+
+static hsa_agent_t hsa_agents[MAX_HSA_AGENTS];
+static hsa_agent_t* last_assigned_agent;
+static int found_hsa_agents = 0;
+
+static hsa_status_t
+pocl_hsa_get_agents_callback(hsa_agent_t agent, void *data)
+{
+  hsa_device_type_t type;
+  HSA_CHECK(hsa_agent_get_info (agent, HSA_AGENT_INFO_DEVICE, &type));
+  if (type != HSA_DEVICE_TYPE_GPU)
+    {
+      return HSA_STATUS_SUCCESS;
+    }
+
+  hsa_agent_feature_t features;
+  HSA_CHECK(hsa_agent_get_info(agent, HSA_AGENT_INFO_FEATURE, &features));
+  if (features != HSA_AGENT_FEATURE_KERNEL_DISPATCH)
+    {
+      return HSA_STATUS_SUCCESS;
+    }
+
+  hsa_agents[found_hsa_agents++] = agent;
+  return HSA_STATUS_SUCCESS;
+}
+
+/*
+ * Sets up the memory regions in pocl_hsa_device_data for a device
+ */
+static
+hsa_status_t
+setup_agent_memory_regions_callback(hsa_region_t region, void* data)
+{
+  pocl_hsa_device_data_t* d = (pocl_hsa_device_data_t*)data;
+
+  hsa_region_segment_t segment;
+  hsa_region_global_flag_t flags;
+  HSA_CHECK(hsa_region_get_info(region, HSA_REGION_INFO_SEGMENT, &segment));
+
+  if (segment == HSA_REGION_SEGMENT_GLOBAL)
+    {
+      d->global_region = region;
+      HSA_CHECK(hsa_region_get_info(region, HSA_REGION_INFO_GLOBAL_FLAGS, &flags));
+      if (flags & HSA_REGION_GLOBAL_FLAG_KERNARG)
+        d->kernarg_region = region;
+    }
+
+  if (segment == HSA_REGION_SEGMENT_GROUP)
+    d->group_region = region;
+
+  return HSA_STATUS_SUCCESS;
+}
+
+//Get hsa-unsupported device features from hsa device list.
+static int num_hsa_device = 1;
+
+static struct _cl_device_id
+supported_hsa_devices[MAX_HSA_AGENTS] =
+{
+  [0] =
+  {
+    .long_name = "Spectre",
+    .llvm_cpu = NULL,                 // native: "kaveri",
+    .llvm_target_triplet = "hsail64", // native: "amdgcn--amdhsa"
+        .has_64bit_long = 1,
+        .vendor_id = 0x1002,
+        .global_mem_cache_type = CL_READ_WRITE_CACHE,
+	.global_mem_cacheline_size = 64,
+	.max_compute_units = 8,
+	.max_clock_frequency = 720,
+	.max_constant_buffer_size = 65536,
+    .local_mem_type = CL_LOCAL,
+    .endian_little = CL_TRUE,
+    .extensions = "cl_khr_fp64 cl_khr_byte_addressable_store"
+      " cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics"
+      " cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics"
+      " cl_khr_int64_base_atomics cl_khr_int64_extended_atomics",
+    .preferred_wg_size_multiple = 64, // wavefront size on Kaveri
+    .preferred_vector_width_char = 4,
+    .preferred_vector_width_short = 2,
+    .preferred_vector_width_int = 1,
+    .preferred_vector_width_long = 1,
+    .preferred_vector_width_float = 1,
+    .preferred_vector_width_double = 1,
+    .native_vector_width_char = 4,
+    .native_vector_width_short = 2,
+    .native_vector_width_int = 1,
+    .native_vector_width_long = 1,
+    .native_vector_width_float = 1,
+    .native_vector_width_double = 1
+  },
+};
+
+// Detect the HSA device and populate its properties to the device
+// struct.
+static void
+get_hsa_device_features(char* dev_name, struct _cl_device_id* dev)
+{
+
+#define COPY_ATTR(ATTR) dev->ATTR = supported_hsa_devices[i].ATTR
+#define COPY_VECWIDTH(ATTR) \
+     dev->preferred_vector_width_ ## ATTR = \
+         supported_hsa_devices[i].preferred_vector_width_ ## ATTR; \
+     dev->native_vector_width_ ## ATTR = \
+         supported_hsa_devices[i].native_vector_width_ ## ATTR;
+
+  int found = 0;
+  int i;
+  for(i = 0; i < num_hsa_device; i++)
+    {
+      if (strcmp(dev_name, supported_hsa_devices[i].long_name) == 0)
+        {
+          COPY_ATTR (llvm_cpu);
+          COPY_ATTR (llvm_target_triplet);
+          COPY_ATTR (has_64bit_long);
+          COPY_ATTR (vendor_id);
+          COPY_ATTR (global_mem_cache_type);
+          COPY_ATTR (global_mem_cacheline_size);
+          COPY_ATTR (max_compute_units);
+          COPY_ATTR (max_clock_frequency);
+          COPY_ATTR (max_constant_buffer_size);
+          COPY_ATTR (local_mem_type);
+          COPY_ATTR (endian_little);
+          COPY_ATTR (preferred_wg_size_multiple);
+          COPY_ATTR (extensions);
+          COPY_VECWIDTH (char);
+          COPY_VECWIDTH (short);
+          COPY_VECWIDTH (int);
+          COPY_VECWIDTH (long);
+          COPY_VECWIDTH (float);
+          COPY_VECWIDTH (double);
+          found = 1;
+          break;
+        }
+    }
+  if (!found)
+    POCL_ABORT("We found a device for which we don't have device"
+               "OpenCL attribute information (compute unit count,"
+               "constant buffer size etc), and there's no way to get"
+               "the required stuff from HSA API. Please create a "
+               "new entry with the information in supported_hsa_devices,"
+               "and send a note/patch to pocl developers. Thanks!");
+}
+
+void
+pocl_hsa_init_device_infos(struct _cl_device_id* dev)
+{
+  pocl_basic_init_device_infos (dev);
+
+  dev->spmd = CL_TRUE;
+  dev->autolocals_to_args = 0;
+
+  assert(found_hsa_agents > 0);
+  assert(last_assigned_agent < (hsa_agents + found_hsa_agents));
+  dev->data = (void*)last_assigned_agent;
+  hsa_agent_t agent = *last_assigned_agent++;
+
+  uint32_t cache_sizes[4];
+  HSA_CHECK(hsa_agent_get_info (agent, HSA_AGENT_INFO_CACHE_SIZE,
+                        &cache_sizes));
+  // The only nonzero value on Kaveri is the first (L1)
+  dev->global_mem_cache_size = cache_sizes[0];
+
+  dev->short_name = dev->long_name = (char*)malloc (64*sizeof(char));
+  HSA_CHECK(hsa_agent_get_info (agent, HSA_AGENT_INFO_NAME, dev->long_name));
+  get_hsa_device_features (dev->long_name, dev);
+
+  dev->type = CL_DEVICE_TYPE_GPU;
+
+  dev->image_support = CL_FALSE;   // until it's actually implemented
+
+  dev->single_fp_config = CL_FP_ROUND_TO_NEAREST | CL_FP_ROUND_TO_ZERO
+      | CL_FP_ROUND_TO_INF | CL_FP_FMA | CL_FP_INF_NAN;
+  dev->double_fp_config = CL_FP_ROUND_TO_NEAREST | CL_FP_ROUND_TO_ZERO
+      | CL_FP_ROUND_TO_INF | CL_FP_FMA | CL_FP_INF_NAN;
+
+  hsa_machine_model_t model;
+  HSA_CHECK(hsa_agent_get_info (agent, HSA_AGENT_INFO_MACHINE_MODEL, &model));
+  dev->address_bits = (model == HSA_MACHINE_MODEL_LARGE) ? 64 : 32;
+
+  uint16_t wg_sizes[3];
+  HSA_CHECK(hsa_agent_get_info(agent, HSA_AGENT_INFO_WORKGROUP_MAX_DIM, &wg_sizes));
+  dev->max_work_item_sizes[0] = wg_sizes[0];
+  dev->max_work_item_sizes[1] = wg_sizes[1];
+  dev->max_work_item_sizes[2] = wg_sizes[2];
+
+  HSA_CHECK(hsa_agent_get_info
+    (agent, HSA_AGENT_INFO_WORKGROUP_MAX_SIZE, &dev->max_work_group_size));
+  /*Image features*/
+  hsa_dim3_t image_size;
+  HSA_CHECK(hsa_agent_get_info (agent, HSA_EXT_AGENT_INFO_IMAGE_1D_MAX_ELEMENTS, &image_size));
+  dev->image_max_buffer_size = image_size.x;
+  HSA_CHECK(hsa_agent_get_info (agent, HSA_EXT_AGENT_INFO_IMAGE_2D_MAX_ELEMENTS, &image_size));
+  dev->image2d_max_height = image_size.x;
+  dev->image2d_max_width = image_size.y;
+  HSA_CHECK(hsa_agent_get_info (agent, HSA_EXT_AGENT_INFO_IMAGE_3D_MAX_ELEMENTS, &image_size));
+  dev->image3d_max_height = image_size.x;
+  dev->image3d_max_width = image_size.y;
+  dev->image3d_max_depth = image_size.z;
+  // is this directly the product of the dimensions?
+  //stat = hsa_agent_get_info(agent, ??, &dev->image_max_array_size);
+  HSA_CHECK(hsa_agent_get_info
+    (agent, HSA_EXT_AGENT_INFO_MAX_IMAGE_RD_HANDLES, &dev->max_read_image_args));
+  HSA_CHECK(hsa_agent_get_info
+    (agent, HSA_EXT_AGENT_INFO_MAX_IMAGE_RORW_HANDLES, &dev->max_write_image_args));
+  HSA_CHECK(hsa_agent_get_info
+    (agent, HSA_EXT_AGENT_INFO_MAX_SAMPLER_HANDLERS, &dev->max_samplers));
+}
+
+unsigned int
+pocl_hsa_probe(struct pocl_device_ops *ops)
+{
+  int env_count = pocl_device_get_env_count(ops->device_name);
+
+  POCL_MSG_PRINT_INFO("pocl-hsa: found %d env devices with %s.\n",
+                      env_count, ops->device_name);
+
+  /* No hsa env specified, the user did not request for HSA agents. */
+  if (env_count <= 0)
+    return 0;
+
+  HSA_CHECK(hsa_init());
+
+  HSA_CHECK(hsa_iterate_agents(pocl_hsa_get_agents_callback, NULL));
+
+  POCL_MSG_PRINT_INFO("pocl-hsa: found %d agents.\n", found_hsa_agents);
+  last_assigned_agent = hsa_agents;
+
+  return found_hsa_agents;
+}
+
+static void hsa_queue_callback(hsa_status_t status, hsa_queue_t *q, void* data) {
+  HSA_CHECK(status);
+}
+
+void
+pocl_hsa_init (cl_device_id device, const char* parameters)
+{
+  pocl_hsa_device_data_t *d;
+  static int global_mem_id;
+  static int first_hsa_init = 1;
+  hsa_device_type_t dev_type;
+
+  if (first_hsa_init)
+    {
+      first_hsa_init = 0;
+      global_mem_id = device->dev_id;
+    }
+  device->global_mem_id = global_mem_id;
+
+  d = (pocl_hsa_device_data_t *) malloc (sizeof(pocl_hsa_device_data_t));
+  memset(d, 0, sizeof(pocl_hsa_device_data_t));
+
+  d->agent = (hsa_agent_t*)device->data;
+  device->data = d;
+
+  HSA_CHECK(hsa_agent_iterate_regions (*d->agent, setup_agent_memory_regions_callback, d));
+
+  uint32_t boolarg;
+  HSA_CHECK(hsa_region_get_info(d->global_region,
+                               HSA_REGION_INFO_RUNTIME_ALLOC_ALLOWED, &boolarg));
+  assert(boolarg != 0);
+
+  size_t sizearg;
+  HSA_CHECK(hsa_region_get_info(d->global_region,
+                               HSA_REGION_INFO_ALLOC_MAX_SIZE, &sizearg));
+  device->max_mem_alloc_size = sizearg;
+
+  /* For some reason, the global region size returned is 128 Terabytes...
+   * for now, use the max alloc size, it seems to be a much more reasonable value.
+  HSA_CHECK(hsa_region_get_info(d->global_region, HSA_REGION_INFO_SIZE, &sizearg));
+  */
+  device->global_mem_size = sizearg;
+
+  HSA_CHECK(hsa_region_get_info(d->group_region, HSA_REGION_INFO_SIZE, &sizearg));
+  device->local_mem_size = sizearg;
+
+  HSA_CHECK(hsa_region_get_info(d->global_region,
+                               HSA_REGION_INFO_RUNTIME_ALLOC_ALIGNMENT, &sizearg));
+  device->mem_base_addr_align = sizearg * 8;
+
+  HSA_CHECK(hsa_agent_get_info(*d->agent, HSA_AGENT_INFO_PROFILE, &d->agent_profile));
+  device->profile = (
+      (d->agent_profile == HSA_PROFILE_FULL) ? "FULL_PROFILE" : "EMBEDDED_PROFILE");
+
+  HSA_CHECK(hsa_queue_create(*d->agent, 4, HSA_QUEUE_TYPE_MULTI,
+                       hsa_queue_callback, device->short_name,
+                       -1, -1, &d->queue));
+}
+
+static void *
+pocl_hsa_malloc (pocl_hsa_device_data_t* d, cl_mem_flags flags, size_t size, void *host_ptr)
+{
+  void *b;
+
+  if (flags & CL_MEM_COPY_HOST_PTR)
+    {
+      assert(host_ptr != NULL);
+      if (hsa_memory_allocate(d->global_region, size, &b) != HSA_STATUS_SUCCESS)
+          return NULL;
+      hsa_memory_copy(b, host_ptr, size);
+      return b;
+    }
+
+  if (flags & CL_MEM_USE_HOST_PTR)
+    {
+      assert(host_ptr != NULL);
+      // TODO bookkeeping of mem registrations
+      hsa_memory_register(host_ptr, size);
+      return host_ptr;
+    }
+
+  assert(host_ptr == NULL);
+  if (hsa_memory_allocate(d->global_region, size, &b) != HSA_STATUS_SUCCESS)
+      return NULL;
+  return b;
+}
+
+void
+pocl_hsa_free (void *data, cl_mem_flags flags, void *ptr)
+{
+  if (flags & CL_MEM_USE_HOST_PTR)
+    return; // TODO: hsa_memory_deregister() (needs size)
+
+  hsa_memory_free(ptr);
+}
+
+cl_int pocl_hsa_alloc_mem_obj(cl_device_id device, cl_mem mem_obj)
+{
+  void *b = NULL;
+  cl_mem_flags flags = mem_obj->flags;
+
+  /* if memory for this global memory is not yet allocated -> do it */
+  if (mem_obj->device_ptrs[device->global_mem_id].mem_ptr == NULL)
+    {
+      b = pocl_hsa_malloc(device->data, flags, mem_obj->size, mem_obj->mem_host_ptr);
+      if (b == NULL)
+        return CL_MEM_OBJECT_ALLOCATION_FAILURE;
+
+      mem_obj->device_ptrs[device->global_mem_id].mem_ptr = b;
+      mem_obj->device_ptrs[device->global_mem_id].global_mem_id =
+        device->global_mem_id;
+    }
+
+  /* copy already allocated global mem info to devices own slot */
+  mem_obj->device_ptrs[device->dev_id] =
+    mem_obj->device_ptrs[device->global_mem_id];
+
+  return CL_SUCCESS;
+
+}
+
+static void
+setup_kernel_args (pocl_hsa_device_data_t *d,
+                   _cl_command_node *cmd,
+                   char *arg_space,
+                   size_t max_args_size,
+                   uint32_t *total_group_size)
+{
+  char *write_pos = arg_space;
+  const char *last_pos = arg_space + max_args_size;
+
+#define CHECK_AND_ALIGN_SPACE(DSIZE)                         \
+  do {                                                       \
+    if (write_pos + (DSIZE) > last_pos)                      \
+      POCL_ABORT("pocl-hsa: too many kernel arguments!\n");  \
+    unsigned unaligned = (intptr_t)write_pos % DSIZE;        \
+    if (unaligned > 0) write_pos += (DSIZE - unaligned);     \
+  } while (0)
+
+  for (size_t i = 0; i < cmd->command.run.kernel->num_args; ++i)
+    {
+      struct pocl_argument *al = &(cmd->command.run.arguments[i]);
+      if (cmd->command.run.kernel->arg_info[i].is_local)
+        {
+          CHECK_AND_ALIGN_SPACE(sizeof (uint32_t));
+          memcpy(write_pos, total_group_size, sizeof(uint32_t));
+          *total_group_size += (uint32_t)al->size;
+          write_pos += sizeof(uint32_t);
+        }
+      else if (cmd->command.run.kernel->arg_info[i].type == POCL_ARG_TYPE_POINTER)
+        {
+          CHECK_AND_ALIGN_SPACE(sizeof (uint64_t));
+          /* Assuming the pointers are 64b (or actually the same as in
+             host) due to HSA. TODO: the 32b profile. */
+
+          if (al->value == NULL)
+            {
+              uint64_t temp = 0;
+              memcpy (write_pos, &temp, sizeof (uint64_t));
+            }
+          else
+            {
+        	  uint64_t temp = (uint64_t)(*(cl_mem *)
+				  (al->value))->device_ptrs[cmd->device->dev_id].mem_ptr;
+              memcpy (write_pos, &temp, sizeof(uint64_t));
+            }
+          write_pos += sizeof(uint64_t);
+#if 0
+          /* TODO: It's legal to pass a NULL pointer to clSetKernelArguments. In
+             that case we must pass the same NULL forward to the kernel.
+             Otherwise, the user must have created a buffer with per device
+             pointers stored in the cl_mem. */
+          if (al->value == NULL)
+            {
+              arguments[i] = malloc (sizeof (void *));
+              *(void **)arguments[i] = NULL;
+            }
+          else
+            arguments[i] =
+              &((*(cl_mem *) (al->value))->device_ptrs[cmd->device->dev_id].mem_ptr);
+#endif
+        }
+      else if (cmd->command.run.kernel->arg_info[i].type == POCL_ARG_TYPE_IMAGE)
+        {
+          POCL_ABORT_UNIMPLEMENTED("pocl-hsa: image arguments not implemented.\n");
+        }
+      else if (cmd->command.run.kernel->arg_info[i].type == POCL_ARG_TYPE_SAMPLER)
+        {
+          POCL_ABORT_UNIMPLEMENTED("pocl-hsa: sampler arguments not implemented.\n");
+        }
+      else
+        {
+          // Scalars.
+          CHECK_AND_ALIGN_SPACE(al->size);
+          memcpy (write_pos, al->value, al->size);
+          write_pos += al->size;
+        }
+    }
+
+#if 0
+  for (size_t i = cmd->command.run.kernel->num_args;
+       i < cmd->command.run.kernel->num_args + cmd->command.run.kernel->num_locals;
+       ++i)
+    {
+      POCL_ABORT_UNIMPLEMENTED("hsa: automatic local buffers not implemented.");
+      al = &(cmd->command.run.arguments[i]);
+      arguments[i] = malloc (sizeof (void *));
+      *(void **)(arguments[i]) = pocl_hsa_malloc (data, 0, al->size, NULL);
+    }
+#endif
+}
+
+/* Sets up things that go into kernel dispatch packet and are cacheable.
+ * If stuff is cached, returns d->program_cache[i].kernel_cache[j]
+ * If stuff is not cached, and d->program_cache[i].kernel_cache is not full,
+ * puts things there;
+ * otherwise puts things into 'stack_cache' argument;
+ * returns a pointer to the actually used storage */
+static pocl_hsa_kernel_cache_t* cache_kernel_dispatch_data(cl_kernel kernel,
+                                pocl_hsa_device_data_t* d,
+                                hsa_executable_t *exe_ptr,
+                                pocl_hsa_kernel_cache_t *stack_cache) {
+  pocl_hsa_kernel_cache_t* out = NULL;
+
+  assert(exe_ptr != NULL);
+  assert(stack_cache != NULL);
+  assert(d != NULL);
+
+  for (unsigned i = 0; i<HSA_KERNEL_CACHE_SIZE; i++)
+    {
+      if (d->kernel_cache[i].kernel == kernel)
+        return &d->kernel_cache[i];
+    }
+
+  if (d->kernel_cache_lastptr < HSA_KERNEL_CACHE_SIZE)
+    out = &d->kernel_cache[d->kernel_cache_lastptr++];
+  else
+    out = stack_cache;
+
+  out->hsa_exe = *exe_ptr;
+
+  hsa_executable_symbol_t kernel_symbol;
+
+  size_t kernel_name_length = strlen (kernel->name);
+  char *symbol = malloc (kernel_name_length + 2);
+  symbol[0] = '&';
+  symbol[1] = '\0';
+
+  strncat (symbol, kernel->name, kernel_name_length);
+
+  POCL_MSG_PRINT_INFO("pocl-hsa: getting kernel symbol %s.\n", symbol);
+
+  HSA_CHECK(hsa_executable_get_symbol
+    (out->hsa_exe, NULL, symbol, *d->agent, 0, &kernel_symbol));
+
+  hsa_symbol_kind_t symtype;
+  HSA_CHECK(hsa_executable_symbol_get_info
+    (kernel_symbol, HSA_EXECUTABLE_SYMBOL_INFO_TYPE, &symtype));
+  if(symtype != HSA_SYMBOL_KIND_KERNEL)
+    POCL_ABORT ("pocl-hsa: the kernel function symbol resolves "
+                "to something else than a function\n");
+
+  uint64_t code_handle;
+  HSA_CHECK(hsa_executable_symbol_get_info
+    (kernel_symbol, HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_OBJECT, &code_handle));
+
+  out->code_handle = code_handle;
+
+  HSA_CHECK(hsa_executable_symbol_get_info(kernel_symbol,
+       HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_GROUP_SEGMENT_SIZE, &out->static_group_size));
+
+  HSA_CHECK(hsa_executable_symbol_get_info
+    (kernel_symbol, HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_PRIVATE_SEGMENT_SIZE, &out->private_size));
+
+  hsa_signal_value_t initial_value = 1;
+  HSA_CHECK(hsa_signal_create(initial_value, 0, NULL, &out->kernel_completion_signal));
+
+  HSA_CHECK(hsa_executable_symbol_get_info
+    (kernel_symbol, HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_KERNARG_SEGMENT_SIZE,
+     &out->args_segment_size));
+
+  HSA_CHECK(hsa_memory_allocate(d->kernarg_region, out->args_segment_size, &out->kernargs));
+
+  out->kernel = (cl_kernel)kernel;
+  return out;
+}
+
+void
+pocl_hsa_run(void *dptr, _cl_command_node* cmd)
+{
+  pocl_hsa_device_data_t *d;
+  unsigned i;
+  cl_kernel kernel = cmd->command.run.kernel;
+  struct pocl_context *pc = &cmd->command.run.pc;
+  hsa_kernel_dispatch_packet_t *kernel_packet;
+  hsa_signal_t kernel_completion_signal;
+  hsa_region_t region;
+  pocl_hsa_kernel_cache_t stack_cache, *cached_data;
+
+  assert (dptr != NULL);
+  d = dptr;
+  d->current_kernel = kernel;
+
+  hsa_executable_t *exe_ptr = (hsa_executable_t*)cmd->command.run.device_data;
+
+  cached_data = cache_kernel_dispatch_data(kernel, d, exe_ptr, &stack_cache);
+
+  /* does NOT free the hsa_executable_t, rather the malloc'ed mem
+   * from compile_submitted_kernels() */
+  free(exe_ptr);
+
+  const uint32_t queueMask = d->queue->size - 1;
+
+  uint64_t queue_index =
+    hsa_queue_load_write_index_relaxed (d->queue);
+  kernel_packet =
+    &(((hsa_kernel_dispatch_packet_t*)(d->queue->base_address))[queue_index & queueMask]);
+
+  /* Process the kernel arguments. Convert the opaque buffer
+     pointers to real device pointers, allocate dynamic local
+     memory buffers, etc. */
+
+  kernel_packet->workgroup_size_x = cmd->command.run.local_x;
+  kernel_packet->workgroup_size_y = cmd->command.run.local_y;
+  kernel_packet->workgroup_size_z = cmd->command.run.local_z;
+
+  kernel_packet->grid_size_x = kernel_packet->grid_size_y = kernel_packet->grid_size_z = 1;
+  kernel_packet->grid_size_x = pc->num_groups[0] * cmd->command.run.local_x;
+  kernel_packet->grid_size_y = pc->num_groups[1] * cmd->command.run.local_y;
+  kernel_packet->grid_size_z = pc->num_groups[2] * cmd->command.run.local_z;
+
+  kernel_packet->kernel_object = cached_data->code_handle;
+  kernel_packet->private_segment_size = cached_data->private_size;
+  uint32_t total_group_size = cached_data->static_group_size;
+
+  /* Reset the signal (it might be cached) to its initial value of 1 */
+  hsa_signal_value_t initial_value = 1;
+  hsa_signal_store_relaxed(cached_data->kernel_completion_signal, initial_value);
+  kernel_packet->completion_signal = cached_data->kernel_completion_signal;
+
+  setup_kernel_args (d, cmd, (char*)cached_data->kernargs,
+                     cached_data->args_segment_size, &total_group_size);
+
+  kernel_packet->group_segment_size = total_group_size;
+
+  POCL_MSG_PRINT_INFO("pocl-hsa: kernel's total group size: %u\n", total_group_size);
+  if (total_group_size > cmd->device->local_mem_size)
+    POCL_ABORT ("pocl-hsa: required local memory > device local memory!\n");
+
+  kernel_packet->kernarg_address = cached_data->kernargs;
+
+  typedef union {
+    uint32_t header_setup;
+    struct {
+      uint16_t header;
+      uint16_t setup;
+    } a;
+  } hsa_header_union_t;
+
+  hsa_header_union_t h;
+  h.a.setup = (uint16_t)cmd->command.run.pc.work_dim << HSA_KERNEL_DISPATCH_PACKET_SETUP_DIMENSIONS;
+  h.a.header |= HSA_FENCE_SCOPE_SYSTEM << HSA_PACKET_HEADER_ACQUIRE_FENCE_SCOPE;
+  h.a.header |= HSA_FENCE_SCOPE_SYSTEM << HSA_PACKET_HEADER_RELEASE_FENCE_SCOPE;
+  h.a.header |= HSA_PACKET_TYPE_KERNEL_DISPATCH << HSA_PACKET_HEADER_TYPE;
+  __atomic_store_n((uint32_t*)(&kernel_packet->header), h.header_setup, __ATOMIC_RELEASE);
+
+   /*
+    * Increment the write index and ring the doorbell to dispatch the kernel.
+    */
+   hsa_queue_store_write_index_relaxed (d->queue, queue_index + 1);
+   hsa_signal_store_relaxed (d->queue->doorbell_signal, queue_index);
+
+  /* Launch the kernel by allocating a slot in the queue, writing the
+     command to it, signaling the update with a door bell and finally,
+     block waiting until finish signalled with the completion_signal. */
+
+  hsa_signal_value_t sigval =
+    hsa_signal_wait_acquire
+    (cached_data->kernel_completion_signal, HSA_SIGNAL_CONDITION_LT, 1,
+     (uint64_t)(-1), HSA_WAIT_STATE_ACTIVE);
+
+  /* if the cache is full, release stuff */
+  if (cached_data == &stack_cache)
+    {
+      hsa_executable_destroy(cached_data->hsa_exe);
+      hsa_signal_destroy(cached_data->kernel_completion_signal);
+      hsa_memory_free(cached_data->kernargs);
+    }
+
+  /* TODO this */
+  for (i = 0; i < kernel->num_args; ++i)
+    {
+      if (kernel->arg_info[i].is_local)
+        {
+#if 0
+          pocl_hsa_free (data, 0, *(void **)(arguments[i]));
+          POCL_MEM_FREE(arguments[i]);
+#endif
+        }
+      else if (kernel->arg_info[i].type == POCL_ARG_TYPE_IMAGE)
+        {
+#if 0
+          pocl_hsa_free (data, 0, *(void **)(arguments[i]));
+          POCL_MEM_FREE(arguments[i]);
+#endif
+        }
+#if 0
+      else if (kernel->arg_info[i].type == POCL_ARG_TYPE_SAMPLER ||
+               (kernel->arg_info[i].type == POCL_ARG_TYPE_POINTER &&
+                *(void**)args->kernel_args[i] == NULL))
+        {
+          POCL_MEM_FREE(arguments[i]);
+        }
+#endif
+    }
+  for (i = kernel->num_args;
+       i < kernel->num_args + kernel->num_locals;
+       ++i)
+    {
+#if 0
+      pocl_hsa_free(data, 0, *(void **)(arguments[i]));
+      POCL_MEM_FREE(arguments[i]);
+#endif
+    }
+}
+
+static int compile_parallel_bc_to_brig(const char* tmpdir, char* brigfile) {
+  int error;
+  char hsailfile[POCL_FILENAME_LENGTH];
+  char bytecode[POCL_FILENAME_LENGTH];
+  char command[4096];
+
+  error = snprintf (bytecode, POCL_FILENAME_LENGTH,
+                    "%s%s", tmpdir, POCL_PARALLEL_BC_FILENAME);
+  assert (error >= 0);
+
+  error = snprintf (brigfile, POCL_FILENAME_LENGTH,
+                    "%s%s.brig", tmpdir, POCL_PARALLEL_BC_FILENAME);
+  assert (error >= 0);
+
+  if (pocl_exists(brigfile))
+    POCL_MSG_PRINT_INFO("pocl-hsa: using existing BRIG file: \n%s\n", brigfile);
+  else
+    {
+      POCL_MSG_PRINT_INFO("pocl-hsa: BRIG file not found, compiling parallel.bc "
+                          "to brig file: \n%s\n", bytecode);
+
+      // TODO call llvm via c++ interface like pocl_llvm_codegen()
+      error = snprintf (hsailfile, POCL_FILENAME_LENGTH,
+                    "%s%s.hsail", tmpdir, POCL_PARALLEL_BC_FILENAME);
+      assert (error >= 0);
+
+      error = snprintf (command, 4096, LLC " -O2 -march=hsail64 -filetype=asm "
+                        "-o %s %s", hsailfile, bytecode);
+      assert (error >= 0);
+      error = system(command);
+      if (error != 0)
+        {
+          POCL_MSG_PRINT_INFO("pocl-hsa: llc exit status %i\n", WEXITSTATUS(error));
+          return error;
+        }
+
+      error = snprintf (command, 4096, HSAIL_ASM " -o %s %s", brigfile, hsailfile);
+      assert (error >= 0);
+      error = system(command);
+      if (error != 0)
+        {
+          POCL_MSG_PRINT_INFO("pocl-hsa: HSAILasm exit status %i\n", WEXITSTATUS(error));
+          return error;
+        }
+    }
+
+  return 0;
+}
+
+void
+pocl_hsa_compile_submitted_kernels (_cl_command_node *cmd)
+{
+  if (cmd->type != CL_COMMAND_NDRANGE_KERNEL)
+    return;
+
+  int error;
+  char brigfile[POCL_FILENAME_LENGTH];
+  char *brig_blob;
+
+  pocl_hsa_device_data_t *d =
+    (pocl_hsa_device_data_t*)cmd->device->data;
+
+  hsa_executable_t *out = malloc(sizeof(hsa_executable_t));
+  cmd->command.run.device_data = (void**)out;
+
+  for (unsigned i = 0; i<HSA_KERNEL_CACHE_SIZE; i++)
+    if (d->kernel_cache[i].kernel == cmd->command.run.kernel)
+      {
+        *out = d->kernel_cache[i].hsa_exe;
+        POCL_MSG_PRINT_INFO("kernel.hsa_exe found in kernel cache, returning\n");
+        return;
+      }
+
+  if (compile_parallel_bc_to_brig(cmd->command.run.tmp_dir, brigfile))
+    POCL_ABORT("Compiling LLVM IR -> HSAIL -> BRIG failed.\n");
+
+  POCL_MSG_PRINT_INFO("pocl-hsa: loading binary from file %s.\n", brigfile);
+  uint64_t filesize = 0;
+  int read = pocl_read_file(brigfile, &brig_blob, &filesize);
+
+  if (read != 0)
+    POCL_ABORT("pocl-hsa: could not read the binary.\n");
+
+  POCL_MSG_PRINT_INFO("pocl-hsa: BRIG binary size: %lu.\n", filesize);
+
+  hsa_ext_module_t hsa_module = (hsa_ext_module_t)brig_blob;
+
+  hsa_ext_program_t hsa_program;
+  memset (&hsa_program, 0, sizeof (hsa_ext_program_t));
+
+  HSA_CHECK(hsa_ext_program_create
+    (HSA_MACHINE_MODEL_LARGE, HSA_PROFILE_FULL,
+     HSA_DEFAULT_FLOAT_ROUNDING_MODE_DEFAULT, NULL,
+     &hsa_program));
+
+  HSA_CHECK(hsa_ext_program_add_module (hsa_program, hsa_module));
+
+  hsa_isa_t isa;
+  HSA_CHECK(hsa_agent_get_info (*d->agent, HSA_AGENT_INFO_ISA, &isa));
+
+  hsa_ext_control_directives_t control_directives;
+  memset (&control_directives, 0, sizeof (hsa_ext_control_directives_t));
+
+  hsa_code_object_t code_object;
+  HSA_CHECK(hsa_ext_program_finalize
+    (hsa_program, isa, 0, control_directives, "",
+     HSA_CODE_OBJECT_TYPE_PROGRAM, &code_object));
+
+  HSA_CHECK(hsa_executable_create (d->agent_profile,
+                                  HSA_EXECUTABLE_STATE_UNFROZEN,
+                                  "", out));
+
+  HSA_CHECK(hsa_executable_load_code_object (*out, *d->agent,
+                                            code_object, ""));
+
+  HSA_CHECK(hsa_executable_freeze (*out, NULL));
+
+  HSA_CHECK(hsa_code_object_destroy(code_object));
+
+  HSA_CHECK(hsa_ext_program_destroy(hsa_program));
+
+  free(brig_blob);
+
+/*
+  if (d->kernel_cache_lastptr < HSA_KERNEL_CACHE_SIZE)
+    {
+      d->kernel_cache[d->kernel_cache_lastptr].kernel = cmd->command.run.kernel;
+      d->kernel_cache[d->kernel_cache_lastptr++].hsa_exe = *out;
+    }
+*/
+
+}
+
+void
+pocl_hsa_uninit (cl_device_id device)
+{
+  pocl_hsa_device_data_t *d = (pocl_hsa_device_data_t*)device->data;
+
+  for (unsigned i = 0; i < HSA_KERNEL_CACHE_SIZE; i++)
+    if (d->kernel_cache[i].kernel)
+      {
+        HSA_CHECK(hsa_executable_destroy(d->kernel_cache[i].hsa_exe));
+        HSA_CHECK(hsa_signal_destroy(d->kernel_cache[i].kernel_completion_signal));
+      }
+
+  HSA_CHECK(hsa_queue_destroy(d->queue));
+  POCL_MEM_FREE(d);
+  device->data = NULL;
+}
diff --git a/lib/CL/clRetainDevice.c b/lib/CL/devices/hsa/pocl-hsa.h
similarity index 76%
copy from lib/CL/clRetainDevice.c
copy to lib/CL/devices/hsa/pocl-hsa.h
index f9c9a88..0bc2854 100644
--- a/lib/CL/clRetainDevice.c
+++ b/lib/CL/devices/hsa/pocl-hsa.h
@@ -1,17 +1,17 @@
-/* OpenCL runtime library: clRetainDevice()
+/* pocl-hsa.h - HSA device declarations
+
+   Copyright (c) 2015 Pekka Jääskeläinen / Tampere University of Technology
 
-   Copyright (c) 2012 Pekka Jääskeläinen / TUT
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -20,12 +20,18 @@
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
 */
+
+#ifndef POCL_HSA_H
+#define POCL_HSA_H
+
 #include "pocl_cl.h"
+#include "pocl_icd.h"
+#include "config.h"
+
+#include "prototypes.inc"
+GEN_PROTOTYPES (hsa)
+
+#include "prototypes.inc"
+GEN_PROTOTYPES (basic)
 
-CL_API_ENTRY cl_int CL_API_CALL
-POname(clRetainDevice)(cl_device_id device) CL_API_SUFFIX__VERSION_1_2
-{
-  POCL_RETAIN_OBJECT (device);
-  return CL_SUCCESS;
-}
-POsym(clRetainDevice)
+#endif /* POCL_BASIC_H */
diff --git a/lib/CL/devices/prototypes.inc b/lib/CL/devices/prototypes.inc
index 72c3c69..0314022 100644
--- a/lib/CL/devices/prototypes.inc
+++ b/lib/CL/devices/prototypes.inc
@@ -90,10 +90,9 @@
   void* pocl_##__DRV__##_unmap_mem (void *data, void *host_ptr, \
                                     void *device_start_ptr, size_t size); \
   cl_ulong pocl_##__DRV__##_get_timer_value(void *data); \
-  char* pocl_##__DRV__##_init_build (void *data, \
-                                         const char *dev_tmpdir); \
+  char* pocl_##__DRV__##_init_build (void *data); \
   void pocl_##__DRV__##_build_hash (void *data, SHA1_CTX *build_hash); \
   cl_int pocl_##__DRV__##_get_supported_image_formats (cl_mem_flags flags,\
                                          const cl_image_format **image_formats,\
-                                         cl_int *num_image_formats);\
+                                         cl_uint *num_image_formats);\
 POP_VISIBILITY_HIDDEN
diff --git a/lib/CL/devices/pthread/Makefile.in b/lib/CL/devices/pthread/Makefile.in
index 8990c9d..3d5fc4f 100644
--- a/lib/CL/devices/pthread/Makefile.in
+++ b/lib/CL/devices/pthread/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -104,8 +114,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = lib/CL/devices/pthread
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -114,6 +122,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -192,6 +201,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -243,6 +253,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -279,6 +292,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -414,7 +428,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/CL/devices/pthread/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign lib/CL/devices/pthread/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -692,6 +705,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/lib/CL/devices/pthread/pthread.c b/lib/CL/devices/pthread/pthread.c
index 9c184d9..9a4916f 100644
--- a/lib/CL/devices/pthread/pthread.c
+++ b/lib/CL/devices/pthread/pthread.c
@@ -48,7 +48,6 @@
 #ifdef CUSTOM_BUFFER_ALLOCATOR
 
 #include "bufalloc.h"
-#include <dev_image.h>
 
 /* Instead of mallocing a buffer size for a region, try to allocate 
    this many times the buffer size to hopefully avoid mallocs for 
@@ -80,7 +79,7 @@
 #endif
 
 #define COMMAND_LENGTH 2048
-#define WORKGROUP_STRING_LENGTH 256
+#define WORKGROUP_STRING_LENGTH 1024
 
 /* The name of the environment variable used to force a certain max thread count
    for the thread execution. */
@@ -93,7 +92,7 @@ struct thread_arguments
   cl_kernel kernel;
   cl_device_id device;
   struct pocl_context pc;
-  int last_gid_x; 
+  unsigned last_gid_x;
   pocl_workgroup workgroup;
   struct pocl_argument *kernel_args;
   thread_arguments *volatile next;
@@ -125,9 +124,13 @@ struct data {
 static thread_arguments *volatile thread_argument_pool = 0;
 static int argument_pool_initialized = 0;
 pocl_lock_t ta_pool_lock;
-static int get_max_thread_count();
+static size_t get_max_thread_count(cl_device_id device);
 static void * workgroup_thread (void *p);
 
+/* TODO: Declare this in a header file */
+void
+pocl_basic_set_buffer_image_limits(cl_device_id device);
+
 static void pocl_init_thread_argument_manager (void)
 {
   if (!argument_pool_initialized)
@@ -148,7 +151,7 @@ static thread_arguments* new_thread_arguments ()
       return ta;
     }
   POCL_UNLOCK (ta_pool_lock);
-    
+
   return (thread_arguments*)calloc (1, sizeof (thread_arguments));
 }
 
@@ -199,15 +202,15 @@ pocl_pthread_init_device_infos(struct _cl_device_id* dev)
   pocl_basic_init_device_infos(dev);
 
   dev->type = CL_DEVICE_TYPE_CPU;
-  dev->max_work_item_sizes[0] = SIZE_MAX;
-  dev->max_work_item_sizes[1] = SIZE_MAX;
-  dev->max_work_item_sizes[2] = SIZE_MAX;
+  dev->max_work_item_sizes[0] = dev->max_work_item_sizes[1] =
+	  dev->max_work_item_sizes[2] = dev->max_work_group_size;
 
 }
 
 void
 pocl_pthread_init (cl_device_id device, const char* parameters)
 {
+  static int device_number = 0;
   struct data *d; 
 #ifdef CUSTOM_BUFFER_ALLOCATOR  
   static mem_regions_management* mrm = NULL;
@@ -237,38 +240,38 @@ pocl_pthread_init (cl_device_id device, const char* parameters)
 
   device->address_bits = sizeof(void*) * 8;
 
-  /* Use the minimum values until we get a more sensible 
-     upper limit from somewhere. */
-  device->max_read_image_args = device->max_write_image_args = 128;
-  device->image2d_max_width = device->image2d_max_height = 8192;
-  device->image3d_max_width = device->image3d_max_height = device->image3d_max_depth = 2048;
-  device->max_samplers = 16;  
-  device->max_constant_args = 8;
-
-  device->min_data_type_align_size = device->mem_base_addr_align = MAX_EXTENDED_ALIGNMENT;
-
-  /* Note: The specification describes identifiers being delimited by
-     only a single space character. Some programs that check the device's
-     extension  string assume this rule. Future extension additions should
-     ensure that there is no more than a single space between
-     identifiers. */
-
-#ifndef _CL_DISABLE_LONG
-#define DOUBLE_EXT "cl_khr_fp64 "
-#else
-#define DOUBLE_EXT
-#endif
-
-#ifndef _CL_DISABLE_HALF
-#define HALF_EXT "cl_khr_fp16 "
-#else
-#define HALF_EXT
-#endif
-
-  device->extensions = DOUBLE_EXT HALF_EXT "cl_khr_byte_addressable_store";
+  device->min_data_type_align_size = MAX_EXTENDED_ALIGNMENT; // this is in bytes
+  device->mem_base_addr_align = MAX_EXTENDED_ALIGNMENT*8; // this is in bits
 
+  /* hwloc probes OpenCL device info at its initialization in case
+     the OpenCL extension is enabled. This causes to printout 
+     an unimplemented property error because hwloc is used to
+     initialize global_mem_size which it is not yet. Just put 
+     a nonzero there for now. */
+  device->global_mem_size = 1;
   pocl_topology_detect_device_info(device);
   pocl_cpuinfo_detect_device_info(device);
+  pocl_basic_set_buffer_image_limits(device);
+
+  /* in case hwloc doesn't provide a PCI ID, let's generate
+     a vendor id that hopefully is unique across vendors. */
+  const char *magic = "pocl";
+  if (device->vendor_id == 0)
+    device->vendor_id =
+      magic[0] | magic[1] << 8 | magic[2] << 16 | magic[3] << 24;
+
+  device->vendor_id += device_number;
+  device_number++;
+
+  // pthread has elementary partitioning support
+  device->max_sub_devices = device->max_compute_units;
+  device->num_partition_properties = 2;
+  device->partition_properties = calloc(device->num_partition_properties,
+    sizeof(cl_device_partition_property));
+  device->partition_properties[0] = CL_DEVICE_PARTITION_EQUALLY;
+  device->partition_properties[1] = CL_DEVICE_PARTITION_BY_COUNTS;
+  device->num_partition_types = 0;
+  device->partition_type = NULL;
 
   if(!strcmp(device->llvm_cpu, "(unknown)"))
     device->llvm_cpu = NULL;
@@ -310,7 +313,7 @@ allocate_aligned_buffer (struct data* d, void **memptr, size_t alignment, size_t
   chunk_info_t *chunk = alloc_buffer (d->mem_regions->mem_regions, size);
   if (chunk == NULL)
     {
-      memory_region_t *new_mem_region = 
+      memory_region_t *new_mem_region =
         (memory_region_t*)malloc (sizeof (memory_region_t));
 
       if (new_mem_region == NULL) 
@@ -345,7 +348,7 @@ allocate_aligned_buffer (struct data* d, void **memptr, size_t alignment, size_t
         }
 
       init_mem_region (new_mem_region, (memory_address_t)space, region_size);
-      new_mem_region->alignment = alignment;
+      new_mem_region->alignment = (unsigned short)(alignment);
       DL_APPEND (d->mem_regions->mem_regions, new_mem_region);
       chunk = alloc_buffer_from_region (new_mem_region, size);
 
@@ -409,22 +412,28 @@ pocl_pthread_alloc_mem_obj (cl_device_id device, cl_mem mem_obj)
 {
   void *b = NULL;
   struct data* d = (struct data*)device->data;
-  cl_int flags = mem_obj->flags;
+  cl_mem_flags flags = mem_obj->flags;
 
   /* if memory for this global memory is not yet allocated -> do it */
   if (mem_obj->device_ptrs[device->global_mem_id].mem_ptr == NULL)
     {
-      if (flags & CL_MEM_USE_HOST_PTR && mem_obj->mem_host_ptr != NULL)
+      if (flags & CL_MEM_USE_HOST_PTR)
         {
+          // mem_host_ptr must be non-NULL
+          assert(mem_obj->mem_host_ptr != NULL);
           b = mem_obj->mem_host_ptr;
         }
-      else if (allocate_aligned_buffer (d, &b, MAX_EXTENDED_ALIGNMENT, 
+      else if (allocate_aligned_buffer (d, &b, MAX_EXTENDED_ALIGNMENT,
                                         mem_obj->size) != 0)
         return CL_MEM_OBJECT_ALLOCATION_FAILURE;
 
       if (flags & CL_MEM_COPY_HOST_PTR)
-        memcpy (b, mem_obj->mem_host_ptr, mem_obj->size);
-    
+        {
+          // mem_host_ptr must be non-NULL
+          assert(mem_obj->mem_host_ptr != NULL);
+          memcpy (b, mem_obj->mem_host_ptr, mem_obj->size);
+        }
+
       mem_obj->device_ptrs[device->global_mem_id].mem_ptr = b;
       mem_obj->device_ptrs[device->global_mem_id].global_mem_id = 
         device->global_mem_id;
@@ -487,7 +496,7 @@ pocl_pthread_read (void *data, void *host_ptr, const void *device_ptr,
   if (host_ptr == device_ptr)
     return;
 
-  memcpy (host_ptr, device_ptr + offset, cb);
+  memcpy (host_ptr, (char*)device_ptr + offset, cb);
 }
 
 void
@@ -497,7 +506,7 @@ pocl_pthread_write (void *data, const void *host_ptr, void *device_ptr,
   if (host_ptr == device_ptr)
     return;
   
-  memcpy (device_ptr + offset, host_ptr, cb);
+  memcpy ((char*)device_ptr + offset, host_ptr, cb);
 }
 
 void
@@ -507,7 +516,7 @@ pocl_pthread_copy (void *data, const void *src_ptr, size_t src_offset,
   if (src_ptr == dst_ptr)
     return;
   
-  memcpy (dst_ptr + dst_offset, src_ptr + src_offset, cb);
+  memcpy ((char*)dst_ptr + dst_offset, (char*)src_ptr + src_offset, cb);
 }
 
 #define FALLBACK_MAX_THREAD_COUNT 8
@@ -518,7 +527,7 @@ pocl_pthread_copy (void *data, const void *src_ptr, size_t src_offset,
  * the maximum parallelism without extra threading overheads.
  */
 static
-int 
+size_t
 get_max_thread_count(cl_device_id device) 
 {
   /* if return THREAD_COUNT_ENV if set, 
@@ -526,7 +535,7 @@ get_max_thread_count(cl_device_id device)
   if (device->max_compute_units == 0)
     return pocl_get_int_option (THREAD_COUNT_ENV, FALLBACK_MAX_THREAD_COUNT);
   else
-    return pocl_get_int_option(THREAD_COUNT_ENV, device->max_compute_units);
+    return pocl_get_int_option(THREAD_COUNT_ENV, POCL_REAL_DEV(device)->max_compute_units);
 }
 
 void
@@ -535,23 +544,28 @@ pocl_pthread_run
  _cl_command_node* cmd)
 {
   int error;
-  unsigned i;
+  unsigned i, max_threads;
   cl_kernel kernel = cmd->command.run.kernel;
   struct pocl_context *pc = &cmd->command.run.pc;
   struct thread_arguments *arguments;
-  static int max_threads = 0; /* this needs to be asked only once */
+  static unsigned default_max_threads = 0; /* this needs to be asked only once */
 
-  int num_groups_x = pc->num_groups[0];
+  size_t num_groups_x = pc->num_groups[0];
   /* TODO: distributing the work groups in the x dimension is not always the
      best option. This assumes x dimension has enough work groups to utilize
      all the threads. */
-  if (max_threads == 0)
-    max_threads = get_max_thread_count(cmd->device);
+  if (default_max_threads == 0)
+    default_max_threads = get_max_thread_count(cmd->device);
+
+  if (cmd->device->parent_device)
+    max_threads = cmd->device->max_compute_units;
+  else
+    max_threads = default_max_threads;
 
-  int num_threads = min(max_threads, num_groups_x);
+  unsigned num_threads = min(max_threads, num_groups_x);
   pthread_t *threads = (pthread_t*) malloc (sizeof (pthread_t)*num_threads);
   
-  int wgs_per_thread = num_groups_x / num_threads;
+  unsigned wgs_per_thread = num_groups_x / num_threads;
   /* In case the work group count is not divisible by the
      number of threads, we have to execute the remaining
      workgroups in one of the threads. */
@@ -564,8 +578,8 @@ pocl_pthread_run
   printf("### wgs per thread==%d leftover wgs==%d\n", wgs_per_thread, leftover_wgs);
 #endif
   
-  int first_gid_x = 0;
-  int last_gid_x = wgs_per_thread - 1;
+  unsigned first_gid_x = 0;
+  unsigned last_gid_x = wgs_per_thread - 1;
   for (i = 0; i < num_threads; 
        ++i, first_gid_x += wgs_per_thread, last_gid_x += wgs_per_thread) {
 
@@ -664,12 +678,12 @@ workgroup_thread (void *p)
       else if (kernel->arg_info[i].type == POCL_ARG_TYPE_SAMPLER)
         {
           dev_sampler_t ds;
+          fill_dev_sampler_t(&ds, al);
           
+          void* devptr = pocl_pthread_malloc(ta->data, 0, sizeof(dev_sampler_t), NULL);
           arguments[i] = malloc (sizeof (void *));
-          *(void **)(arguments[i]) = pocl_pthread_malloc 
-            (ta->data, 0, sizeof(dev_sampler_t), NULL);
-          pocl_pthread_write (ta->data, &ds, *(void**)arguments[i], 0, 
-                              sizeof(dev_sampler_t));
+          *(void **)(arguments[i]) = devptr;
+          pocl_pthread_write (ta->data, &ds, devptr, 0, sizeof(dev_sampler_t));
         }
       else
         arguments[i] = al->value;
@@ -687,7 +701,7 @@ workgroup_thread (void *p)
                                                       NULL);
     }
 
-  int first_gid_x = ta->pc.group_id[0];
+  size_t first_gid_x = ta->pc.group_id[0];
   unsigned gid_z, gid_y, gid_x;
   for (gid_z = 0; gid_z < ta->pc.num_groups[2]; ++gid_z)
     {
@@ -710,13 +724,13 @@ workgroup_thread (void *p)
           pocl_pthread_free (ta->data, 0, *(void **)(arguments[i]));
           POCL_MEM_FREE(arguments[i]);
         }
-      else if (kernel->arg_info[i].type == POCL_ARG_TYPE_IMAGE)
+      else if (kernel->arg_info[i].type == POCL_ARG_TYPE_IMAGE ||
+                kernel->arg_info[i].type == POCL_ARG_TYPE_SAMPLER)
         {
           pocl_pthread_free (ta->data, 0, *(void **)(arguments[i]));
           POCL_MEM_FREE(arguments[i]);
         }
-      else if (kernel->arg_info[i].type == POCL_ARG_TYPE_SAMPLER || 
-               (kernel->arg_info[i].type == POCL_ARG_TYPE_POINTER && *(void**)arguments[i] == NULL))
+      else if (kernel->arg_info[i].type == POCL_ARG_TYPE_POINTER && *(void**)arguments[i] == NULL)
         {
           POCL_MEM_FREE(arguments[i]);
         }
diff --git a/lib/CL/devices/tce/Makefile.am b/lib/CL/devices/tce/Makefile.am
index 496898f..c9f075c 100644
--- a/lib/CL/devices/tce/Makefile.am
+++ b/lib/CL/devices/tce/Makefile.am
@@ -33,6 +33,8 @@ libpocl_devices_tce_la_CPPFLAGS = `@TCE_CONFIG@ --includes` -I$(top_srcdir)/fix-
 -I$(top_srcdir)/lib/CL/devices -I$(top_srcdir)/lib/CL/devices/tce \
 -I$(top_srcdir)/lib/CL $(OCL_ICD_CFLAGS)
 
+libpocl_devices_tce_la_CXXFLAGS = `@TCE_CONFIG@ --cxxflags`
+
 dist_pkgdata_DATA = tta_device_main.c
 
 EXTRA_DIST = CMakeLists.txt
diff --git a/lib/CL/devices/tce/Makefile.in b/lib/CL/devices/tce/Makefile.in
index 0047f52..d5fe6e4 100644
--- a/lib/CL/devices/tce/Makefile.in
+++ b/lib/CL/devices/tce/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -40,7 +40,17 @@
 
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -105,8 +115,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = lib/CL/devices/tce
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp $(dist_pkgdata_DATA)
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -115,6 +123,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(dist_pkgdata_DATA) \
+	$(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -131,8 +141,8 @@ am__v_lt_0 = --silent
 am__v_lt_1 = 
 libpocl_devices_tce_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
-	$(AM_CXXFLAGS) $(CXXFLAGS) $(libpocl_devices_tce_la_LDFLAGS) \
-	$(LDFLAGS) -o $@
+	$(libpocl_devices_tce_la_CXXFLAGS) $(CXXFLAGS) \
+	$(libpocl_devices_tce_la_LDFLAGS) $(LDFLAGS) -o $@
 AM_V_P = $(am__v_P_ at AM_V@)
 am__v_P_ = $(am__v_P_ at AM_DEFAULT_V@)
 am__v_P_0 = false
@@ -257,6 +267,7 @@ am__define_uniq_tagged_files = \
 ETAGS = etags
 CTAGS = ctags
 DIST_SUBDIRS = $(SUBDIRS)
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 am__relativize = \
   dir0=`pwd`; \
@@ -333,6 +344,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -369,6 +383,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -492,6 +507,7 @@ libpocl_devices_tce_la_CPPFLAGS = `@TCE_CONFIG@ --includes` -I$(top_srcdir)/fix-
 -I$(top_srcdir)/lib/CL/devices -I$(top_srcdir)/lib/CL/devices/tce \
 -I$(top_srcdir)/lib/CL $(OCL_ICD_CFLAGS)
 
+libpocl_devices_tce_la_CXXFLAGS = `@TCE_CONFIG@ --cxxflags`
 dist_pkgdata_DATA = tta_device_main.c
 EXTRA_DIST = CMakeLists.txt
 all: all-recursive
@@ -510,7 +526,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/CL/devices/tce/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign lib/CL/devices/tce/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -573,11 +588,11 @@ distclean-compile:
 @am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
 
 libpocl_devices_tce_la-tce_common.lo: tce_common.cc
- at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpocl_devices_tce_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libpocl_devices_tce_la-tce_common.lo -MD -MP -MF $(DEPDIR)/libpocl_devices_tce_la-tce_common.Tpo -c -o libpocl_devices_tce_la-tce_common.lo `test -f 'tce_common.cc' || echo '$(srcdir)/'`tce_common.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpocl_devices_tce_la_CPPFLAGS) $(CPPFLAGS) $(libpocl_devices_tce_la_CXXFLAGS) $(CXXFLAGS) -MT libpocl_devices_tce_la-tce_common.lo -MD -MP -MF $(DEPDIR)/libpocl_devices_tce_la-tce_common.Tpo -c -o libpocl_devices_tce_la-tce_common.lo `test -f 'tce_common.cc' || echo '$(srcdir)/'`tce_common.cc
 @am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libpocl_devices_tce_la-tce_common.Tpo $(DEPDIR)/libpocl_devices_tce_la-tce_common.Plo
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='tce_common.cc' object='libpocl_devices_tce_la-tce_common.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpocl_devices_tce_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libpocl_devices_tce_la-tce_common.lo `test -f 'tce_common.cc' || echo '$(srcdir)/'`tce_common.cc
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpocl_devices_tce_la_CPPFLAGS) $(CPPFLAGS) $(libpocl_devices_tce_la_CXXFLAGS) $(CXXFLAGS) -c -o libpocl_devices_tce_la-tce_common.lo `test -f 'tce_common.cc' || echo '$(srcdir)/'`tce_common.cc
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -887,6 +902,8 @@ uninstall-am: uninstall-dist_pkgdataDATA
 	pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \
 	uninstall-dist_pkgdataDATA
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/lib/CL/devices/tce/tce_common.cc b/lib/CL/devices/tce/tce_common.cc
index f4a8d60..a15d8f6 100644
--- a/lib/CL/devices/tce/tce_common.cc
+++ b/lib/CL/devices/tce/tce_common.cc
@@ -49,11 +49,14 @@
 #include <DataLabel.hh>
 #include <AddressSpace.hh>
 #include <GlobalScope.hh>
+#include <Environment.hh>
+
+#include "pocl_cache.h"
 
 using namespace TTAMachine;
 
 #define COMMAND_LENGTH 256
-#define WORKGROUP_STRING_LENGTH 128
+#define WORKGROUP_STRING_LENGTH 1024
 #define max(a,b) (((a) > (b)) ? (a) : (b))
 
 #define ALIGNMENT (max(ALIGNOF_FLOAT16, ALIGNOF_DOUBLE16))
@@ -411,7 +414,7 @@ pocl_tce_run
     if (access (assemblyFileName.c_str(), F_OK) != 0)
       {
         error = snprintf (bytecode, POCL_FILENAME_LENGTH,
-                          "%s/%s", cmd->command.run.tmp_dir, POCL_PARALLEL_BC_FILENAME);
+                          "%s%s", cmd->command.run.tmp_dir, POCL_PARALLEL_BC_FILENAME);
         TCEString buildCmd = 
           d->tceccCommandLine(&cmd->command.run, bytecode, assemblyFileName);
         
@@ -610,25 +613,31 @@ pocl_tce_map_mem (void *data, void *buf_ptr,
 }
 
 char* 
-pocl_tce_init_build(void *data, const char *dev_tmpdir) 
+pocl_tce_init_build(void *data)
 {
   TCEDevice *tce_dev = (TCEDevice*)data;
+  TCEString mach_tmpdir =
+      Environment::llvmtceCachePath();
+
+  TCEString mach_header_base =
+      mach_tmpdir + "/" + tce_dev->machine_->hash();
 
   int error = 0;
+
+  std::string devextHeaderFn =
+    std::string(mach_header_base) + std::string("_opencl_devext.h");
+
   /* Generate the vendor extensions header to provide explicit
      access to the (custom) hardware operations. */
-  std::string tceopgenCmd = 
-    std::string("tceopgen > ") + std::string(dev_tmpdir) + "/tceops.h";
-  
+  std::string tceopgenCmd =
+      std::string("tceopgen > ") + devextHeaderFn;
+
   error = system (tceopgenCmd.c_str());
   if (error == -1) return NULL;
 
-  std::string devextHeaderFn =
-    std::string(dev_tmpdir) + std::string("/_devext.h");
-
   std::string extgenCmd = 
     std::string("tceoclextgen ") + tce_dev->machine_file + 
-    std::string(" > ") + devextHeaderFn;
+      std::string(" >> ") + devextHeaderFn;
 
   error = system (extgenCmd.c_str());
   if (error == -1) return NULL;
diff --git a/lib/CL/devices/tce/ttasim/Makefile.am b/lib/CL/devices/tce/ttasim/Makefile.am
index c01462d..8127d8b 100644
--- a/lib/CL/devices/tce/ttasim/Makefile.am
+++ b/lib/CL/devices/tce/ttasim/Makefile.am
@@ -30,6 +30,10 @@ libpocl_devices_tce_ttasim_ladir = ${datadir}
 libpocl_devices_tce_ttasim_la_CPPFLAGS = `@TCE_CONFIG@ --includes` -I$(top_srcdir)/include \
 -I$(top_srcdir)/lib/CL/devices -I$(top_srcdir)/lib/CL/devices/tce \
 -I$(top_srcdir)/lib/CL $(OCL_ICD_CFLAGS)
+
+
+libpocl_devices_tce_ttasim_la_CXXFLAGS = `@TCE_CONFIG@ --cxxflags`
+
 libpocl_devices_tce_ttasim_la_LDFLAGS = -lltdl @PTHREAD_CFLAGS@ --version-info ${LIB_VERSION}
 
 EXTRA_DIST = CMakeLists.txt
diff --git a/lib/CL/devices/tce/ttasim/Makefile.in b/lib/CL/devices/tce/ttasim/Makefile.in
index e9229f2..71041c7 100644
--- a/lib/CL/devices/tce/ttasim/Makefile.in
+++ b/lib/CL/devices/tce/ttasim/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -104,8 +114,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = lib/CL/devices/tce/ttasim
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -114,6 +122,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -130,7 +139,7 @@ am__v_lt_0 = --silent
 am__v_lt_1 = 
 libpocl_devices_tce_ttasim_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
-	$(AM_CXXFLAGS) $(CXXFLAGS) \
+	$(libpocl_devices_tce_ttasim_la_CXXFLAGS) $(CXXFLAGS) \
 	$(libpocl_devices_tce_ttasim_la_LDFLAGS) $(LDFLAGS) -o $@
 AM_V_P = $(am__v_P_ at AM_V@)
 am__v_P_ = $(am__v_P_ at AM_DEFAULT_V@)
@@ -210,6 +219,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -261,6 +271,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -297,6 +310,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -418,6 +432,7 @@ libpocl_devices_tce_ttasim_la_CPPFLAGS = `@TCE_CONFIG@ --includes` -I$(top_srcdi
 -I$(top_srcdir)/lib/CL/devices -I$(top_srcdir)/lib/CL/devices/tce \
 -I$(top_srcdir)/lib/CL $(OCL_ICD_CFLAGS)
 
+libpocl_devices_tce_ttasim_la_CXXFLAGS = `@TCE_CONFIG@ --cxxflags`
 libpocl_devices_tce_ttasim_la_LDFLAGS = -lltdl @PTHREAD_CFLAGS@ --version-info ${LIB_VERSION}
 EXTRA_DIST = CMakeLists.txt
 all: all-am
@@ -436,7 +451,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/CL/devices/tce/ttasim/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign lib/CL/devices/tce/ttasim/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -499,11 +513,11 @@ distclean-compile:
 @am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
 
 libpocl_devices_tce_ttasim_la-ttasim.lo: ttasim.cc
- at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpocl_devices_tce_ttasim_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libpocl_devices_tce_ttasim_la-ttasim.lo -MD -MP -MF $(DEPDIR)/libpocl_devices_tce_ttasim_la-ttasim.Tpo -c -o libpocl_devices_tce_ttasim_la-ttasim.lo `test -f 'ttasim.cc' || echo '$(srcdir)/'`ttasim.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpocl_devices_tce_ttasim_la_CPPFLAGS) $(CPPFLAGS) $(libpocl_devices_tce_ttasim_la_CXXFLAGS) $(CXXFLAGS) -MT libpocl_devices_tce_ttasim_la-ttasim.lo -MD -MP -MF $(DEPDIR)/libpocl_devices_tce_ttasim_la-ttasim.Tpo -c -o libpocl_devices_tce_ttasim_la-ttasim.lo `test -f 'ttasim.cc' || echo '$(srcdir)/'`ttasim.cc
 @am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libpocl_devices_tce_ttasim_la-ttasim.Tpo $(DEPDIR)/libpocl_devices_tce_ttasim_la-ttasim.Plo
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='ttasim.cc' object='libpocl_devices_tce_ttasim_la-ttasim.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpocl_devices_tce_ttasim_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libpocl_devices_tce_ttasim_la-ttasim.lo `test -f 'ttasim.cc' || echo '$(srcdir)/'`ttasim.cc
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpocl_devices_tce_ttasim_la_CPPFLAGS) $(CPPFLAGS) $(libpocl_devices_tce_ttasim_la_CXXFLAGS) $(CXXFLAGS) -c -o libpocl_devices_tce_ttasim_la-ttasim.lo `test -f 'ttasim.cc' || echo '$(srcdir)/'`ttasim.cc
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -714,6 +728,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/lib/CL/devices/tce/ttasim/ttasim.cc b/lib/CL/devices/tce/ttasim/ttasim.cc
index 14dfc9b..79b7602 100644
--- a/lib/CL/devices/tce/ttasim/ttasim.cc
+++ b/lib/CL/devices/tce/ttasim/ttasim.cc
@@ -66,8 +66,6 @@
 
 using namespace TTAMachine;
 
-size_t pocl_ttasim_max_work_item_sizes[] = {CL_INT_MAX, CL_INT_MAX, CL_INT_MAX};
-
 static void *pocl_ttasim_thread (void *p);
 
 void
@@ -102,10 +100,8 @@ pocl_ttasim_init_device_infos(struct _cl_device_id* dev)
   dev->type = CL_DEVICE_TYPE_GPU;
   dev->max_compute_units = 1;
   dev->max_work_item_dimensions = 3;
-  dev->max_work_item_sizes[0] = CL_INT_MAX;
-  dev->max_work_item_sizes[1] = CL_INT_MAX;
-  dev->max_work_item_sizes[2] = CL_INT_MAX;
-  dev->max_work_group_size = 8192;
+  dev->max_work_item_sizes[0] = dev->max_work_item_sizes[1] =
+	  dev->max_work_item_sizes[2] = dev->max_work_group_size = 8192;
   dev->preferred_wg_size_multiple = 8;
   dev->preferred_vector_width_char = POCL_DEVICES_PREFERRED_VECTOR_WIDTH_CHAR;
   dev->preferred_vector_width_short = POCL_DEVICES_PREFERRED_VECTOR_WIDTH_SHORT;
@@ -133,6 +129,7 @@ pocl_ttasim_init_device_infos(struct _cl_device_id* dev)
   dev->endian_little = CL_FALSE;
   dev->available = CL_TRUE;
   dev->compiler_available = CL_TRUE;
+  dev->spmd = CL_FALSE;
   dev->execution_capabilities = CL_EXEC_KERNEL;
   dev->queue_properties = CL_QUEUE_PROFILING_ENABLE;
   dev->vendor = "TTA-Based Co-design Environment";
@@ -140,6 +137,16 @@ pocl_ttasim_init_device_infos(struct _cl_device_id* dev)
   dev->extensions = "";
   dev->llvm_target_triplet = "tce-tut-llvm";
   dev->has_64bit_long = 1;
+
+  dev->parent_device = NULL;
+  // ttasim does not support partitioning
+  dev->max_sub_devices = 1;
+  dev->num_partition_properties = 1;
+  dev->partition_properties = (cl_device_partition_property*)calloc(dev->num_partition_properties,
+    sizeof(cl_device_partition_property));
+  dev->num_partition_types = 0;
+  dev->partition_type = NULL;
+
 }
 
 unsigned int
@@ -269,7 +276,7 @@ public:
        the original one. */
 
     /* Create the global buffers along with their initialization data. */
-    for (int i = 0; i < run_cmd->kernel->num_args; ++i)
+    for (size_t i = 0; i < run_cmd->kernel->num_args; ++i)
       {
         struct pocl_argument *al = &(run_cmd->arguments[i]);
         if (run_cmd->kernel->arg_info[i].type == POCL_ARG_TYPE_POINTER)
@@ -344,7 +351,7 @@ public:
     out << "void initialize_kernel_launch() {" << std::endl;
 
     out << "\tkernel_command.kernel = (uint32_t)&" << kernelMdSymbolName << ";" << std::endl;
-    int a = 0;
+    size_t a = 0;
     for (; a < run_cmd->kernel->num_args + run_cmd->kernel->num_locals; ++a)
       {
         struct pocl_argument *al = &(run_cmd->arguments[a]);
diff --git a/lib/CL/devices/topology/Makefile.in b/lib/CL/devices/topology/Makefile.in
index ee5e59f..988418b 100644
--- a/lib/CL/devices/topology/Makefile.in
+++ b/lib/CL/devices/topology/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -15,7 +15,17 @@
 @SET_MAKE@
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -80,8 +90,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = lib/CL/devices/topology
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -90,6 +98,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -169,6 +178,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -220,6 +230,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -256,6 +269,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -392,7 +406,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/CL/devices/topology/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign lib/CL/devices/topology/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -670,6 +683,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/lib/CL/devices/topology/pocl_topology.c b/lib/CL/devices/topology/pocl_topology.c
index 1d58426..716b1fb 100644
--- a/lib/CL/devices/topology/pocl_topology.c
+++ b/lib/CL/devices/topology/pocl_topology.c
@@ -1,6 +1,6 @@
 /* pocl_topology.c - retrieving the topology of OpenCL devices
 
-   Copyright (c) 2012 Cyril Roelandt and Pekka Jääskeläinen
+   Copyright (c) 2012,2015 Cyril Roelandt and Pekka Jääskeläinen
    
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
@@ -23,6 +23,7 @@
 
 #include <pocl_cl.h>
 #include <hwloc.h>
+#include <stdlib.h>
 
 #include "pocl_topology.h"
 
@@ -31,27 +32,73 @@ pocl_topology_detect_device_info(cl_device_id device)
 {
   hwloc_topology_t pocl_topology;
 
+  /*
+   * hwloc's OpenCL backend causes problems at the initialization stage
+   * because it reloads libpocl.so via the ICD loader.
+   *
+   * See: https://github.com/pocl/pocl/issues/261
+   *
+   * The only trick to stop hwloc from initializing the OpenCL plugin
+   * I could find is to point the plugin search path to a place where there
+   * are no plugins to be found.
+   */
+  setenv ("HWLOC_PLUGINS_PATH", "/dev/null", 1);
+
   int ret = hwloc_topology_init(&pocl_topology);
   if (ret == -1)
     POCL_ABORT("Cannot initialize the topology.\n");
+
+  hwloc_topology_set_flags(pocl_topology, HWLOC_TOPOLOGY_FLAG_WHOLE_IO);
+
   ret = hwloc_topology_load(pocl_topology);
   if (ret == -1)
     POCL_ABORT("Cannot load the topology.\n");
 
-  device->global_mem_size = hwloc_get_root_obj(pocl_topology)->memory.total_memory;
-
-  if (device->global_mem_size/4 > MIN_MAX_MEM_ALLOC_SIZE)
-    device->max_mem_alloc_size = device->global_mem_size/4;
-  else
-    device->max_mem_alloc_size = MIN_MAX_MEM_ALLOC_SIZE;
-
-  device->local_mem_size = device->max_constant_buffer_size = device->max_mem_alloc_size;
+  device->global_mem_size =
+      hwloc_get_root_obj(pocl_topology)->memory.total_memory;
 
   // Try to get the number of CPU cores from topology
   int depth = hwloc_get_type_depth(pocl_topology, HWLOC_OBJ_PU);
   if(depth != HWLOC_TYPE_DEPTH_UNKNOWN)
     device->max_compute_units = hwloc_get_nbobjs_by_depth(pocl_topology, depth);
 
+  // A vendor ID for a CPU is not well-defined, so we just use the
+  // PCI vendor ID of a bridge, on the (debatable) assumption that it matches
+  // the CPU vendor (e.g. AMD bridges for AMD CPUs vs Intel bridges for Intel
+  // CPUs). TODO FIXME This is not always true, but we don't have a better
+  // logic for the time
+  do {
+    hwloc_obj_t bridge = NULL;
+    while ((bridge = hwloc_get_next_bridge(pocl_topology, bridge))) {
+      union hwloc_obj_attr_u *attr = bridge->attr;
+      unsigned int vid;
+      if (!attr)
+	continue;
+      vid = attr->bridge.upstream.pci.vendor_id;
+      if (vid) {
+	device->vendor_id = vid;
+	break;
+      }
+    }
+  } while (0);
+
+  /* Find information about global memory cache by looking at the first
+   * cache covering the first PU */
+  do {
+    hwloc_obj_t pu = hwloc_get_next_obj_by_type(pocl_topology, HWLOC_OBJ_PU, NULL);
+    if (!pu)
+      break;
+    hwloc_obj_t cache = hwloc_get_cache_covering_cpuset(pocl_topology, pu->cpuset);
+    if (!cache)
+      break;
+    union hwloc_obj_attr_u *attr = cache->attr;
+    if (!attr)
+      break;
+    device->global_mem_cache_type = 0x2; // CL_READ_WRITE_CACHE, without including all of CL/cl.h
+    device->global_mem_cacheline_size = attr->cache.linesize;
+    device->global_mem_cache_size = attr->cache.size;
+  } while (0);
+
   // Destroy topology object and return
   hwloc_topology_destroy(pocl_topology);
 
diff --git a/lib/CL/devices/topology/pocl_topology.h b/lib/CL/devices/topology/pocl_topology.h
index 4f0a95b..2d04866 100644
--- a/lib/CL/devices/topology/pocl_topology.h
+++ b/lib/CL/devices/topology/pocl_topology.h
@@ -33,10 +33,14 @@
 
 #include "pocl_cl.h"
 
-#define MIN_MAX_MEM_ALLOC_SIZE (128*1024*1024)
-
+#ifdef __GNUC__
 #pragma GCC visibility push(hidden)
+#endif
+
 void pocl_topology_detect_device_info(cl_device_id device);
+
+#ifdef __GNUC__
 #pragma GCC visibility pop
+#endif
 
 #endif /* POCL_TOPOLOGY_H */
diff --git a/lib/CL/pocl_cache.c b/lib/CL/pocl_cache.c
new file mode 100644
index 0000000..be485c2
--- /dev/null
+++ b/lib/CL/pocl_cache.c
@@ -0,0 +1,580 @@
+/* OpenCL runtime library: caching functions
+
+   Copyright (c) 2015 pocl developers
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+*/
+
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "config.h"
+#ifdef POCL_BUILT_WITH_CMAKE
+#include "pocl_build_timestamp.h"
+#endif
+#include "kernellib_hash.h"
+
+#include "pocl_hash.h"
+#include "pocl_cache.h"
+#include "pocl_file_util.h"
+#include "pocl_llvm.h"
+
+#include "pocl_cl.h"
+#include "pocl_runtime_config.h"
+
+#define POCL_LAST_ACCESSED_FILENAME "/last_accessed"
+/* The filename in which the program's build log is stored */
+#define POCL_BUILDLOG_FILENAME      "/build.log"
+/* The filename in which the program source is stored in the program's temp dir. */
+#define POCL_PROGRAM_CL_FILENAME "/program.cl"
+/* The filename in which the program LLVM bc is stored in the program's temp dir. */
+#define POCL_PROGRAM_BC_FILENAME "/program.bc"
+
+static char cache_topdir[POCL_FILENAME_LENGTH];
+static int cache_topdir_initialized = 0;
+
+int pocl_cl_device_to_index(cl_program   program,
+                            cl_device_id device) {
+    unsigned i;
+    assert(program);
+    for (i = 0; i < program->num_devices; i++)
+        if (program->devices[i] == device ||
+            program->devices[i] == device->parent_device)
+            return i;
+    return -1;
+}
+
+static void program_device_dir(char*        path,
+                              cl_program   program,
+                              unsigned     device_i,
+                              char*        append_path) {
+    assert(path);
+    assert(program);
+    assert(device_i < program->num_devices);
+    /* sanity check on SHA1 digest emptiness */
+    assert(program->build_hash[device_i][0] > 0);
+
+    int bytes_written = snprintf(path, POCL_FILENAME_LENGTH,
+                                 "%s/%s%s", cache_topdir,
+                                 program->build_hash[device_i],
+                                 append_path);
+    assert(bytes_written > 0 && bytes_written < POCL_FILENAME_LENGTH);
+}
+
+
+// required in llvm API
+void pocl_cache_program_bc_path(char*        program_bc_path,
+                                cl_program   program,
+                                unsigned     device_i) {
+    program_device_dir(program_bc_path, program,
+                       device_i, POCL_PROGRAM_BC_FILENAME);
+}
+
+static void pocl_cache_kernel_cachedir_path(char* kernel_cachedir_path, cl_program   program,
+                                 unsigned device_i, cl_kernel kernel, char* append_str,
+                                 size_t local_x, size_t local_y, size_t local_z)
+{
+  int bytes_written;
+  char tempstring[POCL_FILENAME_LENGTH];
+
+  if (program->devices[device_i]->spmd)
+    {
+      bytes_written = snprintf(tempstring, POCL_FILENAME_LENGTH,
+                               "/%s/SPMD%s", kernel->name, append_str);
+    }
+  else
+    {
+      bytes_written = snprintf(tempstring, POCL_FILENAME_LENGTH,
+                               "/%s/%zu-%zu-%zu%s", kernel->name,
+                               local_x, local_y, local_z, append_str);
+    }
+
+  assert(bytes_written > 0 && bytes_written < POCL_FILENAME_LENGTH);
+
+  program_device_dir(kernel_cachedir_path, program, device_i, tempstring);
+
+}
+
+
+
+// required in llvm API
+void pocl_cache_work_group_function_path(char* parallel_bc_path, cl_program program,
+                               unsigned device_i, cl_kernel kernel,
+                               size_t local_x, size_t local_y,
+                               size_t local_z) {
+    assert(kernel->name);
+
+    pocl_cache_kernel_cachedir_path(parallel_bc_path, program,
+                         device_i, kernel, POCL_PARALLEL_BC_FILENAME,
+                         local_x, local_y, local_z);
+}
+
+void pocl_cache_final_binary_path(char* final_binary_path, cl_program program,
+                               unsigned device_i, cl_kernel kernel,
+                               size_t local_x, size_t local_y,
+                               size_t local_z) {
+    assert(kernel->name);
+
+
+    /* TODO this should be probably refactored to either
+     * get the binary name from the device itself, or
+     * let the device ops call pocl_llvm_generate_workgroup_function() on their own */
+
+    int bytes_written;
+    char final_binary_name[POCL_FILENAME_LENGTH];
+
+    if (program->devices[device_i]->spmd)
+        bytes_written = snprintf(final_binary_name, POCL_FILENAME_LENGTH,
+                                 "%s.brig", POCL_PARALLEL_BC_FILENAME);
+    else
+        bytes_written = snprintf(final_binary_name, POCL_FILENAME_LENGTH,
+                                 "/%s.so", kernel->name);
+
+    assert(bytes_written > 0 && bytes_written < POCL_FILENAME_LENGTH);
+
+    pocl_cache_kernel_cachedir_path(final_binary_path, program,
+                         device_i, kernel, final_binary_name,
+                         local_x, local_y, local_z);
+}
+
+/******************************************************************************/
+
+static void* acquire_program_lock(cl_program program,
+                                  unsigned device_i,
+                                  int shared) {
+    char lock_path[POCL_FILENAME_LENGTH];
+    program_device_dir(lock_path, program, device_i, "_rw");
+
+    return acquire_lock(lock_path, shared);
+}
+
+void* pocl_cache_acquire_writer_lock_i(cl_program program,
+                                       unsigned device_i) {
+    return acquire_program_lock(program, device_i, 0);
+}
+
+void pocl_cache_release_lock(void* lock) {
+    return release_lock(lock);
+}
+
+void* pocl_cache_acquire_writer_lock(cl_program program,
+                                     cl_device_id device) {
+    int index = pocl_cl_device_to_index(program, device);
+    assert(index >= 0);
+    return pocl_cache_acquire_writer_lock_i(program, (unsigned)index);
+}
+
+
+/******************************************************************************/
+
+void pocl_cache_mk_temp_name(char* path) {
+    assert(cache_topdir_initialized);
+#if defined(_MSC_VER) || defined(__MINGW32__)
+    char* tmp = _tempnam(cache_topdir, "pocl_");
+    assert(tmp);
+    int bytes_written = snprintf(path, POCL_FILENAME_LENGTH, "%s", tmp);
+    free(tmp);
+    assert(bytes_written > 0 && bytes_written < POCL_FILENAME_LENGTH);
+#else
+    int bytes_written = snprintf(path, POCL_FILENAME_LENGTH,
+             "%s/temp_XXXXXX.cl", cache_topdir);
+    assert(bytes_written > 0 && bytes_written < POCL_FILENAME_LENGTH);
+    /* using mkstemp() instead of tmpnam() has no real benefit
+     * here, as we have to pass the filename to llvm,
+     * but tmpnam() generates an annoying warning... */
+    int fd = mkstemps(path, 3);
+    assert(fd >= 0);
+    close(fd);
+#endif
+}
+
+int pocl_cache_write_program_source(char *program_cl_path,
+                                    cl_program program) {
+    pocl_cache_mk_temp_name(program_cl_path);
+    return pocl_write_file(program_cl_path, program->source,
+                           strlen(program->source), 0, 0);
+}
+
+/******************************************************************************/
+
+int pocl_cache_update_program_last_access(cl_program program,
+                                          unsigned device_i) {
+    char last_accessed_path[POCL_FILENAME_LENGTH];
+    program_device_dir(last_accessed_path, program,
+                       device_i, POCL_LAST_ACCESSED_FILENAME);
+
+    return pocl_touch_file(last_accessed_path);
+}
+
+/******************************************************************************/
+
+int pocl_cache_device_cachedir_exists(cl_program   program,
+                                      unsigned device_i) {
+    char device_cachedir_path[POCL_FILENAME_LENGTH];
+    program_device_dir(device_cachedir_path, program, device_i, "");
+
+    return pocl_exists(device_cachedir_path);
+}
+
+/******************************************************************************/
+
+int pocl_cache_write_descriptor(cl_program   program,
+                                unsigned     device_i,
+                                const char*  kernel_name,
+                                const char*  content,
+                                size_t       size) {
+    char devdir[POCL_FILENAME_LENGTH];
+    program_device_dir(devdir, program, device_i, "");
+
+    char descriptor[POCL_FILENAME_LENGTH];
+    int bytes_written = snprintf(descriptor, POCL_FILENAME_LENGTH,
+                                 "%s/%s", devdir, kernel_name);
+    assert(bytes_written > 0 && bytes_written < POCL_FILENAME_LENGTH);
+    if (pocl_mkdir_p(descriptor))
+        return 1;
+
+    bytes_written = snprintf(descriptor, POCL_FILENAME_LENGTH,
+                                 "%s/%s/descriptor.so.kernel_obj.c",
+                                 devdir, kernel_name);
+    assert(bytes_written > 0 && bytes_written < POCL_FILENAME_LENGTH);
+
+    return pocl_write_file(descriptor, content, size, 0, 1);
+}
+
+/******************************************************************************/
+
+
+char* pocl_cache_read_buildlog(cl_program program,
+                               unsigned device_i) {
+    char buildlog_path[POCL_FILENAME_LENGTH];
+    if (program->build_hash[device_i][0] == 0)
+        return NULL;
+    program_device_dir(buildlog_path, program,
+                       device_i, POCL_BUILDLOG_FILENAME);
+
+    if (!pocl_exists(buildlog_path))
+      return strdup("");
+
+    char* res=NULL;
+    uint64_t filesize;
+    if (pocl_read_file(buildlog_path, &res, &filesize))
+        return NULL;
+    return res;
+}
+
+
+int pocl_cache_append_to_buildlog(cl_program  program,
+                                  unsigned    device_i,
+                                  const char *content,
+                                  size_t      size) {
+    char buildlog_path[POCL_FILENAME_LENGTH];
+    program_device_dir(buildlog_path, program,
+                       device_i, POCL_BUILDLOG_FILENAME);
+
+    return pocl_write_file(buildlog_path, content, size, 1, 1);
+}
+
+/******************************************************************************/
+
+
+int pocl_cache_write_kernel_parallel_bc(void*        bc,
+                                        cl_program   program,
+                                        unsigned     device_i,
+                                        cl_kernel    kernel,
+                                        size_t       local_x,
+                                        size_t       local_y,
+                                        size_t       local_z) {
+    assert(bc);
+
+    char kernel_parallel_path[POCL_FILENAME_LENGTH];
+    pocl_cache_kernel_cachedir_path(kernel_parallel_path, program, device_i,
+                                    kernel, "", local_x, local_y, local_z);
+    int err = pocl_mkdir_p(kernel_parallel_path);
+    if (err)
+      return err;
+
+    assert( strlen(kernel_parallel_path) <
+            (POCL_FILENAME_LENGTH - strlen(POCL_PARALLEL_BC_FILENAME)));
+    strcat(kernel_parallel_path, POCL_PARALLEL_BC_FILENAME);
+    return pocl_write_module(bc, kernel_parallel_path, 0);
+}
+
+int pocl_cache_make_kernel_cachedir_path(char*        kernel_cachedir_path,
+                                         cl_program   program,
+                                         cl_device_id device,
+                                         cl_kernel    kernel,
+                                         size_t       local_x,
+                                         size_t       local_y,
+                                         size_t       local_z) {
+    int index = pocl_cl_device_to_index(program, device);
+    assert(index >= 0);
+
+    pocl_cache_kernel_cachedir_path(kernel_cachedir_path, program, index,
+                                     kernel, "", local_x, local_y, local_z);
+
+    return pocl_mkdir_p(kernel_cachedir_path);
+}
+
+
+/******************************************************************************/
+
+
+
+
+
+
+
+static inline void
+build_program_compute_hash(cl_program program,
+                           unsigned   device_i,
+                           const char*      preprocessed_source,
+                           size_t     source_len)
+{
+    SHA1_CTX hash_ctx;
+    unsigned i;
+    cl_device_id device = program->devices[device_i];
+
+    pocl_SHA1_Init(&hash_ctx);
+
+    if (program->source) {
+        assert(preprocessed_source);
+        assert(source_len > 0);
+        pocl_SHA1_Update(&hash_ctx, (uint8_t*)preprocessed_source,
+                         source_len);
+    } else     { /* Program was created with clCreateProgramWithBinary() */
+        assert(program->binaries[device_i]);
+        pocl_SHA1_Update(&hash_ctx,
+                         (uint8_t*) program->binaries[device_i],
+                         program->binary_sizes[device_i]);
+    }
+
+    if (program->compiler_options)
+        pocl_SHA1_Update(&hash_ctx, (uint8_t*) program->compiler_options,
+                         strlen(program->compiler_options));
+
+    /* The kernel compiler work-group function method affects the
+       produced binary heavily. */
+    const char *wg_method=
+        pocl_get_string_option("POCL_WORK_GROUP_METHOD", "");
+
+    pocl_SHA1_Update(&hash_ctx, (uint8_t*) wg_method, strlen(wg_method));
+    pocl_SHA1_Update(&hash_ctx, (uint8_t*) PACKAGE_VERSION,
+                     strlen(PACKAGE_VERSION));
+    pocl_SHA1_Update(&hash_ctx, (uint8_t*) LLVM_VERSION,
+                     strlen(LLVM_VERSION));
+    pocl_SHA1_Update(&hash_ctx, (uint8_t*) POCL_BUILD_TIMESTAMP,
+                     strlen(POCL_BUILD_TIMESTAMP));
+    pocl_SHA1_Update(&hash_ctx, (const uint8_t *)POCL_KERNELLIB_SHA1,
+                     strlen(POCL_KERNELLIB_SHA1));
+    /*devices may include their own information to hash */
+    if (device->ops->build_hash)
+        device->ops->build_hash(device->data, &hash_ctx);
+
+
+    uint8_t digest[SHA1_DIGEST_SIZE];
+    pocl_SHA1_Final(&hash_ctx, digest);
+
+    unsigned char* hashstr = program->build_hash[device_i];
+    for (i=0; i < SHA1_DIGEST_SIZE; i++)
+        {
+            *hashstr++ = (digest[i] & 0x0F) + 65;
+            *hashstr++ = ((digest[i] & 0xF0) >> 4) + 65;
+        }
+    *hashstr = 0;
+
+    program->build_hash[device_i][2] = '/';
+
+}
+
+#ifdef ANDROID
+static
+char* pocl_get_process_name()
+{
+    char tmpStr[64], cmdline[512], *processName=NULL;
+    FILE *statusFile;
+    size_t len, i, begin;
+
+    snprintf(tmpStr, 64, "/proc/%d/cmdline", getpid());
+    statusFile=fopen(tmpStr, "r");
+    if (statusFile == NULL)
+        return NULL;
+
+    if (fgets(cmdline, 511, statusFile) != NULL) {
+        len=strlen(cmdline);
+        begin=0;
+        for (i=len-1; i >= 0; i--) { /* Extract program-name after last '/' */
+            if (cmdline[i] == '/') {
+                begin=i + 1;
+                break;
+            }
+        }
+        processName=strdup(cmdline + begin);
+    }
+
+    fclose(statusFile);
+    return processName;
+}
+#endif
+
+
+/******************************************************************************/
+
+void pocl_cache_init_topdir() {
+
+    if (cache_topdir_initialized)
+        return;
+
+    const char *tmp_path = pocl_get_string_option("POCL_CACHE_DIR", NULL);
+    int needed;
+
+    if (tmp_path && (pocl_exists(tmp_path))) {
+        needed = snprintf(cache_topdir, POCL_FILENAME_LENGTH, "%s", tmp_path);
+    } else     {
+#ifdef POCL_ANDROID
+        char* process_name = pocl_get_process_name();
+        needed = snprintf(cache_topdir, POCL_FILENAME_LENGTH,
+                          "/data/data/%s/cache/", process_name);
+        free(process_name);
+
+        if (!pocl_exists(cache_topdir))
+            needed = snprintf(cache_topdir,
+                              POCL_FILENAME_LENGTH,
+                              "/sdcard/pocl/kcache");
+#elif defined(_MSC_VER) || defined(__MINGW32__)
+        tmp_path = getenv("LOCALAPPDATA");
+        if (!tmp_path)
+            tmp_path = getenv("TEMP");
+        assert(tmp_path);
+        needed = snprintf(cache_topdir, POCL_FILENAME_LENGTH,
+                          "%s\\pocl", tmp_path);
+#else
+        // "If $XDG_CACHE_HOME is either not set or empty, a default equal to
+        // $HOME/.cache should be used."
+        // http://standards.freedesktop.org/basedir-spec/latest/
+        tmp_path = getenv("XDG_CACHE_HOME");
+
+        if (tmp_path && tmp_path[0] != '\0') {
+            needed = snprintf(cache_topdir, POCL_FILENAME_LENGTH,
+                              "%s/pocl/kcache", tmp_path);
+        }
+        else if ((tmp_path = getenv("HOME")) != NULL) {
+            needed = snprintf(cache_topdir, POCL_FILENAME_LENGTH,
+                              "%s/.cache/pocl/kcache", tmp_path);
+        }
+        else {
+            needed = snprintf(cache_topdir, POCL_FILENAME_LENGTH,
+                              "/tmp/pocl/kcache");
+        }
+#endif
+    }
+
+    if (needed >= POCL_FILENAME_LENGTH) {
+        POCL_ABORT("pocl: cache path longer than maximum filename length");
+    }
+
+    assert(strlen(cache_topdir) > 0);
+    if (pocl_mkdir_p(cache_topdir))
+        POCL_ABORT("Could not create topdir for cache");
+    cache_topdir_initialized = 1;
+
+}
+
+/* Create the new program cachedir, invalidating the old program
+ * binaries and IRs if the new computed hash is different from the old
+ * one. The source hash is computed from the preprocessed source
+ * if present, from the original source otherwise: this is to ensure
+ * that cache-related functions (which include log retrieval) still
+ * work correctly even if preprocessing fails
+ */
+
+int
+pocl_cache_create_program_cachedir(cl_program program,
+                                   unsigned device_i,
+                                   const char* preprocessed_source,
+                                   size_t source_len,
+                                   char* program_bc_path,
+                                   void** cache_lock)
+{
+    const char *hash_source = NULL;
+    uint8_t old_build_hash[SHA1_DIGEST_SIZE] = {0};
+    size_t hs_len = 0;
+
+    assert(cache_topdir_initialized);
+
+    if (program->source && preprocessed_source==NULL) {
+        hash_source = program->source;
+        hs_len = strlen(program->source);
+    } else {
+        hash_source = preprocessed_source;
+        hs_len = source_len;
+    }
+
+    if (program->build_hash[device_i])
+        memcpy(old_build_hash, program->build_hash[device_i], SHA1_DIGEST_SIZE);
+
+    build_program_compute_hash(program, device_i, hash_source, hs_len);
+
+    /* if the old hash is nonzero and different, we must free the built binaries
+       before returning, so that they get loaded from the new location */
+    if (old_build_hash[0] && memcmp(old_build_hash, program->build_hash[device_i],
+            SHA1_DIGEST_SIZE))
+    {
+        if (program->binaries[device_i]) {
+            POCL_MEM_FREE(program->binaries[device_i]);
+            program->binary_sizes[device_i] = 0;
+        }
+        pocl_free_llvm_irs(program, device_i);
+    }
+
+    program_device_dir(program_bc_path, program, device_i, "");
+
+    if (pocl_mkdir_p(program_bc_path))
+        return 1;
+
+    pocl_cache_program_bc_path(program_bc_path, program, device_i);
+
+    *cache_lock = pocl_cache_acquire_writer_lock_i(program, device_i);
+
+    return 0;
+}
+
+void pocl_cache_cleanup_cachedir(cl_program program) {
+
+    unsigned i;
+
+    if (!pocl_get_bool_option("POCL_KERNEL_CACHE", POCL_BUILD_KERNEL_CACHE)) {
+
+        for (i=0; i< program->num_devices; i++) {
+            if (program->build_hash[i][0] == 0)
+                continue;
+
+            void* lock = acquire_program_lock(program, i, 0);
+            if (!lock)
+                return;
+            char cachedir[POCL_FILENAME_LENGTH];
+            program_device_dir(cachedir, program, i, "");
+            pocl_rm_rf(cachedir);
+            release_lock(lock);
+        }
+    }
+}
+
+/******************************************************************************/
diff --git a/lib/CL/pocl_cl.h b/lib/CL/pocl_cl.h
index b729fa0..38d6754 100644
--- a/lib/CL/pocl_cl.h
+++ b/lib/CL/pocl_cl.h
@@ -43,23 +43,9 @@
 #  include "pocl_icd.h"
 #endif
 #include "pocl.h"
+#include "pocl_debug.h"
 #include "pocl_hash.h"
 
-#define POCL_FILENAME_LENGTH 1024
-
-#define POCL_BUILD "pocl-build"
-#define POCL_KERNEL "pocl-kernel"
-#define POCL_WORKGROUP "pocl-workgroup"
-
-/* The filename in which the program source is stored in the program's temp dir. */
-#define POCL_PROGRAM_CL_FILENAME "program.cl"
-/* The filename in which the program LLVM bc is stored in the program's temp dir. */
-#define POCL_PROGRAM_BC_FILENAME "program.bc"
-/* The filename in which the work group (parallelizable) kernel LLVM bc is stored in 
-   the kernel's temp dir. */
-#define POCL_PARALLEL_BC_FILENAME   "parallel.bc"
-#define POCL_BUILDLOG_FILENAME      "build.log"
-#define POCL_LAST_ACCESSED_FILENAME "last_accessed"
 
 #if __STDC_VERSION__ < 199901L
 # if __GNUC__ >= 2
@@ -75,130 +61,6 @@
 #define LINK_CMD CLANG
 #endif
 
-/* Debugging macros. Also macros for marking unimplemented parts of specs or
-   untested parts of the implementation. */
-
-#define POCL_ABORT_UNIMPLEMENTED(MSG)                                   \
-    do {                                                                \
-        fprintf(stderr,"%s is unimplemented (%s:%d)\n", MSG, __FILE__, __LINE__);  \
-        exit(2);                                                        \
-    } while (0) 
-
-#define POCL_WARN_UNTESTED()                                            \
-    do {                                                                \
-        fprintf(stderr, "pocl warning: encountered untested part of the implementation in %s:%d\n", __FILE__, __LINE__); \
-    } while (0) 
-
-#define POCL_WARN_INCOMPLETE()                                            \
-    do {                                                                \
-        fprintf(stderr, "pocl warning: encountered incomplete implementation in %s:%d\n", __FILE__, __LINE__); \
-    } while (0) 
-
-#define POCL_ABORT(__MSG__)                                      \
-    do {                                                                \
-        fprintf(stderr, __MSG__); \
-        exit(2);                                                        \
-    } while (0) 
-
-#define POCL_ERROR(x) do { if (errcode_ret != NULL) {*errcode_ret = (x); } return NULL; } while (0)
-#define POCL_SUCCESS() do { if (errcode_ret != NULL) {*errcode_ret = CL_SUCCESS; } } while (0)
-
-
-#ifdef POCL_DEBUG_MESSAGES
-
-extern int pocl_debug_messages;
-
-  #ifdef HAVE_CLOCK_GETTIME
-
-  extern struct timespec pocl_debug_timespec;
-  #define POCL_MSG_PRINT_INFO(...)                                            \
-    do {                                                                      \
-    if (pocl_debug_messages) {                                                \
-      clock_gettime(CLOCK_REALTIME, &pocl_debug_timespec);                    \
-      fprintf(stderr, "[%li.%li] POCL: in function %s"                  \
-      " at line %u:", (long)pocl_debug_timespec.tv_sec, (long)pocl_debug_timespec.tv_nsec, \
-        __func__, __LINE__);                                                  \
-      fprintf(stderr, __VA_ARGS__);                                           \
-    }                                                                         \
-  } while(0)
-
-  #define POCL_MSG_PRINT(TYPE, ERRCODE, ...)                                  \
-    do {                                                                      \
-    if (pocl_debug_messages) {                                                \
-      clock_gettime(CLOCK_REALTIME, &pocl_debug_timespec);                    \
-      fprintf(stderr, "[%li.%li] POCL: " TYPE ERRCODE " in function %s"       \
-      " at line %u: \n", (long)pocl_debug_timespec.tv_sec, (long)pocl_debug_timespec.tv_nsec, \
-        __func__, __LINE__);                                                  \
-      fprintf(stderr, __VA_ARGS__);                                           \
-    }                                                                         \
-  } while(0)
-
-  #else
-
-  #define POCL_MSG_PRINT_INFO(...)                                            \
-    do {                                                                      \
-    if (pocl_debug_messages) {                                                \
-      fprintf(stderr, "** POCL ** : in function %s"                           \
-      " at line %u:", __func__, __LINE__);                                    \
-      fprintf(stderr, __VA_ARGS__);                                           \
-    }                                                                         \
-  } while(0)
-
-  #define POCL_MSG_PRINT(TYPE, ERRCODE, ...)                                  \
-    do {                                                                      \
-    if (pocl_debug_messages) {                                                \
-      fprintf(stderr, "** POCL ** : " TYPE ERRCODE " in function %s"          \
-      " at line %u: \n",  __func__, __LINE__);                                \
-      fprintf(stderr, __VA_ARGS__);                                           \
-    }                                                                         \
-  } while(0)
-
-  #endif
-
-
-#define POCL_MSG_WARN(...) POCL_MSG_PRINT("WARNING", "", __VA_ARGS__)
-#define POCL_MSG_ERR(...) POCL_MSG_PRINT("ERROR", "", __VA_ARGS__)
-
-#else
-
-#define POCL_MSG_WARN(...)
-#define POCL_MSG_ERR(...)
-#define POCL_MSG_PRINT(...)
-#define POCL_MSG_PRINT_INFO(...)
-
-#endif
-
-
-#define POCL_GOTO_ERROR_ON(cond, err_code, ...)                             \
-  if (cond)                                                                 \
-    {                                                                       \
-      POCL_MSG_PRINT("ERROR : ", #err_code, __VA_ARGS__);                   \
-      errcode = err_code;                                                   \
-      goto ERROR;                                                           \
-    }                                                                       \
-
-#define POCL_RETURN_ERROR_ON(cond, err_code, ...)                           \
-  if (cond)                                                                 \
-    {                                                                       \
-      POCL_MSG_PRINT("ERROR : ", #err_code, __VA_ARGS__);                   \
-      return err_code;                                                      \
-    }                                                                       \
-
-#define POCL_RETURN_ERROR_COND(cond, err_code)                              \
-  if (cond)                                                                 \
-    {                                                                       \
-      POCL_MSG_PRINT("ERROR : ", #err_code, "%s\n", #cond);                 \
-      return err_code;                                                      \
-    }                                                                       \
-
-#define POCL_GOTO_ERROR_COND(cond, err_code)                                \
-  if (cond)                                                                 \
-    {                                                                       \
-      POCL_MSG_PRINT("ERROR : ", #err_code, "%s\n", #cond);                 \
-      errcode = err_code;                                                   \
-      goto ERROR;                                                           \
-    }                                                                       \
-
 typedef pthread_mutex_t pocl_lock_t;
 #define POCL_LOCK_INITIALIZER PTHREAD_MUTEX_INITIALIZER
 
@@ -346,7 +208,7 @@ struct pocl_argument_info {
 };
 
 struct pocl_device_ops {
-  char *device_name;
+  const char *device_name;
   void (*init_device_infos) (struct _cl_device_id*);
   /* implementation */
   void (*uninit) (cl_device_id device);
@@ -410,16 +272,14 @@ void (*fill_rect) (void *data,
   /* Perform initialization steps and can return additional
      build options that are required for the device. The caller
      owns the returned string. */
-  char* (*init_build) 
-  (void *data, 
-   const char *dev_tmpdir);
+  char* (*init_build) (void *data);
 
   void (*build_hash) (void *data, SHA1_CTX *build_hash);
 
     /* return supported image formats */
   cl_int (*get_supported_image_formats) (cl_mem_flags flags,
                                          const cl_image_format **image_formats,
-                                         cl_int *num_image_formats);
+                                         cl_uint *num_image_formats);
 };
 
 struct _cl_device_id {
@@ -481,21 +341,29 @@ struct _cl_device_id {
   cl_bool endian_little;
   cl_bool available;
   cl_bool compiler_available;
+  /* Is the target a Single Program Multiple Data machine? If not,
+     we need to generate work-item loops to execute all the work-items
+     in the WG, otherwise the hardware spawns the WIs. */
+  cl_bool spmd;
   cl_device_exec_capabilities execution_capabilities;
   cl_command_queue_properties queue_properties;
   cl_platform_id platform;
-  cl_device_partition_property device_partition_properties[1];
+  cl_uint max_sub_devices;
+  size_t num_partition_properties;
+  cl_device_partition_property *partition_properties;
+  size_t num_partition_types;
+  cl_device_partition_property *partition_type;
   size_t printf_buffer_size;
   char *short_name;
   char *long_name;
   char *cache_dir_name;
   cl_device_id parent_device;
 
-  char *vendor;
-  char *driver_version;
-  char *profile;
-  char *version;
-  char *extensions;
+  const char *vendor;
+  const char *driver_version;
+  const char *profile;
+  const char *version;
+  const char *extensions;
  
   void *data;
   const char* llvm_target_triplet; /* the llvm target triplet to use */
@@ -505,6 +373,8 @@ struct _cl_device_id {
   int dev_id;
   int global_mem_id; /* identifier for device global memory */
   int has_64bit_long;  /* Does the device have 64bit longs */
+  /* Convert automatic local variables to kernel arguments? */
+  int autolocals_to_args;
 
   struct pocl_device_ops *ops; /* Device operations, shared amongst same devices */
 };
@@ -591,6 +461,8 @@ struct _cl_mem {
   cl_mem                  buffer;
 };
 
+typedef uint8_t SHA1_digest_t[SHA1_DIGEST_SIZE * 2 + 1];
+
 struct _cl_program {
   POCL_ICD_OBJECT
   POCL_OBJECT;
@@ -606,12 +478,14 @@ struct _cl_program {
      sequential bitcode produced from the kernel sources.*/
   size_t *binary_sizes; 
   unsigned char **binaries; 
-  /* Cache directory where program files will reside. */
-  char *cache_dir;
   /* implementation */
   cl_kernel kernels;
-  /* program hash after build */
-  uint8_t build_hash[SHA1_DIGEST_SIZE];
+  /* Per-device program hash after build */
+  SHA1_digest_t* build_hash;
+  /* Per-device build logs, for the case when we don't yet have the program's cachedir */
+  char** build_log;
+  /* Per-program build log, for the case when we aren't yet building for devices */
+  char main_build_log[640];
   /* Used to store the llvm IR of the build to save disk I/O. */
   void **llvm_irs;
   /* Use to store build status */
@@ -622,7 +496,6 @@ struct _cl_kernel {
   POCL_ICD_OBJECT
   POCL_OBJECT;
   /* queries */
-  char *function_name;
   char *name;
   cl_uint num_args;
   cl_context context;
@@ -652,6 +525,7 @@ typedef struct _cl_event _cl_event;
 struct _cl_event {
   POCL_ICD_OBJECT
   POCL_OBJECT;
+  cl_context context;
   cl_command_queue queue;
   cl_command_type command_type;
 
@@ -681,50 +555,54 @@ struct _cl_sampler {
   cl_filter_mode      filter_mode;
 };
 
-#define POCL_UPDATE_EVENT_QUEUED(__event, __cq)                         \
+#define POCL_UPDATE_EVENT_QUEUED(__event)                               \
   do {                                                                  \
     if ((__event) != NULL && (*(__event)) != NULL)                      \
       {                                                                 \
+        cl_command_queue __cq = (*(__event))->queue;                    \
         (*(__event))->status = CL_QUEUED;                               \
-        if ((__cq)->properties & CL_QUEUE_PROFILING_ENABLE)             \
+        if (__cq && __cq->properties & CL_QUEUE_PROFILING_ENABLE)       \
           (*(__event))->time_queue =                                    \
-            (__cq)->device->ops->get_timer_value((__cq)->device->data);      \
+            __cq->device->ops->get_timer_value(__cq->device->data);     \
       }                                                                 \
   } while (0)                                                           \
 
-#define POCL_UPDATE_EVENT_SUBMITTED(__event, __cq)                      \
+#define POCL_UPDATE_EVENT_SUBMITTED(__event)                            \
   do {                                                                  \
     if ((__event) != NULL && (*(__event)) != NULL)                      \
       {                                                                 \
         assert((*(__event))->status == CL_QUEUED);                      \
         (*(__event))->status = CL_SUBMITTED;                            \
-        if ((__cq)->properties & CL_QUEUE_PROFILING_ENABLE)             \
+        cl_command_queue __cq = (*(__event))->queue;                    \
+        if (__cq && __cq->properties & CL_QUEUE_PROFILING_ENABLE)       \
           (*(__event))->time_submit =                                   \
-            (__cq)->device->ops->get_timer_value((__cq)->device->data);      \
+            __cq->device->ops->get_timer_value(__cq->device->data);     \
       }                                                                 \
   } while (0)                                                           \
 
-#define POCL_UPDATE_EVENT_RUNNING(__event, __cq)                        \
+#define POCL_UPDATE_EVENT_RUNNING(__event)                              \
   do {                                                                  \
     if (__event != NULL && (*(__event)) != NULL)                        \
       {                                                                 \
         assert((*(__event))->status == CL_SUBMITTED);                   \
         (*(__event))->status = CL_RUNNING;                              \
-        if ((__cq)->properties & CL_QUEUE_PROFILING_ENABLE)             \
+        cl_command_queue __cq = (*(__event))->queue;                    \
+        if (__cq && __cq->properties & CL_QUEUE_PROFILING_ENABLE)       \
           (*(__event))->time_start =                                    \
-            (__cq)->device->ops->get_timer_value((__cq)->device->data);      \
+            __cq->device->ops->get_timer_value(__cq->device->data);     \
       }                                                                 \
   } while (0)                                                           \
 
-#define POCL_UPDATE_EVENT_COMPLETE(__event, __cq)                       \
+#define POCL_UPDATE_EVENT_COMPLETE(__event)                             \
   do {                                                                  \
     if ((__event) != NULL && (*(__event)) != NULL)                      \
       {                                                                 \
         assert((*(__event))->status == CL_RUNNING);                     \
         (*(__event))->status = CL_COMPLETE;                             \
-        if ((__cq)->properties & CL_QUEUE_PROFILING_ENABLE)             \
+        cl_command_queue __cq = (*(__event))->queue;                    \
+        if (__cq && __cq->properties & CL_QUEUE_PROFILING_ENABLE)       \
           (*(__event))->time_end =                                      \
-            (__cq)->device->ops->get_timer_value((__cq)->device->data);      \
+            __cq->device->ops->get_timer_value(__cq->device->data);     \
       }                                                                 \
   } while (0)                                                           \
 
diff --git a/lib/CL/pocl_debug.c b/lib/CL/pocl_debug.c
new file mode 100644
index 0000000..8011b53
--- /dev/null
+++ b/lib/CL/pocl_debug.c
@@ -0,0 +1,56 @@
+#include "pocl_debug.h"
+
+#ifdef POCL_DEBUG_MESSAGES
+int pocl_debug_messages;
+
+#ifdef HAVE_CLOCK_GETTIME
+
+  #if !defined(_MSC_VER) && !defined(__MINGW32__)
+
+    #include <time.h>
+    #include <stdio.h>
+
+    void pocl_debug_print_header(const char* func, unsigned line) {
+        struct tm t;
+        long tm_nanosec;
+        struct timespec timespec;
+
+        clock_gettime(CLOCK_REALTIME, &timespec);
+        tm_nanosec = timespec.tv_nsec;
+        gmtime_r(&timespec.tv_sec, &t);
+        fprintf(stderr,
+            "[%04i-%02i-%02i %02i:%02i:%02i.%09li] POCL: "
+            "in fn %s at line %u:\n", (t.tm_year + 1900),
+            t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min,
+            t.tm_sec, tm_nanosec,  func, line);
+    }
+
+  #else
+
+    #include <windows.h>
+    #include <stdio.h>
+
+    void pocl_debug_print_header(const char* func, unsigned line) {
+        SYSTEMTIME st;
+        FILETIME t;
+        unsigned long st_nanosec;
+        GetSystemTimeAsFileTime(&t);
+        FileTimeToSystemTime(&t, &st);
+        st_nanosec = (t.dwLowDateTime % 10000000) * 100;
+
+        fprintf(stderr,
+            "[%04u-%02u-%02u %02u:%02u:%02u.%09lu] POCL: "
+            "in fn %s at line %u:\n",
+            (unsigned int)st.wYear, (unsigned int)st.wMonth,
+            (unsigned int)st.wDay, (unsigned int)st.wHour,
+            (unsigned int)st.wMinute, (unsigned int)st.wSecond,
+            (unsigned long)st_nanosec, func, line);
+    }
+
+
+  #endif
+
+
+#endif
+
+#endif
diff --git a/lib/CL/pocl_debug.h b/lib/CL/pocl_debug.h
new file mode 100644
index 0000000..6040bbb
--- /dev/null
+++ b/lib/CL/pocl_debug.h
@@ -0,0 +1,146 @@
+#ifndef POCL_DEBUG_H
+#define POCL_DEBUG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
+/* Debugging macros. Also macros for marking unimplemented parts of specs or
+   untested parts of the implementation. */
+
+#define POCL_ABORT_UNIMPLEMENTED(MSG)                                   \
+    do {                                                                \
+        fprintf(stderr,"%s is unimplemented (%s:%d)\n",                 \
+                        MSG, __FILE__, __LINE__);                       \
+        exit(2);                                                        \
+    } while (0)
+
+#define POCL_WARN_UNTESTED()                                            \
+    do {                                                                \
+        fprintf( stderr,                                                \
+            "pocl warning: encountered untested part of the "           \
+            "implementation in %s:%d\n", __FILE__, __LINE__);           \
+    } while (0)
+
+#define POCL_WARN_INCOMPLETE()                                          \
+    do {                                                                \
+        fprintf( stderr,                                                \
+            "pocl warning: encountered incomplete implementation"       \
+            " in %s:%d\n", __FILE__, __LINE__);                         \
+    } while (0)
+
+#define POCL_ABORT(__MSG__)                                             \
+    do {                                                                \
+        fprintf(stderr, __MSG__);                                       \
+        exit(2);                                                        \
+    } while (0)
+
+#define POCL_ERROR(x) do { if (errcode_ret != NULL) {                   \
+                              *errcode_ret = (x);                       \
+                           } return NULL; } while (0)
+
+#define POCL_SUCCESS() do { if (errcode_ret != NULL) {                  \
+                              *errcode_ret = CL_SUCCESS;                \
+                            } } while (0)
+
+
+
+#include "config.h"
+
+#ifdef POCL_DEBUG_MESSAGES
+
+    extern int pocl_debug_messages;
+
+    #if __GNUC__ >= 2
+    #define __func__ __PRETTY_FUNCTION__
+    #else
+    #define __func__ __FUNCTION__
+    #endif
+
+    #ifdef HAVE_CLOCK_GETTIME
+        #define POCL_DEBUG_HEADER pocl_debug_print_header(__func__, __LINE__);
+        extern void pocl_debug_print_header(const char * func, unsigned line);
+    #else
+        #define POCL_DEBUG_HEADER                                           \
+            fprintf(stderr, "** POCL ** : in function %s"                   \
+            " at line %u:\n", __func__, __LINE__);
+    #endif
+
+    #define POCL_MSG_PRINT(TYPE, ERRCODE, ...)                              \
+        do {                                                                \
+            if (pocl_debug_messages) {                                      \
+                POCL_DEBUG_HEADER                                           \
+                fprintf(stderr, TYPE  ERRCODE " ");                         \
+                fprintf(stderr, __VA_ARGS__);                               \
+            }                                                               \
+        } while (0)
+
+    #define POCL_MSG_PRINT2(func, line, ...)                                \
+        do {                                                                \
+            if (pocl_debug_messages) {                                      \
+                pocl_debug_print_header(func, line);                        \
+                fprintf(stderr, __VA_ARGS__);                               \
+            }                                                               \
+        } while (0)
+
+    #define POCL_MSG_WARN(...)    POCL_MSG_PRINT(" *** WARNING *** ", "", __VA_ARGS__)
+    #define POCL_MSG_ERR(...)     POCL_MSG_PRINT(" *** ERROR *** ", "", __VA_ARGS__)
+    #define POCL_MSG_PRINT_INFO(...) POCL_MSG_PRINT(" *** INFO *** ", "", __VA_ARGS__)
+
+#else
+
+    #define POCL_MSG_WARN(...)
+    #define POCL_MSG_ERR(...)
+    #define POCL_MSG_PRINT(...)
+    #define POCL_MSG_PRINT2(...)
+    #define POCL_MSG_PRINT_INFO(...)
+
+#endif
+
+
+#define POCL_GOTO_ERROR_ON(cond, err_code, ...)                             \
+    if (cond)                                                               \
+    {                                                                       \
+        POCL_MSG_PRINT(" *** ERROR *** ", # err_code, __VA_ARGS__);         \
+        errcode = err_code;                                                 \
+        goto ERROR;                                                         \
+    }                                                                       \
+
+#define POCL_RETURN_ERROR_ON(cond, err_code, ...)                           \
+    if (cond)                                                               \
+    {                                                                       \
+        POCL_MSG_PRINT(" *** ERROR *** ", # err_code, __VA_ARGS__);         \
+        return err_code;                                                    \
+    }                                                                       \
+
+#define POCL_RETURN_ERROR_COND(cond, err_code)                              \
+    if (cond)                                                               \
+    {                                                                       \
+        POCL_MSG_PRINT(" *** ERROR *** ", #err_code, "%s\n", #cond);        \
+        return err_code;                                                    \
+    }                                                                       \
+
+#define POCL_GOTO_ERROR_COND(cond, err_code)                                \
+    if (cond)                                                               \
+    {                                                                       \
+        POCL_MSG_PRINT(" *** ERROR *** ", #err_code, "%s\n", #cond);        \
+        errcode = err_code;                                                 \
+        goto ERROR;                                                         \
+    }                                                                       \
+
+
+
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lib/CL/pocl_hash.c b/lib/CL/pocl_hash.c
index 593bdc5..8e50734 100644
--- a/lib/CL/pocl_hash.c
+++ b/lib/CL/pocl_hash.c
@@ -155,6 +155,7 @@ static void SHA1_Transform(uint32_t state[5], const uint8_t buffer[64])
 
     /* Wipe variables */
     a = b = c = d = e = 0;
+    (void)a; /* avoid dead store */
 }
 
 
@@ -215,6 +216,7 @@ void pocl_SHA1_Final(SHA1_CTX* context, uint8_t digest[SHA1_DIGEST_SIZE])
 
     /* Wipe variables */
     i = 0;
+    (void)i; /* avoid dead store */
     memset(context->buffer, 0, 64);
     memset(context->state, 0, 20);
     memset(context->count, 0, 8);
diff --git a/lib/CL/pocl_hash.h b/lib/CL/pocl_hash.h
index 48e6a43..2d9d114 100644
--- a/lib/CL/pocl_hash.h
+++ b/lib/CL/pocl_hash.h
@@ -22,6 +22,14 @@
 #ifndef POCL_HASH_H
 #define POCL_HASH_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __GNUC__
+#pragma GCC visibility push(hidden)
+#endif
+
 /* public api for steve reid's public domain SHA-1 implementation */
 /* this file is in the public domain */
 
@@ -39,4 +47,12 @@ void pocl_SHA1_Init(SHA1_CTX* context);
 void pocl_SHA1_Update(SHA1_CTX* context, const uint8_t* data, const size_t len);
 void pocl_SHA1_Final(SHA1_CTX* context, uint8_t digest[SHA1_DIGEST_SIZE]);
 
+#ifdef __GNUC__
+#pragma GCC visibility pop
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* POCL_HASH_H */
diff --git a/lib/CL/pocl_image_util.c b/lib/CL/pocl_image_util.c
index 2bb1a2f..0a5be92 100644
--- a/lib/CL/pocl_image_util.c
+++ b/lib/CL/pocl_image_util.c
@@ -219,12 +219,12 @@ pocl_read_image(cl_mem               image,
   if ((ptr == NULL) || (region == NULL) || origin == NULL)
     return CL_INVALID_VALUE;
     
-  int width = image->image_width;
-  int height = image->image_height;
+  size_t width = image->image_width;
+  size_t height = image->image_height;
 
   /* dev imagetype = host imagetype, in current implementation */
-  int dev_elem_size = image->image_elem_size;
-  int dev_channels = image->image_channels;
+  size_t dev_elem_size = image->image_elem_size;
+  size_t dev_channels = image->image_channels;
 
   size_t tuned_origin[3] = {origin[0]*dev_elem_size*dev_channels, origin[1], 
                             origin[2]};
diff --git a/lib/CL/pocl_image_util.h b/lib/CL/pocl_image_util.h
index 6893d1e..fc63a88 100644
--- a/lib/CL/pocl_image_util.h
+++ b/lib/CL/pocl_image_util.h
@@ -26,7 +26,9 @@
 
 #include "pocl_cl.h"
 
+#ifdef __GNUC__
 #pragma GCC visibility push(hidden)
+#endif
 
 extern cl_int 
 pocl_check_image_origin_region (const cl_mem image, 
@@ -61,7 +63,8 @@ pocl_read_image(cl_mem               image,
                 size_t               host_slice_pitch, 
                 void *               ptr);
 
-
+#ifdef __GNUC__
 #pragma GCC visibility pop
+#endif
                    
 #endif
diff --git a/lib/CL/pocl_llvm.h b/lib/CL/pocl_llvm.h
index 7a14694..90d1521 100644
--- a/lib/CL/pocl_llvm.h
+++ b/lib/CL/pocl_llvm.h
@@ -33,13 +33,9 @@ extern "C" {
  */
 int pocl_llvm_build_program
 (cl_program program,
- cl_device_id device,
- int device_i,     
- const char* cache_dir,
- const char* binary_filename,
- const char* device_tmpdir,
+ unsigned device_i,
  const char* user_options,
- int fd);
+ void **cache_lock, char *program_bc_path);
 
 
 /* Retrieve metadata of the given kernel in the program to populate the
@@ -50,8 +46,6 @@ int pocl_llvm_get_kernel_metadata
  cl_kernel kernel,
  int device_i,     
  const char* kernel_name,
- const char* device_tmpdir, 
- char* descriptor_filename,
  int *errcode);
 
 /* This function links the input kernel LLVM bitcode and the
@@ -67,11 +61,14 @@ int pocl_llvm_get_kernel_metadata
  * at a time or control the options through thread safe methods.
  */
 int pocl_llvm_generate_workgroup_function
-(cl_device_id device,
- cl_kernel kernel,
- size_t local_x, size_t local_y, size_t local_z,
- const char* parallel_filename,
- const char* kernel_filename);
+(cl_device_id device, cl_kernel kernel,
+ size_t local_x, size_t local_y, size_t local_z
+);
+
+/**
+ * Free the LLVM IR of a program for a given device
+ */
+void pocl_free_llvm_irs(cl_program program, int device_i);
 
 /**
  * Update the program->binaries[] representation of the kernels
@@ -81,6 +78,13 @@ int pocl_llvm_generate_workgroup_function
 void pocl_llvm_update_binaries (cl_program program);
 
 /**
+ * Count the number of "__kernel" functions in 'program'.
+ *
+ * Results are valid as long as program binary is not modified.
+ */
+unsigned pocl_llvm_get_kernel_count(cl_program program);
+
+/**
  * Find the "__kernel" function names in 'program',
  * filling the callee-allocated array with pointer to the program binary.
  * No more than 'max_num_krn' are written.
@@ -90,7 +94,7 @@ void pocl_llvm_update_binaries (cl_program program);
  * Returns the number of kernels found in the program (may be greater than
  * 'max_num_krn')
  */
-int pocl_llvm_get_kernel_names( cl_program program, const char **knames, unsigned max_num_krn);
+unsigned pocl_llvm_get_kernel_names( cl_program program, const char **knames, unsigned max_num_krn);
 
 /** Compile the kernel in infile from LLVM bitcode to native object file for
  * device, into outfile.
@@ -101,11 +105,13 @@ int pocl_llvm_codegen ( cl_kernel kernel,
                         const char *outfile);
 
 /* Parse program file and populate program's llvm_irs */
-void
-pocl_update_program_llvm_irs(cl_program program,
-                       cl_device_id device, const char* program_filename);
+int
+pocl_update_program_llvm_irs(cl_program program, unsigned device_i,
+                             cl_device_id device);
+
+
+
 
 #ifdef __cplusplus
 }
 #endif
-
diff --git a/lib/CL/pocl_llvm_api.cc b/lib/CL/pocl_llvm_api.cc
index 1bf0666..c99243a 100644
--- a/lib/CL/pocl_llvm_api.cc
+++ b/lib/CL/pocl_llvm_api.cc
@@ -1,8 +1,8 @@
 /* pocl_llvm_api.cc: C wrappers for calling the LLVM/Clang C++ APIs to invoke
    the different kernel compilation phases.
 
-   Copyright (c) 2013 Kalle Raiskila 
-                 2013-2014 Pekka Jääskeläinen
+   Copyright (c) 2013 Kalle Raiskila
+                 2013-2015 Pekka Jääskeläinen
    
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
@@ -23,14 +23,33 @@
    THE SOFTWARE.
 */
 
+#include "CompilerWarnings.h"
+IGNORE_COMPILER_WARNING("-Wunused-parameter")
+IGNORE_COMPILER_WARNING("-Wstrict-aliasing")
+
 #include "config.h"
 
 #include "clang/CodeGen/CodeGenAction.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/FrontendActions.h"
 #include "clang/Frontend/TextDiagnosticBuffer.h"
+
+// For some reason including pocl.h before including CodeGenAction.h
+// causes an error. Some kind of macro definition issue. To investigate.
+#include "pocl.h"
+
 #include "llvm/LinkAllPasses.h"
+#ifdef LLVM_OLDER_THAN_3_7
 #include "llvm/PassManager.h"
+#include "llvm/Target/TargetLibraryInfo.h"
+#else
+#include "llvm/Analysis/TargetLibraryInfo.h"
+#include "llvm/Analysis/TargetTransformInfo.h"
+#include "llvm/IR/LegacyPassManager.h"
+using llvm::legacy::PassManager;
+#endif
+
 #include "llvm/Bitcode/ReaderWriter.h"
 #include "llvm/Transforms/Utils/Cloning.h"
 
@@ -66,11 +85,9 @@
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/ToolOutputFile.h"
 #include "llvm/Target/TargetMachine.h"
-#include "llvm/Target/TargetLibraryInfo.h"
 #include "llvm/MC/MCContext.h"
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
-#include <sys/stat.h>
 
 #include <iostream>
 #include <fstream>
@@ -79,13 +96,6 @@
 #include <string>
 #include <cstdio>
 
-#ifndef _MSC_VER
-#  include <unistd.h>
-#  include <sys/types.h>
-#  include <sys/stat.h>
-#  include <fcntl.h>
-#endif
-
 // Note - LLVM/Clang uses symbols defined in Khronos' headers in macros, 
 // causing compilation error if they are included before the LLVM headers.
 #include "pocl_llvm.h"
@@ -93,21 +103,14 @@
 #include "install-paths.h"
 #include "LLVMUtils.h"
 #include "linker.h"
-#include "pocl_util.h"
+#include "pocl_file_util.h"
+#include "pocl_cache.h"
 
 using namespace clang;
 using namespace llvm;
 
-#if defined LLVM_3_2 || defined LLVM_3_3
-#include "llvm/Support/raw_ostream.h"
-#define F_Binary llvm::raw_fd_ostream::F_Binary
-#elif defined LLVM_3_4
-using llvm::sys::fs::F_Binary;
-#else
-// a binary file is "not a text file"
-#define F_Binary llvm::sys::fs::F_None
-#endif
 
+POP_COMPILER_DIAGS
 
 /**
  * Use one global LLVMContext across all LLVM bitcodes. This is because
@@ -138,50 +141,6 @@ static void InitializeLLVM();
 #include <cassert>
 #endif
 
-// Write a kernel compilation intermediate result
-// to file on disk, if user has requested with environment
-// variable
-// TODO: what to do on errors?
-
-// this version simply rewrites the file
-static inline void
-update_temporary_file( const llvm::Module *mod,
-                      const char *filename )
-{
-  tool_output_file *Out;
-#if LLVM_VERSION_MAJOR==3 && LLVM_VERSION_MINOR<6
-  std::string ErrorInfo;
-  Out = new tool_output_file(filename, ErrorInfo, F_Binary);
-#else
-  std::error_code ErrorInfo;
-  Out = new tool_output_file(filename, ErrorInfo, F_Binary);
-#endif
-  WriteBitcodeToFile(mod, Out->os());
-  Out->keep();
-  delete Out;
-}
-
-#if LLVM_VERSION_MAJOR==3 && LLVM_VERSION_MINOR<4
-#define write_temporary_file_fd(A,B,C) update_temporary_file(A,B)
-#else
-// this version works on already open filedescriptor
-static inline void
-write_temporary_file_fd( const llvm::Module *mod,
-                      const char *filename, int fd)
-{
-  tool_output_file *Out;
-#if LLVM_VERSION_MAJOR==3 && LLVM_VERSION_MINOR<6
-  std::string ErrorInfo;
-  Out = new tool_output_file(filename, fd);
-#else
-  std::error_code ErrorInfo;
-  Out = new tool_output_file(filename, fd);
-#endif
-  WriteBitcodeToFile(mod, Out->os());
-  Out->keep();
-  delete Out;
-}
-#endif
 
 // Read input source to clang::FrontendOptions.
 // The source is contained in the program->source array,
@@ -190,21 +149,35 @@ write_temporary_file_fd( const llvm::Module *mod,
 // to find it.
 static inline int
 load_source(FrontendOptions &fe,
-            const char* cache_dir,
             cl_program program)
 {
-  std::string kernel_file(cache_dir);
-  kernel_file += "/" POCL_PROGRAM_CL_FILENAME;
-  std::ofstream ofs(kernel_file.c_str());
-  ofs << program->source;
-  if (!ofs.good())
-    return CL_OUT_OF_HOST_MEMORY;
+  char source_file[POCL_FILENAME_LENGTH];
+  POCL_RETURN_ERROR_ON(pocl_cache_write_program_source(source_file, program),
+                       CL_OUT_OF_HOST_MEMORY, "Could not write program source");
+
   fe.Inputs.push_back
-    (FrontendInputFile(kernel_file, clang::IK_OpenCL));
+    (FrontendInputFile(source_file, clang::IK_OpenCL));
 
   return 0;
 }
 
+// Unlink input sources
+static inline int
+unlink_source(FrontendOptions &fe)
+{
+  // don't unlink in debug mode
+  if (pocl_get_bool_option("POCL_DEBUG", 0))
+    return 0;
+
+  FrontendInputFile const& file = fe.Inputs.front();
+  if (file.isFile() && !file.isSystem()) {
+    return pocl_remove(file.getFile().str().c_str());
+  } else {
+    return 0; // nothing to do
+  }
+
+}
+
 // Compatibility function: this function existed up to LLVM 3.5
 // With 3.6 its name & signature changed
 #if !(defined LLVM_3_2 || defined LLVM_3_3 || \
@@ -216,14 +189,43 @@ ParseIRFile(const char* fname, SMDiagnostic &Err, llvm::LLVMContext &ctx)
 }
 #endif
 
+static void get_build_log(cl_program program,
+                         unsigned device_i,
+                         std::stringstream &ss_build_log,
+                         clang::TextDiagnosticBuffer *diagsBuffer,
+                         const SourceManager &sm)
+{
+    static const bool show_log = pocl_get_bool_option("POCL_VERBOSE", 0) ||
+      pocl_get_bool_option("POCL_DEBUG", 0);
+
+    for (TextDiagnosticBuffer::const_iterator i = diagsBuffer->err_begin(),
+         e = diagsBuffer->err_end(); i != e; ++i)
+      {
+        ss_build_log << "error: " << i->first.printToString(sm)
+                     << ": " << i->second << std::endl;
+      }
+    for (TextDiagnosticBuffer::const_iterator i = diagsBuffer->warn_begin(),
+         e = diagsBuffer->warn_end(); i != e; ++i)
+      {
+        ss_build_log << "warning: " << i->first.printToString(sm)
+                     << ": " << i->second << std::endl;
+      }
+
+    pocl_cache_append_to_buildlog(program, device_i,
+                                  ss_build_log.str().c_str(),
+                                  ss_build_log.str().size());
+
+    if (show_log)
+      std::cerr << ss_build_log.str();
+
+}
+
+
 int pocl_llvm_build_program(cl_program program, 
-                            cl_device_id device, 
-                            int device_i,     
-                            const char* cache_dir,
-                            const char* binary_file_name,
-                            const char* device_tmpdir,
+                            unsigned device_i,
                             const char* user_options,
-                            int fd)
+                            void** cache_lock,
+                            char* program_bc_path)
 
 {
   llvm::MutexGuard lockHolder(kernelCompilerLock);
@@ -244,22 +246,17 @@ int pocl_llvm_build_program(cl_program program,
   CompilerInstance CI;
   CompilerInvocation &pocl_build = CI.getInvocation();
 
-  // add device specific switches, if any
   std::stringstream ss;
   std::stringstream ss_build_log;
 
-  std::stringstream build_log_filename;
-  build_log_filename << cache_dir << "/" << POCL_BUILDLOG_FILENAME;
-  /* Overwrite build log */
-  std::ofstream fp(build_log_filename.str().c_str(), std::ofstream::trunc);
-  fp.close();
-
-  if (device->ops->init_build != NULL) 
+  // add device specific switches, if any
+  // TODO this currently passes NULL as device tmpdir
+  cl_device_id device = program->devices[device_i];
+  if (device->ops->init_build != NULL)
     {
-      assert (device_tmpdir != NULL);
-      char *device_switches = 
-        device->ops->init_build (device->data, device_tmpdir);
-      if (device_switches != NULL) 
+      char *device_switches =
+        device->ops->init_build (device->data);
+      if (device_switches != NULL)
         {
           ss << device_switches << " ";
         }
@@ -315,23 +312,16 @@ int pocl_llvm_build_program(cl_program program,
             << "user_options: " << user_options << std::endl;
 #endif
 
+  if (program->build_log[device_i])
+    POCL_MEM_FREE(program->build_log[device_i]);
+
   if (!CompilerInvocation::CreateFromArgs
       (pocl_build, itemcstrs.data(), itemcstrs.data() + itemcstrs.size(), 
-       diags)) 
+       diags))
     {
-      for (TextDiagnosticBuffer::const_iterator i = diagsBuffer->err_begin(), 
-             e = diagsBuffer->err_end(); i != e; ++i) 
-        {
-          ss_build_log << "error: " << (*i).second << std::endl;
-        }
-      for (TextDiagnosticBuffer::const_iterator i = diagsBuffer->warn_begin(), 
-             e = diagsBuffer->warn_end(); i != e; ++i) 
-        {
-          ss_build_log << "warning: " << (*i).second << std::endl;
-        }
-      pocl_create_or_append_file(build_log_filename.str().c_str(),
-                                 ss_build_log.str().c_str());
-      std::cerr << ss_build_log.str();
+      pocl_cache_create_program_cachedir(program, device_i, NULL, 0,
+        program_bc_path, cache_lock);
+      get_build_log(program, device_i, ss_build_log, diagsBuffer, CI.getSourceManager());
       return CL_INVALID_BUILD_OPTIONS;
     }
   
@@ -388,11 +378,11 @@ int pocl_llvm_build_program(cl_program program,
 #else
   CI.createDiagnostics(diagsBuffer, false);
 #endif 
- 
+
   FrontendOptions &fe = pocl_build.getFrontendOpts();
   // The CreateFromArgs created an stdin input which we should remove first.
   fe.Inputs.clear(); 
-  if (load_source(fe, cache_dir, program)!=0)
+  if (load_source(fe, program)!=0)
     return CL_OUT_OF_HOST_MEMORY;
 
   CodeGenOptions &cg = pocl_build.getCodeGenOpts();
@@ -401,32 +391,73 @@ int pocl_llvm_build_program(cl_program program,
   // Let the vectorizer or another optimization pass unroll the loops,
   // in case it sees beneficial.
   cg.UnrollLoops = false;
+  // This workarounds a Frontend codegen issues with an illegal address
+  // space cast which is later flattened (and thus implicitly fixed) in
+  // the TargetAddressSpaces. See:  https://github.com/pocl/pocl/issues/195
+  cg.VerifyModule = false;
+
+  PreprocessorOutputOptions &poo = pocl_build.getPreprocessorOutputOpts();
+  //PreprocessorOutputOptions prep = CI.getPreprocessorOutputOpts();
+  poo.ShowCPP = 1;
+  poo.ShowComments = 0;
+  poo.ShowLineMarkers = 0;
+  //poo.UseLineDirectives = 0;   // probably LLVM 3.7 thing
+  poo.ShowMacroComments = 0;
+  poo.ShowMacros = 1;
+  poo.RewriteIncludes = 0;
+
+  std::string saved_output(fe.OutputFile);
+
+  char tempfile[POCL_FILENAME_LENGTH];
+  pocl_cache_mk_temp_name(tempfile);
+
+  fe.OutputFile = tempfile;
+
+  bool success = true;
+  clang::FrontendAction *action2 = NULL;
+  action2 = new clang::PrintPreprocessedAction();
+  success = CI.ExecuteAction(*action2);
+  if (!success)
+    {
+      pocl_cache_create_program_cachedir(program, device_i, NULL, 0,
+        program_bc_path, cache_lock);
+      get_build_log(program, device_i, ss_build_log, diagsBuffer, CI.getSourceManager());
+      return CL_BUILD_PROGRAM_FAILURE;
+    }
+
+  char *preprocessed_out;
+  uint64_t size;
+  pocl_read_file(tempfile, &preprocessed_out, &size);
+  if (!preprocessed_out)
+    {
+      pocl_cache_create_program_cachedir(program, device_i, NULL, 0,
+        program_bc_path, cache_lock);
+      get_build_log(program, device_i, ss_build_log, diagsBuffer, CI.getSourceManager());
+      return CL_BUILD_PROGRAM_FAILURE;
+    }
+
+  pocl_cache_create_program_cachedir(program, device_i, preprocessed_out,
+                                     size, program_bc_path, cache_lock);
+
+  POCL_MEM_FREE(preprocessed_out);
+  pocl_remove(tempfile);
+
+  if (pocl_exists(program_bc_path)) {
+    unlink_source(fe);
+    return CL_SUCCESS;
+  }
+
+  fe.OutputFile = saved_output;
 
   // TODO: use pch: it is possible to disable the strict checking for
   // the compilation flags used to compile it and the current translation
   // unit via the preprocessor options directly.
 
-  bool success = true;
   clang::CodeGenAction *action = NULL;
   action = new clang::EmitLLVMOnlyAction(GlobalContext());
-  success |= CI.ExecuteAction(*action);
+  success = CI.ExecuteAction(*action);
 
-  SourceManager &source_manager = CI.getSourceManager();
-  for (TextDiagnosticBuffer::const_iterator i = diagsBuffer->err_begin(),
-       e = diagsBuffer->err_end(); i != e; ++i)
-    {
-      ss_build_log << "error: " << (*i).first.printToString(source_manager)
-                   << ": " << (*i).second << std::endl;
-    }
-  for (TextDiagnosticBuffer::const_iterator i = diagsBuffer->warn_begin(),
-       e = diagsBuffer->warn_end(); i != e; ++i)
-    {
-      ss_build_log << "warning: " << (*i).first.printToString(source_manager)
-                   << ": " << (*i).second << std::endl;
-    }
-  pocl_create_or_append_file(build_log_filename.str().c_str(),
-                                ss_build_log.str().c_str());
-  std::cerr << ss_build_log.str();
+  get_build_log(program, device_i, ss_build_log, diagsBuffer, CI.getSourceManager());
 
   // FIXME: memleak, see FIXME below
   if (!success) return CL_BUILD_PROGRAM_FAILURE;
@@ -445,7 +476,26 @@ int pocl_llvm_build_program(cl_program program,
     return CL_BUILD_PROGRAM_FAILURE;
 
   /* Always retain program.bc. Its required in clBuildProgram */
-  if(fd >= 0) write_temporary_file_fd(*mod, binary_file_name, fd);
+  pocl_write_module(*mod, program_bc_path, 0);
+
+  /* To avoid writing & reading the same back,
+   * save program->binaries[i]
+   */
+
+  std::string content;
+  llvm::raw_string_ostream sos(content);
+  WriteBitcodeToFile(*mod, sos);
+  sos.str(); // flush
+
+  if (program->binaries[device_i])
+    POCL_MEM_FREE(program->binaries[device_i]);
+
+  size_t n = content.size();
+  program->binary_sizes[device_i] = n;
+  program->binaries[device_i] = (unsigned char *) malloc(n);
+  std::memcpy(program->binaries[device_i], content.c_str(), n);
+
+  unlink_source(fe);
 
   // FIXME: cannot delete action as it contains something the llvm::Module
   // refers to. We should create it globally, at compiler initialization time.
@@ -464,7 +514,7 @@ int pocl_llvm_get_kernel_arg_metadata(const char* kernel_name,
   llvm::MDNode *kernel_metadata = NULL;
 
   // Not sure what to do in this case
-  if (!opencl_kernels) return -1;
+  if (!opencl_kernels || opencl_kernels->getNumOperands() == 0) return -1;
 
   for (unsigned i = 0, e = opencl_kernels->getNumOperands(); i != e; ++i) {
     llvm::MDNode *kernel_iter = opencl_kernels->getOperand(i);
@@ -602,14 +652,11 @@ int pocl_llvm_get_kernel_metadata(cl_program program,
                                   cl_kernel kernel,
                                   int device_i,     
                                   const char* kernel_name,
-                                  const char* device_tmpdir, 
-                                  char* descriptor_filename,
                                   int * errcode)
 {
 
   int i;
   llvm::Module *input = NULL;
-  char tmpdir[POCL_FILENAME_LENGTH];
 
   assert(program->devices[device_i]->llvm_target_triplet && 
          "Device has no target triple set"); 
@@ -628,14 +675,6 @@ int pocl_llvm_get_kernel_metadata(cl_program program,
       return 1;
     }
 
-  (void) snprintf(descriptor_filename, POCL_FILENAME_LENGTH,
-                    "%s/%s/descriptor.so", device_tmpdir, kernel_name);
-
-  snprintf(tmpdir, POCL_FILENAME_LENGTH, "%s/%s",
-            device_tmpdir, kernel_name);
-
-  if (access(tmpdir, F_OK) != 0)
-    mkdir(tmpdir, S_IRWXU);
 
 #ifdef DEBUG_POCL_LLVM_API        
   printf("### fetching kernel metadata for kernel %s program %p input llvm::Module %p\n",
@@ -651,8 +690,10 @@ int pocl_llvm_get_kernel_metadata(cl_program program,
   DataLayout *TD = 0;
 #if (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
   const std::string &ModuleDataLayout = input->getDataLayout();
-#else
+#elif (defined LLVM_OLDER_THAN_3_7)
   const std::string &ModuleDataLayout = input->getDataLayout()->getStringRepresentation();
+#else
+  const std::string &ModuleDataLayout = input->getDataLayout().getStringRepresentation();
 #endif
   if (!ModuleDataLayout.empty())
     TD = new DataLayout(ModuleDataLayout);
@@ -788,51 +829,30 @@ int pocl_llvm_get_kernel_metadata(cl_program program,
   // TODO: the scripts use a generated kernel.h header file that
   // gets added to this file. No checks seem to fail if that file
   // is missing though, so it is left out from there for now
-  std::string kobj_s = descriptor_filename; 
-  kobj_s += ".kernel_obj.c";
 
-  int fd;
-  if ((fd = open(kobj_s.c_str(), (O_CREAT | O_EXCL | O_WRONLY),
-      (S_IRUSR | S_IWUSR))) >= 0)
-    {
-      FILE *kobj_c = fdopen(fd, "w");
-
-      fprintf(kobj_c, "\n #include <pocl_device.h>\n");
-
-      fprintf(kobj_c,
-        "void _%s_workgroup(void** args, struct pocl_context*);\n", kernel_name);
-      fprintf(kobj_c,
-        "void _%s_workgroup_fast(void** args, struct pocl_context*);\n", kernel_name);
-
-      fprintf(kobj_c,
-        "__attribute__((address_space(3))) __kernel_metadata _%s_md = {\n", kernel_name);
-      fprintf(kobj_c,
-        "     \"%s\", /* name */ \n", kernel_name );
-      fprintf(kobj_c,"     %d, /* num_args */\n", kernel->num_args);
-      fprintf(kobj_c,"     %d, /* num_locals */\n", kernel->num_locals);
-#if 0
-      // These are not used anymore. The launcher knows the arguments
-      // and sets them up, the device just obeys and launches with
-      // whatever arguments it gets. Remove if none of the private
-      // branches need them neither.
-      fprintf( kobj_c," #if _%s_NUM_LOCALS != 0\n",   kernel_name  );
-      fprintf( kobj_c,"     _%s_LOCAL_SIZE,\n",       kernel_name  );
-      fprintf( kobj_c," #else\n"    );
-      fprintf( kobj_c,"     {0}, \n"    );
-      fprintf( kobj_c," #endif\n"    );
-      fprintf( kobj_c,"     _%s_ARG_IS_LOCAL,\n",    kernel_name  );
-      fprintf( kobj_c,"     _%s_ARG_IS_POINTER,\n",  kernel_name  );
-      fprintf( kobj_c,"     _%s_ARG_IS_IMAGE,\n",    kernel_name  );
-      fprintf( kobj_c,"     _%s_ARG_IS_SAMPLER,\n",  kernel_name  );
-#endif
-      fprintf( kobj_c,"     _%s_workgroup_fast\n",   kernel_name  );
-      fprintf( kobj_c," };\n");
-      fclose(kobj_c);
-   }
+  std::stringstream content;
+
+  content <<  "\n #include <pocl_device.h>\n";
+  content << "void _pocl_launcher_" << kernel_name << "_workgroup(void** args, struct pocl_context*);\n";
+  content << "void _pocl_launcher_" << kernel_name << "_workgroup_fast(void** args, struct pocl_context*);\n";
+  content << "__attribute__((address_space(3))) __kernel_metadata _" << kernel_name << "_md = {\n";
+  content << "     \"" << kernel_name << "\", /* name */ \n";
+  content << "     " << kernel->num_args << ", /* num_args */\n";
+  content << "     " << kernel->num_locals << ", /* num_locals */\n";
+  content << "     _pocl_launcher_" << kernel_name << "_workgroup_fast\n";
+  content << " };\n";
+
+  pocl_cache_write_descriptor(program, device_i,
+                              kernel_name, content.str().c_str(),
+                              content.str().size());
 #endif
 
-  pocl_llvm_get_kernel_arg_metadata(kernel_name, input, kernel);
+  if (pocl_llvm_get_kernel_arg_metadata(kernel_name, input, kernel)) {
+    *errcode = CL_INVALID_KERNEL;
+    return 1;
+  };
 
+  *errcode = CL_SUCCESS;
   return 0;
 }
 
@@ -929,7 +949,7 @@ static void InitializeLLVM() {
  * should be optimized using it.
  */
 static PassManager& kernel_compiler_passes
-(cl_device_id device, std::string module_data_layout)
+(cl_device_id device, const std::string& module_data_layout)
 {
   static std::map<cl_device_id, PassManager*> kernel_compiler_passes;
 
@@ -940,6 +960,9 @@ static PassManager& kernel_compiler_passes
     }
 
   Triple triple(device->llvm_target_triplet);
+
+  bool SPMDDevice = device->spmd;
+
   PassRegistry &Registry = *PassRegistry::getPassRegistry();
 
   const bool first_initialization_call = kernel_compiler_passes.size() == 0;
@@ -966,26 +989,37 @@ static PassManager& kernel_compiler_passes
 #endif
 
 #ifndef LLVM_3_2
+# ifdef LLVM_OLDER_THAN_3_7
   StringMap<llvm::cl::Option*> opts;
   llvm::cl::getRegisteredOptions(opts);
+# else
+  StringMap<llvm::cl::Option *>& opts = llvm::cl::getRegisteredOptions();
+# endif
 #endif
 
   PassManager *Passes = new PassManager();
 
+#if defined LLVM_3_2
+#elif defined LLVM_OLDER_THAN_3_7
   // Need to setup the target info for target specific passes. */
   TargetMachine *Machine = GetTargetMachine(device);
+
   // Add internal analysis passes from the target machine.
-#ifndef LLVM_3_2
   if (Machine != NULL)
     Machine->addAnalysisPasses(*Passes);
+#else 
+  TargetMachine *Machine = GetTargetMachine(device);
+  if (Machine != NULL)
+    Passes->add(createTargetTransformInfoWrapperPass(Machine->getTargetIRAnalysis()));
 #endif
 
+
   if (module_data_layout != "") {
 #if (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
     Passes->add(new DataLayout(module_data_layout));
 #elif (defined LLVM_3_5)
     Passes->add(new DataLayoutPass(DataLayout(module_data_layout)));
-#else
+#elif (defined LLVM_OLDER_THAN_3_7)
     Passes->add(new DataLayoutPass());
 #endif
   }
@@ -995,9 +1029,15 @@ static PassManager& kernel_compiler_passes
      Also the libcalls might be harmful for WG autovectorization where we 
      want to try to vectorize the code it converts to e.g. a memset or 
      a memcpy */
+#ifdef LLVM_OLDER_THAN_3_7
   TargetLibraryInfo *TLI = new TargetLibraryInfo(triple);
   TLI->disableAllFunctions();
   Passes->add(TLI);
+#else
+  TargetLibraryInfoImpl TLII(triple);
+  TLII.disableAllFunctions();
+  Passes->add(new TargetLibraryInfoWrapperPass(TLII));
+#endif
 
   /* The kernel compiler passes to run, in order.
 
@@ -1022,27 +1062,30 @@ static PassManager& kernel_compiler_passes
   passes.push_back("mem2reg");
   passes.push_back("domtree");
   passes.push_back("break-constgeps");
-  passes.push_back("automatic-locals");
+  if(device->autolocals_to_args)
+	  passes.push_back("automatic-locals");
   passes.push_back("flatten");
   passes.push_back("always-inline");
   passes.push_back("globaldce");
-  passes.push_back("simplifycfg");
-  passes.push_back("loop-simplify");
-  passes.push_back("uniformity");
-  passes.push_back("phistoallocas");
-  passes.push_back("isolate-regions");
-  passes.push_back("implicit-loop-barriers");
-  passes.push_back("implicit-cond-barriers");
-  passes.push_back("loop-barriers");
-  passes.push_back("barriertails");
-  passes.push_back("barriers");
-  passes.push_back("isolate-regions");
-  passes.push_back("wi-aa");
-  passes.push_back("workitemrepl");
-  //passes.push_back("print-module");
-  passes.push_back("workitemloops");
+  if (!SPMDDevice) {
+      passes.push_back("simplifycfg");
+      passes.push_back("loop-simplify");
+      passes.push_back("uniformity");
+      passes.push_back("phistoallocas");
+      passes.push_back("isolate-regions");
+      passes.push_back("implicit-loop-barriers");
+      passes.push_back("implicit-cond-barriers");
+      passes.push_back("loop-barriers");
+      passes.push_back("barriertails");
+      passes.push_back("barriers");
+      passes.push_back("isolate-regions");
+      passes.push_back("wi-aa");
+      passes.push_back("workitemrepl");
+      //passes.push_back("print-module");
+      passes.push_back("workitemloops");
+      passes.push_back("workgroup");
+  }
   passes.push_back("allocastoentry");
-  passes.push_back("workgroup");
   passes.push_back("target-address-spaces");
   // Later passes might get confused (and expose possible bugs in them) due to
   // UNREACHABLE blocks left by repl. So let's clean up the CFG before running the
@@ -1110,11 +1153,11 @@ static PassManager& kernel_compiler_passes
                              false); 
           }
 #endif
-        }
 
-      llvm::cl::Option *O = opts["unroll-threshold"];
-      assert(O && "could not find LLVM option 'unroll-threshold'");
-      O->addOccurrence(1, StringRef("unroll-threshold"), StringRef("1"), false); 
+          O = opts["unroll-threshold"];
+          assert(O && "could not find LLVM option 'unroll-threshold'");
+          O->addOccurrence(1, StringRef("unroll-threshold"), StringRef("1"), false); 
+        }
     } 
 #endif
 
@@ -1139,7 +1182,16 @@ static PassManager& kernel_compiler_passes
           if (wg_method == "loopvec") {
             Builder.LoopVectorize = true;
             Builder.SLPVectorize = true;
-            Builder.BBVectorize = true;
+#ifdef LLVM_OLDER_THAN_3_7
+            Builder.BBVectorize = pocl_get_bool_option ("POCL_BBVECTORIZE", 1);
+#else
+            // In LLVM 3.7 the BB vectorizer crashes with some of the
+            // the shuffle tests, but gives performance improvements in
+            // some (see https://github.com/pocl/pocl/issues/251).
+            // Disable by default because of
+            // https://llvm.org/bugs/show_bug.cgi?id=25077
+            Builder.BBVectorize = pocl_get_bool_option ("POCL_BBVECTORIZE", 0);
+#endif
           }
 #endif
 
@@ -1169,10 +1221,11 @@ static PassManager& kernel_compiler_passes
   return *Passes;
 }
 
-/* This is used to communicate the work-group dimensions command-line parameter to the 
-   workitem loop. */
+// Defined in llvmopencl/WorkitemHandler.cc
 namespace pocl {
-extern llvm::cl::list<int> LocalSize;
+    extern size_t WGLocalSizeX;
+    extern size_t WGLocalSizeY;
+    extern size_t WGLocalSizeZ;
 } 
 
 /**
@@ -1181,7 +1234,7 @@ extern llvm::cl::list<int> LocalSize;
  */
 static llvm::Module*
 kernel_library
-(cl_device_id device, llvm::Module* root)
+(cl_device_id device)
 {
   llvm::MutexGuard lockHolder(kernelCompilerLock);
   InitializeLLVM();
@@ -1212,6 +1265,16 @@ kernel_library
           kernellib += "cellspu";
         }
 #endif
+#ifdef BUILD_HSA
+      else if (triple.getArch() == Triple::hsail64) {
+          kernellib += "hsail64";
+      }
+#endif
+#ifdef AMDGCN_ENABLED
+      else if (triple.getArch() == Triple::amdgcn) {
+          kernellib += "amdgcn";
+      }
+#endif
       else 
         {
           kernellib += "host";
@@ -1228,6 +1291,8 @@ kernel_library
       kernellib += ".bc";
     }
 
+  POCL_MSG_PRINT_INFO("using %s as the built-in lib.\n", kernellib.c_str());
+
   SMDiagnostic Err;
   llvm::Module *lib = ParseIRFile(kernellib.c_str(), Err, *GlobalContext());
   assert (lib != NULL);
@@ -1239,19 +1304,32 @@ kernel_library
 /* This is used to control the kernel we want to process in the kernel compilation. */
 extern cl::opt<std::string> KernelName;
 
-int pocl_llvm_generate_workgroup_function(cl_device_id device,
-                                          cl_kernel kernel,
-                                          size_t local_x, size_t local_y, size_t local_z,
-                                          const char* parallel_filename,
-                                          const char* kernel_filename)
+int pocl_llvm_generate_workgroup_function(cl_device_id device, cl_kernel kernel,
+                                          size_t local_x, size_t local_y, size_t local_z)
 {
+  cl_program program = kernel->program;
+  int device_i = pocl_cl_device_to_index(program, device);
+  assert(device_i >= 0);
+
+  char parallel_bc_path[POCL_FILENAME_LENGTH];
+  pocl_cache_work_group_function_path(parallel_bc_path, program, device_i, kernel, local_x, local_y, local_z);
+
+  if (pocl_exists(parallel_bc_path))
+    return CL_SUCCESS;
+
+  char final_binary_path[POCL_FILENAME_LENGTH];
+  pocl_cache_final_binary_path(final_binary_path, program, device_i, kernel, local_x, local_y, local_z);
+
+  if (pocl_exists(final_binary_path))
+    return CL_SUCCESS;
+
   llvm::MutexGuard lockHolder(kernelCompilerLock);
   InitializeLLVM();
 
 #ifdef DEBUG_POCL_LLVM_API        
   printf("### calling the kernel compiler for kernel %s local_x %zu "
          "local_y %zu local_z %zu parallel_filename: %s\n",
-         kernel->name, local_x, local_y, local_z, parallel_filename);
+         kernel->name, local_x, local_y, local_z, parallel_bc_path);
 #endif
 
   Triple triple(device->llvm_target_triplet);
@@ -1262,75 +1340,90 @@ int pocl_llvm_generate_workgroup_function(cl_device_id device,
   // Link the kernel and runtime library
   llvm::Module *input = NULL;
   if (kernel->program->llvm_irs != NULL && 
-      kernel->program->llvm_irs[device->dev_id] != NULL) 
+      kernel->program->llvm_irs[device_i] != NULL)
     {
 #ifdef DEBUG_POCL_LLVM_API        
       printf("### cloning the preloaded LLVM IR\n");
 #endif
       input = 
         llvm::CloneModule
-        ((llvm::Module*)kernel->program->llvm_irs[device->dev_id]);
+        ((llvm::Module*)kernel->program->llvm_irs[device_i]);
     }
   else
     {
 #ifdef DEBUG_POCL_LLVM_API        
       printf("### loading the kernel bitcode from disk\n");
 #endif
-      input = ParseIRFile(kernel_filename, Err, *GlobalContext());
+      char program_bc_path[POCL_FILENAME_LENGTH];
+      pocl_cache_program_bc_path(program_bc_path, program, device_i);
+      input = ParseIRFile(program_bc_path, Err, *GlobalContext());
     }
 
   // Later this should be replaced with indexed linking of source code
   // and/or bitcode for each kernel.
-  llvm::Module *libmodule = kernel_library(device, input);
+  llvm::Module *libmodule = kernel_library(device);
   assert (libmodule != NULL);
   link(input, libmodule);
 
   /* Now finally run the set of passes assembled above */
   // TODO pass these as parameters instead, this is not thread safe!
-  pocl::LocalSize.clear();
-  pocl::LocalSize.addValue(local_x);
-  pocl::LocalSize.addValue(local_y);
-  pocl::LocalSize.addValue(local_z);
+  pocl::WGLocalSizeX = local_x;
+  pocl::WGLocalSizeY = local_y;
+  pocl::WGLocalSizeZ = local_z;
   KernelName = kernel->name;
 
 #if (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
   kernel_compiler_passes(device, input->getDataLayout()).run(*input);
+#elif (defined LLVM_OLDER_THAN_3_7)
+  kernel_compiler_passes(
+      device,
+      input->getDataLayout()->getStringRepresentation()).run(*input);
 #else
-  kernel_compiler_passes(device,
-                         input->getDataLayout()->getStringRepresentation())
-                        .run(*input);
+  kernel_compiler_passes(
+      device,
+      input->getDataLayout().getStringRepresentation())
+      .run(*input);
 #endif
-
   // TODO: don't write this once LLC is called via API, not system()
-  int fd;
-  if ((fd = open(parallel_filename, (O_CREAT | O_EXCL | O_WRONLY),
-      (S_IRUSR | S_IWUSR))) >= 0)
-    write_temporary_file_fd(input, parallel_filename, fd);
-
-#ifndef LLVM_3_2
-  // In LLVM 3.2 the Linker object deletes the associated Modules.
-  // If we delete here, it will crash.
-  /* OPTIMIZE: store the fully linked work-group function llvm::Module 
-     and pass it to code generation without writing to disk. */
-#endif
+  pocl_cache_write_kernel_parallel_bc(input, program, device_i, kernel,
+                                  local_x, local_y, local_z);
 
   return 0;
 }
 
-void
+int
 pocl_update_program_llvm_irs(cl_program program,
-                             cl_device_id device, const char* program_filename)
+                             unsigned device_i,
+                             cl_device_id device)
 {
   SMDiagnostic Err;
 
-  program->llvm_irs[device->dev_id] =
-              ParseIRFile(program_filename, Err, *GlobalContext());
+  char program_bc_path[POCL_FILENAME_LENGTH];
+  pocl_cache_program_bc_path(program_bc_path, program, device_i);
+
+  if (!pocl_exists(program_bc_path))
+    return -1;
+
+  program->llvm_irs[device_i] =
+              ParseIRFile(program_bc_path, Err, *GlobalContext());
+  return 0;
+}
+
+void pocl_free_llvm_irs(cl_program program, int device_i)
+{
+    if (program->llvm_irs[device_i]) {
+        llvm::Module *mod = (llvm::Module *)program->llvm_irs[device_i];
+        delete mod;
+        program->llvm_irs[device_i] = NULL;
+    }
 }
 
 void pocl_llvm_update_binaries (cl_program program) {
 
   llvm::MutexGuard lockHolder(kernelCompilerLock);
   InitializeLLVM();
+  char program_bc_path[POCL_FILENAME_LENGTH];
+  void* cache_lock = NULL;
 
   // Dump the LLVM IR Modules to memory buffers. 
   assert (program->llvm_irs != NULL);
@@ -1341,35 +1434,28 @@ void pocl_llvm_update_binaries (cl_program program) {
    for (size_t i = 0; i < program->num_devices; ++i)
     {
       assert (program->llvm_irs[i] != NULL);
+      if (program->binaries[i])
+          continue;
 
-      std::string binary_filename =
-        std::string(program->cache_dir) + "/" +
-        program->devices[i]->cache_dir_name + "/" +
-        POCL_PROGRAM_BC_FILENAME;
-
-      update_temporary_file((llvm::Module*)program->llvm_irs[i],
-                           binary_filename.c_str()); 
-
-      FILE *binary_file = fopen(binary_filename.c_str(), "r");
-      if (binary_file == NULL)        
-        POCL_ABORT("Failed opening the binary file.");
+      cache_lock = pocl_cache_acquire_writer_lock_i(program, i);
 
-      fseek(binary_file, 0, SEEK_END);
-      
-      program->binary_sizes[i] = ftell(binary_file);
-      fseek(binary_file, 0, SEEK_SET);
+      pocl_cache_program_bc_path(program_bc_path, program, i);
+      pocl_write_module((llvm::Module*)program->llvm_irs[i], program_bc_path, 1);
 
-      unsigned char *binary = (unsigned char *) malloc(program->binary_sizes[i]);
-      if (binary == NULL)
-        POCL_ABORT("Failed allocating memory for the binary.");
+      std::string content;
+      llvm::raw_string_ostream sos(content);
+      WriteBitcodeToFile((llvm::Module*)program->llvm_irs[i], sos);
+      sos.str(); // flush
 
-      size_t n = fread(binary, 1, program->binary_sizes[i], binary_file);
+      size_t n = content.size();
       if (n < program->binary_sizes[i])
-        POCL_ABORT("Failed reading the binary from disk to memory.");
-      program->binaries[i] = binary;
-
-      fclose (binary_file);
+        POCL_ABORT("binary size doesn't match the expected value");
+      if (program->binaries[i])
+          POCL_MEM_FREE(program->binaries[i]);
+      program->binaries[i] = (unsigned char *) malloc(n);
+      std::memcpy(program->binaries[i], content.c_str(), n);
 
+      pocl_cache_release_lock(cache_lock);
 #ifdef DEBUG_POCL_LLVM_API        
       printf("### binary for device %zi was of size %zu\n", i, program->binary_sizes[i]);
 #endif
@@ -1377,8 +1463,11 @@ void pocl_llvm_update_binaries (cl_program program) {
     }
 }
 
-int
-pocl_llvm_get_kernel_names( cl_program program, const char **knames, unsigned max_num_krn )
+/* This is the implementation of the public pocl_llvm_get_kernel_count(),
+ * and is used internally also by pocl_llvm_get_kernel_names to
+ */
+unsigned
+pocl_llvm_get_kernel_count(cl_program program, llvm::NamedMDNode **md_ret)
 {
   llvm::MutexGuard lockHolder(kernelCompilerLock);
   InitializeLLVM();
@@ -1387,10 +1476,29 @@ pocl_llvm_get_kernel_names( cl_program program, const char **knames, unsigned ma
   // has the same set of programs & kernels?
   llvm::Module *mod = (llvm::Module *) program->llvm_irs[0];
   llvm::NamedMDNode *md = mod->getNamedMetadata("opencl.kernels");
-  assert(md);
 
-  unsigned i;
-  for (i=0; i<md->getNumOperands(); i++) {
+  if (md_ret)
+    *md_ret = md;
+
+  if (md == NULL)
+    return 0;
+
+  return md->getNumOperands();
+}
+
+unsigned
+pocl_llvm_get_kernel_count(cl_program program)
+{
+  return pocl_llvm_get_kernel_count(program, NULL);
+}
+
+unsigned
+pocl_llvm_get_kernel_names( cl_program program, const char **knames, unsigned max_num_krn )
+{
+  llvm::NamedMDNode *md;
+  unsigned i, n = pocl_llvm_get_kernel_count(program, &md);
+
+  for (i=0; i<n; i++) {
     assert( md->getOperand(i)->getOperand(0) != NULL);
 #ifdef LLVM_OLDER_THAN_3_6
     llvm::Function *k = cast<Function>(md->getOperand(i)->getOperand(0));
@@ -1415,28 +1523,27 @@ pocl_llvm_codegen(cl_kernel kernel,
                   const char *outfilename)
 {
     SMDiagnostic Err;
-#if defined LLVM_3_2 || defined LLVM_3_3
-    std::string error;
-    tool_output_file outfile(outfilename, error, 0);
-#elif defined LLVM_3_4 || defined LLVM_3_5
-    std::string error;
-    tool_output_file outfile(outfilename, error, F_Binary);
-#else
-    std::error_code error;
-    tool_output_file outfile(outfilename, error, F_Binary);
-#endif
+
+    if (pocl_exists(outfilename))
+      return 0;
+
     llvm::Triple triple(device->llvm_target_triplet);
     llvm::TargetMachine *target = GetTargetMachine(device);
     llvm::Module *input = ParseIRFile(infilename, Err, *GlobalContext());
 
-    llvm::PassManager PM;
+    PassManager PM;
+#ifdef LLVM_OLDER_THAN_3_7
     llvm::TargetLibraryInfo *TLI = new TargetLibraryInfo(triple);
     PM.add(TLI);
+#else
+    llvm::TargetLibraryInfoWrapperPass *TLIPass = new TargetLibraryInfoWrapperPass(triple);
+    PM.add(TLIPass);
+#endif
     if (target != NULL) {
 #if defined LLVM_3_2
       PM.add(new TargetTransformInfo(target->getScalarTargetTransformInfo(),
                                      target->getVectorTargetTransformInfo()));
-#else
+#elif (defined LLVM_OLDER_THAN_3_7)
       target->addAnalysisPasses(PM);
 #endif
     }
@@ -1452,15 +1559,23 @@ pocl_llvm_codegen(cl_kernel kernel,
         PM.add(new DataLayout(input));
 #endif
     // TODO: better error check
-    formatted_raw_ostream FOS(outfile.os());
+#ifdef LLVM_OLDER_THAN_3_7
+    std::string data;
+    llvm::raw_string_ostream sos(data);
     llvm::MCContext *mcc;
-    if(target->addPassesToEmitMC(PM, mcc, FOS))
-        return 1;
+    if (target && target->addPassesToEmitMC(PM, mcc, sos))
+      return 1;
+#else
+    SmallVector<char, 4096> data;
+    llvm::raw_svector_ostream sos(data);
+    if (target && target->addPassesToEmitFile(
+        PM, sos, TargetMachine::CGFT_ObjectFile))
+      return 1;
+#endif
 
     PM.run(*input);
-    outfile.keep();
+    std::string o = sos.str(); // flush
+    return pocl_write_file(outfilename, o.c_str(), o.size(), 0, 0);
 
-    return 0;
 }
 /* vim: set ts=4 expandtab: */
-
diff --git a/lib/CL/pocl_queue_util.c b/lib/CL/pocl_queue_util.c
new file mode 100644
index 0000000..6e3c6b4
--- /dev/null
+++ b/lib/CL/pocl_queue_util.c
@@ -0,0 +1,131 @@
+/* Command queue management functions
+
+   Copyright (c) 2015 Giuseppe Bilotta
+   
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+   
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+   
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+*/
+
+/* We keep a global list of all 'live' command queues in order to be able
+ * to force a clFinish on all of them before this is triggered by the destructors
+ * at program end, which happen in unspecified order and might cause all sorts
+ * of issues. This header defines the signatures of the available functions
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "pocl_debug.h"
+#include "pocl_queue_util.h"
+
+static pocl_lock_t queue_lock = POCL_LOCK_INITIALIZER;
+static size_t queue_size = 0;
+static size_t queue_alloc = 0;
+static cl_command_queue *queue_list = NULL;
+
+#define QUEUE_ALLOC_SIZE 256
+
+void pocl_finish_all_queues()
+{
+  size_t i;
+  for (i = 0; i < queue_size; ++i) {
+    if (queue_list[i])
+      POname(clFinish)(queue_list[i]);
+  }
+}
+
+void pocl_init_queue_list()
+{
+  POCL_INIT_LOCK(queue_lock);
+
+  POCL_LOCK(queue_lock);
+  // will probably never need a realloc, but still
+  queue_alloc = QUEUE_ALLOC_SIZE;
+
+  queue_list = calloc(queue_alloc, sizeof(cl_command_queue));
+
+  if (!queue_list)
+    POCL_ABORT("unable to allocate queue list!");
+
+  atexit(pocl_finish_all_queues);
+
+  POCL_UNLOCK(queue_lock);
+
+}
+
+// walk the queue list, 
+void pocl_compact_queue_list() {
+  size_t i; // walking index
+  size_t compact = 0; // number of non-NULL elements
+  for (i = 0; i < queue_size; ++i) {
+    if (queue_list[i])
+      compact++;
+    else {
+      // look for the first next non-NULL
+      while (i < queue_size && queue_list[i] == NULL)
+        ++i;
+      if (i == queue_size)
+        break; // no more entries
+      // move stuff over
+      memmove(queue_list + compact + 1, queue_list + i,
+        (queue_size - i + 1)*sizeof(*queue_list));
+      queue_size -= i - compact; // number of NULLs compacted
+      i = compact + 1;
+    }
+  }
+  queue_size = compact + 1;
+}
+
+void pocl_queue_list_insert(cl_command_queue q)
+{
+  POCL_LOCK(queue_lock);
+  if (queue_size == queue_alloc) {
+    // queue is full, try and compact it by removing the deleted queues
+    pocl_compact_queue_list();
+  }
+
+  if (queue_size == queue_alloc) {
+    // compaction failed to give us room
+    cl_command_queue *resized = realloc(queue_list, queue_alloc + 256);
+    if (!resized)
+      POCL_ABORT("failed to enlarge queue list!");
+    queue_list = resized;
+    queue_alloc += 256;
+  }
+
+  queue_list[queue_size++] = q;
+  POCL_UNLOCK(queue_lock);
+}
+
+void pocl_queue_list_delete(cl_command_queue q)
+{
+  POCL_LOCK(queue_lock);
+  size_t i;
+  for (i = 0; i < queue_size; ++i) {
+    if (queue_list[i] == q) {
+      queue_list[i] = NULL;
+      goto unlock;
+    }
+  }
+  // not found (?)
+  POCL_MSG_WARN("command queue %p not found during deletion\n", q);
+
+unlock:
+  POCL_UNLOCK(queue_lock);
+  return;
+}
+
diff --git a/lib/CL/devices/topology/pocl_topology.h b/lib/CL/pocl_queue_util.h
similarity index 63%
copy from lib/CL/devices/topology/pocl_topology.h
copy to lib/CL/pocl_queue_util.h
index 4f0a95b..f8e905a 100644
--- a/lib/CL/devices/topology/pocl_topology.h
+++ b/lib/CL/pocl_queue_util.h
@@ -1,6 +1,6 @@
-/* pocl_topology.h - retrieving the topology of OpenCL devices
+/* Command queue management functions
 
-   Copyright (c) 2012 Cyril Roelandt and Pekka Jääskeläinen
+   Copyright (c) 2015 Giuseppe Bilotta
    
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
@@ -21,22 +21,36 @@
    THE SOFTWARE.
 */
 
-/**
- * Functionality for using the hwloc library for automatically detecting
- * the device characteristics and filling the info to the device structure to
- * make the info accessible to the clGetDeviceInfo() etc.
- *
- * http://www.open-mpi.org/projects/hwloc/
+/* We keep a global list of all 'live' command queues in order to be able
+ * to force a clFinish on all of them before this is triggered by the destructors
+ * at program end, which happen in unspecified order and might cause all sorts
+ * of issues. This header defines the signatures of the available functions
  */
-#ifndef POCL_TOPOLOGY_H
-#define POCL_TOPOLOGY_H
 
-#include "pocl_cl.h"
+#ifndef POCL_QUEUE_H
+#define POCL_QUEUE_H
 
-#define MIN_MAX_MEM_ALLOC_SIZE (128*1024*1024)
+#include "pocl_cl.h"
 
+#ifdef __GNUC__
 #pragma GCC visibility push(hidden)
-void pocl_topology_detect_device_info(cl_device_id device);
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void pocl_init_queue_list();
+void pocl_queue_list_insert(cl_command_queue );
+void pocl_queue_list_delete(cl_command_queue );
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef __GNUC__
 #pragma GCC visibility pop
+#endif
+
 
-#endif /* POCL_TOPOLOGY_H */
+#endif
diff --git a/lib/CL/pocl_util.c b/lib/CL/pocl_util.c
index 437a8d2..1edaf73 100644
--- a/lib/CL/pocl_util.c
+++ b/lib/CL/pocl_util.c
@@ -1,17 +1,17 @@
 /* OpenCL runtime library: pocl_util utility functions
 
    Copyright (c) 2012 Pekka Jääskeläinen / Tampere University of Technology
-   
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -39,14 +39,12 @@
 #endif
 
 #include "pocl_util.h"
+#include "pocl_llvm.h"
 #include "utlist.h"
 #include "common.h"
 #include "pocl_mem_management.h"
 #include "pocl_runtime_config.h"
 
-
-#define CACHE_DIR_PATH_CHARS 512
-
 struct list_item;
 
 typedef struct list_item
@@ -55,118 +53,10 @@ typedef struct list_item
   struct list_item *next;
 } list_item;
 
-void 
-pocl_remove_directory (const char *path_name)
-{
-  int str_size = 10 + strlen(path_name) + 1;
-  char *cmd = (char*)malloc(str_size);
-  snprintf(cmd, str_size, "rm -fr '%s'", path_name);
-  system(cmd);
-  POCL_MEM_FREE(cmd);
-}
-
-void
-pocl_remove_file (const char *file_path)
-{
-  int str_size = 10 + strlen(file_path) + 1;
-  char *cmd = (char*)malloc(str_size);
-  snprintf(cmd, str_size, "rm -f '%s'", file_path);
-  system(cmd);
-  POCL_MEM_FREE(cmd);
-}
-
-void
-pocl_make_directory (const char *path_name)
-{
-  int str_size = 12 + strlen(path_name) + 1;
-  char *cmd = (char*)malloc(str_size);
-  snprintf(cmd, str_size, "mkdir -p '%s'", path_name);
-  system(cmd);
-  POCL_MEM_FREE(cmd);
-}
-
-void
-pocl_create_or_append_file (const char *file_name, const char *content)
-{
-  FILE *fp = fopen(file_name, "a");
-  if ((fp == NULL) || (content == NULL))
-    return;
-
-  fprintf(fp, "%s", content);
-
-  fclose(fp);
-}
-
-int
-pocl_read_text_file (const char* file_name, char** content_dptr)
-{
-  FILE *fp;
-  struct stat st;
-  int file_size;
-
-  stat(file_name, &st);
-  file_size = (int)st.st_size;
-
-  fp = fopen(file_name, "r");
-  if (fp == NULL)
-    return 0;
-
-  *content_dptr = (char*) malloc((file_size + 1) * sizeof(char));
-  if (!(*content_dptr)) return 0;
-
-  int read = fread(*content_dptr, sizeof(char), file_size, fp);
-  (*content_dptr)[file_size] = '\0';
-
-  return read;
-}
-
-char*
-pocl_create_program_cache_dir(cl_program program)
-{
-  char *tmp_path = NULL, *cache_path = NULL;
-  char hash_str[SHA1_DIGEST_SIZE * 2 + 1];
-  int i;
-
-  for (i = 0; i < SHA1_DIGEST_SIZE; i++)
-    sprintf(&hash_str[i*2], "%02x", (unsigned int) program->build_hash[i]);
-
-  cache_path = (char*)malloc(CACHE_DIR_PATH_CHARS);
-
-  tmp_path = getenv("POCL_CACHE_DIR");
-  if (tmp_path && (access(tmp_path, W_OK) == 0))
-    {
-      snprintf(cache_path, CACHE_DIR_PATH_CHARS, "%s/%s", tmp_path, hash_str);
-    }
-  else
-    {
-#ifdef POCL_ANDROID
-      snprintf(cache_path, CACHE_DIR_PATH_CHARS,
-                  "/data/data/%s/cache/", pocl_get_process_name());
-
-      if (access(cache_path, W_OK) == 0)
-        strcat(cache_path, hash_str);
-      else
-        snprintf(cache_path, CACHE_DIR_PATH_CHARS, "/sdcard/pocl/kcache/%s", hash_str);
-#else
-      tmp_path = getenv("HOME");
-
-      if (tmp_path)
-        snprintf(cache_path, CACHE_DIR_PATH_CHARS, "%s/.pocl/kcache/%s", tmp_path, hash_str);
-      else
-        snprintf(cache_path, CACHE_DIR_PATH_CHARS, "/tmp/pocl/kcache/%s", hash_str);
-#endif
-    }
-
-  if (access(cache_path, F_OK) != 0)
-    pocl_make_directory(cache_path);
-
-    return cache_path;
-}
-
 uint32_t
-byteswap_uint32_t (uint32_t word, char should_swap) 
+byteswap_uint32_t (uint32_t word, char should_swap)
 {
-    union word_union 
+    union word_union
     {
         uint32_t full_word;
         unsigned char bytes[4];
@@ -182,9 +72,9 @@ byteswap_uint32_t (uint32_t word, char should_swap)
 }
 
 float
-byteswap_float (float word, char should_swap) 
+byteswap_float (float word, char should_swap)
 {
-    union word_union 
+    union word_union
     {
         float full_word;
         unsigned char bytes[4];
@@ -223,7 +113,7 @@ void *
 pocl_aligned_malloc (size_t alignment, size_t size)
 {
 # ifdef HAVE_POSIX_MEMALIGN
-  
+
   /* make sure that size is a multiple of alignment, as posix_memalign
    * does not perform this test, whereas aligned_alloc does */
   if ((size & (alignment - 1)) != 0)
@@ -237,7 +127,7 @@ pocl_aligned_malloc (size_t alignment, size_t size)
     alignment = sizeof(void* );
 
   void* result;
-  
+
   result = pocl_memalign_alloc(alignment, size);
   if (result == NULL)
     {
@@ -248,7 +138,7 @@ pocl_aligned_malloc (size_t alignment, size_t size)
   return result;
 
 # else
-  
+
   /* allow zero-sized allocations, force alignment to 1 */
   if (!size)
     alignment = 1;
@@ -268,7 +158,7 @@ pocl_aligned_malloc (size_t alignment, size_t size)
     return NULL;
 
   /* align the address, and store original pointer for future use
-   * with free in the preceeding bytes */
+   * with free in the preceding bytes */
   uintptr_t aligned_address = (address + mask + sizeof(void *)) & ~mask;
   void** address_ptr = (void **)(aligned_address - sizeof(void *));
   *address_ptr = (void *)address;
@@ -288,17 +178,24 @@ pocl_aligned_free (void *ptr)
 }
 #endif
 
-cl_int pocl_create_event (cl_event *event, cl_command_queue command_queue, 
+cl_int pocl_create_event (cl_event *event, cl_context context,
+                          cl_command_queue command_queue,
                           cl_command_type command_type)
 {
+  if (context == NULL || !(context->valid))
+    return CL_INVALID_CONTEXT;
   if (event != NULL)
     {
       *event = pocl_mem_manager_new_event ();
       if (event == NULL)
         return CL_OUT_OF_HOST_MEMORY;
-      
+
+      (*event)->context = context;
+      POname(clRetainContext) (context);
       (*event)->queue = command_queue;
-      POname(clRetainCommandQueue) (command_queue);
+      /* user events have a NULL command queue, don't retain it */
+      if (command_queue)
+        POname(clRetainCommandQueue) (command_queue);
       (*event)->command_type = command_type;
       (*event)->callback_list = NULL;
       (*event)->implicit_event = 0;
@@ -308,34 +205,53 @@ cl_int pocl_create_event (cl_event *event, cl_command_queue command_queue,
 }
 
 cl_int pocl_create_command (_cl_command_node **cmd,
-                            cl_command_queue command_queue, 
-                            cl_command_type command_type, cl_event *event_p, 
+                            cl_command_queue command_queue,
+                            cl_command_type command_type, cl_event *event_p,
                             cl_int num_events, const cl_event *wait_list)
 {
   int i;
   int err;
   cl_event *event = NULL;
+  /* the provided waiting list will be cloned, because the calling program
+   * might recycle the array for a different command.
+   */
+  cl_event *event_wl = NULL;
+  /* Additionally, if the command queue is non-empty and in-order, we want to
+   * add the previous command to the waiting list: double-bang to ensure that
+   * add_prev_command will be 1 in this case, and 0 otherwise
+   */
+  cl_int add_prev_command = !!(
+    !(command_queue->properties & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE)
+    && command_queue->root != NULL);
 
   if ((wait_list == NULL && num_events != 0) ||
       (wait_list != NULL && num_events == 0))
     return CL_INVALID_EVENT_WAIT_LIST;
-  
+
   for (i = 0; i < num_events; ++i)
     {
       if (wait_list[i] == NULL)
         return CL_INVALID_EVENT_WAIT_LIST;
     }
-  
+
   *cmd = pocl_mem_manager_new_command ();
 
   if (*cmd == NULL)
     return CL_OUT_OF_HOST_MEMORY;
-  
+
+  if (num_events || add_prev_command)
+    {
+      event_wl = (cl_event*)malloc((num_events + add_prev_command)*sizeof(cl_event));
+      if (event_wl == NULL)
+        return CL_OUT_OF_HOST_MEMORY;
+    }
+
   /* if user does not provide event pointer, create event anyway */
   event = &((*cmd)->event);
-  err = pocl_create_event(event, command_queue, command_type);
+  err = pocl_create_event(event, command_queue->context, command_queue, command_type);
   if (err != CL_SUCCESS)
     {
+      POCL_MEM_FREE(event_wl);
       POCL_MEM_FREE(*cmd);
       return err;
     }
@@ -343,40 +259,36 @@ cl_int pocl_create_command (_cl_command_node **cmd,
     *event_p = *event;
   else
     (*event)->implicit_event = 1;
-  
-  /* if in-order command queue and queue is not empty, add event from 
-     previous command to new commands event_waitlist */
-  if (!(command_queue->properties & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) 
-      && command_queue->root != NULL)
+
+  /* clone the event list */
+  for (i = 0; i < num_events; ++i)
     {
+      event_wl[i] = wait_list[i];
+    }
+
+  if (add_prev_command)
+    {
+      // find the previous command
       _cl_command_node *prev_command;
       for (prev_command = command_queue->root; prev_command->next != NULL;
            prev_command = prev_command->next){}
       //printf("create_command: prev_com=%d prev_com->event = %d \n",prev_command, prev_command->event);
-      cl_event *new_wl = (cl_event*)malloc ((num_events +1)*sizeof (cl_event));
-      for (i = 0; i < num_events; ++i)
-        {
-          new_wl[i] = wait_list[i];
-        }
-      new_wl[i] = prev_command->event;
-      (*cmd)->event_wait_list = new_wl;
-      (*cmd)->num_events_in_wait_list = num_events + 1;
-      for (i = 0; i < num_events + 1; ++i)
-        {
-          //printf("create-command: new_wl[%i]=%d\n", i, new_wl[i]);
-        }
+      event_wl[i] = prev_command->event;
     }
-  else
+#if 0
+  for (i = 0; i < num_events + add_prev_command; ++i)
     {
-      (*cmd)->event_wait_list = wait_list;  
-      (*cmd)->num_events_in_wait_list = num_events;
+      printf("create-command: event_wl[%i]=%p\n", i, event_wl[i]);
     }
+#endif
+  (*cmd)->event_wait_list = event_wl;
+  (*cmd)->num_events_in_wait_list = num_events + add_prev_command;
   (*cmd)->type = command_type;
   (*cmd)->next = NULL;
   (*cmd)->device = command_queue->device;
 
   //printf("create_command (end): event=%d new_event=%d cmd->event=%d cmd=%d\n", event, new_event, (*cmd)->event, *cmd);
-  
+
 
   return CL_SUCCESS;
 }
@@ -391,107 +303,10 @@ void pocl_command_enqueue (cl_command_queue command_queue,
   if (pocl_is_option_set("POCL_IMPLICIT_FINISH"))
     POclFinish (command_queue);
   #endif
-  POCL_UPDATE_EVENT_QUEUED (&node->event, command_queue);
-
-}
-
-char* pocl_get_process_name ()
-{
-  char tmpStr[64], cmdline[512], *processName = NULL;
-  FILE *statusFile;
-  int len, i, begin;
-
-  snprintf(tmpStr, 64, "/proc/%d/cmdline", getpid());
-  statusFile = fopen(tmpStr, "r");
-  if (statusFile == NULL)
-    return NULL;
-
-  if (fgets(cmdline, 511, statusFile) != NULL)
-    {
-      len = strlen(cmdline);
-      begin = 0;
-      for (i=len-1; i>=0; i--)     /* Extract program-name after last '/' */
-        {
-          if (cmdline[i] == '/')
-            {
-              begin = i + 1;
-              break;
-            }
-        }
-      processName = strdup(cmdline + begin);
-    }
-
-  fclose(statusFile);
-  return processName;
-}
-
-static int cache_lock_initialized = 0;
-static pocl_lock_t cache_lock = POCL_LOCK_INITIALIZER;
-
-void
-pocl_check_and_invalidate_cache (cl_program program,
-                  int device_i, const char* device_tmpdir)
-{
-  int cache_dirty = 0;
-  char *content = NULL, *s_ptr, *ss_ptr;
-  int read = 0;
-
-  POCL_LOCK(cache_lock);
-
-  if (!pocl_get_bool_option("POCL_KERNEL_CACHE", POCL_BUILD_KERNEL_CACHE))
-    {
-      cache_dirty = 1;
-      goto bottom;
-    }
-
-  /* If program contains "#include", disable caching
-     Included headers might get modified, force recompilation in all the cases
-     Yes, this is a very dirty way to find "# include"
-     but we can live with this for now
-   */
-  if (!pocl_get_bool_option("POCL_KERNEL_CACHE_IGNORE_INCLUDES", 0) &&
-      program->source)
-    {
-      for (s_ptr = program->source; (*s_ptr); s_ptr++)
-        {
-          if ((*s_ptr) == '#')
-            {
-              /* Skip all the white-spaces between # & include */
-              for (ss_ptr = s_ptr+1; *ss_ptr == ' '; ss_ptr++) ;
-              
-              if (strncmp(ss_ptr, "include", 7) == 0)
-                cache_dirty = 1;
-            }
-        }
-    }
-
-  bottom:
-  if (cache_dirty)
-    {
-      pocl_remove_directory(device_tmpdir);
-      mkdir(device_tmpdir, S_IRWXU);
-    }
+  POCL_UPDATE_EVENT_QUEUED (&node->event);
 
-  POCL_UNLOCK(cache_lock);
 }
 
-void pocl_touch_file(const char* file_name)
-{
-  struct stat file_stat;
-  struct utimbuf new_time;
-
-  if (access(file_name, F_OK) != 0)
-    {
-      FILE *fp = fopen(file_name, "w");
-      fclose(fp);
-    }
-
-  stat(file_name, &file_stat);
-
-  new_time.actime = file_stat.st_atime;
-  new_time.modtime = time(NULL);        /* set mtime to current time */
-  utime(file_name, &new_time);
-}
 
 
 int pocl_buffer_boundcheck(cl_mem buffer, size_t offset, size_t size) {
@@ -700,3 +515,39 @@ check_copy_overlap(const size_t src_offset[3],
 
   return overlap;
 }
+
+
+/* Make a list of unique devices. If any device is a subdevice,
+ * replace with parent, then remove duplicate parents. */
+cl_device_id * pocl_unique_device_list(const cl_device_id * in, cl_uint num, cl_uint *real)
+{
+  cl_uint real_num = num;
+  cl_device_id * out = calloc(num, sizeof(cl_device_id));
+  if (!out)
+    return NULL;
+
+  unsigned i;
+  for (i=0; i < num; ++i)
+    out[i] = (in[i] ? POCL_REAL_DEV(in[i]) : NULL);
+
+  i=1;
+  unsigned device_i=0;
+  while (i < real_num)
+    {
+      device_i=0;
+      while (device_i < i)
+        {
+          if (out[device_i] == out[i])
+            {
+              out[device_i] = out[--real_num];
+              out[real_num] = NULL;
+            }
+          else
+            device_i++;
+        }
+      i++;
+    }
+
+  *real = real_num;
+  return out;
+}
diff --git a/lib/CL/pocl_util.h b/lib/CL/pocl_util.h
index 1ade431..0be780c 100644
--- a/lib/CL/pocl_util.h
+++ b/lib/CL/pocl_util.h
@@ -29,24 +29,14 @@
 #include <string.h>
 #include "pocl_cl.h"
 
+#ifdef __GNUC__
 #pragma GCC visibility push(hidden)
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-void pocl_remove_directory (const char *path_name);
-void pocl_remove_file (const char *file_path);
-void pocl_make_directory (const char *path_name);
-
-/**
- * Assign a directory for program based on already computed SHA
- * Create the directory if not present
- * \param program the program for which a path is needed
- *
- * \return a string allocated on the heap
- */
-char* pocl_create_program_cache_dir(cl_program program);
-
 uint32_t byteswap_uint32_t (uint32_t word, char should_swap);
 float byteswap_float (float word, char should_swap);
 
@@ -70,7 +60,8 @@ void pocl_aligned_free(void* ptr);
 #endif
 
 /* Function for creating events */
-cl_int pocl_create_event (cl_event *event, cl_command_queue command_queue,
+cl_int pocl_create_event (cl_event *event, cl_context context,
+                          cl_command_queue command_queue,
                           cl_command_type command_type);
 
 cl_int pocl_create_command (_cl_command_node **cmd,
@@ -82,19 +73,6 @@ cl_int pocl_create_command (_cl_command_node **cmd,
 void pocl_command_enqueue (cl_command_queue command_queue,
                           _cl_command_node *node);
 
-/* Function to get current process name */
-char* pocl_get_process_name ();
-
-/* File utility functions */
-void pocl_create_or_append_file (const char* file_name, const char* content);
-
-/* Allocates memory and places file contents in it. Returns number of chars read */
-int pocl_read_text_file (const char* file_name, char** content_dptr);
-
-void pocl_check_and_invalidate_cache (cl_program program, int device_i, const char* device_tmpdir);
-
-/* Touch file to change last modified time */
-void pocl_touch_file(const char* file_name);
 
 /* does several sanity checks on buffer & given memory region */
 int pocl_buffer_boundcheck(cl_mem buffer, size_t offset, size_t size);
@@ -115,10 +93,29 @@ check_copy_overlap(const size_t src_offset[3],
                    const size_t region[3],
                    const size_t row_pitch, const size_t slice_pitch);
 
+/* Helpers for dealing with devices / subdevices */
+
+#define POCL_REAL_DEV(dev) (dev->parent_device ? dev->parent_device : dev)
+
+cl_device_id * pocl_unique_device_list(const cl_device_id * in, cl_uint num, cl_uint *real);
+
+#define POCL_CHECK_DEV_IN_CMDQ                                               \
+  device = command_queue->device;                                            \
+  for (i = 0; i < command_queue->context->num_devices; ++i)                  \
+    {                                                                        \
+      if (command_queue->context->devices[i] == POCL_REAL_DEV(device))       \
+        break;                                                               \
+    }                                                                        \
+  assert(i < command_queue->context->num_devices);
+
+
 #ifdef __cplusplus
 }
 #endif
+
+#ifdef __GNUC__
 #pragma GCC visibility pop
+#endif
 
 /* Common macro for cleaning up "*GetInfo" API call implementations.
  * All the *GetInfo functions have been specified to look alike, 
@@ -155,4 +152,11 @@ check_copy_overlap(const size_t src_offset[3],
                 *(__TYPE__*)param_value=__VALUE__)                      \
   }
 
+#define POCL_RETURN_GETINFO_ARRAY(__TYPE__, __NUM__, __VALUE__)         \
+  {                                                                     \
+    size_t const value_size = __NUM__*sizeof(__TYPE__);                 \
+    POCL_RETURN_GETINFO_INNER(value_size,                               \
+                memcpy(param_value, __VALUE__, value_size))             \
+  }
+
 #endif
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 78a9aa4..091a448 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -25,7 +25,6 @@
 
 separate_arguments(HOST_CLANG_FLAGS)
 separate_arguments(HOST_LLC_FLAGS)
-string(REPLACE " " ";" POCL_LLVM_LIBS "${POCL_LLVM_LIBS}")
 
 add_subdirectory("llvmopencl")
 
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 9cdf718..33a473a 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -38,7 +38,17 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -103,7 +113,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = lib
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -112,6 +121,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -171,6 +181,7 @@ am__define_uniq_tagged_files = \
 ETAGS = etags
 CTAGS = ctags
 DIST_SUBDIRS = $(SUBDIRS)
+am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 am__relativize = \
   dir0=`pwd`; \
@@ -247,6 +258,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -283,6 +297,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -414,7 +429,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign lib/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -709,6 +723,8 @@ uninstall-am:
 	mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
 	ps ps-am tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/lib/kernel/CMakeLists.txt b/lib/kernel/CMakeLists.txt
index 07fdba2..1ff09a7 100644
--- a/lib/kernel/CMakeLists.txt
+++ b/lib/kernel/CMakeLists.txt
@@ -84,6 +84,7 @@ get_group_id.c
 get_image_depth.cl
 get_image_height.cl
 get_image_width.cl
+get_image_dim.cl
 get_local_id.c
 get_local_size.c
 get_num_groups.c
@@ -127,7 +128,18 @@ mul24.cl
 mul_hi.cl
 nan.cl
 native_cos.cl
+native_divide.cl
+native_exp.cl
+native_exp10.cl
+native_exp2.cl
+native_log.cl
+native_log10.cl
 native_log2.cl
+native_powr.cl
+native_recip.cl
+native_rsqrt.cl
+native_sin.cl
+native_tan.cl
 nextafter.cl
 normalize.cl
 popcount.cl
@@ -192,6 +204,7 @@ get_group_id.c
 get_image_depth.cl
 get_image_height.cl
 get_image_width.cl
+get_image_dim.cl
 get_local_id.c
 get_local_size.c
 get_num_groups.c
@@ -409,5 +422,15 @@ if(OCL_TARGETS MATCHES "tce")
 endif()
 #*********************************************************************
 
+if(OCL_TARGETS MATCHES "amdgcn")
+  add_subdirectory("amdgcn")
+endif()
+
+if(OCL_TARGETS MATCHES "hsail64")
+  add_subdirectory("hsail64")
+endif()
+
+#*********************************************************************
+
 # TODO extra_dist in lib/kernel/Makefile.am:
 # EXTRA_DIST = *.c *.cl *.h *.ll      \
diff --git a/lib/kernel/Makefile.am b/lib/kernel/Makefile.am
index 75c19a4..b4451af 100644
--- a/lib/kernel/Makefile.am
+++ b/lib/kernel/Makefile.am
@@ -1,19 +1,19 @@
 # Process this file with automake to produce Makefile.in (in this,
 # and all subdirectories).
 # Makefile.am for pocl/lib/kernel.
-# 
+#
 # Copyright (c) 2011 Universidad Rey Juan Carlos
-# 
+#
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
 # in the Software without restriction, including without limitation the rights
 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 # copies of the Software, and to permit persons to whom the Software is
 # furnished to do so, subject to the following conditions:
-# 
+#
 # The above copyright notice and this permission notice shall be included in
 # all copies or substantial portions of the Software.
-# 
+#
 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,12 +22,8 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 
-
-
 SUBDIRS = @OCL_TARGETS@
 
-
-
 # The source files in this dir are not built directly
 # but are used with the target specific subdirs as
 # fallback implementations. Include them in the
@@ -35,11 +31,12 @@ SUBDIRS = @OCL_TARGETS@
 EXTRA_DIST = $(srcdir)/*.c $(srcdir)/*.cl $(srcdir)/*.h $(srcdir)/*.ll			\
 	$(srcdir)/vecmathlib/LICENCE			\
 	$(srcdir)/vecmathlib/README			\
-	$(srcdir)/vecmathlib/*.h				\
+	$(srcdir)/vecmathlib/*.h			\
+	$(srcdir)/vecmathlib/vecmathlib.rst		\
 	$(srcdir)/vecmathlib-pocl/*.cc			\
 	$(srcdir)/vecmathlib-pocl/*.cl			\
 	$(srcdir)/vecmathlib-pocl/*.h			\
-	$(srcdir)/vecmathlib-pocl/*.py  \
+	$(srcdir)/vecmathlib-pocl/*.py			\
 	$(srcdir)/cellspu/* \
 	$(srcdir)/tce/* \
 	CMakeLists.txt
diff --git a/lib/kernel/Makefile.in b/lib/kernel/Makefile.in
index 2f6f2c8..405036f 100644
--- a/lib/kernel/Makefile.in
+++ b/lib/kernel/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -17,19 +17,19 @@
 # Process this file with automake to produce Makefile.in (in this,
 # and all subdirectories).
 # Makefile.am for pocl/lib/kernel.
-# 
+#
 # Copyright (c) 2011 Universidad Rey Juan Carlos
-# 
+#
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
 # in the Software without restriction, including without limitation the rights
 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 # copies of the Software, and to permit persons to whom the Software is
 # furnished to do so, subject to the following conditions:
-# 
+#
 # The above copyright notice and this permission notice shall be included in
 # all copies or substantial portions of the Software.
-# 
+#
 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -38,7 +38,17 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -103,7 +113,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = lib/kernel
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -112,6 +121,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -171,6 +181,7 @@ am__define_uniq_tagged_files = \
 ETAGS = etags
 CTAGS = ctags
 DIST_SUBDIRS = $(SUBDIRS)
+am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 am__relativize = \
   dir0=`pwd`; \
@@ -247,6 +258,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -283,6 +297,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -406,11 +421,12 @@ SUBDIRS = @OCL_TARGETS@
 EXTRA_DIST = $(srcdir)/*.c $(srcdir)/*.cl $(srcdir)/*.h $(srcdir)/*.ll			\
 	$(srcdir)/vecmathlib/LICENCE			\
 	$(srcdir)/vecmathlib/README			\
-	$(srcdir)/vecmathlib/*.h				\
+	$(srcdir)/vecmathlib/*.h			\
+	$(srcdir)/vecmathlib/vecmathlib.rst		\
 	$(srcdir)/vecmathlib-pocl/*.cc			\
 	$(srcdir)/vecmathlib-pocl/*.cl			\
 	$(srcdir)/vecmathlib-pocl/*.h			\
-	$(srcdir)/vecmathlib-pocl/*.py  \
+	$(srcdir)/vecmathlib-pocl/*.py			\
 	$(srcdir)/cellspu/* \
 	$(srcdir)/tce/* \
 	CMakeLists.txt
@@ -430,7 +446,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/kernel/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign lib/kernel/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -727,6 +742,8 @@ uninstall-am:
 	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
 	uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Distclean the dirs regardless if the target was enabled or not
 # to cleanup the Makefiles.
diff --git a/lib/kernel/cellspu/Makefile b/lib/kernel/cellspu/Makefile
index e4cdde2..c166bdc 100644
--- a/lib/kernel/cellspu/Makefile
+++ b/lib/kernel/cellspu/Makefile
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # lib/kernel/cellspu/Makefile.  Generated from Makefile.in by configure.
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -90,7 +90,17 @@
 # THE SOFTWARE.
 
 
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -154,8 +164,6 @@ POST_UNINSTALL = :
 build_triplet = x86_64-unknown-linux-gnu
 host_triplet = x86_64-unknown-linux-gnu
 target_triplet = x86_64-unknown-linux-gnu
-DIST_COMMON = $(srcdir)/../rules.mk $(srcdir)/../sources.mk \
-	$(srcdir)/Makefile.in $(srcdir)/Makefile.am
 am__append_1 = printf.c
 subdir = lib/kernel/cellspu
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -166,6 +174,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -219,23 +228,25 @@ am__uninstall_files_from_dir = { \
 am__installdirs = "$(DESTDIR)$(pkgdatadir)"
 DATA = $(nodist_pkgdata_DATA)
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/../rules.mk $(srcdir)/../sources.mk \
+	$(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = ${SHELL} /tmp/poc/config/missing aclocal-1.14
+ACLOCAL = ${SHELL} /tmp/pocl/config/missing aclocal-1.15
 AMTAR = $${TAR-tar}
 AM_DEFAULT_VERBOSITY = 1
 AR = ar
-AUTOCONF = ${SHELL} /tmp/poc/config/missing autoconf
-AUTOHEADER = ${SHELL} /tmp/poc/config/missing autoheader
-AUTOMAKE = ${SHELL} /tmp/poc/config/missing automake-1.14
+AUTOCONF = ${SHELL} /tmp/pocl/config/missing autoconf
+AUTOHEADER = ${SHELL} /tmp/pocl/config/missing autoheader
+AUTOMAKE = ${SHELL} /tmp/pocl/config/missing automake-1.15
 AWK = gawk
 BOOST_CPPFLAGS = 
 BOOST_LDFLAGS = 
-BUILD_TIMESTAMP = 201503102228728153315
+BUILD_TIMESTAMP = 201510261514380399935
 CC = gcc
 CCDEPMODE = depmode=gcc3
 CFLAGS = -g -O2
-CLANG = /home/LLVM_342/bin/clang
-CLANGXX = /home/LLVM_342/bin/clang++
+CLANG = /home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/clang
+CLANGXX = /home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/clang++
 CLANGXX_FLAGS = --target=x86_64-unknown-linux-gnu  -DVML_NO_IOSTREAM
 CLFLAGS =  -D__OPENCL_VERSION__=120
 CPP = gcc -E
@@ -253,24 +264,27 @@ DUMPBIN =
 ECHO_C = 
 ECHO_N = -n
 ECHO_T = 
-EGREP = /bin/grep -E
+EGREP = /usr/bin/grep -E
 EXEEXT = 
-FGREP = /bin/grep -F
+FGREP = /usr/bin/grep -F
 FORCED_CLFLAGS = -Xclang -ffake-address-space-map -fno-math-errno -fblocks -fno-builtin -fasm -Wno-format
-GLEW_CFLAGS = -I/usr/include/GL -I/usr/include/libdrm 
+GLEW_CFLAGS = -I/usr/include/libdrm 
 GLEW_LIBS = -lGLEW -lGLU -lGL 
-GREP = /bin/grep
+GREP = /usr/bin/grep
 HOST = x86_64-unknown-linux-gnu
 HOST_AS_FLAGS = 
-HOST_CLANG_FLAGS =  --target=x86_64-unknown-linux-gnu -march=bdver1 -D_CL_DISABLE_HALF
+HOST_CLANG_FLAGS =  --target=x86_64-unknown-linux-gnu -march=bdver3 -D_CL_DISABLE_HALF
 HOST_CPU = x86_64
 HOST_LD_FLAGS = -shared -lm
-HOST_LLC_FLAGS = -relocation-model=pic -mtriple=x86_64-unknown-linux-gnu -mcpu=bdver1
+HOST_LLC_FLAGS = -relocation-model=pic -mtriple=x86_64-unknown-linux-gnu -mcpu=bdver3
 HOST_SIZEOF_DOUBLE = 8
 HOST_SIZEOF_HALF = 2
 HOST_SIZEOF_LONG = 8
 HOST_SIZEOF_VOID_P = 8
-HWLOC_CFLAGS = 
+HSAILASM = /opt/HSA/bin/HSAILasm
+HSA_INCLUDES = -I/opt/HSA/include
+HSA_LIBS = -lhsa-runtime64 
+HWLOC_CFLAGS = -I/usr/include/libxml2 
 HWLOC_LIBS = -lhwloc 
 ICD_LD_FLAGS = -Wl,-Bsymbolic
 INSTALL = /usr/bin/install -c
@@ -278,9 +292,9 @@ INSTALL_DATA = ${INSTALL} -m 644
 INSTALL_PROGRAM = ${INSTALL}
 INSTALL_SCRIPT = ${INSTALL}
 INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
-KERNEL_COMPILER_LIB_VERSION = 5:0:0
+KERNEL_COMPILER_LIB_VERSION = 6:0:0
 LD = /usr/bin/ld -m elf_x86_64
-LDFLAGS = 
+LDFLAGS =  -L/opt/HSA/lib
 LD_FLAGS_BIN =  
 LIBOBJS = 
 LIBRARY_SUFFIX = .so
@@ -288,27 +302,28 @@ LIBS =
 LIBSPE_CFLAGS = 
 LIBSPE_LIBS = 
 LIBTOOL = $(SHELL) $(top_builddir)/libtool
-LIB_AGE_VERSION = 4
-LIB_CURRENT_VERSION = 5
+LIB_AGE_VERSION = 5
+LIB_CURRENT_VERSION = 6
 LIB_FIRST_VERSION = 1
 LIB_REVISION_VERSION = 0
-LIB_VERSION = 5:0:4
+LIB_VERSION = 6:0:5
 LIPO = 
-LLC = /home/LLVM_342/bin/llc
-LLVM_AS = /home/LLVM_342/bin/llvm-as
-LLVM_CONFIG = /home/LLVM_342/bin/llvm-config
-LLVM_CXX_FLAGS = -I/home/LLVM_342/include  -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -g -O2 -fomit-frame-pointer -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -fPIC -Woverloaded-virtual -Wcast-qual -fno-rtti
-LLVM_LDFLAGS = -L/home/LLVM_342/lib  -lz -lpthread -lffi -ltinfo -ldl -lm 
-LLVM_LIBS = -lLLVM-3.4.2
-LLVM_LINK = /home/LLVM_342/bin/llvm-link
-LLVM_OPT = /home/LLVM_342/bin/opt
-LLVM_VERSION = 3.4.2
+LLC = /home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/llc
+LLVM_AS = /home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/llvm-as
+LLVM_CONFIG = /home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/llvm-config
+LLVM_CXX_FLAGS = -I/home/LLVM_370_HSAIL_rwdi_NA_rtti/include  -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wnon-virtual-dtor -Wno-comment -std=c++11 -ffunction-sections -fdata-sections -O2 -g -DNDEBUG  -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
+LLVM_LDFLAGS = -L/home/LLVM_370_HSAIL_rwdi_NA_rtti/lib  -lrt -ldl -lcurses -lpthread -lz -lm
+LLVM_LIBS = -lLLVMLTO -lLLVMObjCARCOpts -lLLVMLinker -lLLVMBitWriter -lLLVMTableGen -lLLVMMIRParser -lLLVMDebugInfoPDB -lLLVMOrcJIT -lLLVMIRReader -lLLVMAsmParser -lLLVMHSAILCodeGen -lLLVMHSAILDesc -lLLVMHSAILInfo -lLLVMHSAILAsmPrinter -lLLVMAMDGPUCodeGen -lLLVMAMDGPUAsmParser -lLLVMAMDGPUUtils -lLLVMAMDGPUDesc -lLLVMAMDGPUInfo -lLLVMAMDGPUAsmPrinter -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMX86Desc -lLLVMMCDisassembler -lLLVMX86I [...]
+LLVM_LINK = /home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/llvm-link
+LLVM_OPT = /home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/opt
+LLVM_VERSION = 3.7.0svn
 LN_S = ln -s
 LTDL_LIBS = -lltdl 
 LTLIBOBJS = 
-MAKEINFO = ${SHELL} /tmp/poc/config/missing makeinfo
+LT_SYS_LIBRARY_PATH = 
+MAKEINFO = ${SHELL} /tmp/pocl/config/missing makeinfo
 MANIFEST_TOOL = :
-MKDIR_P = /bin/mkdir -p
+MKDIR_P = /usr/bin/mkdir -p
 NM = /usr/bin/nm -B
 NMEDIT = 
 OBJDUMP = objdump
@@ -317,27 +332,27 @@ OCL_ICD_CFLAGS =
 OCL_ICD_LIBS = 
 OCL_KERNEL_ARCH = 
 OCL_KERNEL_TARGET = x86_64-unknown-linux-gnu
-OCL_KERNEL_TARGET_CPU = bdver1
-OCL_TARGETS = host
+OCL_KERNEL_TARGET_CPU = bdver3
+OCL_TARGETS = host hsail64
 OPENCL_CFLAGS = 
 OPENCL_CMAKE = 
 OPENCL_EXTLIBS = -lOpenCL 
 OPENCL_LIBS = -lOpenCL 
-OPT = /home/LLVM_342/bin/opt
+OPT = /home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/opt
 OTOOL = 
 OTOOL64 = 
 PACKAGE = pocl
 PACKAGE_BUGREPORT = pocl-devel at lists.sourceforge.net
 PACKAGE_NAME = pocl
-PACKAGE_STRING = pocl 0.11
+PACKAGE_STRING = pocl 0.12
 PACKAGE_TARNAME = pocl
 PACKAGE_URL = 
-PACKAGE_VERSION = 0.11
+PACKAGE_VERSION = 0.12
 PATH_SEPARATOR = :
 PKG_CONFIG = /usr/bin/pkg-config
 PKG_CONFIG_LIBDIR = 
 PKG_CONFIG_PATH = 
-POAT_TESTSUITES = 
+POAT_TESTSUITES =  hsa
 POCL_DEVICE_ADDRESS_BITS = 64
 PTHREAD_CC = gcc
 PTHREAD_CFLAGS = -pthread
@@ -345,9 +360,9 @@ PTHREAD_LIBS =
 RANLIB = ranlib
 SDL_CFLAGS = 
 SDL_LIBS = 
-SED = /bin/sed
+SED = /usr/bin/sed
 SET_MAKE = 
-SHELL = /bin/bash
+SHELL = /bin/sh
 STRIP = strip
 TARGET = x86_64-unknown-linux-gnu
 TARGET_CLANG_FLAGS = 
@@ -361,11 +376,11 @@ TCECC =
 TCEMC_AVAILABLE = 
 TCE_AVAILABLE = 
 TCE_CONFIG = 
-VERSION = 0.11
-abs_builddir = /tmp/poc/lib/kernel/cellspu
-abs_srcdir = /tmp/poc/lib/kernel/cellspu
-abs_top_builddir = /tmp/poc
-abs_top_srcdir = /tmp/poc
+VERSION = 0.12
+abs_builddir = /tmp/pocl/lib/kernel/cellspu
+abs_srcdir = /tmp/pocl/lib/kernel/cellspu
+abs_top_builddir = /tmp/pocl
+abs_top_srcdir = /tmp/pocl
 ac_ct_AR = ar
 ac_ct_CC = gcc
 ac_ct_CXX = g++
@@ -396,7 +411,7 @@ host_vendor = unknown
 htmldir = ${docdir}
 includedir = ${prefix}/include
 infodir = ${datarootdir}/info
-install_sh = ${SHELL} /tmp/poc/config/install-sh
+install_sh = ${SHELL} /tmp/pocl/config/install-sh
 libdir = ${exec_prefix}/lib
 libexecdir = ${exec_prefix}/libexec
 localedir = ${datarootdir}/locale
@@ -450,16 +465,19 @@ LKERNEL_SRCS_DEFAULT = abs.cl abs_diff.cl acos.cl acosh.cl acospi.cl \
 	fast_normalize.cl fdim.cl floor.cl fma.cl fmax.cl fmin.cl \
 	fmod.cl fract.cl get_global_id.c get_global_offset.c \
 	get_global_size.c get_group_id.c get_image_depth.cl \
-	get_image_height.cl get_image_width.cl get_local_id.c \
-	get_local_size.c get_num_groups.c get_work_dim.c hadd.cl \
-	hypot.cl ilogb.cl isequal.cl isfinite.cl isgreater.cl \
-	isgreaterequal.cl isinf.cl isless.cl islessequal.cl \
-	islessgreater.cl isnan.cl isnormal.cl isnotequal.cl \
-	isordered.cl isunordered.cl ldexp.cl length.cl lgamma.cl \
-	log.cl log10.cl log1p.cl log2.cl logb.cl mad.cl mad24.cl \
-	mad_hi.cl mad_sat.cl max.cl max_i.cl maxmag.cl min.cl min_i.cl \
-	minmag.cl mix.cl mul24.cl mul_hi.cl nan.cl native_cos.cl \
-	native_log2.cl nextafter.cl normalize.cl popcount.cl pow.cl \
+	get_image_height.cl get_image_width.cl get_image_dim.cl \
+	get_local_id.c get_local_size.c get_num_groups.c \
+	get_work_dim.c hadd.cl hypot.cl ilogb.cl isequal.cl \
+	isfinite.cl isgreater.cl isgreaterequal.cl isinf.cl isless.cl \
+	islessequal.cl islessgreater.cl isnan.cl isnormal.cl \
+	isnotequal.cl isordered.cl isunordered.cl ldexp.cl length.cl \
+	lgamma.cl log.cl log10.cl log1p.cl log2.cl logb.cl mad.cl \
+	mad24.cl mad_hi.cl mad_sat.cl max.cl max_i.cl maxmag.cl min.cl \
+	min_i.cl minmag.cl mix.cl mul24.cl mul_hi.cl nan.cl \
+	native_cos.cl native_exp.cl native_exp10.cl native_exp2.cl \
+	native_log.cl native_log10.cl native_log2.cl native_powr.cl \
+	native_recip.cl native_rsqrt.cl native_sin.cl native_sqrt.cl \
+	native_tan.cl nextafter.cl normalize.cl popcount.cl pow.cl \
 	pown.cl powr.cl radians.cl read_image.cl recip.cl remainder.cl \
 	rhadd.cl rint.cl rootn.cl rotate.cl round.cl rsqrt.cl \
 	select.cl shuffle.cl sign.cl signbit.cl sin.cl sincos.cl \
@@ -483,7 +501,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(srcdir)/../rules.mk $(srcdir)/..
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/kernel/cellspu/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign lib/kernel/cellspu/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -492,7 +509,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
 	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
 	esac;
-$(srcdir)/../rules.mk $(srcdir)/../sources.mk:
+$(srcdir)/../rules.mk $(srcdir)/../sources.mk $(am__empty):
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
@@ -685,6 +702,8 @@ uninstall-am: uninstall-nodist_pkgdataDATA
 	mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \
 	uninstall-am uninstall-nodist_pkgdataDATA
 
+.PRECIOUS: Makefile
+
 
 all: ${KERNEL_BC}
 
@@ -701,7 +720,7 @@ vpath %.ll ../../../lib/kernel
 # feature switches. Otherwise it will fail when compiling the kernel
 # against the precompiled header.
 _kernel.h.pch: ../../../include/${TARGET_DIR}/types.h ../../../include/_kernel.h
-	/home/LLVM_342/bin/clang -Xclang -ffake-address-space-map -fno-math-errno -fblocks -fno-builtin -fasm -Wno-format  -D__OPENCL_VERSION__=120 -Xclang -ffake-address-space-map -c -target ${KERNEL_TARGET} -x cl \
+	/home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/clang -Xclang -ffake-address-space-map -fno-math-errno -fblocks -fno-builtin -fasm -Wno-format  -D__OPENCL_VERSION__=120 -Xclang -ffake-address-space-map -c -target ${KERNEL_TARGET} -x cl \
 	-include ../../../include/${TARGET_DIR}/types.h \
 	-Xclang -emit-pch ../../../include/_kernel.h -o _kernel.h.pch 
 
@@ -709,21 +728,21 @@ _kernel.h.pch: ../../../include/${TARGET_DIR}/types.h ../../../include/_kernel.h
 # LLVM bitcode
 %.c.bc: %.c ${abs_top_srcdir}/include/pocl_types.h ${abs_top_srcdir}/include/pocl_features.h ${abs_top_srcdir}/include/_kernel_c.h ${LKERNEL_HDRS_EXTRA}
 	mkdir -p ${dir $@}
-	/home/LLVM_342/bin/clang ${CLANG_FLAGS} ${CLFLAGS} -D__CBUILD__ -c -o $@ -include ${abs_top_srcdir}/include/_kernel_c.h $< 
+	/home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/clang ${CLANG_FLAGS} ${CLFLAGS} -D__CBUILD__ -c -o $@ -include ${abs_top_srcdir}/include/_kernel_c.h $< 
 %.cc.bc: %.cc ${abs_top_srcdir}/include/pocl_features.h ${LKERNEL_HDRS_EXTRA}
 	mkdir -p ${dir $@}
-	/home/LLVM_342/bin/clang++ ${CLANG_FLAGS} ${CLANGXX_FLAGS} -c -o $@ $< -include ${abs_top_srcdir}/include/pocl_features.h
+	/home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/clang++ ${CLANG_FLAGS} ${CLANGXX_FLAGS} -c -o $@ $< -include ${abs_top_srcdir}/include/pocl_features.h
 %.cl.bc: %.cl ${abs_top_srcdir}/include/_kernel.h ${abs_top_srcdir}/include/_kernel_c.h ${abs_top_srcdir}/include/pocl_types.h ${abs_top_srcdir}/include/pocl_features.h ${LKERNEL_HDRS_EXTRA}
 	mkdir -p ${dir $@}
-	/home/LLVM_342/bin/clang ${CLANG_FLAGS} -x cl ${CLFLAGS} -fsigned-char -c -o $@ $< -include ${abs_top_srcdir}/include/_kernel.h
+	/home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/clang ${CLANG_FLAGS} -x cl ${CLFLAGS} -fsigned-char -c -o $@ $< -include ${abs_top_srcdir}/include/_kernel.h
 %.ll.bc: %.ll
 	mkdir -p ${dir $@}
-	/home/LLVM_342/bin/llvm-as -o $@ $<
+	/home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/llvm-as -o $@ $<
 
 # Optimize the bitcode library to speed up optimization times for the
 # OpenCL kernels
 ${KERNEL_BC}: ${OBJ}
-	/home/LLVM_342/bin/llvm-link $^ -o - | /home/LLVM_342/bin/opt ${LLC_FLAGS} ${KERNEL_LIB_OPT_FLAGS} -O3 -fp-contract=off -o $@
+	/home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/llvm-link $^ -o - | /home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/opt ${LLC_FLAGS} ${KERNEL_LIB_OPT_FLAGS} -O3 -fp-contract=off -o $@
 
 # vim: set noexpandtab ts=8:
 
diff --git a/lib/kernel/cellspu/Makefile.in b/lib/kernel/cellspu/Makefile.in
index a6eafba..a6f15af 100644
--- a/lib/kernel/cellspu/Makefile.in
+++ b/lib/kernel/cellspu/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -90,7 +90,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -154,8 +164,6 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-DIST_COMMON = $(srcdir)/../rules.mk $(srcdir)/../sources.mk \
-	$(srcdir)/Makefile.in $(srcdir)/Makefile.am
 @NEW_PRINTF_WORKS_TRUE at am__append_1 = printf.c
 subdir = lib/kernel/cellspu
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -166,6 +174,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -219,6 +228,8 @@ am__uninstall_files_from_dir = { \
 am__installdirs = "$(DESTDIR)$(pkgdatadir)"
 DATA = $(nodist_pkgdata_DATA)
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/../rules.mk $(srcdir)/../sources.mk \
+	$(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -270,6 +281,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -306,6 +320,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -450,16 +465,19 @@ LKERNEL_SRCS_DEFAULT = abs.cl abs_diff.cl acos.cl acosh.cl acospi.cl \
 	fast_normalize.cl fdim.cl floor.cl fma.cl fmax.cl fmin.cl \
 	fmod.cl fract.cl get_global_id.c get_global_offset.c \
 	get_global_size.c get_group_id.c get_image_depth.cl \
-	get_image_height.cl get_image_width.cl get_local_id.c \
-	get_local_size.c get_num_groups.c get_work_dim.c hadd.cl \
-	hypot.cl ilogb.cl isequal.cl isfinite.cl isgreater.cl \
-	isgreaterequal.cl isinf.cl isless.cl islessequal.cl \
-	islessgreater.cl isnan.cl isnormal.cl isnotequal.cl \
-	isordered.cl isunordered.cl ldexp.cl length.cl lgamma.cl \
-	log.cl log10.cl log1p.cl log2.cl logb.cl mad.cl mad24.cl \
-	mad_hi.cl mad_sat.cl max.cl max_i.cl maxmag.cl min.cl min_i.cl \
-	minmag.cl mix.cl mul24.cl mul_hi.cl nan.cl native_cos.cl \
-	native_log2.cl nextafter.cl normalize.cl popcount.cl pow.cl \
+	get_image_height.cl get_image_width.cl get_image_dim.cl \
+	get_local_id.c get_local_size.c get_num_groups.c \
+	get_work_dim.c hadd.cl hypot.cl ilogb.cl isequal.cl \
+	isfinite.cl isgreater.cl isgreaterequal.cl isinf.cl isless.cl \
+	islessequal.cl islessgreater.cl isnan.cl isnormal.cl \
+	isnotequal.cl isordered.cl isunordered.cl ldexp.cl length.cl \
+	lgamma.cl log.cl log10.cl log1p.cl log2.cl logb.cl mad.cl \
+	mad24.cl mad_hi.cl mad_sat.cl max.cl max_i.cl maxmag.cl min.cl \
+	min_i.cl minmag.cl mix.cl mul24.cl mul_hi.cl nan.cl \
+	native_cos.cl native_exp.cl native_exp10.cl native_exp2.cl \
+	native_log.cl native_log10.cl native_log2.cl native_powr.cl \
+	native_recip.cl native_rsqrt.cl native_sin.cl native_sqrt.cl \
+	native_tan.cl nextafter.cl normalize.cl popcount.cl pow.cl \
 	pown.cl powr.cl radians.cl read_image.cl recip.cl remainder.cl \
 	rhadd.cl rint.cl rootn.cl rotate.cl round.cl rsqrt.cl \
 	select.cl shuffle.cl sign.cl signbit.cl sin.cl sincos.cl \
@@ -483,7 +501,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(srcdir)/../rules.mk $(srcdir)/..
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/kernel/cellspu/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign lib/kernel/cellspu/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -492,7 +509,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
 	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
 	esac;
-$(srcdir)/../rules.mk $(srcdir)/../sources.mk:
+$(srcdir)/../rules.mk $(srcdir)/../sources.mk $(am__empty):
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
@@ -685,6 +702,8 @@ uninstall-am: uninstall-nodist_pkgdataDATA
 	mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \
 	uninstall-am uninstall-nodist_pkgdataDATA
 
+.PRECIOUS: Makefile
+
 
 all: ${KERNEL_BC}
 
diff --git a/lib/kernel/divide.cl b/lib/kernel/divide.cl
index 790f699..4411233 100644
--- a/lib/kernel/divide.cl
+++ b/lib/kernel/divide.cl
@@ -25,4 +25,3 @@
 #include "templates.h"
 
 DEFINE_EXPR_F_FF(half_divide, a/b)
-DEFINE_EXPR_F_FF(native_divide, a/b)
diff --git a/lib/kernel/exp.cl b/lib/kernel/exp.cl
index ce3ef3d..36b1cb2 100644
--- a/lib/kernel/exp.cl
+++ b/lib/kernel/exp.cl
@@ -27,4 +27,3 @@
 DEFINE_BUILTIN_V_V(exp)
 
 DEFINE_EXPR_F_F(half_exp, exp(a))
-DEFINE_EXPR_F_F(native_exp, exp(a))
diff --git a/lib/kernel/exp10.cl b/lib/kernel/exp10.cl
index 737402c..ed9b772 100644
--- a/lib/kernel/exp10.cl
+++ b/lib/kernel/exp10.cl
@@ -27,4 +27,3 @@
 DEFINE_EXPR_V_V(exp10, exp10(a*TYPED_CONST(stype, M_LN10_H, M_LN10_F, M_LN10)))
 
 DEFINE_EXPR_F_F(half_exp10, exp10(a))
-DEFINE_EXPR_F_F(native_exp10, exp10(a))
diff --git a/lib/kernel/exp2.cl b/lib/kernel/exp2.cl
index 1d08685..fa73a09 100644
--- a/lib/kernel/exp2.cl
+++ b/lib/kernel/exp2.cl
@@ -27,4 +27,3 @@
 DEFINE_BUILTIN_V_V(exp2)
 
 DEFINE_EXPR_F_F(half_exp2, exp2(a))
-DEFINE_EXPR_F_F(native_exp2, exp2(a))
diff --git a/lib/kernel/get_image_depth.cl b/lib/kernel/get_image_depth.cl
index 4371214..365f9fb 100644
--- a/lib/kernel/get_image_depth.cl
+++ b/lib/kernel/get_image_depth.cl
@@ -39,10 +39,5 @@
   }                                                         \
 
 IMPLEMENT_GET_IMAGE_DEPTH(image1d_t)
-
-#if (__clang_major__ == 3) && (__clang_minor__ >= 3)
-// with LLVM 3.2 the image types are not defined by the frontend
-// and we reuse the same struct for all dimensions
 IMPLEMENT_GET_IMAGE_DEPTH(image2d_t)
 IMPLEMENT_GET_IMAGE_DEPTH(image3d_t)
-#endif
diff --git a/lib/kernel/get_image_width.cl b/lib/kernel/get_image_dim.cl
similarity index 70%
copy from lib/kernel/get_image_width.cl
copy to lib/kernel/get_image_dim.cl
index 0dca76d..2648afb 100644
--- a/lib/kernel/get_image_width.cl
+++ b/lib/kernel/get_image_dim.cl
@@ -1,18 +1,19 @@
-/* OpenCL built-in library: get_image_width()
+/* OpenCL built-in library: get_image_dim()
 
    Copyright (c) 2013-2014 Ville Korhonen, Pekka Jääskeläinen
                            Tampere University of Technology
-   
+   Copyright (c) 2015      Giuseppe Bilotta
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -33,17 +34,20 @@
 #define ADDRESS_SPACE
 #endif
 
-#define IMPLEMENT_GET_IMAGE_WIDTH(__IMGTYPE__)               \
-  int _CL_OVERLOADABLE get_image_width(__IMGTYPE__ image){   \
-    return (*(ADDRESS_SPACE dev_image_t**)&image)->width;           \
-  }                                                          \
+int2 _CL_OVERLOADABLE get_image_dim(image2d_t image)
+{
+  ADDRESS_SPACE dev_image_t* img = *(ADDRESS_SPACE dev_image_t**)ℑ
+  return (int2)(img->width, img->height);
+}
 
-IMPLEMENT_GET_IMAGE_WIDTH(image1d_t)
-
-#if (__clang_major__ == 3) && (__clang_minor__ >= 3)
-// with LLVM 3.2 the image types are not defined by the frontend
-// and we reuse the same struct for all dimensions
-IMPLEMENT_GET_IMAGE_WIDTH(image2d_t)
-IMPLEMENT_GET_IMAGE_WIDTH(image3d_t)
-#endif
+int2 _CL_OVERLOADABLE get_image_dim(image2d_array_t image)
+{
+  ADDRESS_SPACE dev_image_t* img = *(ADDRESS_SPACE dev_image_t**)ℑ
+  return (int2)(img->width, img->height);
+}
 
+int4 _CL_OVERLOADABLE get_image_dim(image3d_t image)
+{
+  ADDRESS_SPACE dev_image_t* img = *(ADDRESS_SPACE dev_image_t**)ℑ
+  return (int4)(img->width, img->height, img->depth, 0);
+}
diff --git a/lib/kernel/get_image_height.cl b/lib/kernel/get_image_height.cl
index 984733e..da519ae 100644
--- a/lib/kernel/get_image_height.cl
+++ b/lib/kernel/get_image_height.cl
@@ -40,12 +40,7 @@
 
 
 IMPLEMENT_GET_IMAGE_HEIGHT(image1d_t)
-
-#if (__clang_major__ == 3) && (__clang_minor__ >= 3)
-// with LLVM 3.2 the image types are not defined by the frontend
-// and we reuse the same struct for all dimensions
 IMPLEMENT_GET_IMAGE_HEIGHT(image2d_t)
 IMPLEMENT_GET_IMAGE_HEIGHT(image3d_t)
-#endif
 
 
diff --git a/lib/kernel/get_image_width.cl b/lib/kernel/get_image_width.cl
index 0dca76d..f68c2de 100644
--- a/lib/kernel/get_image_width.cl
+++ b/lib/kernel/get_image_width.cl
@@ -39,11 +39,6 @@
   }                                                          \
 
 IMPLEMENT_GET_IMAGE_WIDTH(image1d_t)
-
-#if (__clang_major__ == 3) && (__clang_minor__ >= 3)
-// with LLVM 3.2 the image types are not defined by the frontend
-// and we reuse the same struct for all dimensions
 IMPLEMENT_GET_IMAGE_WIDTH(image2d_t)
 IMPLEMENT_GET_IMAGE_WIDTH(image3d_t)
-#endif
 
diff --git a/lib/kernel/host/CMakeLists.txt b/lib/kernel/host/CMakeLists.txt
index 9204f15..3c99dc2 100644
--- a/lib/kernel/host/CMakeLists.txt
+++ b/lib/kernel/host/CMakeLists.txt
@@ -51,9 +51,8 @@ make_kernel_bc(KERNEL_BC "${OCL_KERNEL_TARGET}" ${KERNEL_SOURCES})
 message(STATUS "Host Kernel BC: ${KERNEL_BC}")
 
 # a target is needed...
-add_custom_target("kernel_host" ALL DEPENDS ${KERNEL_BC})
+add_custom_target("kernel_host" ALL
+    DEPENDS ${KERNEL_BC} "${CMAKE_BINARY_DIR}/kernellib_hash.h")
 
-install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${KERNEL_BC}"
+install(FILES "${KERNEL_BC}"
         DESTINATION "${POCL_INSTALL_PRIVATE_DATADIR}")
-
-
diff --git a/lib/kernel/host/Makefile.in b/lib/kernel/host/Makefile.in
index 7a772b4..6271293 100644
--- a/lib/kernel/host/Makefile.in
+++ b/lib/kernel/host/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -90,7 +90,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -154,9 +164,6 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-DIST_COMMON = $(srcdir)/../rules.mk $(srcdir)/../sources.mk \
-	$(srcdir)/../sources-vml.mk $(srcdir)/Makefile.in \
-	$(srcdir)/Makefile.am
 @NEW_PRINTF_WORKS_TRUE at am__append_1 = printf.c
 subdir = lib/kernel/host
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -167,6 +174,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -220,6 +228,8 @@ am__uninstall_files_from_dir = { \
 am__installdirs = "$(DESTDIR)$(pkgdatadir)"
 DATA = $(nodist_pkgdata_DATA)
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/../rules.mk $(srcdir)/../sources-vml.mk \
+	$(srcdir)/../sources.mk $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -271,6 +281,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -307,6 +320,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -451,16 +465,19 @@ LKERNEL_SRCS_DEFAULT = abs.cl abs_diff.cl acos.cl acosh.cl acospi.cl \
 	fast_normalize.cl fdim.cl floor.cl fma.cl fmax.cl fmin.cl \
 	fmod.cl fract.cl get_global_id.c get_global_offset.c \
 	get_global_size.c get_group_id.c get_image_depth.cl \
-	get_image_height.cl get_image_width.cl get_local_id.c \
-	get_local_size.c get_num_groups.c get_work_dim.c hadd.cl \
-	hypot.cl ilogb.cl isequal.cl isfinite.cl isgreater.cl \
-	isgreaterequal.cl isinf.cl isless.cl islessequal.cl \
-	islessgreater.cl isnan.cl isnormal.cl isnotequal.cl \
-	isordered.cl isunordered.cl ldexp.cl length.cl lgamma.cl \
-	log.cl log10.cl log1p.cl log2.cl logb.cl mad.cl mad24.cl \
-	mad_hi.cl mad_sat.cl max.cl max_i.cl maxmag.cl min.cl min_i.cl \
-	minmag.cl mix.cl mul24.cl mul_hi.cl nan.cl native_cos.cl \
-	native_log2.cl nextafter.cl normalize.cl popcount.cl pow.cl \
+	get_image_height.cl get_image_width.cl get_image_dim.cl \
+	get_local_id.c get_local_size.c get_num_groups.c \
+	get_work_dim.c hadd.cl hypot.cl ilogb.cl isequal.cl \
+	isfinite.cl isgreater.cl isgreaterequal.cl isinf.cl isless.cl \
+	islessequal.cl islessgreater.cl isnan.cl isnormal.cl \
+	isnotequal.cl isordered.cl isunordered.cl ldexp.cl length.cl \
+	lgamma.cl log.cl log10.cl log1p.cl log2.cl logb.cl mad.cl \
+	mad24.cl mad_hi.cl mad_sat.cl max.cl max_i.cl maxmag.cl min.cl \
+	min_i.cl minmag.cl mix.cl mul24.cl mul_hi.cl nan.cl \
+	native_cos.cl native_exp.cl native_exp10.cl native_exp2.cl \
+	native_log.cl native_log10.cl native_log2.cl native_powr.cl \
+	native_recip.cl native_rsqrt.cl native_sin.cl native_sqrt.cl \
+	native_tan.cl nextafter.cl normalize.cl popcount.cl pow.cl \
 	pown.cl powr.cl radians.cl read_image.cl recip.cl remainder.cl \
 	rhadd.cl rint.cl rootn.cl rotate.cl round.cl rsqrt.cl \
 	select.cl shuffle.cl sign.cl signbit.cl sin.cl sincos.cl \
@@ -557,8 +574,19 @@ LKERNEL_SRCS_DEFAULT = abs.cl abs_diff.cl acos.cl acosh.cl acospi.cl \
 @USE_VECMATHLIB_TRUE@	minmag.cl				\
 @USE_VECMATHLIB_TRUE@	mix.cl					\
 @USE_VECMATHLIB_TRUE@	nan.cl					\
- at USE_VECMATHLIB_TRUE@	native_cos.cl				\
- at USE_VECMATHLIB_TRUE@	native_log2.cl				\
+ at USE_VECMATHLIB_TRUE@        native_cos.cl                           \
+ at USE_VECMATHLIB_TRUE@        native_divide.cl                        \
+ at USE_VECMATHLIB_TRUE@        native_exp.cl                           \
+ at USE_VECMATHLIB_TRUE@        native_exp10.cl                         \
+ at USE_VECMATHLIB_TRUE@        native_exp2.cl                          \
+ at USE_VECMATHLIB_TRUE@        native_log.cl                           \
+ at USE_VECMATHLIB_TRUE@        native_log10.cl                         \
+ at USE_VECMATHLIB_TRUE@        native_log2.cl                          \
+ at USE_VECMATHLIB_TRUE@        native_powr.cl                          \
+ at USE_VECMATHLIB_TRUE@        native_recip.cl                         \
+ at USE_VECMATHLIB_TRUE@        native_rsqrt.cl                         \
+ at USE_VECMATHLIB_TRUE@        native_sin.cl                           \
+ at USE_VECMATHLIB_TRUE@        native_tan.cl                           \
 @USE_VECMATHLIB_TRUE@	normalize.cl				\
 @USE_VECMATHLIB_TRUE@	pow.cl					\
 @USE_VECMATHLIB_TRUE@	pown.cl					\
@@ -759,7 +787,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(srcdir)/../rules.mk $(srcdir)/..
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/kernel/host/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign lib/kernel/host/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -768,7 +795,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
 	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
 	esac;
-$(srcdir)/../rules.mk $(srcdir)/../sources.mk $(srcdir)/../sources-vml.mk:
+$(srcdir)/../rules.mk $(srcdir)/../sources.mk $(srcdir)/../sources-vml.mk $(am__empty):
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
@@ -961,6 +988,8 @@ uninstall-am: uninstall-nodist_pkgdataDATA
 	mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \
 	uninstall-am uninstall-nodist_pkgdataDATA
 
+.PRECIOUS: Makefile
+
 
 all: ${KERNEL_BC}
 
diff --git a/lib/kernel/hsail64/CMakeLists.txt b/lib/kernel/hsail64/CMakeLists.txt
new file mode 100644
index 0000000..bf2f825
--- /dev/null
+++ b/lib/kernel/hsail64/CMakeLists.txt
@@ -0,0 +1,68 @@
+#=============================================================================
+#   CMake build system files
+#
+#   Copyright (c) 2015 pocl developers
+#
+#   Permission is hereby granted, free of charge, to any person obtaining a copy
+#   of this software and associated documentation files (the "Software"), to deal
+#   in the Software without restriction, including without limitation the rights
+#   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+#   copies of the Software, and to permit persons to whom the Software is
+#   furnished to do so, subject to the following conditions:
+#
+#   The above copyright notice and this permission notice shall be included in
+#   all copies or substantial portions of the Software.
+#
+#   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+#   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+#   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+#   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+#   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+#   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+#   THE SOFTWARE.
+#
+#=============================================================================
+
+include("bitcode_rules")
+
+set(KERNEL_SOURCES ${SOURCES_WITHOUT_VML})
+
+foreach(FILE printf.c barrier.ll get_image_depth.cl get_image_dim.cl
+  get_image_height.cl get_image_width.cl read_image.cl write_image.cl)
+  list(REMOVE_ITEM KERNEL_SOURCES "${FILE}")
+endforeach()
+
+
+foreach(FILE atomics.cl atomic_impl.ll barrier.c
+        get_global_id.c get_global_size.c get_group_id.c
+        get_local_id.c get_local_size.c get_num_groups.c get_work_dim.c
+        native_cos.cl native_exp.cl native_exp10.cl native_exp2.cl
+        native_log.cl native_log10.cl native_log2.cl native_recip.cl
+        native_rsqrt.cl  native_sin.cl  native_sqrt.cl
+        fabs.cl floor.cl rint.cl trunc.cl remainder.cl
+        fma.cl mad.cl mad_hi.cl mul_hi.cl mul24.cl mad24.cl
+        sqrt.cl sqrt_default.ll cbrt.cl hypot.cl copysign.cl
+        exp.cl exp2.cl exp10.cl expm1.cl
+        log.cl log2.cl log10.cl log1p.cl
+        sin.cl tan.cl cos.cl sinh.cl tanh.cl cosh.cl
+        asin.cl acos.cl atan.cl asinh.cl acosh.cl atanh.cl
+        ilogb.cl ldexp.cl fract.cl frexp.cl atan2.cl pow.cl)
+
+  list(REMOVE_ITEM KERNEL_SOURCES "${FILE}")
+  list(APPEND KERNEL_SOURCES "hsail64/${FILE}")
+endforeach()
+
+set(CLANG_FLAGS "-Xclang" "-ffake-address-space-map" "-emit-llvm" "-target" "hsail64" "-D_CL_DISABLE_HALF")
+set(LLC_FLAGS "")
+
+make_kernel_bc(KERNEL_BC "hsail64" ${KERNEL_SOURCES})
+
+# just debug
+message(STATUS "HSAIL64 Kernel BC: ${KERNEL_BC}")
+
+# a target is needed...
+add_custom_target("kernel_hsail64" ALL
+    DEPENDS ${KERNEL_BC} "${CMAKE_BINARY_DIR}/kernellib_hash.h")
+
+install(FILES "${KERNEL_BC}"
+        DESTINATION "${POCL_INSTALL_PRIVATE_DATADIR}")
diff --git a/tests/tce/ttasim/Makefile.am b/lib/kernel/hsail64/Makefile.am
similarity index 61%
copy from tests/tce/ttasim/Makefile.am
copy to lib/kernel/hsail64/Makefile.am
index 30d13fe..6f37982 100644
--- a/tests/tce/ttasim/Makefile.am
+++ b/lib/kernel/hsail64/Makefile.am
@@ -1,18 +1,17 @@
-# Process this file with automake to produce Makefile.in (in this,
-# and all subdirectories).
-# 
-# Copyright (c) 2012 Pekka Jääskeläinen / Tampere University of Technology
-# 
+# Process this file with automake to produce Makefile.in
+#
+# Copyright (c) 2015 Pekka Jääskeläinen
+#
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
 # in the Software without restriction, including without limitation the rights
 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 # copies of the Software, and to permit persons to whom the Software is
 # furnished to do so, subject to the following conditions:
-# 
+#
 # The above copyright notice and this permission notice shall be included in
 # all copies or substantial portions of the Software.
-# 
+#
 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,17 +20,18 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 
-noinst_PROGRAMS = host
+KERNEL_TARGET = hsail64
 
-host_SOURCES = host.cpp 
-host_LDADD = @OPENCL_LIBS@ ../../../lib/poclu/libpoclu.la @LD_FLAGS_BIN@
-host_CXXFLAGS = @PTHREAD_CFLAGS@ -Wno-deprecated -Wno-deprecated-declarations
+# Use TARGET flags:
+CLANG_FLAGS = @TARGET_CLANG_FLAGS@ -Xclang -ffake-address-space-map -emit-llvm -D_CL_DISABLE_HALF -target ${KERNEL_TARGET} -I${abs_top_srcdir}/lib/kernel/hsail64
+LLC_FLAGS   = @TARGET_LLC_FLAGS@
+LD_FLAGS    = @TARGET_LD_FLAGS@
 
-AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include  -I$(top_srcdir)/lib/CL \
-	-DSRCDIR='"$(abs_srcdir)"'
+include ../rules.mk
+include ../sources.mk
 
+# TODO: a global memory ring buffer stdout based printf
+LKERNEL_SRCS_EXCLUDE = printf.c barrier.ll
+LKERNEL_SRCS_EXTRA = barrier.c sqrt_default.ll
 
-all-local: host
-
-run: host
-	@POCL_DEVICES="ttasim" POCL_TTASIM0_PARAMETERS="$(top_srcdir)/tools/data/test_machine.adf" ./host
+EXTRA_DIST = CMakeLists.txt $(srcdir)/*.c $(srcdir)/*.cl $(srcdir)/*.h $(srcdir)/*.ll frexp.inc
diff --git a/lib/kernel/tce/Makefile.in b/lib/kernel/hsail64/Makefile.in
similarity index 92%
copy from lib/kernel/tce/Makefile.in
copy to lib/kernel/hsail64/Makefile.in
index 9750070..935ea63 100644
--- a/lib/kernel/tce/Makefile.in
+++ b/lib/kernel/hsail64/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -15,19 +15,19 @@
 @SET_MAKE@
 
 # Process this file with automake to produce Makefile.in
-# 
-# Copyright (c) 2011 Universidad Rey Juan Carlos
-# 
+#
+# Copyright (c) 2015 Pekka Jääskeläinen
+#
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
 # in the Software without restriction, including without limitation the rights
 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 # copies of the Software, and to permit persons to whom the Software is
 # furnished to do so, subject to the following conditions:
-# 
+#
 # The above copyright notice and this permission notice shall be included in
 # all copies or substantial portions of the Software.
-# 
+#
 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -90,7 +90,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -154,10 +164,8 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-DIST_COMMON = $(srcdir)/../rules.mk $(srcdir)/../sources.mk \
-	$(srcdir)/Makefile.in $(srcdir)/Makefile.am
 @NEW_PRINTF_WORKS_TRUE at am__append_1 = printf.c
-subdir = lib/kernel/tce
+subdir = lib/kernel/hsail64
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -166,6 +174,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -219,6 +228,8 @@ am__uninstall_files_from_dir = { \
 am__installdirs = "$(DESTDIR)$(pkgdatadir)"
 DATA = $(nodist_pkgdata_DATA)
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/../rules.mk $(srcdir)/../sources.mk \
+	$(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -270,6 +281,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -306,6 +320,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -420,10 +435,10 @@ target_vendor = @target_vendor@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-KERNEL_TARGET = tce-tut-llvm
+KERNEL_TARGET = hsail64
 
 # Use TARGET flags:
-CLANG_FLAGS = @TARGET_CLANG_FLAGS@ -Xclang -ffake-address-space-map -Xclang -menable-no-nans -emit-llvm -ffp-contract=off -target tce-tut-llvm  -isystem `tce-config --prefix`/tce-llvm/include
+CLANG_FLAGS = @TARGET_CLANG_FLAGS@ -Xclang -ffake-address-space-map -emit-llvm -D_CL_DISABLE_HALF -target ${KERNEL_TARGET} -I${abs_top_srcdir}/lib/kernel/hsail64
 LLC_FLAGS = @TARGET_LLC_FLAGS@
 LD_FLAGS = @TARGET_LD_FLAGS@
 KERNEL_BC = kernel-${KERNEL_TARGET}.bc
@@ -450,16 +465,19 @@ LKERNEL_SRCS_DEFAULT = abs.cl abs_diff.cl acos.cl acosh.cl acospi.cl \
 	fast_normalize.cl fdim.cl floor.cl fma.cl fmax.cl fmin.cl \
 	fmod.cl fract.cl get_global_id.c get_global_offset.c \
 	get_global_size.c get_group_id.c get_image_depth.cl \
-	get_image_height.cl get_image_width.cl get_local_id.c \
-	get_local_size.c get_num_groups.c get_work_dim.c hadd.cl \
-	hypot.cl ilogb.cl isequal.cl isfinite.cl isgreater.cl \
-	isgreaterequal.cl isinf.cl isless.cl islessequal.cl \
-	islessgreater.cl isnan.cl isnormal.cl isnotequal.cl \
-	isordered.cl isunordered.cl ldexp.cl length.cl lgamma.cl \
-	log.cl log10.cl log1p.cl log2.cl logb.cl mad.cl mad24.cl \
-	mad_hi.cl mad_sat.cl max.cl max_i.cl maxmag.cl min.cl min_i.cl \
-	minmag.cl mix.cl mul24.cl mul_hi.cl nan.cl native_cos.cl \
-	native_log2.cl nextafter.cl normalize.cl popcount.cl pow.cl \
+	get_image_height.cl get_image_width.cl get_image_dim.cl \
+	get_local_id.c get_local_size.c get_num_groups.c \
+	get_work_dim.c hadd.cl hypot.cl ilogb.cl isequal.cl \
+	isfinite.cl isgreater.cl isgreaterequal.cl isinf.cl isless.cl \
+	islessequal.cl islessgreater.cl isnan.cl isnormal.cl \
+	isnotequal.cl isordered.cl isunordered.cl ldexp.cl length.cl \
+	lgamma.cl log.cl log10.cl log1p.cl log2.cl logb.cl mad.cl \
+	mad24.cl mad_hi.cl mad_sat.cl max.cl max_i.cl maxmag.cl min.cl \
+	min_i.cl minmag.cl mix.cl mul24.cl mul_hi.cl nan.cl \
+	native_cos.cl native_exp.cl native_exp10.cl native_exp2.cl \
+	native_log.cl native_log10.cl native_log2.cl native_powr.cl \
+	native_recip.cl native_rsqrt.cl native_sin.cl native_sqrt.cl \
+	native_tan.cl nextafter.cl normalize.cl popcount.cl pow.cl \
 	pown.cl powr.cl radians.cl read_image.cl recip.cl remainder.cl \
 	rhadd.cl rint.cl rootn.cl rotate.cl round.cl rsqrt.cl \
 	select.cl shuffle.cl sign.cl signbit.cl sin.cl sincos.cl \
@@ -468,13 +486,10 @@ LKERNEL_SRCS_DEFAULT = abs.cl abs_diff.cl acos.cl acosh.cl acospi.cl \
 	vload.cl vload_half.cl vstore.cl vstore_half.cl \
 	wait_group_events.cl write_image.cl $(am__append_1)
 
-# Use the libc (newlib) printf() for now because the pocl's
-# fails in TCE code gen:
-# SplitVectorResult #0: 0x24c5ae0: v8i16,ch = vaarg 0x20628e8, 0x2423ed0, 0x24c59e0, 0x24c4fe0 [ORD=223] [ID=0]
-# LLVM ERROR: Do not know how to split the result of this operator!
- at NEW_PRINTF_WORKS_TRUE@LKERNEL_SRCS_EXCLUDE = printf.c 
- at NEW_PRINTF_WORKS_TRUE@LKERNEL_SRCS_EXTRA = printf_constant.c
-EXTRA_DIST = CMakeLists.txt
+# TODO: a global memory ring buffer stdout based printf
+LKERNEL_SRCS_EXCLUDE = printf.c barrier.ll
+LKERNEL_SRCS_EXTRA = barrier.c sqrt_default.ll
+EXTRA_DIST = CMakeLists.txt $(srcdir)/*.c $(srcdir)/*.cl $(srcdir)/*.h $(srcdir)/*.ll frexp.inc
 all: all-am
 
 .SUFFIXES:
@@ -487,10 +502,9 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(srcdir)/../rules.mk $(srcdir)/..
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/kernel/tce/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/kernel/hsail64/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign lib/kernel/tce/Makefile
-.PRECIOUS: Makefile
+	  $(AUTOMAKE) --foreign lib/kernel/hsail64/Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -499,7 +513,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
 	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
 	esac;
-$(srcdir)/../rules.mk $(srcdir)/../sources.mk:
+$(srcdir)/../rules.mk $(srcdir)/../sources.mk $(am__empty):
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
@@ -692,6 +706,8 @@ uninstall-am: uninstall-nodist_pkgdataDATA
 	mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \
 	uninstall-am uninstall-nodist_pkgdataDATA
 
+.PRECIOUS: Makefile
+
 
 all: ${KERNEL_BC}
 
diff --git a/lib/kernel/exp10.cl b/lib/kernel/hsail64/acos.cl
similarity index 66%
copy from lib/kernel/exp10.cl
copy to lib/kernel/hsail64/acos.cl
index 737402c..6d2afb1 100644
--- a/lib/kernel/exp10.cl
+++ b/lib/kernel/hsail64/acos.cl
@@ -1,18 +1,17 @@
-/* OpenCL built-in library: exp10()
+/* OpenCL built-in library: acos()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011 Erik Schnetter <eschnetter at perimeterinstitute.ca>
-                      Perimeter Institute for Theoretical Physics
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,9 +21,18 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "hsail_templates.h"
+
+#include "vml_constants.h"
+
+double _CL_OVERLOADABLE _cl_atan2k(double y, double x);
+
+float _CL_OVERLOADABLE _cl_atan2k(float y, float x);
+
+MULSIGN(float, uint, PROPS_FLOAT_SIGNBIT_MASK)
 
-DEFINE_EXPR_V_V(exp10, exp10(a*TYPED_CONST(stype, M_LN10_H, M_LN10_F, M_LN10)))
+MULSIGN(double, ulong, PROPS_DOUBLE_SIGNBIT_MASK)
 
-DEFINE_EXPR_F_F(half_exp10, exp10(a))
-DEFINE_EXPR_F_F(native_exp10, exp10(a))
+IMPLEMENT_EXPR_ALL_SINGLE(acos, V_V, \
+  mulsign(_cl_atan2k(sqrt(((vtype)(1.0)+a)*((vtype)(1.0)-a)), fabs(a)), a) \
+     + ((a < (vtype)(0.0)) ? (vtype)(M_PI) : (vtype)(0.0)))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/acosh.cl
similarity index 84%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/acosh.cl
index 8f7714f..d9b103f 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/acosh.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: acosh.cl()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,6 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "../templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_EXPR_V_V(acosh, log(a + sqrt(a*a - (vtype)1.0)))
diff --git a/lib/kernel/log.cl b/lib/kernel/hsail64/asin.cl
similarity index 68%
copy from lib/kernel/log.cl
copy to lib/kernel/hsail64/asin.cl
index cb05e8d..9b4a017 100644
--- a/lib/kernel/log.cl
+++ b/lib/kernel/hsail64/asin.cl
@@ -1,18 +1,17 @@
-/* OpenCL built-in library: log()
+/* OpenCL built-in library: asin()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011 Erik Schnetter <eschnetter at perimeterinstitute.ca>
-                      Perimeter Institute for Theoretical Physics
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,9 +21,18 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "hsail_templates.h"
+
+#include "vml_constants.h"
+
+double _CL_OVERLOADABLE _cl_atan2k(double y, double x);
+
+float _CL_OVERLOADABLE _cl_atan2k(float y, float x);
+
+MULSIGN(float, uint, PROPS_FLOAT_SIGNBIT_MASK)
+
+MULSIGN(double, ulong, PROPS_DOUBLE_SIGNBIT_MASK)
 
-DEFINE_BUILTIN_V_V(log)
 
-DEFINE_EXPR_F_F(half_log, log(a))
-DEFINE_EXPR_F_F(native_log, log(a))
+IMPLEMENT_EXPR_ALL_SINGLE(asin, V_V, \
+   mulsign(_cl_atan2k(fabs(a), sqrt( ((vtype)(1.0) + a) * ((vtype)(1.0) - a) )), a))
diff --git a/lib/CL/pocl_hash.h b/lib/kernel/hsail64/asinh.cl
similarity index 57%
copy from lib/CL/pocl_hash.h
copy to lib/kernel/hsail64/asinh.cl
index 48e6a43..d1154ce 100644
--- a/lib/CL/pocl_hash.h
+++ b/lib/kernel/hsail64/asinh.cl
@@ -1,4 +1,6 @@
-/* pocl_hash.h: interface for hash in pocl to allow easier changes later
+/* OpenCL built-in library: asinh.cl()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
@@ -19,24 +21,23 @@
    THE SOFTWARE.
 */
 
-#ifndef POCL_HASH_H
-#define POCL_HASH_H
 
-/* public api for steve reid's public domain SHA-1 implementation */
-/* this file is in the public domain */
 
-#include <stdint.h>
+#include "hsail_templates.h"
+
+#define ASINH(FTYPE)                                                      \
+  FTYPE _CL_OVERLOADABLE asinh(FTYPE x)                                   \
+  {                                                                       \
+    FTYPE r = fabs(x);                                                    \
+    r = log(r + sqrt(r*r + (FTYPE)1.0));                                  \
+    r = copysign(r, x);                                                   \
+    return r;                                                             \
+  }
 
-typedef struct {
-    uint32_t state[5];
-    uint32_t count[2];
-    uint8_t  buffer[64];
-} SHA1_CTX;
+ASINH(float)
 
-#define SHA1_DIGEST_SIZE 20
+ASINH(double)
 
-void pocl_SHA1_Init(SHA1_CTX* context);
-void pocl_SHA1_Update(SHA1_CTX* context, const uint8_t* data, const size_t len);
-void pocl_SHA1_Final(SHA1_CTX* context, uint8_t digest[SHA1_DIGEST_SIZE]);
+IMPLEMENT_VECWITHSCALARS(asinh, V_V, float, int)
 
-#endif /* POCL_HASH_H */
+IMPLEMENT_VECWITHSCALARS(asinh, V_V, double, long)
diff --git a/lib/kernel/hsail64/atan.cl b/lib/kernel/hsail64/atan.cl
new file mode 100644
index 0000000..8e6deba
--- /dev/null
+++ b/lib/kernel/hsail64/atan.cl
@@ -0,0 +1,103 @@
+/* OpenCL built-in library: atan()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+*/
+
+#include "hsail_templates.h"
+
+#include "vml_constants.h"
+
+float _CL_OVERLOADABLE atan(float s)
+{
+  // Algorithm taken from SLEEF 2.80
+
+  float q1 = s;
+  s = fabs(s);
+
+  bool q0 = (s > (1.0f));
+  if (q0)
+    s = 1.0f / s;
+
+  float t = s * s;
+
+  float u;
+  u = (0.00282363896258175373077393f);
+  u = mad(u, t, (-0.0159569028764963150024414f));
+  u = mad(u, t, (0.0425049886107444763183594f));
+  u = mad(u, t, (-0.0748900920152664184570312f));
+  u = mad(u, t, (0.106347933411598205566406f));
+  u = mad(u, t, (-0.142027363181114196777344f));
+  u = mad(u, t, (0.199926957488059997558594f));
+  u = mad(u, t, (-0.333331018686294555664062f));
+
+  t = s + s * (t * u);
+
+  if (q0)
+    t = (float)M_PI_2 - t;
+
+  return copysign(t, q1);
+}
+
+double _CL_OVERLOADABLE atan(double s)
+{
+  // Algorithm taken from SLEEF 2.80
+
+  double q1 = s;
+  s = fabs(s);
+
+  bool q0 = (s > 1.0f);
+  if (q0)
+    s = 1.0 / s;
+
+  double t = s * s;
+
+  double u;
+  u = (-1.88796008463073496563746e-05);
+  u = mad(u, t, (0.000209850076645816976906797));
+  u = mad(u, t, (-0.00110611831486672482563471));
+  u = mad(u, t, (0.00370026744188713119232403));
+  u = mad(u, t, (-0.00889896195887655491740809));
+  u = mad(u, t, (0.016599329773529201970117));
+  u = mad(u, t, (-0.0254517624932312641616861));
+  u = mad(u, t, (0.0337852580001353069993897));
+  u = mad(u, t, (-0.0407629191276836500001934));
+  u = mad(u, t, (0.0466667150077840625632675));
+  u = mad(u, t, (-0.0523674852303482457616113));
+  u = mad(u, t, (0.0587666392926673580854313));
+  u = mad(u, t, (-0.0666573579361080525984562));
+  u = mad(u, t, (0.0769219538311769618355029));
+  u = mad(u, t, (-0.090908995008245008229153));
+  u = mad(u, t, (0.111111105648261418443745));
+  u = mad(u, t, (-0.14285714266771329383765));
+  u = mad(u, t, (0.199999999996591265594148));
+  u = mad(u, t, (-0.333333333333311110369124));
+
+  t = s + s * (t * u);
+
+  if (q0)
+    t = M_PI_2 - t;
+
+  return copysign(t, q1);
+}
+
+IMPLEMENT_VECWITHSCALARS(atan, V_V, float, int)
+
+IMPLEMENT_VECWITHSCALARS(atan, V_V, double, long)
diff --git a/lib/kernel/hsail64/atan2.cl b/lib/kernel/hsail64/atan2.cl
new file mode 100644
index 0000000..bc1572d
--- /dev/null
+++ b/lib/kernel/hsail64/atan2.cl
@@ -0,0 +1,187 @@
+/* OpenCL built-in library: atan2()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+*/
+
+#include "hsail_templates.h"
+
+#include "vml_constants.h"
+
+MULSIGN(float, uint, PROPS_FLOAT_SIGNBIT_MASK)
+
+MULSIGN(double, ulong, PROPS_DOUBLE_SIGNBIT_MASK)
+
+// double
+double _CL_OVERLOADABLE _cl_atan2k(double y, double x)
+{
+  // Algorithm taken from SLEEF 2.80
+
+  double q = 0.0;
+
+  if (signbit(x))
+    q = -2.0;
+  x = fabs(x);
+
+  bool q0 = (y > x);
+  double x0 = x;
+  double y0 = y;
+  x = q0 ? y0 : x0;
+  y = q0 ? -x0 : y0;
+  if (q0)
+    q += 1.0;
+
+  double s = y / x;
+  double t = s * s;
+
+  double u;
+    u = (-1.88796008463073496563746e-05);
+    u = mad(u, t, (0.000209850076645816976906797));
+    u = mad(u, t, (-0.00110611831486672482563471));
+    u = mad(u, t, (0.00370026744188713119232403));
+    u = mad(u, t, (-0.00889896195887655491740809));
+    u = mad(u, t, (0.016599329773529201970117));
+    u = mad(u, t, (-0.0254517624932312641616861));
+    u = mad(u, t, (0.0337852580001353069993897));
+    u = mad(u, t, (-0.0407629191276836500001934));
+    u = mad(u, t, (0.0466667150077840625632675));
+    u = mad(u, t, (-0.0523674852303482457616113));
+    u = mad(u, t, (0.0587666392926673580854313));
+    u = mad(u, t, (-0.0666573579361080525984562));
+    u = mad(u, t, (0.0769219538311769618355029));
+    u = mad(u, t, (-0.090908995008245008229153));
+    u = mad(u, t, (0.111111105648261418443745));
+    u = mad(u, t, (-0.14285714266771329383765));
+    u = mad(u, t, (0.199999999996591265594148));
+    u = mad(u, t, (-0.333333333333311110369124));
+
+  t = mad(u, t * s, s);
+  t = mad(q, M_PI_2, t);
+
+  return t;
+}
+
+// Note: the order of arguments is y, x, as is convention for atan2 float
+float _CL_OVERLOADABLE _cl_atan2k(float y, float x)
+{
+  // Algorithm taken from SLEEF 2.80
+
+  float q = 0.0f;
+
+  if (signbit(x))
+    q = -2.0;
+  x = fabs(x);
+
+  bool q0 = (y > x);
+  float x0 = x;
+  float y0 = y;
+  x = q0 ? y0 : x0;
+  y = q0 ? -x0 : y0;
+  if (q0)
+    q += 1.0;
+
+  float s = y / x;
+  float t = s * s;
+
+  float u;
+  u = (0.00282363896258175373077393f);
+  u = mad(u, t, (-0.0159569028764963150024414f));
+  u = mad(u, t, (0.0425049886107444763183594f));
+  u = mad(u, t, (-0.0748900920152664184570312f));
+  u = mad(u, t, (0.106347933411598205566406f));
+  u = mad(u, t, (-0.142027363181114196777344f));
+  u = mad(u, t, (0.199926957488059997558594f));
+  u = mad(u, t, (-0.333331018686294555664062f));
+
+  t = mad(u, t * s, s);
+  t = mad(q, (float)M_PI_2, t);
+
+  return t;
+}
+
+// Note: the order of arguments is y, x, as is convention for atan2
+float _CL_OVERLOADABLE atan2(float y, float x)
+{
+  // Algorithm taken from SLEEF 2.80
+  float r = _cl_atan2k(fabs(y), x);
+  r = mulsign(r, x);
+  if(isinf(x) || x == 0.0f)
+    {
+      if (isinf(x))
+        r = (float)M_PI_2 - copysign((float)M_PI_2, x);
+      else
+        r = (float)M_PI_2;
+    }
+  if (isinf(y))
+    {
+      if (isinf(x))
+        r = (float)M_PI_2 - copysign((float)M_PI_4, x);
+      else
+        r = (float)M_PI_2;
+    }
+  if (y == 0.0)
+    {
+      if (signbit(x))
+        r = (float)M_PI;
+      else
+        r = 0.0;
+    }
+  if (isnan(x) || isnan(y))
+    return NAN;
+  else
+    return mulsign(r, y);
+}
+
+  // Note: the order of arguments is y, x, as is convention for atan2
+double _CL_OVERLOADABLE atan2(double y, double x)
+{
+  // Algorithm taken from SLEEF 2.80
+  double r = _cl_atan2k(fabs(y), x);
+  r = mulsign(r, x);
+  if(isinf(x) || x == 0.0f)
+    {
+      if (isinf(x))
+        r = (double)M_PI_2 - copysign((double)M_PI_2, x);
+      else
+        r = (double)M_PI_2;
+    }
+  if (isinf(y))
+    {
+      if (isinf(x))
+        r = (double)M_PI_2 - copysign((double)M_PI_4, x);
+      else
+        r = (double)M_PI_2;
+    }
+  if (y == 0.0)
+    {
+      if (signbit(x))
+        r = (double)M_PI;
+      else
+        r = 0.0;
+    }
+  if (isnan(x) || isnan(y))
+    return NAN;
+  else
+    return mulsign(r, y);
+}
+
+IMPLEMENT_VECWITHSCALARS(atan2, V_VV, float, int)
+
+IMPLEMENT_VECWITHSCALARS(atan2, V_VV, double, long)
diff --git a/lib/CL/pocl_hash.h b/lib/kernel/hsail64/atanh.cl
similarity index 57%
copy from lib/CL/pocl_hash.h
copy to lib/kernel/hsail64/atanh.cl
index 48e6a43..91adab6 100644
--- a/lib/CL/pocl_hash.h
+++ b/lib/kernel/hsail64/atanh.cl
@@ -1,4 +1,6 @@
-/* pocl_hash.h: interface for hash in pocl to allow easier changes later
+/* OpenCL built-in library: atanh.cl()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
@@ -19,24 +21,22 @@
    THE SOFTWARE.
 */
 
-#ifndef POCL_HASH_H
-#define POCL_HASH_H
 
-/* public api for steve reid's public domain SHA-1 implementation */
-/* this file is in the public domain */
+#include "hsail_templates.h"
 
-#include <stdint.h>
+#define ATANH(FTYPE)                                                      \
+  FTYPE _CL_OVERLOADABLE atanh(FTYPE x)                                   \
+  {                                                                       \
+    FTYPE r = fabs(x);                                                    \
+    r = (FTYPE)(0.5) * log(((FTYPE)(1.0) + r) / ((FTYPE)(1.0) - r));      \
+    r = copysign(r, x);                                                   \
+    return r;                                                             \
+  }
 
-typedef struct {
-    uint32_t state[5];
-    uint32_t count[2];
-    uint8_t  buffer[64];
-} SHA1_CTX;
+ATANH(float)
 
-#define SHA1_DIGEST_SIZE 20
+ATANH(double)
 
-void pocl_SHA1_Init(SHA1_CTX* context);
-void pocl_SHA1_Update(SHA1_CTX* context, const uint8_t* data, const size_t len);
-void pocl_SHA1_Final(SHA1_CTX* context, uint8_t digest[SHA1_DIGEST_SIZE]);
+IMPLEMENT_VECWITHSCALARS(atanh, V_V, float, int)
 
-#endif /* POCL_HASH_H */
+IMPLEMENT_VECWITHSCALARS(atanh, V_V, double, long)
diff --git a/lib/kernel/hsail64/atomic_impl.ll b/lib/kernel/hsail64/atomic_impl.ll
new file mode 100644
index 0000000..b161e7a
--- /dev/null
+++ b/lib/kernel/hsail64/atomic_impl.ll
@@ -0,0 +1,276 @@
+target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:64:64-p8:32:32-p9:64:64-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
+target triple = "hsail64"
+
+; This file is originally from libclc
+
+; *************************************************************************
+
+define i32 @__clc_atomic_add_addr1(i32 addrspace(1)* nocapture %ptr, i32 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile add i32 addrspace(1)* %ptr, i32 %value seq_cst
+  ret i32 %0
+}
+
+define i32 @__clc_atomic_add_addr3(i32 addrspace(2)* nocapture %ptr, i32 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile add i32 addrspace(2)* %ptr, i32 %value seq_cst
+  ret i32 %0
+}
+
+define i32 @__clc_atomic_and_addr1(i32 addrspace(1)* nocapture %ptr, i32 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile and i32 addrspace(1)* %ptr, i32 %value seq_cst
+  ret i32 %0
+}
+
+define i32 @__clc_atomic_and_addr3(i32 addrspace(2)* nocapture %ptr, i32 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile and i32 addrspace(2)* %ptr, i32 %value seq_cst
+  ret i32 %0
+}
+
+define i32 @__clc_atomic_cmpxchg_addr1(i32 addrspace(1)* nocapture %ptr, i32 %compare, i32 %value) nounwind alwaysinline {
+entry:
+  %0 = cmpxchg volatile i32 addrspace(1)* %ptr, i32 %compare, i32 %value seq_cst seq_cst
+  %1 = extractvalue { i32, i1 } %0, 0
+  ret i32 %1
+}
+
+define i32 @__clc_atomic_cmpxchg_addr3(i32 addrspace(2)* nocapture %ptr, i32 %compare, i32 %value) nounwind alwaysinline {
+entry:
+  %0 = cmpxchg volatile i32 addrspace(2)* %ptr, i32 %compare, i32 %value seq_cst seq_cst
+  %1 = extractvalue { i32, i1 } %0, 0
+  ret i32 %1
+}
+
+define i32 @__clc_atomic_max_addr1(i32 addrspace(1)* nocapture %ptr, i32 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile max i32 addrspace(1)* %ptr, i32 %value seq_cst
+  ret i32 %0
+}
+
+define i32 @__clc_atomic_max_addr3(i32 addrspace(2)* nocapture %ptr, i32 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile max i32 addrspace(2)* %ptr, i32 %value seq_cst
+  ret i32 %0
+}
+
+define i32 @__clc_atomic_min_addr1(i32 addrspace(1)* nocapture %ptr, i32 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile min i32 addrspace(1)* %ptr, i32 %value seq_cst
+  ret i32 %0
+}
+
+define i32 @__clc_atomic_min_addr3(i32 addrspace(2)* nocapture %ptr, i32 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile min i32 addrspace(2)* %ptr, i32 %value seq_cst
+  ret i32 %0
+}
+
+define i32 @__clc_atomic_or_addr1(i32 addrspace(1)* nocapture %ptr, i32 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile or i32 addrspace(1)* %ptr, i32 %value seq_cst
+  ret i32 %0
+}
+
+define i32 @__clc_atomic_or_addr3(i32 addrspace(2)* nocapture %ptr, i32 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile or i32 addrspace(2)* %ptr, i32 %value seq_cst
+  ret i32 %0
+}
+
+define i32 @__clc_atomic_umax_addr1(i32 addrspace(1)* nocapture %ptr, i32 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile umax i32 addrspace(1)* %ptr, i32 %value seq_cst
+  ret i32 %0
+}
+
+define i32 @__clc_atomic_umax_addr3(i32 addrspace(2)* nocapture %ptr, i32 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile umax i32 addrspace(2)* %ptr, i32 %value seq_cst
+  ret i32 %0
+}
+
+define i32 @__clc_atomic_umin_addr1(i32 addrspace(1)* nocapture %ptr, i32 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile umin i32 addrspace(1)* %ptr, i32 %value seq_cst
+  ret i32 %0
+}
+
+define i32 @__clc_atomic_umin_addr3(i32 addrspace(2)* nocapture %ptr, i32 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile umin i32 addrspace(2)* %ptr, i32 %value seq_cst
+  ret i32 %0
+}
+
+define i32 @__clc_atomic_sub_addr1(i32 addrspace(1)* nocapture %ptr, i32 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile sub i32 addrspace(1)* %ptr, i32 %value seq_cst
+  ret i32 %0
+}
+
+define i32 @__clc_atomic_sub_addr3(i32 addrspace(2)* nocapture %ptr, i32 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile sub i32 addrspace(2)* %ptr, i32 %value seq_cst
+  ret i32 %0
+}
+
+define i32 @__clc_atomic_xchg_addr1(i32 addrspace(1)* nocapture %ptr, i32 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile xchg i32 addrspace(1)* %ptr, i32 %value seq_cst
+  ret i32 %0
+}
+
+define i32 @__clc_atomic_xchg_addr3(i32 addrspace(2)* nocapture %ptr, i32 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile xchg i32 addrspace(2)* %ptr, i32 %value seq_cst
+  ret i32 %0
+}
+
+define i32 @__clc_atomic_xor_addr1(i32 addrspace(1)* nocapture %ptr, i32 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile xor i32 addrspace(1)* %ptr, i32 %value seq_cst
+  ret i32 %0
+}
+
+define i32 @__clc_atomic_xor_addr3(i32 addrspace(2)* nocapture %ptr, i32 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile xor i32 addrspace(2)* %ptr, i32 %value seq_cst
+  ret i32 %0
+}
+
+; *************************************************************************
+
+define i64 @__clc_atom_add_addr1(i64 addrspace(1)* nocapture %ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile add i64 addrspace(1)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc_atom_add_addr3(i64 addrspace(2)* nocapture %ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile add i64 addrspace(2)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc_atom_and_addr1(i64 addrspace(1)* nocapture %ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile and i64 addrspace(1)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc_atom_and_addr3(i64 addrspace(2)* nocapture %ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile and i64 addrspace(2)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc_atom_cmpxchg_addr1(i64 addrspace(1)* nocapture %ptr, i64 %compare, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = cmpxchg volatile i64 addrspace(1)* %ptr, i64 %compare, i64 %value seq_cst seq_cst
+  %1 = extractvalue { i64, i1 } %0, 0
+  ret i64 %1
+}
+
+define i64 @__clc_atom_cmpxchg_addr3(i64 addrspace(2)* nocapture %ptr, i64 %compare, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = cmpxchg volatile i64 addrspace(2)* %ptr, i64 %compare, i64 %value seq_cst seq_cst
+  %1 = extractvalue { i64, i1 } %0, 0
+  ret i64 %1
+}
+
+define i64 @__clc_atom_max_addr1(i64 addrspace(1)* nocapture %ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile max i64 addrspace(1)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc_atom_max_addr3(i64 addrspace(2)* nocapture %ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile max i64 addrspace(2)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc_atom_min_addr1(i64 addrspace(1)* nocapture %ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile min i64 addrspace(1)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc_atom_min_addr3(i64 addrspace(2)* nocapture %ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile min i64 addrspace(2)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc_atom_or_addr1(i64 addrspace(1)* nocapture %ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile or i64 addrspace(1)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc_atom_or_addr3(i64 addrspace(2)* nocapture %ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile or i64 addrspace(2)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc_atom_umax_addr1(i64 addrspace(1)* nocapture %ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile umax i64 addrspace(1)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc_atom_umax_addr3(i64 addrspace(2)* nocapture %ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile umax i64 addrspace(2)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc_atom_umin_addr1(i64 addrspace(1)* nocapture %ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile umin i64 addrspace(1)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc_atom_umin_addr3(i64 addrspace(2)* nocapture %ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile umin i64 addrspace(2)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc_atom_sub_addr1(i64 addrspace(1)* nocapture %ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile sub i64 addrspace(1)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc_atom_sub_addr3(i64 addrspace(2)* nocapture %ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile sub i64 addrspace(2)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc_atom_xchg_addr1(i64 addrspace(1)* nocapture %ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile xchg i64 addrspace(1)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc_atom_xchg_addr3(i64 addrspace(2)* nocapture %ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile xchg i64 addrspace(2)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc_atom_xor_addr1(i64 addrspace(1)* nocapture %ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile xor i64 addrspace(1)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc_atom_xor_addr3(i64 addrspace(2)* nocapture %ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile xor i64 addrspace(2)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
diff --git a/lib/kernel/hsail64/atomics.cl b/lib/kernel/hsail64/atomics.cl
new file mode 100644
index 0000000..8eee9d2
--- /dev/null
+++ b/lib/kernel/hsail64/atomics.cl
@@ -0,0 +1,130 @@
+/* This file is from libclc, licensed:
+
+Copyright (c) 2011-2014 by the contributors listed in CREDITS.TXT
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+*/
+
+
+/* These are defined in _kernel.h to be aliases of atomic_*,
+ * which breaks the following macros, so undef them for now
+ * (64bit atomics are all named "atom_" not "atomic_")
+ */
+#undef atom_add
+#undef atom_sub
+#undef atom_xchg
+#undef atom_inc
+#undef atom_dec
+#undef atom_cmpxchg
+#undef atom_min
+#undef atom_max
+#undef atom_and
+#undef atom_or
+#undef atom_xor
+
+#define ATOMIC_FUNC_DEFINE(RET_SIGN, ARG_SIGN, TYPE, CL_FUNCTION, CLC_FUNCTION, CL_ADDRSPACE, LLVM_ADDRSPACE) \
+_CL_OVERLOADABLE  RET_SIGN TYPE CL_FUNCTION (volatile CL_ADDRSPACE RET_SIGN TYPE *p, RET_SIGN TYPE val) { \
+    return (RET_SIGN TYPE)__clc_##CLC_FUNCTION##_addr##LLVM_ADDRSPACE((volatile CL_ADDRSPACE ARG_SIGN TYPE*)p, (ARG_SIGN TYPE)val); \
+}
+
+/* For atomic functions that don't need different bitcode dependending on argument signedness */
+#define ATOMIC_FUNC_SIGN(TYPE, FUNCTION, CL_ADDRSPACE, LLVM_ADDRSPACE) \
+    signed TYPE __clc_##FUNCTION##_addr##LLVM_ADDRSPACE(volatile CL_ADDRSPACE signed TYPE*, signed TYPE); \
+    ATOMIC_FUNC_DEFINE(signed, signed, TYPE, FUNCTION, FUNCTION, CL_ADDRSPACE, LLVM_ADDRSPACE) \
+    ATOMIC_FUNC_DEFINE(unsigned, signed, TYPE, FUNCTION, FUNCTION, CL_ADDRSPACE, LLVM_ADDRSPACE)
+
+#define ATOMIC_FUNC_ADDRSPACE(TYPE, FUNCTION) \
+    ATOMIC_FUNC_SIGN(TYPE, FUNCTION, global, 1) \
+    ATOMIC_FUNC_SIGN(TYPE, FUNCTION, local, 3)
+
+#define ATOMIC_FUNC(FUNCTION) \
+    ATOMIC_FUNC_ADDRSPACE(int, atomic ## FUNCTION) \
+    ATOMIC_FUNC_ADDRSPACE(long, atom ## FUNCTION)
+
+#define ATOMIC_FUNC_DEFINE_3_ARG(RET_SIGN, ARG_SIGN, TYPE, CL_FUNCTION, CLC_FUNCTION, CL_ADDRSPACE, LLVM_ADDRSPACE) \
+_CL_OVERLOADABLE  RET_SIGN TYPE CL_FUNCTION (volatile CL_ADDRSPACE RET_SIGN TYPE *p, RET_SIGN TYPE cmp, RET_SIGN TYPE val) { \
+	return (RET_SIGN TYPE)__clc_##CLC_FUNCTION##_addr##LLVM_ADDRSPACE((volatile CL_ADDRSPACE ARG_SIGN TYPE*)p, (ARG_SIGN TYPE)cmp, (ARG_SIGN TYPE)val); \
+}
+
+/* For atomic functions that don't need different bitcode dependending on argument signedness */
+#define ATOMIC_FUNC_SIGN_3_ARG(TYPE, FUNCTION, CL_ADDRSPACE, LLVM_ADDRSPACE) \
+    signed TYPE  __clc_##FUNCTION##_addr##LLVM_ADDRSPACE(volatile CL_ADDRSPACE signed TYPE*, signed TYPE, signed TYPE); \
+    ATOMIC_FUNC_DEFINE_3_ARG(signed, signed, TYPE, FUNCTION, FUNCTION, CL_ADDRSPACE, LLVM_ADDRSPACE) \
+    ATOMIC_FUNC_DEFINE_3_ARG(unsigned, signed, TYPE, FUNCTION, FUNCTION, CL_ADDRSPACE, LLVM_ADDRSPACE)
+
+#define ATOMIC_FUNC_ADDRSPACE_3_ARG(TYPE, FUNCTION) \
+    ATOMIC_FUNC_SIGN_3_ARG(TYPE, FUNCTION, global, 1) \
+    ATOMIC_FUNC_SIGN_3_ARG(TYPE, FUNCTION, local, 3)
+
+#define ATOMIC_FUNC_3_ARG(FUNCTION) \
+    ATOMIC_FUNC_ADDRSPACE_3_ARG(int, atomic ## FUNCTION) \
+    ATOMIC_FUNC_ADDRSPACE_3_ARG(long, atom ## FUNCTION)
+
+ATOMIC_FUNC(_add)
+ATOMIC_FUNC(_and)
+ATOMIC_FUNC(_or)
+ATOMIC_FUNC(_sub)
+ATOMIC_FUNC(_xchg)
+ATOMIC_FUNC(_xor)
+ATOMIC_FUNC_3_ARG(_cmpxchg)
+
+// 32bit
+
+signed int __clc_atomic_max_addr1(volatile global signed int*, signed int);
+signed int __clc_atomic_max_addr3(volatile local signed int*, signed int);
+uint __clc_atomic_umax_addr1(volatile global uint*, uint);
+uint __clc_atomic_umax_addr3(volatile local uint*, uint);
+
+ATOMIC_FUNC_DEFINE(signed, signed, int, atomic_max, atomic_max, global, 1)
+ATOMIC_FUNC_DEFINE(signed, signed, int, atomic_max, atomic_max, local, 3)
+ATOMIC_FUNC_DEFINE(unsigned, unsigned, int, atomic_max, atomic_umax, global, 1)
+ATOMIC_FUNC_DEFINE(unsigned, unsigned, int, atomic_max, atomic_umax, local, 3)
+
+signed int __clc_atomic_min_addr1(volatile global signed int*, signed int);
+signed int __clc_atomic_min_addr3(volatile local signed int*, signed int);
+uint __clc_atomic_umin_addr1(volatile global uint*, uint);
+uint __clc_atomic_umin_addr3(volatile local uint*, uint);
+
+ATOMIC_FUNC_DEFINE(signed, signed, int, atomic_min, atomic_min, global, 1)
+ATOMIC_FUNC_DEFINE(signed, signed, int, atomic_min, atomic_min, local, 3)
+ATOMIC_FUNC_DEFINE(unsigned, unsigned, int, atomic_min, atomic_umin, global, 1)
+ATOMIC_FUNC_DEFINE(unsigned, unsigned, int, atomic_min, atomic_umin, local, 3)
+
+// 64bit
+
+signed long __clc_atom_max_addr1(volatile global signed long*, signed long);
+signed long __clc_atom_max_addr3(volatile local signed long*, signed long);
+ulong __clc_atom_umax_addr1(volatile global ulong*, ulong);
+ulong __clc_atom_umax_addr3(volatile local ulong*, ulong);
+
+ATOMIC_FUNC_DEFINE(signed, signed, long, atom_max, atom_max, global, 1)
+ATOMIC_FUNC_DEFINE(signed, signed, long, atom_max, atom_max, local, 3)
+ATOMIC_FUNC_DEFINE(unsigned, unsigned, long, atom_max, atom_umax, global, 1)
+ATOMIC_FUNC_DEFINE(unsigned, unsigned, long, atom_max, atom_umax, local, 3)
+
+signed long __clc_atom_min_addr1(volatile global signed long*, signed long);
+signed long __clc_atom_min_addr3(volatile local signed long*, signed long);
+ulong __clc_atom_umin_addr1(volatile global ulong*, ulong);
+ulong __clc_atom_umin_addr3(volatile local ulong*, ulong);
+
+ATOMIC_FUNC_DEFINE(signed, signed, long, atom_min, atom_min, global, 1)
+ATOMIC_FUNC_DEFINE(signed, signed, long, atom_min, atom_min, local, 3)
+ATOMIC_FUNC_DEFINE(unsigned, unsigned, long, atom_min, atom_umin, global, 1)
+ATOMIC_FUNC_DEFINE(unsigned, unsigned, long, atom_min, atom_umin, local, 3)
diff --git a/lib/kernel/hsail64/barrier.c b/lib/kernel/hsail64/barrier.c
new file mode 100644
index 0000000..95ee858
--- /dev/null
+++ b/lib/kernel/hsail64/barrier.c
@@ -0,0 +1,56 @@
+/* OpenCL built-in library: HSAIL barrier
+
+   Copyright (c) 2015 Pekka Jääskeläinen of
+                      Tampere University of Technology
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+*/
+
+/* TODO: the noduplicate attribute for the builtin declarations
+   doesn't seem to propagate to LLVM IR. Might need to define this
+   in .ll due to this. */
+void __builtin_hsail_memfence (int, int) __attribute__((noduplicate));
+void __builtin_barrier () __attribute__((noduplicate));
+
+void _Z7barrierj(int flags)
+{
+/* HSA specs say that the barrier is only for cflow and there's a need for mem
+   fences to implement the OpenCL barrier() semantics.
+
+    2 = sequentially consistent acquire, 3 = release
+
+    3 = work-group (local) scope, 4 = agent (global) scope , 5 = system (~SVM) scope)
+*/
+
+  /* Release fence */
+  if (flags & CLK_GLOBAL_MEM_FENCE)
+    __builtin_hsail_memfence (3, 4);
+  else
+    __builtin_hsail_memfence (3, 3);
+
+/* Looking at test/CodeGen/HSAIL/llvm.hsail.barrier.ll the magic
+   number 34 seems to denote ALL WI synching. */
+  __builtin_hsail_barrier (34);
+
+  /* Acquire fence */
+  if (flags & CLK_GLOBAL_MEM_FENCE)
+    __builtin_hsail_memfence (2, 4);
+  else
+    __builtin_hsail_memfence (2, 3);
+}
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/cbrt.cl
similarity index 85%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/cbrt.cl
index 8f7714f..afb7a3c 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/cbrt.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: cbrt()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,6 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "../templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_EXPR_V_V(cbrt, (pow(a, (vtype)(1.0/3.0))))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/copysign.cl
similarity index 82%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/copysign.cl
index 8f7714f..31a2a1e 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/copysign.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: copysign()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,7 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "hsail_templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+#undef copysign
+DEFINE_LLVM_INTRIN_FP32_FP64(_cl_copysign, V_VV, copysign, 0.0)
diff --git a/lib/kernel/hsail64/cos.cl b/lib/kernel/hsail64/cos.cl
new file mode 100644
index 0000000..8b4e2a4
--- /dev/null
+++ b/lib/kernel/hsail64/cos.cl
@@ -0,0 +1,119 @@
+/* OpenCL built-in library: cos()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+*/
+
+#include "hsail_templates.h"
+
+float _CL_OVERLOADABLE cos(float d)
+{
+  // Algorithm taken from SLEEF 2.80
+
+  float PI4_A, PI4_B, PI4_C, PI4_D;
+  PI4_A = 0.78515625f;
+  PI4_B = 0.00024187564849853515625f;
+  PI4_C = 3.7747668102383613586e-08f;
+  PI4_D = 1.2816720341285448015e-12f;
+
+  float q = mad(2.0f, rint(mad(d, (float)M_1_PI, -0.5f)), 1.0f);
+  int iq = convert_int(q);
+
+#ifdef VML_HAVE_FP_CONTRACT
+  d = mad(q, (float)(-PI4_A*2), d);
+  d = mad(q, (float)(-PI4_B*2), d);
+  d = mad(q, (float)(-PI4_C*2), d);
+  d = mad(q, (float)(-PI4_D*2), d);
+#else
+  d = mad(q, (float)(-M_PI_2), d);
+#endif
+
+  float s = d * d;
+
+  //d = ifthen(convert_bool(iq & IV(I(2))), d, -d);
+  if (!(iq & 1))
+    d = -d;
+
+  float u;
+  u = (float)(2.6083159809786593541503e-06f);
+  u = mad(u, s, (float)(-0.0001981069071916863322258f));
+  u = mad(u, s, (float)(0.00833307858556509017944336f));
+  u = mad(u, s, (float)(-0.166666597127914428710938f));
+
+  u = mad(s, u * d, d);
+
+  if (isinf(d))
+    return NAN;
+  else
+    return u;
+}
+
+double _CL_OVERLOADABLE cos(double d)
+{
+  // Algorithm taken from SLEEF 2.80
+
+  double PI4_A, PI4_B, PI4_C, PI4_D;
+  PI4_A = 0.78539816290140151978;
+  PI4_B = 4.9604678871439933374e-10;
+  PI4_C = 1.1258708853173288931e-18;
+  PI4_D = 1.7607799325916000908e-27;
+
+  double q = mad((double)(2.0), rint(mad(d, (double)(M_1_PI), (double)(-0.5))), (double)(1.0));
+  int iq = convert_int(q);
+
+#ifdef VML_HAVE_FP_CONTRACT
+  d = mad(q, (double)(-PI4_A*2), d);
+  d = mad(q, (double)(-PI4_B*2), d);
+  d = mad(q, (double)(-PI4_C*2), d);
+  d = mad(q, (double)(-PI4_D*2), d);
+#else
+  d = mad(q, (double)(-M_PI_2), d);
+#endif
+
+  double s = d * d;
+
+  //d = ifthen(convert_bool(iq & IV(I(2))), d, -d);
+  if (!(iq & 2))
+    d = -d;
+
+  double u;
+  u = (double)(-7.97255955009037868891952e-18);
+  u = mad(u, s, (double)(2.81009972710863200091251e-15));
+  u = mad(u, s, (double)(-7.64712219118158833288484e-13));
+  u = mad(u, s, (double)(1.60590430605664501629054e-10));
+  u = mad(u, s, (double)(-2.50521083763502045810755e-08));
+  u = mad(u, s, (double)(2.75573192239198747630416e-06));
+  u = mad(u, s, (double)(-0.000198412698412696162806809));
+  u = mad(u, s, (double)(0.00833333333333332974823815));
+  u = mad(u, s, (double)(-0.166666666666666657414808));
+
+  u = mad(s, u * d, d);
+
+  //const real_t nan = std::numeric_limits<real_t>::quiet_NaN();
+  //u = ifthen(isinf(d), (double)(nan), u);
+
+  if (isinf(d))
+    return NAN;
+  else
+    return u;
+}
+
+IMPLEMENT_VECWITHSCALARS(cos, V_V, float, int)
+IMPLEMENT_VECWITHSCALARS(cos, V_V, double, int)
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/cosh.cl
similarity index 84%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/cosh.cl
index 8f7714f..00f12c3 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/cosh.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: hyper()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,7 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+#include "../templates.h"
+
+DEFINE_EXPR_V_V(cosh, ((exp(a) + exp(-a)) / (vtype)(2.0)))
diff --git a/lib/kernel/hsail64/exp.cl b/lib/kernel/hsail64/exp.cl
new file mode 100644
index 0000000..c6b6195
--- /dev/null
+++ b/lib/kernel/hsail64/exp.cl
@@ -0,0 +1,102 @@
+/* OpenCL built-in library: exp()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+
+   This implementation of exp() comes from libclc/generic/lib/math/exp.cl
+   License:
+
+ * Copyright (c) 2014,2015 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+
+*/
+
+/*
+#include "hsail_templates.h"
+
+#define MATH_DIVIDE(X, Y) ((X) / (Y))
+
+#undef exp
+
+__attribute__ ((overloadable)) float _cl_exp(float x) {
+
+    // Reduce x
+    const float ln2HI = 0x1.62e300p-1f;
+    const float ln2LO = 0x1.2fefa2p-17f;
+    const float invln2 = 0x1.715476p+0f;
+
+    float fhalF = x < 0.0f ? -0.5f : 0.5f;
+    int p = convert_int(mad(x, invln2, fhalF));
+    float fp = (float)p;
+    float hi = mad(fp, -ln2HI, x); // t*ln2HI is exact here
+    float lo = -fp*ln2LO;
+
+    // Evaluate poly
+    float t = hi + lo;
+    float tt  = t*t;
+    float v = mad(tt,
+                  -mad(tt,
+                       mad(tt,
+                           mad(tt,
+                               mad(tt, 0x1.637698p-25f, -0x1.bbd41cp-20f),
+                               0x1.1566aap-14f),
+                           -0x1.6c16c2p-9f),
+                       0x1.555556p-3f),
+                  t);
+
+    float y = 1.0f - (((-lo) - MATH_DIVIDE(t * v, 2.0f - v)) - hi);
+
+    // Scale by 2^p
+    float r =  as_float(as_int(y) + (p << 23));
+
+    const float ulim =  0x1.62e430p+6f; // ln(largest_normal) = 88.72283905206835305366
+    const float llim = -0x1.5d589ep+6f; // ln(smallest_normal) = -87.33654475055310898657
+
+    r = x < llim ? 0.0f : r;
+    r = x < ulim ? r : as_float(0x7f800000);
+    return isnan(x) ? x : r;
+}
+
+IMPLEMENT_VECWITHSCALARS(_cl_exp, V_V, float, float)
+
+IMPLEMENT_VECWITHSCALARS(_cl_exp, V_V, double, double)
+
+*/
+
+#include "../templates.h"
+
+DEFINE_EXPR_V_V(exp, exp2(TYPED_CONST(stype, M_LOG2E_H, M_LOG2E_F, M_LOG2E) * a))
diff --git a/lib/kernel/exp.cl b/lib/kernel/hsail64/exp10.cl
similarity index 77%
copy from lib/kernel/exp.cl
copy to lib/kernel/hsail64/exp10.cl
index ce3ef3d..bfa9e60 100644
--- a/lib/kernel/exp.cl
+++ b/lib/kernel/hsail64/exp10.cl
@@ -1,18 +1,17 @@
-/* OpenCL built-in library: exp()
+/* OpenCL built-in library: exp10()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011 Erik Schnetter <eschnetter at perimeterinstitute.ca>
-                      Perimeter Institute for Theoretical Physics
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,9 +21,8 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
-
-DEFINE_BUILTIN_V_V(exp)
+#include "../templates.h"
 
-DEFINE_EXPR_F_F(half_exp, exp(a))
-DEFINE_EXPR_F_F(native_exp, exp(a))
+DEFINE_EXPR_V_V(exp10, exp2(TYPED_CONST(stype, \
+                             (M_LOG2E_H * M_LN10_H), (M_LOG2E_F * M_LN10_F), \
+                             (M_LOG2E * M_LN10)) * a))
diff --git a/lib/kernel/hsail64/exp2.cl b/lib/kernel/hsail64/exp2.cl
new file mode 100644
index 0000000..355a3b1
--- /dev/null
+++ b/lib/kernel/hsail64/exp2.cl
@@ -0,0 +1,150 @@
+/* OpenCL built-in library: exp2()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+
+*/
+
+#include "hsail_templates.h"
+
+#include "vml_constants.h"
+
+float _CL_OVERLOADABLE exp2(float x)
+{
+  // TODO: Check SLEEF 2.80 algorithm
+  // (in particular the improved-precision truncation)
+
+  // Rescale
+  float x0 = x;
+
+  // Round by adding, then subtracting again a large number
+  // Add a large number to move the mantissa bits to the right
+  int large = ((int)1 << PROPS_FLOAT_MANTISSA_BITS) + PROPS_FLOAT_EXPONENT_OFFSET;
+  float tmp = x + (float)large;
+  // tmp.barrier();
+  __asm__ ("");
+
+  float round_x = tmp - (float)large;
+  x -= round_x;
+
+  //VML_ASSERT(all(x >= (float)(-0.5) && x <= (float)(0.5)));
+
+  // Polynomial expansion
+  float r;
+#ifdef VML_HAVE_FP_CONTRACT
+  // float, error=4.55549108005200277750378992345e-9
+  r = (float)(0.000154653240842602623787395880898);
+  r = mad(r, x, (float)(0.00133952915439234389712105060319));
+  r = mad(r, x, (float)(0.0096180399118156827664944870552));
+  r = mad(r, x, (float)(0.055503406540531310853149866446));
+  r = mad(r, x, (float)(0.240226511015459465468737123346));
+  r = mad(r, x, (float)(0.69314720007380208630542805293));
+  r = mad(r, x, (float)(0.99999999997182023878745628977));
+#else
+  // float, error=1.62772721960621336664735896836e-7
+  r = (float)(0.00133952915439234389712105060319);
+  r = mad(r, x, (float)(0.009670773148229417605024318985));
+  r = mad(r, x, (float)(0.055503406540531310853149866446));
+  r = mad(r, x, (float)(0.240222115700585316818177639177));
+  r = mad(r, x, (float)(0.69314720007380208630542805293));
+  r = mad(r, x, (float)(1.00000005230745711373079206024));
+#endif
+
+  // Use direct integer manipulation
+  // Extract integer as lowest mantissa bits (highest bits still
+  // contain offset, exponent, and sign)
+  int itmp = as_int(tmp);
+  // Construct scale factor by setting exponent (this shifts out the
+  // highest bits)
+  float scale = as_float(itmp << PROPS_FLOAT_MANTISSA_BITS);
+  r *= scale;
+
+  if (x0 < (float)PROPS_FLOAT_MIN_EXPONENT)
+    return 0.0f;
+  else
+    return r;
+}
+
+double _CL_OVERLOADABLE exp2(double x)
+{
+  // TODO: Check SLEEF 2.80 algorithm
+  // (in particular the improved-precision truncation)
+
+  // Rescale
+  double x0 = x;
+
+  // Round by adding, then subtracting again a large number
+  // Add a large number to move the mantissa bits to the right
+  long large = ((long)1 << PROPS_DOUBLE_MANTISSA_BITS) + PROPS_DOUBLE_EXPONENT_OFFSET;
+  double tmp = x + (double)large;
+  // tmp.barrier();
+  __asm__ ("");
+
+  double round_x = tmp - (double)large;
+  x -= round_x;
+
+  // Polynomial expansion
+  double r;
+#ifdef VML_HAVE_FP_CONTRACT
+  // double, error=9.32016781355638010975628074746e-18
+  r = (double)(4.45623165388261696886670014471e-10);
+  r = mad(r, x, (double)(7.0733589360775271430968224806e-9));
+  r = mad(r, x, (double)(1.01780540270960163558119510246e-7));
+  r = mad(r, x, (double)(1.3215437348041505269462510712e-6));
+  r = mad(r, x, (double)(0.000015252733849766201174247690629));
+  r = mad(r, x, (double)(0.000154035304541242555115696403795));
+  r = mad(r, x, (double)(0.00133335581463968601407096905671));
+  r = mad(r, x, (double)(0.0096181291075949686712855561931));
+  r = mad(r, x, (double)(0.055504108664821672870565883052));
+  r = mad(r, x, (double)(0.240226506959101382690753994082));
+  r = mad(r, x, (double)(0.69314718055994530864272481773));
+  r = mad(r, x, (double)(0.9999999999999999978508676375));
+#else
+  // double, error=3.74939899823302048807873981077e-14
+  r = (double)(1.02072375599725694063203809188e-7);
+  r = mad(r, x, (double)(1.32573274434801314145133004073e-6));
+  r = mad(r, x, (double)(0.0000152526647170731944840736190013));
+  r = mad(r, x, (double)(0.000154034441925859828261898614555));
+  r = mad(r, x, (double)(0.00133335582175770747495287552557));
+  r = mad(r, x, (double)(0.0096181291794939392517233403183));
+  r = mad(r, x, (double)(0.055504108664525029438908798685));
+  r = mad(r, x, (double)(0.240226506957026959772247598695));
+  r = mad(r, x, (double)(0.6931471805599487321347668143));
+  r = mad(r, x, (double)(1.00000000000000942892870993489));
+#endif
+
+  // Use direct integer manipulation
+  // Extract integer as lowest mantissa bits (highest bits still
+  // contain offset, exponent, and sign)
+  long itmp = as_long(tmp);
+  // Construct scale factor by setting exponent (this shifts out the
+  // highest bits)
+  double scale = as_double(itmp << PROPS_DOUBLE_MANTISSA_BITS);
+  r *= scale;
+
+  if (x0 < (float)PROPS_DOUBLE_MIN_EXPONENT)
+    return 0.0;
+  else
+    return r;
+}
+
+IMPLEMENT_VECWITHSCALARS(exp2, V_V, float, int)
+
+IMPLEMENT_VECWITHSCALARS(exp2, V_V, double, int)
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/expm1.cl
similarity index 85%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/expm1.cl
index 8f7714f..0bb8e3f 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/expm1.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: expm1()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,6 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "../templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_EXPR_V_V(expm1, (exp(a) - (vtype)1.0))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/fabs.cl
similarity index 82%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/fabs.cl
index 8f7714f..3a7f2b1 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/fabs.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: fabs()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,7 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "hsail_templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+#undef fabs
+IMPLEMENT_EXPR_ALL(_cl_fabs, V_V, __builtin_fabsf(a), __builtin_fabs(a))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/floor.cl
similarity index 82%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/floor.cl
index 8f7714f..e17a2f1 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/floor.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: floor()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,7 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "hsail_templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+#undef floor
+IMPLEMENT_EXPR_ALL(_cl_floor, V_V, __builtin_floorf(a), __builtin_floor(a))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/fma.cl
similarity index 84%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/fma.cl
index 8f7714f..33c25b5 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/fma.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: fma()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,7 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "hsail_templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+#undef fma
+DEFINE_LLVM_INTRIN_FP32_FP64(_cl_fma, V_VVV, fma, 0.0)
diff --git a/lib/CL/clReleaseEvent.c b/lib/kernel/hsail64/fract.cl
similarity index 51%
copy from lib/CL/clReleaseEvent.c
copy to lib/kernel/hsail64/fract.cl
index 436f568..af83a2a 100644
--- a/lib/CL/clReleaseEvent.c
+++ b/lib/kernel/hsail64/fract.cl
@@ -1,17 +1,17 @@
-/* OpenCL runtime library: clReleaseEvent()
+/* OpenCL built-in library: fract()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2012 Pekka Jääskeläinen / Tampere University of Technology
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,25 +21,47 @@
    THE SOFTWARE.
 */
 
-#include "pocl_cl.h"
-#include "pocl_mem_management.h"
+#include "hsail_templates.h"
 
-CL_API_ENTRY cl_int CL_API_CALL
-POname(clReleaseEvent)(cl_event event) CL_API_SUFFIX__VERSION_1_0
+
+float _CL_OVERLOADABLE fract(float a, __global float *b)
 {
-  int new_refcount;
-  POCL_RETURN_ERROR_COND((event == NULL), CL_INVALID_EVENT);
+  *b = floor(a);
+  return fmin(a - floor(a), 0x1.fffffep-1f);
+}
 
-  POCL_RETURN_ERROR_COND((event->queue == NULL), CL_INVALID_EVENT);
+double _CL_OVERLOADABLE fract(double a, __global double *b)
+{
+  *b = floor(a);
+  return fmin(a - floor(a), 0x1.fffffffffffffp-1);
+}
 
-  POCL_RELEASE_OBJECT (event, new_refcount);
 
-  if (new_refcount == 0)
-    {
-      POname(clReleaseCommandQueue) (event->queue);
-      pocl_mem_manager_free_event (event);
-    }
+float _CL_OVERLOADABLE fract(float a, __local float *b)
+{
+  *b = floor(a);
+  return fmin(a - floor(a), 0x1.fffffep-1f);
+}
 
-  return CL_SUCCESS;
+double _CL_OVERLOADABLE fract(double a, __local double *b)
+{
+  *b = floor(a);
+  return fmin(a - floor(a), 0x1.fffffffffffffp-1);
 }
-POsym(clReleaseEvent)
+
+
+float _CL_OVERLOADABLE fract(float a, __private float *b)
+{
+  *b = floor(a);
+  return fmin(a - floor(a), 0x1.fffffep-1f);
+}
+
+double _CL_OVERLOADABLE fract(double a, __private double *b)
+{
+  *b = floor(a);
+  return fmin(a - floor(a), 0x1.fffffffffffffp-1);
+}
+
+IMPLEMENT_EXPR_V_VP_ALL(fract, float, float)
+
+IMPLEMENT_EXPR_V_VP_ALL(fract, double, double)
diff --git a/lib/kernel/exp10.cl b/lib/kernel/hsail64/frexp.cl
similarity index 70%
copy from lib/kernel/exp10.cl
copy to lib/kernel/hsail64/frexp.cl
index 737402c..49c1f0b 100644
--- a/lib/kernel/exp10.cl
+++ b/lib/kernel/hsail64/frexp.cl
@@ -1,18 +1,17 @@
-/* OpenCL built-in library: exp10()
+/* OpenCL built-in library: frexp()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011 Erik Schnetter <eschnetter at perimeterinstitute.ca>
-                      Perimeter Institute for Theoretical Physics
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,9 +21,22 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "hsail_templates.h"
+
+#include "vml_constants.h"
+
+#define ADDRSPACE __local
+#include "frexp.inc"
+#undef ADDRSPACE
+
+#define ADDRSPACE __global
+#include "frexp.inc"
+#undef ADDRSPACE
+
+#define ADDRSPACE __private
+#include "frexp.inc"
+#undef ADDRSPACE
 
-DEFINE_EXPR_V_V(exp10, exp10(a*TYPED_CONST(stype, M_LN10_H, M_LN10_F, M_LN10)))
+IMPLEMENT_EXPR_V_VP_ALL(frexp, float, int)
 
-DEFINE_EXPR_F_F(half_exp10, exp10(a))
-DEFINE_EXPR_F_F(native_exp10, exp10(a))
+IMPLEMENT_EXPR_V_VP_ALL(frexp, double, int)
diff --git a/lib/kernel/hsail64/frexp.inc b/lib/kernel/hsail64/frexp.inc
new file mode 100644
index 0000000..a1d7074
--- /dev/null
+++ b/lib/kernel/hsail64/frexp.inc
@@ -0,0 +1,63 @@
+float _CL_OVERLOADABLE frexp(float x, ADDRSPACE int* irp)
+{
+  int e = LSR_F(x);
+  int ir = e - (int)(PROPS_FLOAT_EXPONENT_OFFSET - 1);
+  //ir = ifthen(convert_bool(e), ir, IV(std::numeric_limits<int_t>::min()));
+  if (!(e))
+    ir = INT_MIN;
+#if defined VML_HAVE_INF
+  //ir = ifthen(isinf(x), IV(std::numeric_limits<int_t>::max()), ir);
+  if (isinf(x))
+    ir = INT_MAX;
+#endif
+#if defined VML_HAVE_NAN
+  //ir = ifthen(isnan(x), IV(std::numeric_limits<int_t>::min()), ir);
+  if (isnan(x))
+    ir = INT_MIN;
+#endif
+  float r =
+    as_float((as_int(x) & (int)(PROPS_FLOAT_SIGNBIT_MASK | PROPS_FLOAT_MANTISSA_MASK)) |
+             (int)(as_int(0.5f) & PROPS_FLOAT_EXPONENT_MASK));
+  // bool iszero = (x == 0.0f);
+  if (x == 0.0f)
+    {
+      //ir = ifthen(iszero, IV(I(0)), ir);
+      //r = ifthen(iszero, copysign(RV(R(0.0)), r), r);
+      ir = 0;
+      r = copysign(0.0f, r);
+    }
+  *irp = ir;
+  return r;
+}
+
+double _CL_OVERLOADABLE frexp(double x, ADDRSPACE int* irp)
+{
+  int e = LSR_D(x);
+  int ir = e - (int)(PROPS_DOUBLE_EXPONENT_OFFSET - 1);
+  //ir = ifthen(convert_bool(e), ir, IV(std::numeric_limits<long_t>::min()));
+  if (!(e))
+    ir = INT_MIN;
+#if defined VML_HAVE_INF
+  //ir = ifthen(isinf(x), IV(std::numeric_limits<long_t>::max()), ir);
+  if (isinf(x))
+    ir = INT_MAX;
+#endif
+#if defined VML_HAVE_NAN
+  //ir = ifthen(isnan(x), IV(std::numeric_limits<long_t>::min()), ir);
+  if (isnan(x))
+    ir = INT_MIN;
+#endif
+  double r =
+    as_double((as_long(x) & (long)(PROPS_DOUBLE_SIGNBIT_MASK | PROPS_DOUBLE_MANTISSA_MASK)) |
+             (as_long(0.5f) & PROPS_DOUBLE_EXPONENT_MASK));
+  // bool iszero = (x == 0.0f);
+  if (x == 0.0)
+    {
+      //ir = ifthen(iszero, IV(I(0)), ir);
+      //r = ifthen(iszero, copysign(RV(R(0.0)), r), r);
+      ir = 0;
+      r = copysign(0.0, r);
+    }
+  *irp = ir;
+  return r;
+}
diff --git a/lib/CL/clRetainDevice.c b/lib/kernel/hsail64/get_global_id.c
similarity index 71%
copy from lib/CL/clRetainDevice.c
copy to lib/kernel/hsail64/get_global_id.c
index f9c9a88..ac999f6 100644
--- a/lib/CL/clRetainDevice.c
+++ b/lib/kernel/hsail64/get_global_id.c
@@ -1,17 +1,17 @@
-/* OpenCL runtime library: clRetainDevice()
+/* OpenCL built-in library: get_global_id() for HSAIL64
+
+   Copyright (c) 2015 Pekka Jääskeläinen
 
-   Copyright (c) 2012 Pekka Jääskeläinen / TUT
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -20,12 +20,16 @@
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
 */
-#include "pocl_cl.h"
 
-CL_API_ENTRY cl_int CL_API_CALL
-POname(clRetainDevice)(cl_device_id device) CL_API_SUFFIX__VERSION_1_2
+size_t _CL_OVERLOADABLE
+get_global_id(unsigned int dimindx)
 {
-  POCL_RETAIN_OBJECT (device);
-  return CL_SUCCESS;
+  switch(dimindx)
+    {
+      /* TODO: add get_global_offset(X) to these! */
+      case 0: return __builtin_hsail_workitemabsid(0);
+      case 1: return __builtin_hsail_workitemabsid(1);
+      case 2: return __builtin_hsail_workitemabsid(2);
+      default: return 0;
+    }
 }
-POsym(clRetainDevice)
diff --git a/lib/CL/clReleaseEvent.c b/lib/kernel/hsail64/get_global_size.c
similarity index 61%
copy from lib/CL/clReleaseEvent.c
copy to lib/kernel/hsail64/get_global_size.c
index 436f568..2aff753 100644
--- a/lib/CL/clReleaseEvent.c
+++ b/lib/kernel/hsail64/get_global_size.c
@@ -1,17 +1,17 @@
-/* OpenCL runtime library: clReleaseEvent()
+/* OpenCL built-in library: get_global_size() for HSAIL64
+
+   Copyright (c) 2015 Michal Babej
 
-   Copyright (c) 2012 Pekka Jääskeläinen / Tampere University of Technology
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,25 +21,20 @@
    THE SOFTWARE.
 */
 
-#include "pocl_cl.h"
-#include "pocl_mem_management.h"
-
-CL_API_ENTRY cl_int CL_API_CALL
-POname(clReleaseEvent)(cl_event event) CL_API_SUFFIX__VERSION_1_0
+size_t _CL_OVERLOADABLE
+get_global_size(unsigned int dimindx)
 {
-  int new_refcount;
-  POCL_RETURN_ERROR_COND((event == NULL), CL_INVALID_EVENT);
-
-  POCL_RETURN_ERROR_COND((event->queue == NULL), CL_INVALID_EVENT);
-
-  POCL_RELEASE_OBJECT (event, new_refcount);
-
-  if (new_refcount == 0)
+  switch(dimindx)
     {
-      POname(clReleaseCommandQueue) (event->queue);
-      pocl_mem_manager_free_event (event);
+/*
+ * TODO This should be the actual code used, but currently it crashes llvm
+      case 0: return __builtin_hsail_gridsize(0);
+      case 1: return __builtin_hsail_gridsize(1);
+      case 2: return __builtin_hsail_gridsize(2);
+*/
+      case 0: return __builtin_hsail_gridgroups(0) * __builtin_hsail_workgroupsize(0);
+      case 1: return __builtin_hsail_gridgroups(1) * __builtin_hsail_workgroupsize(1);
+      case 2: return __builtin_hsail_gridgroups(2) * __builtin_hsail_workgroupsize(2);
+      default: return 0;
     }
-
-  return CL_SUCCESS;
 }
-POsym(clReleaseEvent)
diff --git a/lib/CL/clRetainDevice.c b/lib/kernel/hsail64/get_group_id.c
similarity index 74%
copy from lib/CL/clRetainDevice.c
copy to lib/kernel/hsail64/get_group_id.c
index f9c9a88..dafb353 100644
--- a/lib/CL/clRetainDevice.c
+++ b/lib/kernel/hsail64/get_group_id.c
@@ -1,17 +1,17 @@
-/* OpenCL runtime library: clRetainDevice()
+/* OpenCL built-in library: get_group_id() for HSAIL64
+
+   Copyright (c) 2015 Pekka Jääskeläinen of TUT
 
-   Copyright (c) 2012 Pekka Jääskeläinen / TUT
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -20,12 +20,15 @@
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
 */
-#include "pocl_cl.h"
 
-CL_API_ENTRY cl_int CL_API_CALL
-POname(clRetainDevice)(cl_device_id device) CL_API_SUFFIX__VERSION_1_2
+size_t _CL_OVERLOADABLE
+get_group_id(unsigned int dimindx)
 {
-  POCL_RETAIN_OBJECT (device);
-  return CL_SUCCESS;
-}
-POsym(clRetainDevice)
+  switch(dimindx)
+    {
+    case 0: return __builtin_hsail_workgroupid(0);
+    case 1: return __builtin_hsail_workgroupid(1);
+    case 2: return __builtin_hsail_workgroupid(2);
+    default: return 0;
+    }
+ }
diff --git a/lib/CL/clRetainDevice.c b/lib/kernel/hsail64/get_local_id.c
similarity index 71%
copy from lib/CL/clRetainDevice.c
copy to lib/kernel/hsail64/get_local_id.c
index f9c9a88..90a1c15 100644
--- a/lib/CL/clRetainDevice.c
+++ b/lib/kernel/hsail64/get_local_id.c
@@ -1,17 +1,18 @@
-/* OpenCL runtime library: clRetainDevice()
+/* OpenCL built-in library: get_local_id() for HSAIL64
+
+   Copyright (c) 2015 Pekka Jääskeläinen of
+                      Tampere University of Technology
 
-   Copyright (c) 2012 Pekka Jääskeläinen / TUT
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -20,12 +21,15 @@
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
 */
-#include "pocl_cl.h"
 
-CL_API_ENTRY cl_int CL_API_CALL
-POname(clRetainDevice)(cl_device_id device) CL_API_SUFFIX__VERSION_1_2
+size_t _CL_OVERLOADABLE
+get_local_id(unsigned int dimindx)
 {
-  POCL_RETAIN_OBJECT (device);
-  return CL_SUCCESS;
+  switch(dimindx)
+    {
+    case 0: return __builtin_hsail_workitemid (0);
+    case 1: return __builtin_hsail_workitemid (1);
+    case 2: return __builtin_hsail_workitemid (2);
+    default: return 0;
+    }
 }
-POsym(clRetainDevice)
diff --git a/lib/CL/clRetainDevice.c b/lib/kernel/hsail64/get_local_size.c
similarity index 72%
copy from lib/CL/clRetainDevice.c
copy to lib/kernel/hsail64/get_local_size.c
index f9c9a88..f6a724e 100644
--- a/lib/CL/clRetainDevice.c
+++ b/lib/kernel/hsail64/get_local_size.c
@@ -1,17 +1,17 @@
-/* OpenCL runtime library: clRetainDevice()
+/* OpenCL built-in library: get_local_size() for HSAIL64
+
+   Copyright (c) 2015 Pekka Jääskeläinen of TUT
 
-   Copyright (c) 2012 Pekka Jääskeläinen / TUT
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -20,12 +20,16 @@
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
 */
-#include "pocl_cl.h"
 
-CL_API_ENTRY cl_int CL_API_CALL
-POname(clRetainDevice)(cl_device_id device) CL_API_SUFFIX__VERSION_1_2
+size_t _CL_OVERLOADABLE
+get_local_size(unsigned int dimindx)
 {
-  POCL_RETAIN_OBJECT (device);
-  return CL_SUCCESS;
+  switch(dimindx)
+    {
+    case 0: return  __builtin_hsail_currentworkgroupsize(0);
+    case 1: return  __builtin_hsail_currentworkgroupsize(1);
+    case 2: return  __builtin_hsail_currentworkgroupsize(2);
+    default: return 0;
+    }
 }
-POsym(clRetainDevice)
+
diff --git a/lib/CL/clRetainDevice.c b/lib/kernel/hsail64/get_num_groups.c
similarity index 74%
copy from lib/CL/clRetainDevice.c
copy to lib/kernel/hsail64/get_num_groups.c
index f9c9a88..9898690 100644
--- a/lib/CL/clRetainDevice.c
+++ b/lib/kernel/hsail64/get_num_groups.c
@@ -1,17 +1,17 @@
-/* OpenCL runtime library: clRetainDevice()
+/* OpenCL built-in library: get_num_groups() for HSAIL64
+
+   Copyright (c) 2015 Michal Babej
 
-   Copyright (c) 2012 Pekka Jääskeläinen / TUT
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -20,12 +20,15 @@
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
 */
-#include "pocl_cl.h"
 
-CL_API_ENTRY cl_int CL_API_CALL
-POname(clRetainDevice)(cl_device_id device) CL_API_SUFFIX__VERSION_1_2
+size_t _CL_OVERLOADABLE
+get_num_groups(unsigned int dimindx)
 {
-  POCL_RETAIN_OBJECT (device);
-  return CL_SUCCESS;
+  switch(dimindx)
+    {
+      case 0: return __builtin_hsail_gridgroups(0);
+      case 1: return __builtin_hsail_gridgroups(1);
+      case 2: return __builtin_hsail_gridgroups(2);
+      default: return 0;
+    }
 }
-POsym(clRetainDevice)
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/get_work_dim.c
similarity index 86%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/get_work_dim.c
index 8f7714f..cffda29 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/get_work_dim.c
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: get_work_dim() for HSAIL64
+
+   Copyright (c) 2015 Michal Babej
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,8 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
-
-DEFINE_EXPR_F_F(native_log2, log2(a))
+uint _CL_OVERLOADABLE
+get_work_dim(void)
+{
+  return __builtin_hsail_dim();
+}
diff --git a/lib/kernel/hsail64/hsail_templates.h b/lib/kernel/hsail64/hsail_templates.h
new file mode 100644
index 0000000..1fa922b
--- /dev/null
+++ b/lib/kernel/hsail64/hsail_templates.h
@@ -0,0 +1,304 @@
+/* OpenCL built-in library: builtin implementation templates for HSAIL
+
+   Copyright (c) 2011-2013 Erik Schnetter
+   Copyright (c) 2015 Michal Babej
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+*/
+
+/* TODO possibly prefix with HSAIL to not conflict with ../templates.h */
+
+/**********************************************************************/
+
+// Make vectorized versions of a scalar builtin using Divide-n-Conquer
+
+#define IMPLEMENT_VECWITHSCALARS_V_V(NAME, VTYPE, ITYPE, IVTYPE, LO, HI)      \
+  VTYPE _CL_OVERLOADABLE                  \
+  NAME(VTYPE a)                                         \
+  {                                                     \
+    return (VTYPE)(NAME(a.LO), NAME(a.HI));             \
+  }
+
+#define IMPLEMENT_VECWITHSCALARS_V_VV(NAME, VTYPE, ITYPE, IVTYPE, LO, HI)     \
+  VTYPE _CL_OVERLOADABLE                  \
+  NAME(VTYPE a, VTYPE b)                                \
+  {                                                     \
+    return (VTYPE)(NAME(a.LO, b.LO), NAME(a.HI, b.HI)); \
+  }
+
+#define IMPLEMENT_VECWITHSCALARS_V_VVV(NAME, VTYPE, ITYPE, IVTYPE, LO, HI)    \
+  VTYPE _CL_OVERLOADABLE                                  \
+  NAME(VTYPE a, VTYPE b, VTYPE c)                                       \
+  {                                                                     \
+    return (VTYPE)(NAME(a.LO, b.LO, c.LO), NAME(a.HI, b.HI, c.HI));     \
+  }
+
+// ldexp
+#define IMPLEMENT_VECWITHSCALARS_V_VI(NAME, VTYPE, ITYPE, IVTYPE, LO, HI)     \
+  VTYPE _CL_OVERLOADABLE                  \
+  NAME(VTYPE a, IVTYPE b)                               \
+  {                                                     \
+    return (VTYPE)(NAME(a.LO, b.LO), NAME(a.HI, b.HI)); \
+  }                                                     \
+  VTYPE _CL_OVERLOADABLE                  \
+  NAME(VTYPE a, ITYPE b)                                \
+  {                                                     \
+    return (VTYPE)(NAME(a, (IVTYPE)b)); \
+  }
+
+// ilogb
+#define IMPLEMENT_VECWITHSCALARS_I_V(NAME, VTYPE, ITYPE, IVTYPE, LO, HI)     \
+  IVTYPE _CL_OVERLOADABLE                  \
+  NAME(VTYPE a)                               \
+  {                                                     \
+    return (IVTYPE)(NAME(a.LO), NAME(a.HI)); \
+  }
+
+/**********************************************************************/
+
+#define  IMPLEMENT_VECWITHSCALARS(NAME, TYPE, STYPE, ITYPE)    \
+  IMPLEMENT_VECWITHSCALARS_ ## TYPE(NAME, STYPE ## 2, ITYPE, ITYPE ## 2, lo, hi)          \
+  IMPLEMENT_VECWITHSCALARS_ ## TYPE(NAME, STYPE ## 3, ITYPE, ITYPE ## 3, lo, s2)          \
+  IMPLEMENT_VECWITHSCALARS_ ## TYPE(NAME, STYPE ## 4, ITYPE, ITYPE ## 4, lo, hi)          \
+  IMPLEMENT_VECWITHSCALARS_ ## TYPE(NAME, STYPE ## 8, ITYPE, ITYPE ## 8, lo, hi)          \
+  IMPLEMENT_VECWITHSCALARS_ ## TYPE(NAME, STYPE ## 16, ITYPE, ITYPE ## 16, lo, hi)
+
+/**********************************************************************/
+
+// ASM for scalar, DnC for vectors
+#define  IMPLEMENT_LLVM_INTRIN_V_V_ALL(NAME, STYPE, BUILTIN, SUFFIX) \
+  STYPE NAME ## _internal_v_ ## STYPE(STYPE a)  __asm("llvm."#BUILTIN#SUFFIX);  \
+  _CL_OVERLOADABLE STYPE NAME(STYPE a) { return NAME ## _internal_v_ ## STYPE(a); } \
+  IMPLEMENT_VECWITHSCALARS(NAME, V_V, STYPE, STYPE)
+
+#define  IMPLEMENT_LLVM_INTRIN_V_VV_ALL(NAME, STYPE, BUILTIN, SUFFIX) \
+  STYPE NAME ## _internal_vv_ ## STYPE(STYPE a, STYPE b)  __asm("llvm."#BUILTIN#SUFFIX);  \
+  _CL_OVERLOADABLE STYPE NAME(STYPE a, STYPE b) { return NAME ## _internal_vv_ ## STYPE(a, b); } \
+  IMPLEMENT_VECWITHSCALARS(NAME, V_VV, STYPE, STYPE)
+
+#define  IMPLEMENT_LLVM_INTRIN_V_VVV_ALL(NAME, STYPE, BUILTIN, SUFFIX) \
+  STYPE NAME ## _internal_vvv_ ## STYPE(STYPE a, STYPE b,STYPE c)  __asm("llvm."#BUILTIN#SUFFIX);  \
+  _CL_OVERLOADABLE STYPE NAME(STYPE a, STYPE b,STYPE c) { return NAME ## _internal_vvv_ ## STYPE(a, b, c); } \
+  IMPLEMENT_VECWITHSCALARS(NAME, V_VVV, STYPE, STYPE)
+
+#define  IMPLEMENT_LLVM_INTRIN_V_VI_ALL(NAME, STYPE, ITYPE, BUILTIN, SUFFIX) \
+  STYPE NAME ## _internal_vi_ ## STYPE(STYPE a, ITYPE b) __asm("llvm."#BUILTIN#SUFFIX);   \
+  _CL_OVERLOADABLE STYPE NAME(STYPE a, ITYPE b) { return NAME ## _internal_vi_ ## STYPE(a, b); } \
+  IMPLEMENT_VECWITHSCALARS(NAME, V_VI, STYPE, ITYPE)
+
+/**********************************************************************/
+
+// Implement a builtin using an Expression
+
+#define IMPL_BODY(VTYPE, STYPE, VTYPE2, STYPE2, EXPR) \
+  {                                                                     \
+    typedef VTYPE vtype;                                                \
+    typedef STYPE stype;                                                \
+    typedef VTYPE2 vtype2;                                              \
+    typedef STYPE2 stype2;                                              \
+    return EXPR;                                                        \
+  }
+
+#define IMPLEMENT_EXPR_V_V(NAME, EXPR, VTYPE, STYPE, VTYPE2, STYPE2)    \
+  VTYPE _CL_OVERLOADABLE                                  \
+  NAME(VTYPE a)                                                         \
+  IMPL_BODY(VTYPE, STYPE, VTYPE2, STYPE2, EXPR)
+
+#define IMPLEMENT_EXPR_V_VV(NAME, EXPR, VTYPE, STYPE, VTYPE2, STYPE2)   \
+  VTYPE _CL_OVERLOADABLE                                  \
+  NAME(VTYPE a, VTYPE b)                                                \
+  IMPL_BODY(VTYPE, STYPE, VTYPE2, STYPE2, EXPR)
+
+#define IMPLEMENT_EXPR_V_VVV(NAME, EXPR, VTYPE, STYPE, VTYPE2, STYPE2)  \
+  VTYPE _CL_OVERLOADABLE                                  \
+  NAME(VTYPE a, VTYPE b, VTYPE c)                                       \
+  IMPL_BODY(VTYPE, STYPE, VTYPE2, STYPE2, EXPR)
+
+#define IMPLEMENT_EXPR_V_VS(NAME, EXPR, VTYPE, STYPE, VTYPE2, STYPE2)   \
+  VTYPE _CL_OVERLOADABLE                                  \
+  NAME(VTYPE a, STYPE b)                                                \
+  IMPL_BODY(VTYPE, STYPE, VTYPE2, STYPE2, EXPR)
+
+/**********************************************************************/
+
+// Converts, useful for when you only have builtin for uint32 & uint64,
+// but need opencl for all the integers
+#define IMPLEMENT_CONV_V_V(NAME, EXPR, VTYPE, STYPE, VTYPE2, STYPE2)    \
+  VTYPE _CL_OVERLOADABLE                                  \
+  NAME(VTYPE a)                                                         \
+  {                                                                     \
+    return convert_ ## VTYPE(NAME(convert_ ## VTYPE2(a)));                   \
+  }
+
+#define IMPLEMENT_CONV_V_VV(NAME, EXPR, VTYPE, STYPE, VTYPE2, STYPE2)    \
+  VTYPE _CL_OVERLOADABLE                                  \
+  NAME(VTYPE a, VTYPE b)                                                \
+  {                                                                     \
+    return convert_ ## VTYPE(NAME(convert_ ## VTYPE2(a), convert_ ## VTYPE2(b))); \
+  }
+
+#define IMPLEMENT_CONV_V_VVV(NAME, EXPR, VTYPE, STYPE, VTYPE2, STYPE2)   \
+  VTYPE _CL_OVERLOADABLE                                  \
+  NAME(VTYPE a, VTYPE b, VTYPE c)                                       \
+  {                                                                     \
+    return convert_ ## VTYPE(NAME(convert_ ## VTYPE2(a), convert_ ## VTYPE2(b),    \
+                       convert_ ## VTYPE2(c)));                           \
+  }
+/**********************************************************************/
+
+#define IMPLEMENT_EXPR_VECS_ONLY(NAME, ARGTYPE, IMPTYPE, STYPE, SSTYPE, EXPR)    \
+  IMPLEMENT_ ## IMPTYPE ## ARGTYPE(NAME, EXPR, STYPE ## 2, STYPE, SSTYPE ## 2, SSTYPE)          \
+  IMPLEMENT_ ## IMPTYPE ## ARGTYPE(NAME, EXPR, STYPE ## 3, STYPE, SSTYPE ## 3, SSTYPE)          \
+  IMPLEMENT_ ## IMPTYPE ## ARGTYPE(NAME, EXPR, STYPE ## 4, STYPE, SSTYPE ## 4, SSTYPE)          \
+  IMPLEMENT_ ## IMPTYPE ## ARGTYPE(NAME, EXPR, STYPE ## 8, STYPE, SSTYPE ## 8, SSTYPE)          \
+  IMPLEMENT_ ## IMPTYPE ## ARGTYPE(NAME, EXPR, STYPE ## 16, STYPE, SSTYPE ## 16, SSTYPE)
+
+#define IMPLEMENT_EXPR_VECS_AND_SCALAR(NAME, TYPE, IMPTYPE, STYPE, SSTYPE, EXPR)    \
+  IMPLEMENT_ ## IMPTYPE ## TYPE(NAME, EXPR, STYPE, STYPE, SSTYPE, SSTYPE)          \
+  IMPLEMENT_EXPR_VECS_ONLY(NAME, TYPE, IMPTYPE, STYPE, SSTYPE, EXPR)
+
+/**********************************************************************/
+
+// EXPR for scalar, DnC for vectors, useful for GCC builtins
+#define IMPLEMENT_EXPR_ALL(NAME, ARGTYPE, EXPR32, EXPR64)                      \
+  IMPLEMENT_EXPR_ ## ARGTYPE(NAME, EXPR32, float, float, float, float)         \
+  IMPLEMENT_VECWITHSCALARS(NAME, ARGTYPE, float, int)                   \
+  IMPLEMENT_EXPR_ ## ARGTYPE(NAME, EXPR64, double, double, double, double)     \
+  IMPLEMENT_VECWITHSCALARS(NAME, ARGTYPE, double, long)
+
+#define IMPLEMENT_EXPR_ALL_SINGLE(NAME, ARGTYPE, EXPR)                       \
+  IMPLEMENT_EXPR_ ## ARGTYPE(NAME, EXPR, float, float, float, float)         \
+  IMPLEMENT_VECWITHSCALARS(NAME, ARGTYPE, float, int)                 \
+  IMPLEMENT_EXPR_ ## ARGTYPE(NAME, EXPR, double, double, double, double)     \
+  IMPLEMENT_VECWITHSCALARS(NAME, ARGTYPE, double, long)
+
+/**********************************************************************/
+
+// Convert from char/shorts to ints
+
+#define EXPR_V_VV_ALL_SMALLINTS(NAME) \
+  IMPLEMENT_EXPR_VECS_AND_SCALAR(NAME, V_VV, CONV_, char, int, "")          \
+  IMPLEMENT_EXPR_VECS_AND_SCALAR(NAME, V_VV, CONV_, uchar, uint, "")        \
+  IMPLEMENT_EXPR_VECS_AND_SCALAR(NAME, V_VV, CONV_, short, int, "")         \
+  IMPLEMENT_EXPR_VECS_AND_SCALAR(NAME, V_VV, CONV_, ushort, uint, "")
+
+#define EXPR_V_VVV_ALL_SMALLINTS(NAME)          \
+  IMPLEMENT_EXPR_VECS_AND_SCALAR(NAME, V_VVV, CONV_, char, int, "")          \
+  IMPLEMENT_EXPR_VECS_AND_SCALAR(NAME, V_VVV, CONV_, uchar, uint, "")        \
+  IMPLEMENT_EXPR_VECS_AND_SCALAR(NAME, V_VVV, CONV_, short, int, "")         \
+  IMPLEMENT_EXPR_VECS_AND_SCALAR(NAME, V_VVV, CONV_, ushort, uint, "")
+
+/**********************************************************************/
+
+// Define OpenCL runtime func via LLVM intrinsics (IMPL_*_ALL)
+
+#define DEFINE_LLVM_INTRIN_FP32_FP64(NAME, ARGTYPE, BUILTIN, EXPR16)       \
+  IMPLEMENT_LLVM_INTRIN_ ## ARGTYPE ## _ALL(NAME, float, BUILTIN, .f32)                     \
+  __IF_FP64(                                                               \
+    IMPLEMENT_LLVM_INTRIN_ ## ARGTYPE ## _ALL(NAME, double, BUILTIN, .f64))                 \
+  __IF_FP16(                                                               \
+    IMPLEMENT_EXPR_VECS_AND_SCALAR(NAME, ARGTYPE, EXPR_, half, short, EXPR16))
+
+#define DEFINE_LLVM_INTRIN_ONLY_FP32(NAME, ARGTYPE, BUILTIN, EXPR64, EXPR16)    \
+  IMPLEMENT_LLVM_INTRIN_ ## ARGTYPE ## _ALL(NAME, float, BUILTIN, .f32)                          \
+  __IF_FP64(                                                                    \
+    IMPLEMENT_EXPR_VECS_AND_SCALAR(NAME, ARGTYPE, EXPR_, double, long, EXPR64)) \
+  __IF_FP16(                                                                    \
+    IMPLEMENT_EXPR_VECS_AND_SCALAR(NAME, ARGTYPE, EXPR_, half, short, EXPR16))  \
+
+/**********************************************************************/
+
+// ldexp, doesnt work yet
+
+#define DEFINE_LLVM_INTRIN_V_VI_FP32_FP64(NAME, BUILTIN)                \
+  IMPLEMENT_LLVM_INTRIN_V_VI_ALL(NAME, float, int, BUILTIN, .f32)                          \
+  __IF_FP16(                                                            \
+    IMPLEMENT_LLVM_INTRIN_V_VI_ALL(NAME, half, int, BUILTIN, .f32))                        \
+  __IF_FP64(                                                            \
+    IMPLEMENT_LLVM_INTRIN_V_VI_ALL(NAME, double, int, BUILTIN, .f64))                      \
+
+/**********************************************************************/
+
+// For mul_hi  /* - has hsail.smulhi.i32 & hsail.umulhi.i32 */
+#define DEFINE_LLVM_INTRIN_SU_INT32_ONLY(NAME, ARGTYPE, SIGNED_BUILTIN, UNSIGNED_BUILTIN)   \
+  IMPLEMENT_LLVM_INTRIN_ ## ARGTYPE ## _ALL(NAME, int, SIGNED_BUILTIN, .i32)                         \
+  IMPLEMENT_LLVM_INTRIN_ ## ARGTYPE ## _ALL(NAME, uint, UNSIGNED_BUILTIN, .i32)                       \
+  IMPLEMENT_LLVM_INTRIN_ ## ARGTYPE ## _ALL(NAME, long, SIGNED_BUILTIN, .i64)                         \
+  IMPLEMENT_LLVM_INTRIN_ ## ARGTYPE ## _ALL(NAME, ulong, UNSIGNED_BUILTIN, .i64)                       \
+  EXPR_ ## ARGTYPE ## _ALL_SMALLINTS(NAME)
+/*
+  IMPLEMENT_LLVM_INTRIN_ ## ARGTYPE ## _ALL(NAME, short, SIGNED_BUILTIN, .i16)                         \
+  IMPLEMENT_LLVM_INTRIN_ ## ARGTYPE ## _ALL(NAME, ushort, UNSIGNED_BUILTIN, .i16)                       \
+  IMPLEMENT_LLVM_INTRIN_ ## ARGTYPE ## _ALL(NAME, char, SIGNED_BUILTIN, .i8)                         \
+  IMPLEMENT_LLVM_INTRIN_ ## ARGTYPE ## _ALL(NAME, uchar, UNSIGNED_BUILTIN, .i8)
+*/
+
+
+// For mad_hi, defined as mul_hi(a,b)+c
+#define DEFINE_EXPR_V_VVV_ALL_INTS(NAME, EXPR)         \
+  IMPLEMENT_EXPR_VECS_AND_SCALAR(NAME, V_VVV, EXPR_, int, int, EXPR)      \
+  IMPLEMENT_EXPR_VECS_AND_SCALAR(NAME, V_VVV, EXPR_, uint, uint, EXPR)    \
+  IMPLEMENT_EXPR_VECS_AND_SCALAR(NAME, V_VVV, EXPR_, long, long, EXPR)    \
+  IMPLEMENT_EXPR_VECS_AND_SCALAR(NAME, V_VVV, EXPR_, ulong, ulong, EXPR)  \
+  EXPR_V_VVV_ALL_SMALLINTS(NAME)
+/*
+  IMPLEMENT_EXPR_VECS_AND_SCALAR(NAME, V_VVV, EXPR_, long, long, EXPR)    \
+  IMPLEMENT_EXPR_VECS_AND_SCALAR(NAME, V_VVV, EXPR_, ulong, ulong, EXPR)  \
+  IMPLEMENT_EXPR_VECS_AND_SCALAR(NAME, V_VVV, EXPR_, long, long, EXPR)    \
+  IMPLEMENT_EXPR_VECS_AND_SCALAR(NAME, V_VVV, EXPR_, ulong, ulong, EXPR)  \
+*/
+
+/**********************************************************************/
+
+// Vector - Pointer to Vector, for frexp() / fract()
+
+#define VPV_BODY(N, NAME, VTYPE, STYPE, PTYPE, ADDRSP)            \
+{                                                                     \
+  typedef VTYPE vtype;                                                \
+  typedef STYPE stype;                                                \
+  typedef PTYPE ptype;                                                \
+  ADDRSP ptype* temp = (ADDRSP ptype*)b;                              \
+  typedef union {                                                             \
+    stype s[N];                                   \
+    vtype v;                                       \
+  } E;                                             \
+  E e; e.v = a;                                     \
+  E out;                                                          \
+  for (unsigned i=0; i<N; i++)                                        \
+    out.s[i] = NAME(e.s[i], temp+i);                               \
+  return out.v;                                                         \
+}                                                                     \
+
+#define IMPLEMENT_EXPR_V_VP_N(NAME, N, STYPE, PTYPE)  \
+  STYPE ## N _CL_OVERLOADABLE                                  \
+  NAME(STYPE ## N a, __global PTYPE ## N *b)                                      \
+  VPV_BODY(N, NAME, STYPE ## N, STYPE, PTYPE, __global)                              \
+  STYPE ## N _CL_OVERLOADABLE                                  \
+  NAME(STYPE ## N a, __local PTYPE ## N *b)                                       \
+  VPV_BODY(N, NAME, STYPE ## N, STYPE, PTYPE, __local)                               \
+  STYPE ## N _CL_OVERLOADABLE                                  \
+  NAME(STYPE ## N a, __private PTYPE ## N *b)                                     \
+  VPV_BODY(N, NAME, STYPE ## N, STYPE, PTYPE, __private)                             \
+
+#define IMPLEMENT_EXPR_V_VP_ALL(NAME, STYPE, PTYPE)                \
+  IMPLEMENT_EXPR_V_VP_N(NAME, 2, STYPE, PTYPE)                     \
+  IMPLEMENT_EXPR_V_VP_N(NAME, 3, STYPE, PTYPE)                     \
+  IMPLEMENT_EXPR_V_VP_N(NAME, 4, STYPE, PTYPE)                     \
+  IMPLEMENT_EXPR_V_VP_N(NAME, 8, STYPE, PTYPE)                     \
+  IMPLEMENT_EXPR_V_VP_N(NAME, 16, STYPE, PTYPE)
diff --git a/lib/kernel/divide.cl b/lib/kernel/hsail64/hypot.cl
similarity index 89%
copy from lib/kernel/divide.cl
copy to lib/kernel/hsail64/hypot.cl
index 790f699..cc76e5d 100644
--- a/lib/kernel/divide.cl
+++ b/lib/kernel/hsail64/hypot.cl
@@ -1,18 +1,18 @@
-/* OpenCL built-in library: divide()
+/* OpenCL built-in library: hypot()
 
    Copyright (c) 2011 Erik Schnetter <eschnetter at perimeterinstitute.ca>
                       Perimeter Institute for Theoretical Physics
-   
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,7 +22,6 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "../templates.h"
 
-DEFINE_EXPR_F_FF(half_divide, a/b)
-DEFINE_EXPR_F_FF(native_divide, a/b)
+DEFINE_EXPR_V_VV(hypot, sqrt(a*a + b*b))
diff --git a/lib/kernel/hsail64/ilogb.cl b/lib/kernel/hsail64/ilogb.cl
new file mode 100644
index 0000000..1484afa
--- /dev/null
+++ b/lib/kernel/hsail64/ilogb.cl
@@ -0,0 +1,75 @@
+/* OpenCL built-in library: ilogb()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+*/
+
+#include "hsail_templates.h"
+
+#include "vml_constants.h"
+
+int _CL_OVERLOADABLE ilogb(float x)
+{
+  // TODO: Check SLEEF 2.80 algorithm
+  //intvec_t e = lsr(as_int(x) & IV(FP::exponent_mask), FP::mantissa_bits);
+  int e = LSR_F(x);
+  //intvec_t r = e - IV(FP::exponent_offset);
+  int r = e - (int)(PROPS_FLOAT_EXPONENT_OFFSET);
+  //r = ifthen((e), r, IV(std::numeric_limits<int_t>::min()));
+  if (!e)
+    r = INT_MIN;
+#if defined VML_HAVE_INF
+  //r = ifthen(isinf(x), IV(std::numeric_limits<int_t>::max()), r);
+  if (isinf(x))
+    r = INT_MAX;
+#endif
+#if defined VML_HAVE_NAN
+  // r = ifthen(isnan(x), IV(std::numeric_limits<int_t>::min()), r);
+  if (isnan(x))
+    r = INT_MIN;
+#endif
+  return r;
+}
+
+int _CL_OVERLOADABLE ilogb(double x)
+{
+  // TODO: Check SLEEF 2.80 algorithm
+  //intvec_t e = lsr(as_int(x) & IV(FP::exponent_mask), FP::mantissa_bits);
+  int e = LSR_D(x);
+  //intvec_t r = e - IV(FP::exponent_offset);
+  int r = e - (int)(PROPS_DOUBLE_EXPONENT_OFFSET);
+  //r = ifthen((e), r, IV(std::numeric_limits<int_t>::min()));
+  if (!e)
+    r = INT_MIN;
+#if defined VML_HAVE_INF
+  //r = ifthen(isinf(x), IV(std::numeric_limits<int_t>::max()), r);
+  if (isinf(x))
+    r = INT_MAX;
+#endif
+#if defined VML_HAVE_NAN
+  // r = ifthen(isnan(x), IV(std::numeric_limits<int_t>::min()), r);
+  if (isnan(x))
+    r = INT_MIN;
+#endif
+  return r;
+}
+
+IMPLEMENT_VECWITHSCALARS(ilogb, I_V, float, int)
+IMPLEMENT_VECWITHSCALARS(ilogb, I_V, double, int)
diff --git a/lib/kernel/hsail64/ldexp.cl b/lib/kernel/hsail64/ldexp.cl
new file mode 100644
index 0000000..53a06d9
--- /dev/null
+++ b/lib/kernel/hsail64/ldexp.cl
@@ -0,0 +1,83 @@
+/* OpenCL built-in library: ldexp()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+*/
+
+#include "hsail_templates.h"
+
+#include "vml_constants.h"
+
+float _CL_OVERLOADABLE ldexp(float x, int n)
+  {
+    // TODO: Check SLEEF 2.80 algorithm
+    float r = as_float(as_int(x) + (n << (unsigned)(PROPS_FLOAT_MANTISSA_BITS)));
+    int max_n = PROPS_FLOAT_MAX_EXPONENT - PROPS_FLOAT_MIN_EXPONENT;
+    bool underflow = n < (-max_n);
+    bool overflow = n > max_n;
+    int old_exp = LSR_F(x);
+    int new_exp = old_exp + n;
+    // TODO: check bit patterns instead
+    underflow =
+      underflow || new_exp < (int)(PROPS_FLOAT_MIN_EXPONENT + PROPS_FLOAT_EXPONENT_OFFSET);
+    overflow =
+      overflow || new_exp > (int)(PROPS_FLOAT_MAX_EXPONENT + PROPS_FLOAT_EXPONENT_OFFSET);
+    //r = ifthen(underflow, copysign(RV(R(0.0)), x), r);
+    if (underflow)
+      r = copysign(0.0f, x);
+    //r = ifthen(overflow, copysign(RV(FP::infinity()), x), r);
+    if (overflow)
+      r = copysign(PROPS_FLOAT_INFINITY, x);
+    //bool dont_change = (x == RV(R(0.0)) || isinf(x) || isnan(x));
+    // r = ifthen(dont_change, x, r);
+    if (x == 0.0f || isinf(x) || isnan(x))
+      r = x;
+    return r;
+  }
+
+double _CL_OVERLOADABLE ldexp(double x, int n)
+  {
+    // TODO: Check SLEEF 2.80 algorithm
+    double r = as_double(as_long(x) + (n << (unsigned)(PROPS_DOUBLE_MANTISSA_BITS)));
+    int max_n = PROPS_DOUBLE_MAX_EXPONENT - PROPS_DOUBLE_MIN_EXPONENT;
+    bool underflow = n < (-max_n);
+    bool overflow = n > max_n;
+    int old_exp = LSR_D(x);
+    int new_exp = old_exp + n;
+    // TODO: check bit patterns instead
+    underflow =
+      underflow || new_exp < (int)(PROPS_DOUBLE_MIN_EXPONENT + PROPS_DOUBLE_EXPONENT_OFFSET);
+    overflow =
+      overflow || new_exp > (int)(PROPS_DOUBLE_MAX_EXPONENT + PROPS_DOUBLE_EXPONENT_OFFSET);
+    //r = ifthen(underflow, copysign(RV(R(0.0)), x), r);
+    if (underflow)
+      r = copysign(0.0, x);
+    //r = ifthen(overflow, copysign(RV(FP::infinity()), x), r);
+    if (overflow)
+      r = copysign(PROPS_DOUBLE_INFINITY, x);
+    //bool dont_change = (x == RV(R(0.0)) || isinf(x) || isnan(x));
+    // r = ifthen(dont_change, x, r);
+    if (x == 0.0 || isinf(x) || isnan(x))
+      r = x;
+    return r;
+  }
+
+IMPLEMENT_VECWITHSCALARS(ldexp, V_VI, double, int)
+IMPLEMENT_VECWITHSCALARS(ldexp, V_VI, float, int)
diff --git a/lib/kernel/log.cl b/lib/kernel/hsail64/log.cl
similarity index 77%
copy from lib/kernel/log.cl
copy to lib/kernel/hsail64/log.cl
index cb05e8d..6678ca8 100644
--- a/lib/kernel/log.cl
+++ b/lib/kernel/hsail64/log.cl
@@ -1,18 +1,17 @@
 /* OpenCL built-in library: log()
 
-   Copyright (c) 2011 Erik Schnetter <eschnetter at perimeterinstitute.ca>
-                      Perimeter Institute for Theoretical Physics
-   
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,9 +21,11 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "../templates.h"
+
+#define M_LOG2E_H_R ((half)(1.0 / M_LOG2E))
+#define M_LOG2E_F_R ((float)(1.0f / M_LOG2E_F))
+#define M_LOG2E_R (1.0 / M_LOG2E)
 
-DEFINE_BUILTIN_V_V(log)
 
-DEFINE_EXPR_F_F(half_log, log(a))
-DEFINE_EXPR_F_F(native_log, log(a))
+DEFINE_EXPR_V_V(log, log2(a) * (TYPED_CONST(stype, M_LOG2E_H_R, M_LOG2E_F_R, M_LOG2E_R)) )
diff --git a/lib/kernel/log10.cl b/lib/kernel/hsail64/log10.cl
similarity index 75%
copy from lib/kernel/log10.cl
copy to lib/kernel/hsail64/log10.cl
index e1f7619..e9f9d11 100644
--- a/lib/kernel/log10.cl
+++ b/lib/kernel/hsail64/log10.cl
@@ -1,18 +1,17 @@
 /* OpenCL built-in library: log10()
 
-   Copyright (c) 2011 Erik Schnetter <eschnetter at perimeterinstitute.ca>
-                      Perimeter Institute for Theoretical Physics
-   
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,9 +21,11 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "../templates.h"
 
-DEFINE_BUILTIN_V_V(log10)
+#define M_LOG2_10_H_R ((half)(M_LOG10E_H / M_LOG2E_H))
+#define M_LOG2_10_F_R ((float)(M_LOG10E_F / M_LOG2E_F))
+#define M_LOG2_10_R (M_LOG10E / M_LOG2E)
 
-DEFINE_EXPR_F_F(half_log10, log10(a))
-DEFINE_EXPR_F_F(native_log10, log10(a))
+DEFINE_EXPR_V_V(log10, (log2(a) * \
+     TYPED_CONST(stype, M_LOG2_10_H_R, M_LOG2_10_F_R, M_LOG2_10_R)))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/log1p.cl
similarity index 85%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/log1p.cl
index 8f7714f..54e86ea 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/log1p.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: log1p()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,6 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "../templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_EXPR_V_V(log1p, (log((vtype)(1.0) + a)))
diff --git a/lib/kernel/hsail64/log2.cl b/lib/kernel/hsail64/log2.cl
new file mode 100644
index 0000000..26351b3
--- /dev/null
+++ b/lib/kernel/hsail64/log2.cl
@@ -0,0 +1,99 @@
+/* OpenCL built-in library: log2()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+*/
+
+
+#include "hsail_templates.h"
+
+float _CL_OVERLOADABLE log2(float x)
+{
+  // Algorithm inspired by SLEEF 2.80
+
+  // Rescale
+  int ilogb_x = ilogb(x * (float)M_SQRT2);
+  x = ldexp(x, -ilogb_x);
+  //VML_ASSERT(all(x >= (float)(M_SQRT1_2) && x <= (float)(M_SQRT2)));
+
+  float y = (x - 1.0f) / (x + 1.0f);
+  float y2 = y*y;
+
+  float r;
+  // float, error=7.09807175879142775648452461821e-8
+  r = (float)(0.59723611417135718739797302426);
+  r = mad(r, y2, (float)(0.961524413175528426101613434));
+  r = mad(r, y2, (float)(2.88539097665498228703236701));
+  r *= y;
+
+  // Undo rescaling
+  r += convert_float(ilogb_x);
+
+  if (x>0)
+    return r;
+  else
+    return NAN;
+}
+
+double _CL_OVERLOADABLE log2(double x)
+{
+  // Algorithm inspired by SLEEF 2.80
+
+  // Rescale
+  int ilogb_x = ilogb(x * (double)M_SQRT2);
+  x = ldexp(x, -ilogb_x);
+  // VML_ASSERT(all(x >= (double)(M_SQRT1_2) && x <= (double)(M_SQRT2)));
+
+  double y = (x - 1.0) / (x + 1.0);
+  double y2 = y*y;
+
+  double r;
+#ifdef VML_HAVE_FP_CONTRACT
+  // double, error=1.48294180185938512675770096324e-16
+  r = (double)(0.243683403415639178527756320773);
+  r = mad(r, y2, (double)(0.26136626803870009948502658));
+  r = mad(r, y2, (double)(0.320619429891299265439389));
+  r = mad(r, y2, (double)(0.4121983452028499242926));
+  r = mad(r, y2, (double)(0.577078017761894161436));
+  r = mad(r, y2, (double)(0.96179669392233355927));
+  r = mad(r, y2, (double)(2.8853900817779295236));
+#else
+  // double, error=2.1410114030383689267772704676e-14
+  r = (double)(0.283751646449323373643963474845);
+  r = mad(r, y2, (double)(0.31983138095551191299118812));
+  r = mad(r, y2, (double)(0.412211603844146279666022));
+  r = mad(r, y2, (double)(0.5770779098948940070516));
+  r = mad(r, y2, (double)(0.961796694295973716912));
+  r = mad(r, y2, (double)(2.885390081777562819196));
+#endif
+  r *= y;
+
+  // Undo rescaling
+  r += convert_double(ilogb_x);
+
+  if (x>0)
+    return r;
+  else
+    return NAN;
+}
+
+IMPLEMENT_VECWITHSCALARS(log2, V_V, float, int)
+
+IMPLEMENT_VECWITHSCALARS(log2, V_V, double, int)
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/mad.cl
similarity index 84%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/mad.cl
index 8f7714f..19f4240 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/mad.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: mad()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,6 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "hsail_templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_LLVM_INTRIN_FP32_FP64(mad, V_VVV, hsail.nfma, 0.0)
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/mad24.cl
similarity index 79%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/mad24.cl
index 8f7714f..5225f51 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/mad24.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: mad24()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,8 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "hsail_templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+#undef mad24
+IMPLEMENT_LLVM_INTRIN_V_VVV_ALL(_cl_mad24, int, hsail.smad24, )
+IMPLEMENT_LLVM_INTRIN_V_VVV_ALL(_cl_mad24, uint, hsail.umad24, )
diff --git a/lib/kernel/exp.cl b/lib/kernel/hsail64/mad_hi.cl
similarity index 77%
copy from lib/kernel/exp.cl
copy to lib/kernel/hsail64/mad_hi.cl
index ce3ef3d..36ac7e9 100644
--- a/lib/kernel/exp.cl
+++ b/lib/kernel/hsail64/mad_hi.cl
@@ -1,18 +1,17 @@
-/* OpenCL built-in library: exp()
+/* OpenCL built-in library: mad_hi()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011 Erik Schnetter <eschnetter at perimeterinstitute.ca>
-                      Perimeter Institute for Theoretical Physics
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,9 +21,10 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "hsail_templates.h"
 
-DEFINE_BUILTIN_V_V(exp)
+// TODO:
+// The standard says this is mul_hi(a, b) + c.
+// Shouldn't this be the high part of a*b+c instead?
 
-DEFINE_EXPR_F_F(half_exp, exp(a))
-DEFINE_EXPR_F_F(native_exp, exp(a))
+DEFINE_EXPR_V_VVV_ALL_INTS(_cl_mad_hi, (_cl_mul_hi(a, b) + c))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/mul24.cl
similarity index 79%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/mul24.cl
index 8f7714f..5a7b7cf 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/mul24.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: mul24()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,8 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "hsail_templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+#undef mul24
+IMPLEMENT_LLVM_INTRIN_V_VV_ALL(_cl_mul24, int, hsail.smul24, )
+IMPLEMENT_LLVM_INTRIN_V_VV_ALL(_cl_mul24, uint, hsail.umul24, )
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/mul_hi.cl
similarity index 82%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/mul_hi.cl
index 8f7714f..bfb5438 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/mul_hi.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: mul_hi()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,7 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "hsail_templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+#undef mul_hi
+DEFINE_LLVM_INTRIN_SU_INT32_ONLY(_cl_mul_hi, V_VV, hsail.smulhi, hsail.umulhi)
diff --git a/lib/kernel/native_cos.cl b/lib/kernel/hsail64/native_cos.cl
similarity index 86%
copy from lib/kernel/native_cos.cl
copy to lib/kernel/hsail64/native_cos.cl
index 2a977ef..0d08556 100644
--- a/lib/kernel/native_cos.cl
+++ b/lib/kernel/hsail64/native_cos.cl
@@ -1,17 +1,17 @@
 /* OpenCL built-in library: native_cos()
 
-   Copyright (c) 2011-2013 Erik Schnetter 
-   
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,6 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "hsail_templates.h"
 
-DEFINE_EXPR_F_F(native_cos, cos(a))
+DEFINE_LLVM_INTRIN_ONLY_FP32(native_cos, V_V, hsail.ncos, cos(a), cos(a))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/native_exp.cl
similarity index 82%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/native_exp.cl
index 8f7714f..bf54553 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/native_exp.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: native_exp()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,6 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "../templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_EXPR_V_V(native_exp, native_exp2(a*TYPED_CONST(stype, M_LOG2E_H, M_LOG2E_F, M_LOG2E)))
diff --git a/lib/kernel/exp.cl b/lib/kernel/hsail64/native_exp10.cl
similarity index 73%
copy from lib/kernel/exp.cl
copy to lib/kernel/hsail64/native_exp10.cl
index ce3ef3d..8429a0d 100644
--- a/lib/kernel/exp.cl
+++ b/lib/kernel/hsail64/native_exp10.cl
@@ -1,18 +1,17 @@
-/* OpenCL built-in library: exp()
+/* OpenCL built-in library: native_exp10()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011 Erik Schnetter <eschnetter at perimeterinstitute.ca>
-                      Perimeter Institute for Theoretical Physics
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,9 +21,10 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "../templates.h"
 
-DEFINE_BUILTIN_V_V(exp)
+#define M_LOG2_10_H ((half)(M_LOG2E_H / M_LOG10E_H))
+#define M_LOG2_10_F (M_LOG2E_F / M_LOG10E_F)
+#define M_LOG2_10 (M_LOG2E / M_LOG10E)
 
-DEFINE_EXPR_F_F(half_exp, exp(a))
-DEFINE_EXPR_F_F(native_exp, exp(a))
+DEFINE_EXPR_V_V(native_exp10, native_exp2(a*TYPED_CONST(stype, M_LOG2_10_H, M_LOG2_10_F, M_LOG2_10)) )
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/native_exp2.cl
similarity index 82%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/native_exp2.cl
index 8f7714f..1da41e7 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/native_exp2.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: native_exp2()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,6 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "hsail_templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_LLVM_INTRIN_ONLY_FP32(native_exp2, V_V, hsail.nexp2, exp2(a), exp2(a))
diff --git a/lib/kernel/log.cl b/lib/kernel/hsail64/native_log.cl
similarity index 73%
copy from lib/kernel/log.cl
copy to lib/kernel/hsail64/native_log.cl
index cb05e8d..d432ef2 100644
--- a/lib/kernel/log.cl
+++ b/lib/kernel/hsail64/native_log.cl
@@ -1,18 +1,17 @@
-/* OpenCL built-in library: log()
+/* OpenCL built-in library: native_log()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011 Erik Schnetter <eschnetter at perimeterinstitute.ca>
-                      Perimeter Institute for Theoretical Physics
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,9 +21,13 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "../templates.h"
+
+
+#define M_LOG2E_H_R ((half)(1.0 / M_LOG2E))
+#define M_LOG2E_F_R ((float)(1.0f / M_LOG2E_F))
+#define M_LOG2E_R (1.0 / M_LOG2E)
 
-DEFINE_BUILTIN_V_V(log)
 
-DEFINE_EXPR_F_F(half_log, log(a))
-DEFINE_EXPR_F_F(native_log, log(a))
+DEFINE_EXPR_V_V(native_log, native_log2(a) * \
+    (TYPED_CONST(stype, M_LOG2E_H_R, M_LOG2E_F_R, M_LOG2E_R)) )
diff --git a/lib/kernel/exp.cl b/lib/kernel/hsail64/native_log10.cl
similarity index 72%
copy from lib/kernel/exp.cl
copy to lib/kernel/hsail64/native_log10.cl
index ce3ef3d..0a1f443 100644
--- a/lib/kernel/exp.cl
+++ b/lib/kernel/hsail64/native_log10.cl
@@ -1,18 +1,17 @@
-/* OpenCL built-in library: exp()
+/* OpenCL built-in library: native_log10()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011 Erik Schnetter <eschnetter at perimeterinstitute.ca>
-                      Perimeter Institute for Theoretical Physics
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,9 +21,11 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "../templates.h"
 
-DEFINE_BUILTIN_V_V(exp)
+#define M_LOG2_10_H_R ((half)(M_LOG10E_H / M_LOG2E_H))
+#define M_LOG2_10_F_R ((float)(M_LOG10E_F / M_LOG2E_F))
+#define M_LOG2_10_R (M_LOG10E / M_LOG2E)
 
-DEFINE_EXPR_F_F(half_exp, exp(a))
-DEFINE_EXPR_F_F(native_exp, exp(a))
+DEFINE_EXPR_V_V(native_log10, (native_log2(a) * \
+     TYPED_CONST(stype, M_LOG2_10_H_R, M_LOG2_10_F_R, M_LOG2_10_R)))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/native_log2.cl
similarity index 86%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/native_log2.cl
index 8f7714f..557d6c9 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/native_log2.cl
@@ -1,17 +1,17 @@
 /* OpenCL built-in library: native_log2()
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,6 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "hsail_templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_LLVM_INTRIN_ONLY_FP32(native_log2, V_V, hsail.nlog2, log2(a), log2(a))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/native_recip.cl
similarity index 82%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/native_recip.cl
index 8f7714f..2a108b7 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/native_recip.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: native_recip()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -20,7 +20,6 @@
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
 */
+#include "hsail_templates.h"
 
-#include "templates.h"
-
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_LLVM_INTRIN_FP32_FP64(native_recip, V_V, hsail.nrcp, ((vtype)(1.0) / a))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/native_rsqrt.cl
similarity index 83%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/native_rsqrt.cl
index 8f7714f..98390aa 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/native_rsqrt.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: native_rsqrt()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,6 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "hsail_templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_LLVM_INTRIN_FP32_FP64(native_rsqrt, V_V, hsail.nrsqrt, rsqrt(a))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/native_sin.cl
similarity index 83%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/native_sin.cl
index 8f7714f..1fef21c 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/native_sin.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: native_sin()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,6 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "hsail_templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_LLVM_INTRIN_ONLY_FP32(native_sin, V_V, hsail.nsin, sin(a), sin(a))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/native_sqrt.cl
similarity index 83%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/native_sqrt.cl
index 8f7714f..7585b1f 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/native_sqrt.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: native_sqrt()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,6 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "hsail_templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_LLVM_INTRIN_FP32_FP64(native_sqrt, V_V, hsail.nsqrt, sqrt(a))
diff --git a/lib/kernel/powr.cl b/lib/kernel/hsail64/pow.cl
similarity index 51%
copy from lib/kernel/powr.cl
copy to lib/kernel/hsail64/pow.cl
index a78491e..7d1a742 100644
--- a/lib/kernel/powr.cl
+++ b/lib/kernel/hsail64/pow.cl
@@ -1,18 +1,17 @@
 /* OpenCL built-in library: pow()
 
-   Copyright (c) 2011 Erik Schnetter <eschnetter at perimeterinstitute.ca>
-                      Perimeter Institute for Theoretical Physics
-   
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,9 +21,48 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
 
-DEFINE_EXPR_V_VV(powr, pow(a, b))
 
-DEFINE_EXPR_F_FF(half_powr, powr(a, b))
-DEFINE_EXPR_F_FF(native_powr, powr(a, b))
+#include "hsail_templates.h"
+
+float _CL_OVERLOADABLE pow(float x, float y)
+  {
+    // Handle zero
+    if (x == 0.0f)
+      return 0.0f;
+
+    float r = exp(log(fabs(x)) * y);
+
+    // The result is negative if x<0 and if y is integer and odd
+    float mod_y = fabs(y) - (2.0f * floor(0.5f * fabs(y)));
+    float sign = copysign(mod_y, x) + 0.5f;
+    r = copysign(r, sign);
+
+    // Handle zero
+    // r = ifthen(is_zero, (float)(0.0), r);
+
+    return r;
+  }
+
+
+double _CL_OVERLOADABLE pow(double x, double y)
+  {
+    // Handle zero
+    if (x == 0.0)
+      return 0.0;
+
+    double r = exp(log(fabs(x)) * y);
+
+    // The result is negative if x<0 and if y is integer and odd
+    double mod_y = fabs(y) - (2.0 * floor(0.5 * fabs(y)));
+    double sign = copysign(mod_y, x) + 0.5;
+    r = copysign(r, sign);
+
+    // Handle zero
+    // r = ifthen(is_zero, (double)(0.0), r);
+
+    return r;
+  }
+
+IMPLEMENT_VECWITHSCALARS(pow, V_VV, float, int)
+IMPLEMENT_VECWITHSCALARS(pow, V_VV, double, int)
diff --git a/lib/kernel/exp.cl b/lib/kernel/hsail64/remainder.cl
similarity index 84%
copy from lib/kernel/exp.cl
copy to lib/kernel/hsail64/remainder.cl
index ce3ef3d..d6c8aaa 100644
--- a/lib/kernel/exp.cl
+++ b/lib/kernel/hsail64/remainder.cl
@@ -1,18 +1,18 @@
-/* OpenCL built-in library: exp()
+/* OpenCL built-in library: remainder()
 
    Copyright (c) 2011 Erik Schnetter <eschnetter at perimeterinstitute.ca>
                       Perimeter Institute for Theoretical Physics
-   
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,9 +22,8 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "hsail_templates.h"
 
-DEFINE_BUILTIN_V_V(exp)
+// TODO currently this produces the exact same code as fmod().
 
-DEFINE_EXPR_F_F(half_exp, exp(a))
-DEFINE_EXPR_F_F(native_exp, exp(a))
+IMPLEMENT_EXPR_ALL(remainder, V_VV, __builtin_fmodf(a,b), __builtin_fmod(a,b))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/rint.cl
similarity index 84%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/rint.cl
index 8f7714f..c31b5c5 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/rint.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: rint()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,7 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "hsail_templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+#undef rint
+DEFINE_LLVM_INTRIN_FP32_FP64(_cl_rint, V_V, rint, 0.0)
diff --git a/lib/kernel/hsail64/sin.cl b/lib/kernel/hsail64/sin.cl
new file mode 100644
index 0000000..090bafb
--- /dev/null
+++ b/lib/kernel/hsail64/sin.cl
@@ -0,0 +1,123 @@
+/* OpenCL built-in library: sin()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+*/
+
+
+#include "hsail_templates.h"
+
+
+  float _CL_OVERLOADABLE sin(float d)
+  {
+    // Algorithm taken from SLEEF 2.80
+
+    float PI4_A, PI4_B, PI4_C, PI4_D;
+      PI4_A = 0.78515625f;
+      PI4_B = 0.00024187564849853515625f;
+      PI4_C = 3.7747668102383613586e-08f;
+      PI4_D = 1.2816720341285448015e-12f;
+
+    float q = rint(d * (float)(M_1_PI));
+    int iq = convert_int(q);
+
+#ifdef VML_HAVE_FP_CONTRACT
+    d = mad(q, (float)(-PI4_A*4), d);
+    d = mad(q, (float)(-PI4_B*4), d);
+    d = mad(q, (float)(-PI4_C*4), d);
+    d = mad(q, (float)(-PI4_D*4), d);
+#else
+    d = mad(q, (float)(-M_PI), d);
+#endif
+
+    float s = d * d;
+
+    if (iq & 1)
+      d = -d;
+
+    float u;
+      u = (float)(2.6083159809786593541503e-06f);
+      u = mad(u, s, (float)(-0.0001981069071916863322258f));
+      u = mad(u, s, (float)(0.00833307858556509017944336f));
+      u = mad(u, s, (float)(-0.166666597127914428710938f));
+
+    u = mad(s, u * d, d);
+
+    //const real_t nan = std::numeric_limits<real_t>::quiet_NaN();
+    //u = ifthen(isinf(d), (float)(nan), u);
+
+    if (isinf(d))
+      return NAN;
+    else
+      return u;
+  }
+
+  double _CL_OVERLOADABLE sin(double d)
+  {
+    // Algorithm taken from SLEEF 2.80
+
+    double PI4_A, PI4_B, PI4_C, PI4_D;
+      PI4_A = 0.78539816290140151978;
+      PI4_B = 4.9604678871439933374e-10;
+      PI4_C = 1.1258708853173288931e-18;
+      PI4_D = 1.7607799325916000908e-27;
+
+    double q = rint(d * (double)M_1_PI);
+    int iq = convert_int(q);
+
+#ifdef VML_HAVE_FP_CONTRACT
+    d = mad(q, (double)(-PI4_A*4), d);
+    d = mad(q, (double)(-PI4_B*4), d);
+    d = mad(q, (double)(-PI4_C*4), d);
+    d = mad(q, (double)(-PI4_D*4), d);
+#else
+    d = mad(q, (double)(-M_PI), d);
+#endif
+
+    double s = d * d;
+
+    if (iq & 1)
+      d = -d;
+
+    double u;
+      u = (double)(-7.97255955009037868891952e-18);
+      u = mad(u, s, (double)(2.81009972710863200091251e-15));
+      u = mad(u, s, (double)(-7.64712219118158833288484e-13));
+      u = mad(u, s, (double)(1.60590430605664501629054e-10));
+      u = mad(u, s, (double)(-2.50521083763502045810755e-08));
+      u = mad(u, s, (double)(2.75573192239198747630416e-06));
+      u = mad(u, s, (double)(-0.000198412698412696162806809));
+      u = mad(u, s, (double)(0.00833333333333332974823815));
+      u = mad(u, s, (double)(-0.166666666666666657414808));
+
+    u = mad(s, u * d, d);
+
+    //const real_t nan = std::numeric_limits<real_t>::quiet_NaN();
+    //u = ifthen(isinf(d), (double)(nan), u);
+
+    if (isinf(d))
+      return NAN;
+    else
+      return u;
+
+  }
+
+IMPLEMENT_VECWITHSCALARS(sin, V_V, float, int)
+IMPLEMENT_VECWITHSCALARS(sin, V_V, double, int)
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/sinh.cl
similarity index 84%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/sinh.cl
index 8f7714f..69e4487 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/sinh.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: sinh()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,8 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+#include "../templates.h"
+
+
+DEFINE_EXPR_V_V(sinh, ((exp(a) - exp(-a)) / (vtype)(2.0)))
diff --git a/lib/kernel/hsail64/sqrt.cl b/lib/kernel/hsail64/sqrt.cl
new file mode 100644
index 0000000..ef1852b
--- /dev/null
+++ b/lib/kernel/hsail64/sqrt.cl
@@ -0,0 +1,53 @@
+/* OpenCL built-in library: sqrt()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+*/
+
+#include "hsail_templates.h"
+
+/* TODO:
+
+   Clang does not recognize __builtin_sqrt* in CGBuiltin.cpp (around line 1285)
+   to be a call to sqrt and cannot selectively convert it to the llvm.sqrt.*
+   intrinsics with looser math flags. Therefore we have to call it as a libcall
+   so it regonized it. For the double we still call the __builtin_sqrt() to
+   disambiguate from the sqrt() to avoid infinite recursion. Probably the
+   correct fix is to patch CGBuiltin.cpp to recognize also the call via
+   __builtin_sqrt*. */
+
+/* TODO HSAIL:
+   related to previous TODO, neither __builtin_sqrt() nor any
+  "high-level" intrinsics (llvm.sqrt, llvm.hsail.sqrt) works.
+
+  I have implemented a workaround using bitcode in sqrt_default.ll, this however
+  uses intrinsics with fixed behaviour (rounding mode etc.) so it's not a long
+  term solution.
+*/
+
+#undef sqrt
+
+float _CL_OVERLOADABLE _sqrt_default_f32(float a);
+IMPLEMENT_VECWITHSCALARS(_sqrt_default_f32, V_V, float, float)
+double _CL_OVERLOADABLE _sqrt_default_f64(double a);
+IMPLEMENT_VECWITHSCALARS(_sqrt_default_f64, V_V, double, double)
+
+IMPLEMENT_EXPR_VECS_AND_SCALAR(_cl_sqrt, V_V, EXPR_, float, int,_sqrt_default_f32(a) )
+IMPLEMENT_EXPR_VECS_AND_SCALAR(_cl_sqrt, V_V, EXPR_, double, long, _sqrt_default_f64(a) )
diff --git a/lib/kernel/hsail64/sqrt_default.ll b/lib/kernel/hsail64/sqrt_default.ll
new file mode 100644
index 0000000..7fb3403
--- /dev/null
+++ b/lib/kernel/hsail64/sqrt_default.ll
@@ -0,0 +1,19 @@
+target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:64:64-p8:32:32-p9:64:64-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
+target triple = "hsail64"
+
+; This is taken from tests/CodeGen/HSAIL/llvm.hsail.fsqrt.ll
+
+declare float @llvm.hsail.fsqrt.f32(i1, i32, float) #0
+declare double @llvm.hsail.fsqrt.f64(i1, i32, double) #0
+
+define float @_Z17_sqrt_default_f32f(float %x) #0 {
+  %ret = call float @llvm.hsail.fsqrt.f32(i1 false, i32 2, float %x) #0
+  ret float %ret
+}
+
+define double @_Z17_sqrt_default_f64d(double %x) #0 {
+  %ret = call double @llvm.hsail.fsqrt.f64(i1 false, i32 2, double %x) #0
+  ret double %ret
+}
+
+attributes #0 = { nounwind readnone }
diff --git a/lib/kernel/hsail64/tan.cl b/lib/kernel/hsail64/tan.cl
new file mode 100644
index 0000000..35c337d
--- /dev/null
+++ b/lib/kernel/hsail64/tan.cl
@@ -0,0 +1,141 @@
+/* OpenCL built-in library: tan()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+*/
+
+#include "hsail_templates.h"
+
+  float _CL_OVERLOADABLE tan(float d)
+  {
+    // Algorithm taken from SLEEF 2.80
+
+    float PI4_A, PI4_B, PI4_C, PI4_D;
+      PI4_A = 0.78515625f;
+      PI4_B = 0.00024187564849853515625f;
+      PI4_C = 3.7747668102383613586e-08f;
+      PI4_D = 1.2816720341285448015e-12f;
+
+    float q = rint(d * (float)(2 * M_1_PI));
+    int ib = (convert_int(q) & 1);
+
+    float x = d;
+
+#ifdef VML_HAVE_FP_CONTRACT
+    x = mad(q, (float)(-PI4_A*2), x);
+    x = mad(q, (float)(-PI4_B*2), x);
+    x = mad(q, (float)(-PI4_C*2), x);
+    x = mad(q, (float)(-PI4_D*2), x);
+#else
+    x = mad(q, (float)(-M_PI_2), x);
+#endif
+
+    float s = x * x;
+
+    //x = ifthen(convert_bool(iq & IV(I(1))), -x, x);
+    if (ib)
+      x = -x;
+
+    float u;
+      u = (float)(0.00927245803177356719970703f);
+      u = mad(u, s, (float)(0.00331984995864331722259521f));
+      u = mad(u, s, (float)(0.0242998078465461730957031f));
+      u = mad(u, s, (float)(0.0534495301544666290283203f));
+      u = mad(u, s, (float)(0.133383005857467651367188f));
+      u = mad(u, s, (float)(0.333331853151321411132812f));
+
+    u = mad(s, u * x, x);
+
+    //u = ifthen(convert_bool(iq & IV(I(1))), rcp(u), u);
+    if (ib)
+      u = 1.0f / u;
+
+    //const real_t nan = std::numeric_limits<real_t>::quiet_NaN();
+    //u = ifthen(isinf(d), (float)(nan), u);
+    if (isinf(d))
+      return NAN;
+    else
+      return u;
+  }
+
+  double _CL_OVERLOADABLE tan(double d)
+  {
+    // Algorithm taken from SLEEF 2.80
+
+    double PI4_A, PI4_B, PI4_C, PI4_D;
+      PI4_A = 0.78539816290140151978;
+      PI4_B = 4.9604678871439933374e-10;
+      PI4_C = 1.1258708853173288931e-18;
+      PI4_D = 1.7607799325916000908e-27;
+
+    double q = rint(d * (double)(2 * M_1_PI));
+    //int iq = convert_int(q);
+    int ib = (convert_int(q) & 1);
+
+    double x = d;
+
+#ifdef VML_HAVE_FP_CONTRACT
+    x = mad(q, (double)(-PI4_A*2), x);
+    x = mad(q, (double)(-PI4_B*2), x);
+    x = mad(q, (double)(-PI4_C*2), x);
+    x = mad(q, (double)(-PI4_D*2), x);
+#else
+    x = mad(q, (double)(-M_PI_2), x);
+#endif
+
+    double s = x * x;
+
+    //x = ifthen(convert_bool(iq & IV(I(1))), -x, x);
+    if (ib)
+      x = -x;
+
+    double u;
+      u = (double)(1.01419718511083373224408e-05);
+      u = mad(u, s, (double)(-2.59519791585924697698614e-05));
+      u = mad(u, s, (double)(5.23388081915899855325186e-05));
+      u = mad(u, s, (double)(-3.05033014433946488225616e-05));
+      u = mad(u, s, (double)(7.14707504084242744267497e-05));
+      u = mad(u, s, (double)(8.09674518280159187045078e-05));
+      u = mad(u, s, (double)(0.000244884931879331847054404));
+      u = mad(u, s, (double)(0.000588505168743587154904506));
+      u = mad(u, s, (double)(0.00145612788922812427978848));
+      u = mad(u, s, (double)(0.00359208743836906619142924));
+      u = mad(u, s, (double)(0.00886323944362401618113356));
+      u = mad(u, s, (double)(0.0218694882853846389592078));
+      u = mad(u, s, (double)(0.0539682539781298417636002));
+      u = mad(u, s, (double)(0.133333333333125941821962));
+      u = mad(u, s, (double)(0.333333333333334980164153));
+
+    u = mad(s, u * x, x);
+
+    //u = ifthen(convert_bool(iq & IV(I(1))), rcp(u), u);
+    if (ib)
+      u = 1.0 / u;
+
+    //const real_t nan = std::numeric_limits<real_t>::quiet_NaN();
+    //u = ifthen(isinf(d), (double)(nan), u);
+    if (isinf(d))
+      return NAN;
+    else
+      return u;
+  }
+
+IMPLEMENT_VECWITHSCALARS(tan, V_V, float, int)
+IMPLEMENT_VECWITHSCALARS(tan, V_V, double, int)
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/tanh.cl
similarity index 85%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/tanh.cl
index 8f7714f..838e860 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/tanh.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: tanh()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,7 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+#include "../templates.h"
+
+DEFINE_EXPR_V_V(tanh, (sinh(a) / cosh(a)))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/hsail64/trunc.cl
similarity index 83%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/hsail64/trunc.cl
index 8f7714f..488d471 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/hsail64/trunc.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: trunc()
+
+   Copyright (c) 2015 Michal Babej / Tampere University of Technology
 
-   Copyright (c) 2011-2013 Erik Schnetter
-   
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,7 @@
    THE SOFTWARE.
 */
 
-#include "templates.h"
+#include "hsail_templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+#undef trunc
+DEFINE_LLVM_INTRIN_FP32_FP64(_cl_trunc, V_V, trunc, 0.0)
diff --git a/lib/kernel/hsail64/vml_constants.h b/lib/kernel/hsail64/vml_constants.h
new file mode 100644
index 0000000..5be8101
--- /dev/null
+++ b/lib/kernel/hsail64/vml_constants.h
@@ -0,0 +1,38 @@
+#define PROPS_FLOAT_BITS 32
+#define PROPS_FLOAT_DIGITS 24
+#define PROPS_FLOAT_DIGITS10 6
+#define PROPS_FLOAT_SIGNBIT_BITS 1
+#define PROPS_FLOAT_SIGNBIT_MASK (1 << (PROPS_FLOAT_BITS-1))
+#define PROPS_FLOAT_MANTISSA_BITS (PROPS_FLOAT_DIGITS - 1)
+#define PROPS_FLOAT_MANTISSA_MASK ((1 << PROPS_FLOAT_MANTISSA_BITS) - 1)
+#define PROPS_FLOAT_EXPONENT_BITS (PROPS_FLOAT_BITS - PROPS_FLOAT_MANTISSA_BITS - PROPS_FLOAT_SIGNBIT_BITS)
+#define PROPS_FLOAT_MIN_EXPONENT (-125)
+#define PROPS_FLOAT_MAX_EXPONENT (128)
+#define PROPS_FLOAT_INFINITY (HUGE_VALF)
+#define PROPS_FLOAT_EXPONENT_OFFSET (2 - PROPS_FLOAT_MIN_EXPONENT)
+#define PROPS_FLOAT_EXPONENT_MASK (((1 << PROPS_FLOAT_EXPONENT_BITS) - 1) << PROPS_FLOAT_MANTISSA_BITS)
+
+#define PROPS_DOUBLE_BITS 64
+#define PROPS_DOUBLE_DIGITS 53
+#define PROPS_DOUBLE_DIGITS10 15
+#define PROPS_DOUBLE_SIGNBIT_BITS 1
+#define PROPS_DOUBLE_SIGNBIT_MASK (1 << (PROPS_DOUBLE_BITS-1))
+#define PROPS_DOUBLE_MANTISSA_BITS (PROPS_DOUBLE_DIGITS - 1)
+#define PROPS_DOUBLE_MANTISSA_MASK ((1 << PROPS_DOUBLE_MANTISSA_BITS) - 1)
+#define PROPS_DOUBLE_EXPONENT_BITS (PROPS_DOUBLE_BITS - PROPS_DOUBLE_MANTISSA_BITS - PROPS_DOUBLE_SIGNBIT_BITS)
+#define PROPS_DOUBLE_MIN_EXPONENT (-1021)
+#define PROPS_DOUBLE_MAX_EXPONENT (1024)
+#define PROPS_DOUBLE_INFINITY (HUGE_VAL)
+#define PROPS_DOUBLE_EXPONENT_OFFSET (2 - PROPS_DOUBLE_MIN_EXPONENT)
+#define PROPS_DOUBLE_EXPONENT_MASK (((1 << PROPS_DOUBLE_EXPONENT_BITS) - 1) << PROPS_DOUBLE_MANTISSA_BITS)
+
+#define LSR_D(x) (int)(((unsigned long)(as_long(x) & (long)PROPS_DOUBLE_EXPONENT_MASK)) >> PROPS_DOUBLE_MANTISSA_BITS)
+#define LSR_F(x) (int)(((unsigned)(as_int(x) & (int)PROPS_FLOAT_EXPONENT_MASK)) >> PROPS_FLOAT_MANTISSA_BITS)
+
+#define MULSIGN(FTYPE, ITYPE, SIGNMASK)                                     \
+    FTYPE _CL_OVERLOADABLE inline mulsign(FTYPE x, FTYPE y)          \
+    {                                                                       \
+      ITYPE value = as_ ## ITYPE(x);                                        \
+      ITYPE sign = as_ ## ITYPE(y) & SIGNMASK;                              \
+      return as_ ## FTYPE(value ^ sign);                                    \
+    }
diff --git a/lib/kernel/log.cl b/lib/kernel/log.cl
index cb05e8d..80b500c 100644
--- a/lib/kernel/log.cl
+++ b/lib/kernel/log.cl
@@ -27,4 +27,3 @@
 DEFINE_BUILTIN_V_V(log)
 
 DEFINE_EXPR_F_F(half_log, log(a))
-DEFINE_EXPR_F_F(native_log, log(a))
diff --git a/lib/kernel/log10.cl b/lib/kernel/log10.cl
index e1f7619..395cfed 100644
--- a/lib/kernel/log10.cl
+++ b/lib/kernel/log10.cl
@@ -27,4 +27,3 @@
 DEFINE_BUILTIN_V_V(log10)
 
 DEFINE_EXPR_F_F(half_log10, log10(a))
-DEFINE_EXPR_F_F(native_log10, log10(a))
diff --git a/lib/kernel/native_cos.cl b/lib/kernel/native_cos.cl
index 2a977ef..436a634 100644
--- a/lib/kernel/native_cos.cl
+++ b/lib/kernel/native_cos.cl
@@ -1,17 +1,17 @@
 /* OpenCL built-in library: native_cos()
 
-   Copyright (c) 2011-2013 Erik Schnetter 
-   
+   Copyright (c) 2011-2013 Erik Schnetter
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/native_divide.cl
similarity index 92%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/native_divide.cl
index 8f7714f..230c9bf 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/native_divide.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: native_divide()
 
    Copyright (c) 2011-2013 Erik Schnetter
-   
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -23,4 +23,4 @@
 
 #include "templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_EXPR_F_FF(native_divide, a/b)
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/native_exp.cl
similarity index 92%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/native_exp.cl
index 8f7714f..ebcfb74 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/native_exp.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: native_exp()
 
    Copyright (c) 2011-2013 Erik Schnetter
-   
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -23,4 +23,4 @@
 
 #include "templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_EXPR_F_F(native_exp, exp(a))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/native_exp10.cl
similarity index 92%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/native_exp10.cl
index 8f7714f..3011e04 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/native_exp10.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: native_exp10()
 
    Copyright (c) 2011-2013 Erik Schnetter
-   
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -23,4 +23,4 @@
 
 #include "templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_EXPR_F_F(native_exp10, exp10(a))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/native_exp2.cl
similarity index 92%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/native_exp2.cl
index 8f7714f..c0a7d29 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/native_exp2.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: native_exp2()
 
    Copyright (c) 2011-2013 Erik Schnetter
-   
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -23,4 +23,4 @@
 
 #include "templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_EXPR_F_F(native_exp2, exp2(a))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/native_log.cl
similarity index 92%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/native_log.cl
index 8f7714f..adddf48 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/native_log.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: native_log()
 
    Copyright (c) 2011-2013 Erik Schnetter
-   
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -23,4 +23,4 @@
 
 #include "templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_EXPR_F_F(native_log, log(a))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/native_log10.cl
similarity index 92%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/native_log10.cl
index 8f7714f..5b1b134 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/native_log10.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: native_log10()
 
    Copyright (c) 2011-2013 Erik Schnetter
-   
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -23,4 +23,4 @@
 
 #include "templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_EXPR_F_F(native_log10, log10(a))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/native_log2.cl
index 8f7714f..be481db 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/native_log2.cl
@@ -1,17 +1,17 @@
 /* OpenCL built-in library: native_log2()
 
    Copyright (c) 2011-2013 Erik Schnetter
-   
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/native_powr.cl
similarity index 92%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/native_powr.cl
index 8f7714f..60e8923 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/native_powr.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: native_powr()
 
    Copyright (c) 2011-2013 Erik Schnetter
-   
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -23,4 +23,4 @@
 
 #include "templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_EXPR_F_FF(native_powr, powr(a, b))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/native_recip.cl
similarity index 92%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/native_recip.cl
index 8f7714f..726f3e0 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/native_recip.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: native_recip()
 
    Copyright (c) 2011-2013 Erik Schnetter
-   
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -23,4 +23,4 @@
 
 #include "templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_EXPR_F_F(native_recip, (stype)1/a)
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/native_rsqrt.cl
similarity index 92%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/native_rsqrt.cl
index 8f7714f..58a602d 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/native_rsqrt.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: native_rsqrt()
 
    Copyright (c) 2011-2013 Erik Schnetter
-   
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -23,4 +23,4 @@
 
 #include "templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_EXPR_F_F(native_rsqrt, rsqrt(a))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/native_sin.cl
similarity index 92%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/native_sin.cl
index 8f7714f..ca360c6 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/native_sin.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: native_sin()
 
    Copyright (c) 2011-2013 Erik Schnetter
-   
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -23,4 +23,4 @@
 
 #include "templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_EXPR_F_F(native_sin, sin(a))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/native_sqrt.cl
similarity index 92%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/native_sqrt.cl
index 8f7714f..3f4cdc8 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/native_sqrt.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: native_sqrt()
 
    Copyright (c) 2011-2013 Erik Schnetter
-   
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -23,4 +23,4 @@
 
 #include "templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_EXPR_F_F(native_sqrt, sqrt(a))
diff --git a/lib/kernel/native_log2.cl b/lib/kernel/native_tan.cl
similarity index 92%
copy from lib/kernel/native_log2.cl
copy to lib/kernel/native_tan.cl
index 8f7714f..b40fe76 100644
--- a/lib/kernel/native_log2.cl
+++ b/lib/kernel/native_tan.cl
@@ -1,17 +1,17 @@
-/* OpenCL built-in library: native_log2()
+/* OpenCL built-in library: native_tan()
 
    Copyright (c) 2011-2013 Erik Schnetter
-   
+
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
-   
+
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
-   
+
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -23,4 +23,4 @@
 
 #include "templates.h"
 
-DEFINE_EXPR_F_F(native_log2, log2(a))
+DEFINE_EXPR_F_F(native_tan, tan(a))
diff --git a/lib/kernel/powr.cl b/lib/kernel/powr.cl
index a78491e..ee4bee7 100644
--- a/lib/kernel/powr.cl
+++ b/lib/kernel/powr.cl
@@ -27,4 +27,3 @@
 DEFINE_EXPR_V_VV(powr, pow(a, b))
 
 DEFINE_EXPR_F_FF(half_powr, powr(a, b))
-DEFINE_EXPR_F_FF(native_powr, powr(a, b))
diff --git a/lib/kernel/recip.cl b/lib/kernel/recip.cl
index 238f351..8308cb6 100644
--- a/lib/kernel/recip.cl
+++ b/lib/kernel/recip.cl
@@ -25,4 +25,3 @@
 #include "templates.h"
 
 DEFINE_EXPR_F_F(half_recip, (stype)1/a)
-DEFINE_EXPR_F_F(native_recip, (stype)1/a)
diff --git a/lib/kernel/rsqrt.cl b/lib/kernel/rsqrt.cl
index 8a01163..3c75ca1 100644
--- a/lib/kernel/rsqrt.cl
+++ b/lib/kernel/rsqrt.cl
@@ -27,4 +27,3 @@
 DEFINE_EXPR_V_V(rsqrt, (stype)1/sqrt(a))
 
 DEFINE_EXPR_F_F(half_rsqrt, rsqrt(a))
-DEFINE_EXPR_F_F(native_rsqrt, rsqrt(a))
diff --git a/lib/kernel/sin.cl b/lib/kernel/sin.cl
index 2defba4..3f2835e 100644
--- a/lib/kernel/sin.cl
+++ b/lib/kernel/sin.cl
@@ -27,4 +27,3 @@
 DEFINE_BUILTIN_V_V(sin)
 
 DEFINE_EXPR_F_F(half_sin, sin(a))
-DEFINE_EXPR_F_F(native_sin, sin(a))
diff --git a/lib/kernel/sources-vml.mk b/lib/kernel/sources-vml.mk
index 184ed78..d92fcea 100644
--- a/lib/kernel/sources-vml.mk
+++ b/lib/kernel/sources-vml.mk
@@ -88,8 +88,19 @@ LKERNEL_SRCS_EXCLUDE =				\
 	minmag.cl				\
 	mix.cl					\
 	nan.cl					\
-	native_cos.cl				\
-	native_log2.cl				\
+        native_cos.cl                           \
+        native_divide.cl                        \
+        native_exp.cl                           \
+        native_exp10.cl                         \
+        native_exp2.cl                          \
+        native_log.cl                           \
+        native_log10.cl                         \
+        native_log2.cl                          \
+        native_powr.cl                          \
+        native_recip.cl                         \
+        native_rsqrt.cl                         \
+        native_sin.cl                           \
+        native_tan.cl                           \
 	normalize.cl				\
 	pow.cl					\
 	pown.cl					\
diff --git a/lib/kernel/sources.mk b/lib/kernel/sources.mk
index 9d78252..a1b73b4 100644
--- a/lib/kernel/sources.mk
+++ b/lib/kernel/sources.mk
@@ -85,6 +85,7 @@ LKERNEL_SRCS_DEFAULT =				\
 	get_image_depth.cl			\
 	get_image_height.cl			\
 	get_image_width.cl			\
+	get_image_dim.cl			\
 	get_local_id.c				\
 	get_local_size.c			\
 	get_num_groups.c			\
@@ -128,7 +129,18 @@ LKERNEL_SRCS_DEFAULT =				\
 	mul_hi.cl				\
 	nan.cl					\
 	native_cos.cl				\
+	native_exp.cl				\
+	native_exp10.cl				\
+	native_exp2.cl				\
+	native_log.cl				\
+	native_log10.cl				\
 	native_log2.cl				\
+	native_powr.cl				\
+	native_recip.cl				\
+	native_rsqrt.cl				\
+	native_sin.cl				\
+	native_sqrt.cl				\
+	native_tan.cl				\
 	nextafter.cl				\
 	normalize.cl				\
 	popcount.cl				\
diff --git a/lib/kernel/sqrt.cl b/lib/kernel/sqrt.cl
index 2021794..f87a3e3 100644
--- a/lib/kernel/sqrt.cl
+++ b/lib/kernel/sqrt.cl
@@ -150,4 +150,3 @@ double16 _CL_OVERLOADABLE sqrt(double16 a)
 #endif
 
 DEFINE_EXPR_F_F(half_sqrt, sqrt(a))
-DEFINE_EXPR_F_F(native_sqrt, sqrt(a))
diff --git a/lib/kernel/tan.cl b/lib/kernel/tan.cl
index f217e12..fc86299 100644
--- a/lib/kernel/tan.cl
+++ b/lib/kernel/tan.cl
@@ -27,4 +27,3 @@
 DEFINE_BUILTIN_V_V(tan)
 
 DEFINE_EXPR_F_F(half_tan, tan(a))
-DEFINE_EXPR_F_F(native_tan, tan(a))
diff --git a/lib/kernel/tce/Makefile b/lib/kernel/tce/Makefile
index 5545d44..86ab8f2 100644
--- a/lib/kernel/tce/Makefile
+++ b/lib/kernel/tce/Makefile
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # lib/kernel/tce/Makefile.  Generated from Makefile.in by configure.
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -90,7 +90,17 @@
 # THE SOFTWARE.
 
 
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -154,8 +164,6 @@ POST_UNINSTALL = :
 build_triplet = x86_64-unknown-linux-gnu
 host_triplet = x86_64-unknown-linux-gnu
 target_triplet = x86_64-unknown-linux-gnu
-DIST_COMMON = $(srcdir)/../rules.mk $(srcdir)/../sources.mk \
-	$(srcdir)/Makefile.in $(srcdir)/Makefile.am
 am__append_1 = printf.c
 subdir = lib/kernel/tce
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -166,6 +174,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -219,23 +228,25 @@ am__uninstall_files_from_dir = { \
 am__installdirs = "$(DESTDIR)$(pkgdatadir)"
 DATA = $(nodist_pkgdata_DATA)
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/../rules.mk $(srcdir)/../sources.mk \
+	$(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = ${SHELL} /tmp/poc/config/missing aclocal-1.14
+ACLOCAL = ${SHELL} /tmp/pocl/config/missing aclocal-1.15
 AMTAR = $${TAR-tar}
 AM_DEFAULT_VERBOSITY = 1
 AR = ar
-AUTOCONF = ${SHELL} /tmp/poc/config/missing autoconf
-AUTOHEADER = ${SHELL} /tmp/poc/config/missing autoheader
-AUTOMAKE = ${SHELL} /tmp/poc/config/missing automake-1.14
+AUTOCONF = ${SHELL} /tmp/pocl/config/missing autoconf
+AUTOHEADER = ${SHELL} /tmp/pocl/config/missing autoheader
+AUTOMAKE = ${SHELL} /tmp/pocl/config/missing automake-1.15
 AWK = gawk
 BOOST_CPPFLAGS = 
 BOOST_LDFLAGS = 
-BUILD_TIMESTAMP = 201503102228728153315
+BUILD_TIMESTAMP = 201510261514380399935
 CC = gcc
 CCDEPMODE = depmode=gcc3
 CFLAGS = -g -O2
-CLANG = /home/LLVM_342/bin/clang
-CLANGXX = /home/LLVM_342/bin/clang++
+CLANG = /home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/clang
+CLANGXX = /home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/clang++
 CLANGXX_FLAGS = --target=x86_64-unknown-linux-gnu  -DVML_NO_IOSTREAM
 CLFLAGS =  -D__OPENCL_VERSION__=120
 CPP = gcc -E
@@ -253,24 +264,27 @@ DUMPBIN =
 ECHO_C = 
 ECHO_N = -n
 ECHO_T = 
-EGREP = /bin/grep -E
+EGREP = /usr/bin/grep -E
 EXEEXT = 
-FGREP = /bin/grep -F
+FGREP = /usr/bin/grep -F
 FORCED_CLFLAGS = -Xclang -ffake-address-space-map -fno-math-errno -fblocks -fno-builtin -fasm -Wno-format
-GLEW_CFLAGS = -I/usr/include/GL -I/usr/include/libdrm 
+GLEW_CFLAGS = -I/usr/include/libdrm 
 GLEW_LIBS = -lGLEW -lGLU -lGL 
-GREP = /bin/grep
+GREP = /usr/bin/grep
 HOST = x86_64-unknown-linux-gnu
 HOST_AS_FLAGS = 
-HOST_CLANG_FLAGS =  --target=x86_64-unknown-linux-gnu -march=bdver1 -D_CL_DISABLE_HALF
+HOST_CLANG_FLAGS =  --target=x86_64-unknown-linux-gnu -march=bdver3 -D_CL_DISABLE_HALF
 HOST_CPU = x86_64
 HOST_LD_FLAGS = -shared -lm
-HOST_LLC_FLAGS = -relocation-model=pic -mtriple=x86_64-unknown-linux-gnu -mcpu=bdver1
+HOST_LLC_FLAGS = -relocation-model=pic -mtriple=x86_64-unknown-linux-gnu -mcpu=bdver3
 HOST_SIZEOF_DOUBLE = 8
 HOST_SIZEOF_HALF = 2
 HOST_SIZEOF_LONG = 8
 HOST_SIZEOF_VOID_P = 8
-HWLOC_CFLAGS = 
+HSAILASM = /opt/HSA/bin/HSAILasm
+HSA_INCLUDES = -I/opt/HSA/include
+HSA_LIBS = -lhsa-runtime64 
+HWLOC_CFLAGS = -I/usr/include/libxml2 
 HWLOC_LIBS = -lhwloc 
 ICD_LD_FLAGS = -Wl,-Bsymbolic
 INSTALL = /usr/bin/install -c
@@ -278,9 +292,9 @@ INSTALL_DATA = ${INSTALL} -m 644
 INSTALL_PROGRAM = ${INSTALL}
 INSTALL_SCRIPT = ${INSTALL}
 INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
-KERNEL_COMPILER_LIB_VERSION = 5:0:0
+KERNEL_COMPILER_LIB_VERSION = 6:0:0
 LD = /usr/bin/ld -m elf_x86_64
-LDFLAGS = 
+LDFLAGS =  -L/opt/HSA/lib
 LD_FLAGS_BIN =  
 LIBOBJS = 
 LIBRARY_SUFFIX = .so
@@ -288,27 +302,28 @@ LIBS =
 LIBSPE_CFLAGS = 
 LIBSPE_LIBS = 
 LIBTOOL = $(SHELL) $(top_builddir)/libtool
-LIB_AGE_VERSION = 4
-LIB_CURRENT_VERSION = 5
+LIB_AGE_VERSION = 5
+LIB_CURRENT_VERSION = 6
 LIB_FIRST_VERSION = 1
 LIB_REVISION_VERSION = 0
-LIB_VERSION = 5:0:4
+LIB_VERSION = 6:0:5
 LIPO = 
-LLC = /home/LLVM_342/bin/llc
-LLVM_AS = /home/LLVM_342/bin/llvm-as
-LLVM_CONFIG = /home/LLVM_342/bin/llvm-config
-LLVM_CXX_FLAGS = -I/home/LLVM_342/include  -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -g -O2 -fomit-frame-pointer -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -fPIC -Woverloaded-virtual -Wcast-qual -fno-rtti
-LLVM_LDFLAGS = -L/home/LLVM_342/lib  -lz -lpthread -lffi -ltinfo -ldl -lm 
-LLVM_LIBS = -lLLVM-3.4.2
-LLVM_LINK = /home/LLVM_342/bin/llvm-link
-LLVM_OPT = /home/LLVM_342/bin/opt
-LLVM_VERSION = 3.4.2
+LLC = /home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/llc
+LLVM_AS = /home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/llvm-as
+LLVM_CONFIG = /home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/llvm-config
+LLVM_CXX_FLAGS = -I/home/LLVM_370_HSAIL_rwdi_NA_rtti/include  -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wnon-virtual-dtor -Wno-comment -std=c++11 -ffunction-sections -fdata-sections -O2 -g -DNDEBUG  -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
+LLVM_LDFLAGS = -L/home/LLVM_370_HSAIL_rwdi_NA_rtti/lib  -lrt -ldl -lcurses -lpthread -lz -lm
+LLVM_LIBS = -lLLVMLTO -lLLVMObjCARCOpts -lLLVMLinker -lLLVMBitWriter -lLLVMTableGen -lLLVMMIRParser -lLLVMDebugInfoPDB -lLLVMOrcJIT -lLLVMIRReader -lLLVMAsmParser -lLLVMHSAILCodeGen -lLLVMHSAILDesc -lLLVMHSAILInfo -lLLVMHSAILAsmPrinter -lLLVMAMDGPUCodeGen -lLLVMAMDGPUAsmParser -lLLVMAMDGPUUtils -lLLVMAMDGPUDesc -lLLVMAMDGPUInfo -lLLVMAMDGPUAsmPrinter -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMX86Desc -lLLVMMCDisassembler -lLLVMX86I [...]
+LLVM_LINK = /home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/llvm-link
+LLVM_OPT = /home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/opt
+LLVM_VERSION = 3.7.0svn
 LN_S = ln -s
 LTDL_LIBS = -lltdl 
 LTLIBOBJS = 
-MAKEINFO = ${SHELL} /tmp/poc/config/missing makeinfo
+LT_SYS_LIBRARY_PATH = 
+MAKEINFO = ${SHELL} /tmp/pocl/config/missing makeinfo
 MANIFEST_TOOL = :
-MKDIR_P = /bin/mkdir -p
+MKDIR_P = /usr/bin/mkdir -p
 NM = /usr/bin/nm -B
 NMEDIT = 
 OBJDUMP = objdump
@@ -317,27 +332,27 @@ OCL_ICD_CFLAGS =
 OCL_ICD_LIBS = 
 OCL_KERNEL_ARCH = 
 OCL_KERNEL_TARGET = x86_64-unknown-linux-gnu
-OCL_KERNEL_TARGET_CPU = bdver1
-OCL_TARGETS = host
+OCL_KERNEL_TARGET_CPU = bdver3
+OCL_TARGETS = host hsail64
 OPENCL_CFLAGS = 
 OPENCL_CMAKE = 
 OPENCL_EXTLIBS = -lOpenCL 
 OPENCL_LIBS = -lOpenCL 
-OPT = /home/LLVM_342/bin/opt
+OPT = /home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/opt
 OTOOL = 
 OTOOL64 = 
 PACKAGE = pocl
 PACKAGE_BUGREPORT = pocl-devel at lists.sourceforge.net
 PACKAGE_NAME = pocl
-PACKAGE_STRING = pocl 0.11
+PACKAGE_STRING = pocl 0.12
 PACKAGE_TARNAME = pocl
 PACKAGE_URL = 
-PACKAGE_VERSION = 0.11
+PACKAGE_VERSION = 0.12
 PATH_SEPARATOR = :
 PKG_CONFIG = /usr/bin/pkg-config
 PKG_CONFIG_LIBDIR = 
 PKG_CONFIG_PATH = 
-POAT_TESTSUITES = 
+POAT_TESTSUITES =  hsa
 POCL_DEVICE_ADDRESS_BITS = 64
 PTHREAD_CC = gcc
 PTHREAD_CFLAGS = -pthread
@@ -345,9 +360,9 @@ PTHREAD_LIBS =
 RANLIB = ranlib
 SDL_CFLAGS = 
 SDL_LIBS = 
-SED = /bin/sed
+SED = /usr/bin/sed
 SET_MAKE = 
-SHELL = /bin/bash
+SHELL = /bin/sh
 STRIP = strip
 TARGET = x86_64-unknown-linux-gnu
 TARGET_CLANG_FLAGS = 
@@ -361,11 +376,11 @@ TCECC =
 TCEMC_AVAILABLE = 
 TCE_AVAILABLE = 
 TCE_CONFIG = 
-VERSION = 0.11
-abs_builddir = /tmp/poc/lib/kernel/tce
-abs_srcdir = /tmp/poc/lib/kernel/tce
-abs_top_builddir = /tmp/poc
-abs_top_srcdir = /tmp/poc
+VERSION = 0.12
+abs_builddir = /tmp/pocl/lib/kernel/tce
+abs_srcdir = /tmp/pocl/lib/kernel/tce
+abs_top_builddir = /tmp/pocl
+abs_top_srcdir = /tmp/pocl
 ac_ct_AR = ar
 ac_ct_CC = gcc
 ac_ct_CXX = g++
@@ -396,7 +411,7 @@ host_vendor = unknown
 htmldir = ${docdir}
 includedir = ${prefix}/include
 infodir = ${datarootdir}/info
-install_sh = ${SHELL} /tmp/poc/config/install-sh
+install_sh = ${SHELL} /tmp/pocl/config/install-sh
 libdir = ${exec_prefix}/lib
 libexecdir = ${exec_prefix}/libexec
 localedir = ${datarootdir}/locale
@@ -450,16 +465,19 @@ LKERNEL_SRCS_DEFAULT = abs.cl abs_diff.cl acos.cl acosh.cl acospi.cl \
 	fast_normalize.cl fdim.cl floor.cl fma.cl fmax.cl fmin.cl \
 	fmod.cl fract.cl get_global_id.c get_global_offset.c \
 	get_global_size.c get_group_id.c get_image_depth.cl \
-	get_image_height.cl get_image_width.cl get_local_id.c \
-	get_local_size.c get_num_groups.c get_work_dim.c hadd.cl \
-	hypot.cl ilogb.cl isequal.cl isfinite.cl isgreater.cl \
-	isgreaterequal.cl isinf.cl isless.cl islessequal.cl \
-	islessgreater.cl isnan.cl isnormal.cl isnotequal.cl \
-	isordered.cl isunordered.cl ldexp.cl length.cl lgamma.cl \
-	log.cl log10.cl log1p.cl log2.cl logb.cl mad.cl mad24.cl \
-	mad_hi.cl mad_sat.cl max.cl max_i.cl maxmag.cl min.cl min_i.cl \
-	minmag.cl mix.cl mul24.cl mul_hi.cl nan.cl native_cos.cl \
-	native_log2.cl nextafter.cl normalize.cl popcount.cl pow.cl \
+	get_image_height.cl get_image_width.cl get_image_dim.cl \
+	get_local_id.c get_local_size.c get_num_groups.c \
+	get_work_dim.c hadd.cl hypot.cl ilogb.cl isequal.cl \
+	isfinite.cl isgreater.cl isgreaterequal.cl isinf.cl isless.cl \
+	islessequal.cl islessgreater.cl isnan.cl isnormal.cl \
+	isnotequal.cl isordered.cl isunordered.cl ldexp.cl length.cl \
+	lgamma.cl log.cl log10.cl log1p.cl log2.cl logb.cl mad.cl \
+	mad24.cl mad_hi.cl mad_sat.cl max.cl max_i.cl maxmag.cl min.cl \
+	min_i.cl minmag.cl mix.cl mul24.cl mul_hi.cl nan.cl \
+	native_cos.cl native_exp.cl native_exp10.cl native_exp2.cl \
+	native_log.cl native_log10.cl native_log2.cl native_powr.cl \
+	native_recip.cl native_rsqrt.cl native_sin.cl native_sqrt.cl \
+	native_tan.cl nextafter.cl normalize.cl popcount.cl pow.cl \
 	pown.cl powr.cl radians.cl read_image.cl recip.cl remainder.cl \
 	rhadd.cl rint.cl rootn.cl rotate.cl round.cl rsqrt.cl \
 	select.cl shuffle.cl sign.cl signbit.cl sin.cl sincos.cl \
@@ -490,7 +508,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(srcdir)/../rules.mk $(srcdir)/..
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/kernel/tce/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign lib/kernel/tce/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -499,7 +516,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
 	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
 	esac;
-$(srcdir)/../rules.mk $(srcdir)/../sources.mk:
+$(srcdir)/../rules.mk $(srcdir)/../sources.mk $(am__empty):
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
@@ -692,6 +709,8 @@ uninstall-am: uninstall-nodist_pkgdataDATA
 	mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \
 	uninstall-am uninstall-nodist_pkgdataDATA
 
+.PRECIOUS: Makefile
+
 
 all: ${KERNEL_BC}
 
@@ -708,7 +727,7 @@ vpath %.ll ../../../lib/kernel
 # feature switches. Otherwise it will fail when compiling the kernel
 # against the precompiled header.
 _kernel.h.pch: ../../../include/${TARGET_DIR}/types.h ../../../include/_kernel.h
-	/home/LLVM_342/bin/clang -Xclang -ffake-address-space-map -fno-math-errno -fblocks -fno-builtin -fasm -Wno-format  -D__OPENCL_VERSION__=120 -Xclang -ffake-address-space-map -c -target ${KERNEL_TARGET} -x cl \
+	/home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/clang -Xclang -ffake-address-space-map -fno-math-errno -fblocks -fno-builtin -fasm -Wno-format  -D__OPENCL_VERSION__=120 -Xclang -ffake-address-space-map -c -target ${KERNEL_TARGET} -x cl \
 	-include ../../../include/${TARGET_DIR}/types.h \
 	-Xclang -emit-pch ../../../include/_kernel.h -o _kernel.h.pch 
 
@@ -716,21 +735,21 @@ _kernel.h.pch: ../../../include/${TARGET_DIR}/types.h ../../../include/_kernel.h
 # LLVM bitcode
 %.c.bc: %.c ${abs_top_srcdir}/include/pocl_types.h ${abs_top_srcdir}/include/pocl_features.h ${abs_top_srcdir}/include/_kernel_c.h ${LKERNEL_HDRS_EXTRA}
 	mkdir -p ${dir $@}
-	/home/LLVM_342/bin/clang ${CLANG_FLAGS} ${CLFLAGS} -D__CBUILD__ -c -o $@ -include ${abs_top_srcdir}/include/_kernel_c.h $< 
+	/home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/clang ${CLANG_FLAGS} ${CLFLAGS} -D__CBUILD__ -c -o $@ -include ${abs_top_srcdir}/include/_kernel_c.h $< 
 %.cc.bc: %.cc ${abs_top_srcdir}/include/pocl_features.h ${LKERNEL_HDRS_EXTRA}
 	mkdir -p ${dir $@}
-	/home/LLVM_342/bin/clang++ ${CLANG_FLAGS} ${CLANGXX_FLAGS} -c -o $@ $< -include ${abs_top_srcdir}/include/pocl_features.h
+	/home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/clang++ ${CLANG_FLAGS} ${CLANGXX_FLAGS} -c -o $@ $< -include ${abs_top_srcdir}/include/pocl_features.h
 %.cl.bc: %.cl ${abs_top_srcdir}/include/_kernel.h ${abs_top_srcdir}/include/_kernel_c.h ${abs_top_srcdir}/include/pocl_types.h ${abs_top_srcdir}/include/pocl_features.h ${LKERNEL_HDRS_EXTRA}
 	mkdir -p ${dir $@}
-	/home/LLVM_342/bin/clang ${CLANG_FLAGS} -x cl ${CLFLAGS} -fsigned-char -c -o $@ $< -include ${abs_top_srcdir}/include/_kernel.h
+	/home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/clang ${CLANG_FLAGS} -x cl ${CLFLAGS} -fsigned-char -c -o $@ $< -include ${abs_top_srcdir}/include/_kernel.h
 %.ll.bc: %.ll
 	mkdir -p ${dir $@}
-	/home/LLVM_342/bin/llvm-as -o $@ $<
+	/home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/llvm-as -o $@ $<
 
 # Optimize the bitcode library to speed up optimization times for the
 # OpenCL kernels
 ${KERNEL_BC}: ${OBJ}
-	/home/LLVM_342/bin/llvm-link $^ -o - | /home/LLVM_342/bin/opt ${LLC_FLAGS} ${KERNEL_LIB_OPT_FLAGS} -O3 -fp-contract=off -o $@
+	/home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/llvm-link $^ -o - | /home/LLVM_370_HSAIL_rwdi_NA_rtti/bin/opt ${LLC_FLAGS} ${KERNEL_LIB_OPT_FLAGS} -O3 -fp-contract=off -o $@
 
 # vim: set noexpandtab ts=8:
 
diff --git a/lib/kernel/tce/Makefile.in b/lib/kernel/tce/Makefile.in
index 9750070..f9035e9 100644
--- a/lib/kernel/tce/Makefile.in
+++ b/lib/kernel/tce/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -90,7 +90,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -154,8 +164,6 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-DIST_COMMON = $(srcdir)/../rules.mk $(srcdir)/../sources.mk \
-	$(srcdir)/Makefile.in $(srcdir)/Makefile.am
 @NEW_PRINTF_WORKS_TRUE at am__append_1 = printf.c
 subdir = lib/kernel/tce
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -166,6 +174,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -219,6 +228,8 @@ am__uninstall_files_from_dir = { \
 am__installdirs = "$(DESTDIR)$(pkgdatadir)"
 DATA = $(nodist_pkgdata_DATA)
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/../rules.mk $(srcdir)/../sources.mk \
+	$(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -270,6 +281,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -306,6 +320,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -450,16 +465,19 @@ LKERNEL_SRCS_DEFAULT = abs.cl abs_diff.cl acos.cl acosh.cl acospi.cl \
 	fast_normalize.cl fdim.cl floor.cl fma.cl fmax.cl fmin.cl \
 	fmod.cl fract.cl get_global_id.c get_global_offset.c \
 	get_global_size.c get_group_id.c get_image_depth.cl \
-	get_image_height.cl get_image_width.cl get_local_id.c \
-	get_local_size.c get_num_groups.c get_work_dim.c hadd.cl \
-	hypot.cl ilogb.cl isequal.cl isfinite.cl isgreater.cl \
-	isgreaterequal.cl isinf.cl isless.cl islessequal.cl \
-	islessgreater.cl isnan.cl isnormal.cl isnotequal.cl \
-	isordered.cl isunordered.cl ldexp.cl length.cl lgamma.cl \
-	log.cl log10.cl log1p.cl log2.cl logb.cl mad.cl mad24.cl \
-	mad_hi.cl mad_sat.cl max.cl max_i.cl maxmag.cl min.cl min_i.cl \
-	minmag.cl mix.cl mul24.cl mul_hi.cl nan.cl native_cos.cl \
-	native_log2.cl nextafter.cl normalize.cl popcount.cl pow.cl \
+	get_image_height.cl get_image_width.cl get_image_dim.cl \
+	get_local_id.c get_local_size.c get_num_groups.c \
+	get_work_dim.c hadd.cl hypot.cl ilogb.cl isequal.cl \
+	isfinite.cl isgreater.cl isgreaterequal.cl isinf.cl isless.cl \
+	islessequal.cl islessgreater.cl isnan.cl isnormal.cl \
+	isnotequal.cl isordered.cl isunordered.cl ldexp.cl length.cl \
+	lgamma.cl log.cl log10.cl log1p.cl log2.cl logb.cl mad.cl \
+	mad24.cl mad_hi.cl mad_sat.cl max.cl max_i.cl maxmag.cl min.cl \
+	min_i.cl minmag.cl mix.cl mul24.cl mul_hi.cl nan.cl \
+	native_cos.cl native_exp.cl native_exp10.cl native_exp2.cl \
+	native_log.cl native_log10.cl native_log2.cl native_powr.cl \
+	native_recip.cl native_rsqrt.cl native_sin.cl native_sqrt.cl \
+	native_tan.cl nextafter.cl normalize.cl popcount.cl pow.cl \
 	pown.cl powr.cl radians.cl read_image.cl recip.cl remainder.cl \
 	rhadd.cl rint.cl rootn.cl rotate.cl round.cl rsqrt.cl \
 	select.cl shuffle.cl sign.cl signbit.cl sin.cl sincos.cl \
@@ -490,7 +508,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(srcdir)/../rules.mk $(srcdir)/..
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/kernel/tce/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign lib/kernel/tce/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -499,7 +516,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
 	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
 	esac;
-$(srcdir)/../rules.mk $(srcdir)/../sources.mk:
+$(srcdir)/../rules.mk $(srcdir)/../sources.mk $(am__empty):
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
@@ -692,6 +709,8 @@ uninstall-am: uninstall-nodist_pkgdataDATA
 	mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \
 	uninstall-am uninstall-nodist_pkgdataDATA
 
+.PRECIOUS: Makefile
+
 
 all: ${KERNEL_BC}
 
diff --git a/lib/kernel/vecmathlib-pocl/frexp.cl b/lib/kernel/vecmathlib-pocl/frexp.cl
index 11295c3..05aeee1 100644
--- a/lib/kernel/vecmathlib-pocl/frexp.cl
+++ b/lib/kernel/vecmathlib-pocl/frexp.cl
@@ -51,8 +51,10 @@ half _cl_frexp(half x0, global int* x1)
 #define ldexp_vector_ _cl_ldexp_half_short
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -86,8 +88,10 @@ half _cl_frexp(half x0, local int* x1)
 #define ldexp_vector_ _cl_ldexp_half_short
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -121,8 +125,10 @@ half _cl_frexp(half x0, private int* x1)
 #define ldexp_vector_ _cl_ldexp_half_short
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -156,8 +162,10 @@ half2 _cl_frexp(half2 x0, global int2* x1)
 #define ldexp_vector_ _cl_ldexp_half2_short2
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -191,8 +199,10 @@ half2 _cl_frexp(half2 x0, local int2* x1)
 #define ldexp_vector_ _cl_ldexp_half2_short2
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -226,8 +236,10 @@ half2 _cl_frexp(half2 x0, private int2* x1)
 #define ldexp_vector_ _cl_ldexp_half2_short2
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -261,8 +273,10 @@ half3 _cl_frexp(half3 x0, global int3* x1)
 #define ldexp_vector_ _cl_ldexp_half3_short3
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -296,8 +310,10 @@ half3 _cl_frexp(half3 x0, local int3* x1)
 #define ldexp_vector_ _cl_ldexp_half3_short3
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -331,8 +347,10 @@ half3 _cl_frexp(half3 x0, private int3* x1)
 #define ldexp_vector_ _cl_ldexp_half3_short3
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -366,8 +384,10 @@ half4 _cl_frexp(half4 x0, global int4* x1)
 #define ldexp_vector_ _cl_ldexp_half4_short4
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -401,8 +421,10 @@ half4 _cl_frexp(half4 x0, local int4* x1)
 #define ldexp_vector_ _cl_ldexp_half4_short4
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -436,8 +458,10 @@ half4 _cl_frexp(half4 x0, private int4* x1)
 #define ldexp_vector_ _cl_ldexp_half4_short4
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -471,8 +495,10 @@ half8 _cl_frexp(half8 x0, global int8* x1)
 #define ldexp_vector_ _cl_ldexp_half8_short8
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -506,8 +532,10 @@ half8 _cl_frexp(half8 x0, local int8* x1)
 #define ldexp_vector_ _cl_ldexp_half8_short8
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -541,8 +569,10 @@ half8 _cl_frexp(half8 x0, private int8* x1)
 #define ldexp_vector_ _cl_ldexp_half8_short8
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -576,8 +606,10 @@ half16 _cl_frexp(half16 x0, global int16* x1)
 #define ldexp_vector_ _cl_ldexp_half16_short16
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -611,8 +643,10 @@ half16 _cl_frexp(half16 x0, local int16* x1)
 #define ldexp_vector_ _cl_ldexp_half16_short16
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -646,8 +680,10 @@ half16 _cl_frexp(half16 x0, private int16* x1)
 #define ldexp_vector_ _cl_ldexp_half16_short16
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -683,8 +719,10 @@ float _cl_frexp(float x0, global int* x1)
 #define ldexp_vector_ _cl_ldexp_float_int
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -718,8 +756,10 @@ float _cl_frexp(float x0, local int* x1)
 #define ldexp_vector_ _cl_ldexp_float_int
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -753,8 +793,10 @@ float _cl_frexp(float x0, private int* x1)
 #define ldexp_vector_ _cl_ldexp_float_int
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -788,8 +830,10 @@ float2 _cl_frexp(float2 x0, global int2* x1)
 #define ldexp_vector_ _cl_ldexp_float2_int2
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -823,8 +867,10 @@ float2 _cl_frexp(float2 x0, local int2* x1)
 #define ldexp_vector_ _cl_ldexp_float2_int2
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -858,8 +904,10 @@ float2 _cl_frexp(float2 x0, private int2* x1)
 #define ldexp_vector_ _cl_ldexp_float2_int2
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -893,8 +941,10 @@ float3 _cl_frexp(float3 x0, global int3* x1)
 #define ldexp_vector_ _cl_ldexp_float3_int3
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -928,8 +978,10 @@ float3 _cl_frexp(float3 x0, local int3* x1)
 #define ldexp_vector_ _cl_ldexp_float3_int3
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -963,8 +1015,10 @@ float3 _cl_frexp(float3 x0, private int3* x1)
 #define ldexp_vector_ _cl_ldexp_float3_int3
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -998,8 +1052,10 @@ float4 _cl_frexp(float4 x0, global int4* x1)
 #define ldexp_vector_ _cl_ldexp_float4_int4
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1033,8 +1089,10 @@ float4 _cl_frexp(float4 x0, local int4* x1)
 #define ldexp_vector_ _cl_ldexp_float4_int4
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1068,8 +1126,10 @@ float4 _cl_frexp(float4 x0, private int4* x1)
 #define ldexp_vector_ _cl_ldexp_float4_int4
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1103,8 +1163,10 @@ float8 _cl_frexp(float8 x0, global int8* x1)
 #define ldexp_vector_ _cl_ldexp_float8_int8
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1138,8 +1200,10 @@ float8 _cl_frexp(float8 x0, local int8* x1)
 #define ldexp_vector_ _cl_ldexp_float8_int8
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1173,8 +1237,10 @@ float8 _cl_frexp(float8 x0, private int8* x1)
 #define ldexp_vector_ _cl_ldexp_float8_int8
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1208,8 +1274,10 @@ float16 _cl_frexp(float16 x0, global int16* x1)
 #define ldexp_vector_ _cl_ldexp_float16_int16
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1243,8 +1311,10 @@ float16 _cl_frexp(float16 x0, local int16* x1)
 #define ldexp_vector_ _cl_ldexp_float16_int16
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1278,8 +1348,10 @@ float16 _cl_frexp(float16 x0, private int16* x1)
 #define ldexp_vector_ _cl_ldexp_float16_int16
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1315,8 +1387,10 @@ double _cl_frexp(double x0, global int* x1)
 #define ldexp_vector_ _cl_ldexp_double_long
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1350,8 +1424,10 @@ double _cl_frexp(double x0, local int* x1)
 #define ldexp_vector_ _cl_ldexp_double_long
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1385,8 +1461,10 @@ double _cl_frexp(double x0, private int* x1)
 #define ldexp_vector_ _cl_ldexp_double_long
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1420,8 +1498,10 @@ double2 _cl_frexp(double2 x0, global int2* x1)
 #define ldexp_vector_ _cl_ldexp_double2_long2
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1455,8 +1535,10 @@ double2 _cl_frexp(double2 x0, local int2* x1)
 #define ldexp_vector_ _cl_ldexp_double2_long2
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1490,8 +1572,10 @@ double2 _cl_frexp(double2 x0, private int2* x1)
 #define ldexp_vector_ _cl_ldexp_double2_long2
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1525,8 +1609,10 @@ double3 _cl_frexp(double3 x0, global int3* x1)
 #define ldexp_vector_ _cl_ldexp_double3_long3
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1560,8 +1646,10 @@ double3 _cl_frexp(double3 x0, local int3* x1)
 #define ldexp_vector_ _cl_ldexp_double3_long3
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1595,8 +1683,10 @@ double3 _cl_frexp(double3 x0, private int3* x1)
 #define ldexp_vector_ _cl_ldexp_double3_long3
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1630,8 +1720,10 @@ double4 _cl_frexp(double4 x0, global int4* x1)
 #define ldexp_vector_ _cl_ldexp_double4_long4
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1665,8 +1757,10 @@ double4 _cl_frexp(double4 x0, local int4* x1)
 #define ldexp_vector_ _cl_ldexp_double4_long4
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1700,8 +1794,10 @@ double4 _cl_frexp(double4 x0, private int4* x1)
 #define ldexp_vector_ _cl_ldexp_double4_long4
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1735,8 +1831,10 @@ double8 _cl_frexp(double8 x0, global int8* x1)
 #define ldexp_vector_ _cl_ldexp_double8_long8
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1770,8 +1868,10 @@ double8 _cl_frexp(double8 x0, local int8* x1)
 #define ldexp_vector_ _cl_ldexp_double8_long8
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1805,8 +1905,10 @@ double8 _cl_frexp(double8 x0, private int8* x1)
 #define ldexp_vector_ _cl_ldexp_double8_long8
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1840,8 +1942,10 @@ double16 _cl_frexp(double16 x0, global int16* x1)
 #define ldexp_vector_ _cl_ldexp_double16_long16
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1875,8 +1979,10 @@ double16 _cl_frexp(double16 x0, local int16* x1)
 #define ldexp_vector_ _cl_ldexp_double16_long16
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
@@ -1910,8 +2016,10 @@ double16 _cl_frexp(double16 x0, private int16* x1)
 #define ldexp_vector_ _cl_ldexp_double16_long16
   return 
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 ;
 #undef convert_ivector_t
diff --git a/lib/kernel/vecmathlib-pocl/generate-files.py b/lib/kernel/vecmathlib-pocl/generate-files.py
index f91b5d7..d14bcd7 100755
--- a/lib/kernel/vecmathlib-pocl/generate-files.py
+++ b/lib/kernel/vecmathlib-pocl/generate-files.py
@@ -145,8 +145,10 @@ directfuncs = [
 """),
     ("frexp"         , [VF, PVK    ], VF, """
     ({
-      *x1 = ilogb(x0);
-      ldexp(x0, -ilogb(x0));
+      kvector_t e0 = ilogb(x0);
+      kvector_t e = e0==INT_MIN || e0==INT_MAX ? (kvector_t)0 : e0+1;
+      *x1 = e;
+      convert_ivector_t(e0==INT_MIN || e0==INT_MAX) ? x0 : ldexp(x0, -e);
     })
 """),
     ("ilogb"         , [VF         ], VK, """
@@ -588,7 +590,7 @@ def output_directfunc_direct(func, vectype):
         groups())
     size = 1 if sizename=="" else int(sizename)
     funcargstr = ", ".join(map(lambda (n, arg):
-                                   "%s x%d" % (mktype(arg, vectype), n),
+                               "%s x%d" % (mktype(arg, vectype), n),
                                zip(range(0, 100), args)))
     funcretstr = mktype(ret, vectype)
     decl("%s %s(%s)" % (funcretstr, prefixed(name), funcargstr))
@@ -646,9 +648,11 @@ def output_vmlfunc(func):
     out("// %s: %s -> %s" % (name, args, ret))
     for basetype in ["half", "float", "double"]:
         if basetype=="half":
+            decl("#ifdef cl_khr_fp16")
             out("")
             out("#ifdef cl_khr_fp16")
-        if basetype=="double":
+        elif basetype=="double":
+            decl("#ifdef cl_khr_fp64")
             out("")
             out("#ifdef cl_khr_fp64")
         for size in [1, 2, 3, 4, 8, 16]:
@@ -690,9 +694,11 @@ def output_vmlfunc(func):
                 output_vmlfunc_split(func, vectype)
             out("#endif")
         if basetype=="half":
+            decl("#endif // #ifdef cl_khr_fp16")
             out("")
             out("#endif // #ifdef cl_khr_fp16")
-        if basetype=="double":
+        elif basetype=="double":
+            decl("#endif // #ifdef cl_khr_fp64")
             out("")
             out("#endif // #ifdef cl_khr_fp64")
     out_close()
@@ -746,9 +752,11 @@ def output_directfunc(func):
             basetype!="float"):
             continue
         if basetype=="half":
+            decl("#ifdef cl_khr_fp16")
             out("")
             out("#ifdef cl_khr_fp16")
-        if basetype=="double":
+        elif basetype=="double":
+            decl("#ifdef cl_khr_fp64")
             out("")
             out("#ifdef cl_khr_fp64")
         for size in [1, 2, 3, 4, 8, 16]:
@@ -764,9 +772,11 @@ def output_directfunc(func):
                 out("// %s: VF=%s" % (name, vectype))
                 output_directfunc_direct(func, vectype)
         if basetype=="half":
+            decl("#endif // #ifdef cl_khr_fp16")
             out("")
             out("#endif // #ifdef cl_khr_fp16")
-        if basetype=="double":
+        elif basetype=="double":
+            decl("#endif // #ifdef cl_khr_fp64")
             out("")
             out("#endif // #ifdef cl_khr_fp64")
     out_close()
diff --git a/lib/kernel/vecmathlib-pocl/kernel-vecmathlib.h b/lib/kernel/vecmathlib-pocl/kernel-vecmathlib.h
index 406eab5..b37c4da 100644
--- a/lib/kernel/vecmathlib-pocl/kernel-vecmathlib.h
+++ b/lib/kernel/vecmathlib-pocl/kernel-vecmathlib.h
@@ -5,6 +5,7 @@
 // acos: ['VF'] -> VF
 #undef acos
 #define acos _cl_acos
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_acos(half x0);
 __attribute__((__overloadable__)) half _cl_acos(half x0);
 __attribute__((__overloadable__)) half _cl_acos(half x0);
@@ -22,6 +23,7 @@ __attribute__((__overloadable__)) half8 _cl_acos(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_acos(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_acos(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_acos(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_acos(float x0);
 __attribute__((__overloadable__)) float _cl_acos(float x0);
 __attribute__((__overloadable__)) float _cl_acos(float x0);
@@ -39,6 +41,7 @@ __attribute__((__overloadable__)) float8 _cl_acos(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_acos(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_acos(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_acos(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_acos(double x0);
 __attribute__((__overloadable__)) double _cl_acos(double x0);
 __attribute__((__overloadable__)) double _cl_acos(double x0);
@@ -56,10 +59,12 @@ __attribute__((__overloadable__)) double8 _cl_acos(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_acos(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_acos(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_acos(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // acosh: ['VF'] -> VF
 #undef acosh
 #define acosh _cl_acosh
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_acosh(half x0);
 __attribute__((__overloadable__)) half _cl_acosh(half x0);
 __attribute__((__overloadable__)) half _cl_acosh(half x0);
@@ -77,6 +82,7 @@ __attribute__((__overloadable__)) half8 _cl_acosh(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_acosh(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_acosh(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_acosh(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_acosh(float x0);
 __attribute__((__overloadable__)) float _cl_acosh(float x0);
 __attribute__((__overloadable__)) float _cl_acosh(float x0);
@@ -94,6 +100,7 @@ __attribute__((__overloadable__)) float8 _cl_acosh(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_acosh(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_acosh(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_acosh(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_acosh(double x0);
 __attribute__((__overloadable__)) double _cl_acosh(double x0);
 __attribute__((__overloadable__)) double _cl_acosh(double x0);
@@ -111,10 +118,12 @@ __attribute__((__overloadable__)) double8 _cl_acosh(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_acosh(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_acosh(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_acosh(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // asin: ['VF'] -> VF
 #undef asin
 #define asin _cl_asin
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_asin(half x0);
 __attribute__((__overloadable__)) half _cl_asin(half x0);
 __attribute__((__overloadable__)) half _cl_asin(half x0);
@@ -132,6 +141,7 @@ __attribute__((__overloadable__)) half8 _cl_asin(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_asin(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_asin(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_asin(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_asin(float x0);
 __attribute__((__overloadable__)) float _cl_asin(float x0);
 __attribute__((__overloadable__)) float _cl_asin(float x0);
@@ -149,6 +159,7 @@ __attribute__((__overloadable__)) float8 _cl_asin(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_asin(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_asin(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_asin(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_asin(double x0);
 __attribute__((__overloadable__)) double _cl_asin(double x0);
 __attribute__((__overloadable__)) double _cl_asin(double x0);
@@ -166,10 +177,12 @@ __attribute__((__overloadable__)) double8 _cl_asin(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_asin(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_asin(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_asin(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // asinh: ['VF'] -> VF
 #undef asinh
 #define asinh _cl_asinh
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_asinh(half x0);
 __attribute__((__overloadable__)) half _cl_asinh(half x0);
 __attribute__((__overloadable__)) half _cl_asinh(half x0);
@@ -187,6 +200,7 @@ __attribute__((__overloadable__)) half8 _cl_asinh(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_asinh(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_asinh(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_asinh(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_asinh(float x0);
 __attribute__((__overloadable__)) float _cl_asinh(float x0);
 __attribute__((__overloadable__)) float _cl_asinh(float x0);
@@ -204,6 +218,7 @@ __attribute__((__overloadable__)) float8 _cl_asinh(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_asinh(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_asinh(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_asinh(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_asinh(double x0);
 __attribute__((__overloadable__)) double _cl_asinh(double x0);
 __attribute__((__overloadable__)) double _cl_asinh(double x0);
@@ -221,10 +236,12 @@ __attribute__((__overloadable__)) double8 _cl_asinh(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_asinh(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_asinh(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_asinh(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // atan: ['VF'] -> VF
 #undef atan
 #define atan _cl_atan
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_atan(half x0);
 __attribute__((__overloadable__)) half _cl_atan(half x0);
 __attribute__((__overloadable__)) half _cl_atan(half x0);
@@ -242,6 +259,7 @@ __attribute__((__overloadable__)) half8 _cl_atan(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_atan(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_atan(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_atan(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_atan(float x0);
 __attribute__((__overloadable__)) float _cl_atan(float x0);
 __attribute__((__overloadable__)) float _cl_atan(float x0);
@@ -259,6 +277,7 @@ __attribute__((__overloadable__)) float8 _cl_atan(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_atan(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_atan(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_atan(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_atan(double x0);
 __attribute__((__overloadable__)) double _cl_atan(double x0);
 __attribute__((__overloadable__)) double _cl_atan(double x0);
@@ -276,10 +295,12 @@ __attribute__((__overloadable__)) double8 _cl_atan(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_atan(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_atan(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_atan(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // atanh: ['VF'] -> VF
 #undef atanh
 #define atanh _cl_atanh
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_atanh(half x0);
 __attribute__((__overloadable__)) half _cl_atanh(half x0);
 __attribute__((__overloadable__)) half _cl_atanh(half x0);
@@ -297,6 +318,7 @@ __attribute__((__overloadable__)) half8 _cl_atanh(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_atanh(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_atanh(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_atanh(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_atanh(float x0);
 __attribute__((__overloadable__)) float _cl_atanh(float x0);
 __attribute__((__overloadable__)) float _cl_atanh(float x0);
@@ -314,6 +336,7 @@ __attribute__((__overloadable__)) float8 _cl_atanh(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_atanh(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_atanh(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_atanh(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_atanh(double x0);
 __attribute__((__overloadable__)) double _cl_atanh(double x0);
 __attribute__((__overloadable__)) double _cl_atanh(double x0);
@@ -331,10 +354,12 @@ __attribute__((__overloadable__)) double8 _cl_atanh(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_atanh(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_atanh(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_atanh(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // cbrt: ['VF'] -> VF
 #undef cbrt
 #define cbrt _cl_cbrt
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_cbrt(half x0);
 __attribute__((__overloadable__)) half _cl_cbrt(half x0);
 __attribute__((__overloadable__)) half _cl_cbrt(half x0);
@@ -352,6 +377,7 @@ __attribute__((__overloadable__)) half8 _cl_cbrt(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_cbrt(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_cbrt(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_cbrt(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_cbrt(float x0);
 __attribute__((__overloadable__)) float _cl_cbrt(float x0);
 __attribute__((__overloadable__)) float _cl_cbrt(float x0);
@@ -369,6 +395,7 @@ __attribute__((__overloadable__)) float8 _cl_cbrt(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_cbrt(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_cbrt(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_cbrt(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_cbrt(double x0);
 __attribute__((__overloadable__)) double _cl_cbrt(double x0);
 __attribute__((__overloadable__)) double _cl_cbrt(double x0);
@@ -386,10 +413,12 @@ __attribute__((__overloadable__)) double8 _cl_cbrt(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_cbrt(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_cbrt(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_cbrt(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // ceil: ['VF'] -> VF
 #undef ceil
 #define ceil _cl_ceil
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_ceil(half x0);
 __attribute__((__overloadable__)) half _cl_ceil(half x0);
 __attribute__((__overloadable__)) half _cl_ceil(half x0);
@@ -407,6 +436,7 @@ __attribute__((__overloadable__)) half8 _cl_ceil(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_ceil(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_ceil(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_ceil(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_ceil(float x0);
 __attribute__((__overloadable__)) float _cl_ceil(float x0);
 __attribute__((__overloadable__)) float _cl_ceil(float x0);
@@ -424,6 +454,7 @@ __attribute__((__overloadable__)) float8 _cl_ceil(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_ceil(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_ceil(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_ceil(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_ceil(double x0);
 __attribute__((__overloadable__)) double _cl_ceil(double x0);
 __attribute__((__overloadable__)) double _cl_ceil(double x0);
@@ -441,10 +472,12 @@ __attribute__((__overloadable__)) double8 _cl_ceil(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_ceil(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_ceil(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_ceil(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // copysign: ['VF', 'VF'] -> VF
 #undef copysign
 #define copysign _cl_copysign
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_copysign(half x0, half x1);
 __attribute__((__overloadable__)) half _cl_copysign(half x0, half x1);
 __attribute__((__overloadable__)) half _cl_copysign(half x0, half x1);
@@ -462,6 +495,7 @@ __attribute__((__overloadable__)) half8 _cl_copysign(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half8 _cl_copysign(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half16 _cl_copysign(half16 x0, half16 x1);
 __attribute__((__overloadable__)) half16 _cl_copysign(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_copysign(float x0, float x1);
 __attribute__((__overloadable__)) float _cl_copysign(float x0, float x1);
 __attribute__((__overloadable__)) float _cl_copysign(float x0, float x1);
@@ -479,6 +513,7 @@ __attribute__((__overloadable__)) float8 _cl_copysign(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float8 _cl_copysign(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float16 _cl_copysign(float16 x0, float16 x1);
 __attribute__((__overloadable__)) float16 _cl_copysign(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_copysign(double x0, double x1);
 __attribute__((__overloadable__)) double _cl_copysign(double x0, double x1);
 __attribute__((__overloadable__)) double _cl_copysign(double x0, double x1);
@@ -496,10 +531,12 @@ __attribute__((__overloadable__)) double8 _cl_copysign(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double8 _cl_copysign(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double16 _cl_copysign(double16 x0, double16 x1);
 __attribute__((__overloadable__)) double16 _cl_copysign(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // cos: ['VF'] -> VF
 #undef cos
 #define cos _cl_cos
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_cos(half x0);
 __attribute__((__overloadable__)) half _cl_cos(half x0);
 __attribute__((__overloadable__)) half _cl_cos(half x0);
@@ -517,6 +554,7 @@ __attribute__((__overloadable__)) half8 _cl_cos(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_cos(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_cos(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_cos(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_cos(float x0);
 __attribute__((__overloadable__)) float _cl_cos(float x0);
 __attribute__((__overloadable__)) float _cl_cos(float x0);
@@ -534,6 +572,7 @@ __attribute__((__overloadable__)) float8 _cl_cos(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_cos(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_cos(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_cos(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_cos(double x0);
 __attribute__((__overloadable__)) double _cl_cos(double x0);
 __attribute__((__overloadable__)) double _cl_cos(double x0);
@@ -551,10 +590,12 @@ __attribute__((__overloadable__)) double8 _cl_cos(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_cos(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_cos(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_cos(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // cosh: ['VF'] -> VF
 #undef cosh
 #define cosh _cl_cosh
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_cosh(half x0);
 __attribute__((__overloadable__)) half _cl_cosh(half x0);
 __attribute__((__overloadable__)) half _cl_cosh(half x0);
@@ -572,6 +613,7 @@ __attribute__((__overloadable__)) half8 _cl_cosh(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_cosh(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_cosh(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_cosh(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_cosh(float x0);
 __attribute__((__overloadable__)) float _cl_cosh(float x0);
 __attribute__((__overloadable__)) float _cl_cosh(float x0);
@@ -589,6 +631,7 @@ __attribute__((__overloadable__)) float8 _cl_cosh(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_cosh(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_cosh(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_cosh(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_cosh(double x0);
 __attribute__((__overloadable__)) double _cl_cosh(double x0);
 __attribute__((__overloadable__)) double _cl_cosh(double x0);
@@ -606,10 +649,12 @@ __attribute__((__overloadable__)) double8 _cl_cosh(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_cosh(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_cosh(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_cosh(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // exp: ['VF'] -> VF
 #undef exp
 #define exp _cl_exp
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_exp(half x0);
 __attribute__((__overloadable__)) half _cl_exp(half x0);
 __attribute__((__overloadable__)) half _cl_exp(half x0);
@@ -627,6 +672,7 @@ __attribute__((__overloadable__)) half8 _cl_exp(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_exp(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_exp(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_exp(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_exp(float x0);
 __attribute__((__overloadable__)) float _cl_exp(float x0);
 __attribute__((__overloadable__)) float _cl_exp(float x0);
@@ -644,6 +690,7 @@ __attribute__((__overloadable__)) float8 _cl_exp(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_exp(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_exp(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_exp(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_exp(double x0);
 __attribute__((__overloadable__)) double _cl_exp(double x0);
 __attribute__((__overloadable__)) double _cl_exp(double x0);
@@ -661,10 +708,12 @@ __attribute__((__overloadable__)) double8 _cl_exp(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_exp(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_exp(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_exp(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // exp2: ['VF'] -> VF
 #undef exp2
 #define exp2 _cl_exp2
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_exp2(half x0);
 __attribute__((__overloadable__)) half _cl_exp2(half x0);
 __attribute__((__overloadable__)) half _cl_exp2(half x0);
@@ -682,6 +731,7 @@ __attribute__((__overloadable__)) half8 _cl_exp2(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_exp2(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_exp2(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_exp2(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_exp2(float x0);
 __attribute__((__overloadable__)) float _cl_exp2(float x0);
 __attribute__((__overloadable__)) float _cl_exp2(float x0);
@@ -699,6 +749,7 @@ __attribute__((__overloadable__)) float8 _cl_exp2(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_exp2(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_exp2(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_exp2(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_exp2(double x0);
 __attribute__((__overloadable__)) double _cl_exp2(double x0);
 __attribute__((__overloadable__)) double _cl_exp2(double x0);
@@ -716,10 +767,12 @@ __attribute__((__overloadable__)) double8 _cl_exp2(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_exp2(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_exp2(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_exp2(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // exp10: ['VF'] -> VF
 #undef exp10
 #define exp10 _cl_exp10
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_exp10(half x0);
 __attribute__((__overloadable__)) half _cl_exp10(half x0);
 __attribute__((__overloadable__)) half _cl_exp10(half x0);
@@ -737,6 +790,7 @@ __attribute__((__overloadable__)) half8 _cl_exp10(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_exp10(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_exp10(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_exp10(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_exp10(float x0);
 __attribute__((__overloadable__)) float _cl_exp10(float x0);
 __attribute__((__overloadable__)) float _cl_exp10(float x0);
@@ -754,6 +808,7 @@ __attribute__((__overloadable__)) float8 _cl_exp10(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_exp10(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_exp10(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_exp10(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_exp10(double x0);
 __attribute__((__overloadable__)) double _cl_exp10(double x0);
 __attribute__((__overloadable__)) double _cl_exp10(double x0);
@@ -771,10 +826,12 @@ __attribute__((__overloadable__)) double8 _cl_exp10(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_exp10(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_exp10(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_exp10(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // expm1: ['VF'] -> VF
 #undef expm1
 #define expm1 _cl_expm1
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_expm1(half x0);
 __attribute__((__overloadable__)) half _cl_expm1(half x0);
 __attribute__((__overloadable__)) half _cl_expm1(half x0);
@@ -792,6 +849,7 @@ __attribute__((__overloadable__)) half8 _cl_expm1(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_expm1(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_expm1(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_expm1(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_expm1(float x0);
 __attribute__((__overloadable__)) float _cl_expm1(float x0);
 __attribute__((__overloadable__)) float _cl_expm1(float x0);
@@ -809,6 +867,7 @@ __attribute__((__overloadable__)) float8 _cl_expm1(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_expm1(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_expm1(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_expm1(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_expm1(double x0);
 __attribute__((__overloadable__)) double _cl_expm1(double x0);
 __attribute__((__overloadable__)) double _cl_expm1(double x0);
@@ -826,10 +885,12 @@ __attribute__((__overloadable__)) double8 _cl_expm1(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_expm1(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_expm1(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_expm1(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // fabs: ['VF'] -> VF
 #undef fabs
 #define fabs _cl_fabs
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_fabs(half x0);
 __attribute__((__overloadable__)) half _cl_fabs(half x0);
 __attribute__((__overloadable__)) half _cl_fabs(half x0);
@@ -847,6 +908,7 @@ __attribute__((__overloadable__)) half8 _cl_fabs(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_fabs(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_fabs(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_fabs(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_fabs(float x0);
 __attribute__((__overloadable__)) float _cl_fabs(float x0);
 __attribute__((__overloadable__)) float _cl_fabs(float x0);
@@ -864,6 +926,7 @@ __attribute__((__overloadable__)) float8 _cl_fabs(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_fabs(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_fabs(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_fabs(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_fabs(double x0);
 __attribute__((__overloadable__)) double _cl_fabs(double x0);
 __attribute__((__overloadable__)) double _cl_fabs(double x0);
@@ -881,10 +944,12 @@ __attribute__((__overloadable__)) double8 _cl_fabs(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_fabs(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_fabs(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_fabs(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // fdim: ['VF', 'VF'] -> VF
 #undef fdim
 #define fdim _cl_fdim
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_fdim(half x0, half x1);
 __attribute__((__overloadable__)) half _cl_fdim(half x0, half x1);
 __attribute__((__overloadable__)) half _cl_fdim(half x0, half x1);
@@ -902,6 +967,7 @@ __attribute__((__overloadable__)) half8 _cl_fdim(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half8 _cl_fdim(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half16 _cl_fdim(half16 x0, half16 x1);
 __attribute__((__overloadable__)) half16 _cl_fdim(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_fdim(float x0, float x1);
 __attribute__((__overloadable__)) float _cl_fdim(float x0, float x1);
 __attribute__((__overloadable__)) float _cl_fdim(float x0, float x1);
@@ -919,6 +985,7 @@ __attribute__((__overloadable__)) float8 _cl_fdim(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float8 _cl_fdim(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float16 _cl_fdim(float16 x0, float16 x1);
 __attribute__((__overloadable__)) float16 _cl_fdim(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_fdim(double x0, double x1);
 __attribute__((__overloadable__)) double _cl_fdim(double x0, double x1);
 __attribute__((__overloadable__)) double _cl_fdim(double x0, double x1);
@@ -936,10 +1003,12 @@ __attribute__((__overloadable__)) double8 _cl_fdim(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double8 _cl_fdim(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double16 _cl_fdim(double16 x0, double16 x1);
 __attribute__((__overloadable__)) double16 _cl_fdim(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // floor: ['VF'] -> VF
 #undef floor
 #define floor _cl_floor
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_floor(half x0);
 __attribute__((__overloadable__)) half _cl_floor(half x0);
 __attribute__((__overloadable__)) half _cl_floor(half x0);
@@ -957,6 +1026,7 @@ __attribute__((__overloadable__)) half8 _cl_floor(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_floor(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_floor(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_floor(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_floor(float x0);
 __attribute__((__overloadable__)) float _cl_floor(float x0);
 __attribute__((__overloadable__)) float _cl_floor(float x0);
@@ -974,6 +1044,7 @@ __attribute__((__overloadable__)) float8 _cl_floor(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_floor(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_floor(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_floor(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_floor(double x0);
 __attribute__((__overloadable__)) double _cl_floor(double x0);
 __attribute__((__overloadable__)) double _cl_floor(double x0);
@@ -991,10 +1062,12 @@ __attribute__((__overloadable__)) double8 _cl_floor(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_floor(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_floor(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_floor(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // fma: ['VF', 'VF', 'VF'] -> VF
 #undef fma
 #define fma _cl_fma
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_fma(half x0, half x1, half x2);
 __attribute__((__overloadable__)) half _cl_fma(half x0, half x1, half x2);
 __attribute__((__overloadable__)) half _cl_fma(half x0, half x1, half x2);
@@ -1012,6 +1085,7 @@ __attribute__((__overloadable__)) half8 _cl_fma(half8 x0, half8 x1, half8 x2);
 __attribute__((__overloadable__)) half8 _cl_fma(half8 x0, half8 x1, half8 x2);
 __attribute__((__overloadable__)) half16 _cl_fma(half16 x0, half16 x1, half16 x2);
 __attribute__((__overloadable__)) half16 _cl_fma(half16 x0, half16 x1, half16 x2);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_fma(float x0, float x1, float x2);
 __attribute__((__overloadable__)) float _cl_fma(float x0, float x1, float x2);
 __attribute__((__overloadable__)) float _cl_fma(float x0, float x1, float x2);
@@ -1029,6 +1103,7 @@ __attribute__((__overloadable__)) float8 _cl_fma(float8 x0, float8 x1, float8 x2
 __attribute__((__overloadable__)) float8 _cl_fma(float8 x0, float8 x1, float8 x2);
 __attribute__((__overloadable__)) float16 _cl_fma(float16 x0, float16 x1, float16 x2);
 __attribute__((__overloadable__)) float16 _cl_fma(float16 x0, float16 x1, float16 x2);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_fma(double x0, double x1, double x2);
 __attribute__((__overloadable__)) double _cl_fma(double x0, double x1, double x2);
 __attribute__((__overloadable__)) double _cl_fma(double x0, double x1, double x2);
@@ -1046,10 +1121,12 @@ __attribute__((__overloadable__)) double8 _cl_fma(double8 x0, double8 x1, double
 __attribute__((__overloadable__)) double8 _cl_fma(double8 x0, double8 x1, double8 x2);
 __attribute__((__overloadable__)) double16 _cl_fma(double16 x0, double16 x1, double16 x2);
 __attribute__((__overloadable__)) double16 _cl_fma(double16 x0, double16 x1, double16 x2);
+#endif // #ifdef cl_khr_fp64
 
 // fmax: ['VF', 'VF'] -> VF
 #undef fmax
 #define fmax _cl_fmax
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_fmax(half x0, half x1);
 __attribute__((__overloadable__)) half _cl_fmax(half x0, half x1);
 __attribute__((__overloadable__)) half _cl_fmax(half x0, half x1);
@@ -1067,6 +1144,7 @@ __attribute__((__overloadable__)) half8 _cl_fmax(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half8 _cl_fmax(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half16 _cl_fmax(half16 x0, half16 x1);
 __attribute__((__overloadable__)) half16 _cl_fmax(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_fmax(float x0, float x1);
 __attribute__((__overloadable__)) float _cl_fmax(float x0, float x1);
 __attribute__((__overloadable__)) float _cl_fmax(float x0, float x1);
@@ -1084,6 +1162,7 @@ __attribute__((__overloadable__)) float8 _cl_fmax(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float8 _cl_fmax(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float16 _cl_fmax(float16 x0, float16 x1);
 __attribute__((__overloadable__)) float16 _cl_fmax(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_fmax(double x0, double x1);
 __attribute__((__overloadable__)) double _cl_fmax(double x0, double x1);
 __attribute__((__overloadable__)) double _cl_fmax(double x0, double x1);
@@ -1101,10 +1180,12 @@ __attribute__((__overloadable__)) double8 _cl_fmax(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double8 _cl_fmax(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double16 _cl_fmax(double16 x0, double16 x1);
 __attribute__((__overloadable__)) double16 _cl_fmax(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // fmin: ['VF', 'VF'] -> VF
 #undef fmin
 #define fmin _cl_fmin
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_fmin(half x0, half x1);
 __attribute__((__overloadable__)) half _cl_fmin(half x0, half x1);
 __attribute__((__overloadable__)) half _cl_fmin(half x0, half x1);
@@ -1122,6 +1203,7 @@ __attribute__((__overloadable__)) half8 _cl_fmin(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half8 _cl_fmin(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half16 _cl_fmin(half16 x0, half16 x1);
 __attribute__((__overloadable__)) half16 _cl_fmin(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_fmin(float x0, float x1);
 __attribute__((__overloadable__)) float _cl_fmin(float x0, float x1);
 __attribute__((__overloadable__)) float _cl_fmin(float x0, float x1);
@@ -1139,6 +1221,7 @@ __attribute__((__overloadable__)) float8 _cl_fmin(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float8 _cl_fmin(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float16 _cl_fmin(float16 x0, float16 x1);
 __attribute__((__overloadable__)) float16 _cl_fmin(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_fmin(double x0, double x1);
 __attribute__((__overloadable__)) double _cl_fmin(double x0, double x1);
 __attribute__((__overloadable__)) double _cl_fmin(double x0, double x1);
@@ -1156,10 +1239,12 @@ __attribute__((__overloadable__)) double8 _cl_fmin(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double8 _cl_fmin(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double16 _cl_fmin(double16 x0, double16 x1);
 __attribute__((__overloadable__)) double16 _cl_fmin(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // fmod: ['VF', 'VF'] -> VF
 #undef fmod
 #define fmod _cl_fmod
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_fmod(half x0, half x1);
 __attribute__((__overloadable__)) half _cl_fmod(half x0, half x1);
 __attribute__((__overloadable__)) half _cl_fmod(half x0, half x1);
@@ -1177,6 +1262,7 @@ __attribute__((__overloadable__)) half8 _cl_fmod(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half8 _cl_fmod(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half16 _cl_fmod(half16 x0, half16 x1);
 __attribute__((__overloadable__)) half16 _cl_fmod(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_fmod(float x0, float x1);
 __attribute__((__overloadable__)) float _cl_fmod(float x0, float x1);
 __attribute__((__overloadable__)) float _cl_fmod(float x0, float x1);
@@ -1194,6 +1280,7 @@ __attribute__((__overloadable__)) float8 _cl_fmod(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float8 _cl_fmod(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float16 _cl_fmod(float16 x0, float16 x1);
 __attribute__((__overloadable__)) float16 _cl_fmod(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_fmod(double x0, double x1);
 __attribute__((__overloadable__)) double _cl_fmod(double x0, double x1);
 __attribute__((__overloadable__)) double _cl_fmod(double x0, double x1);
@@ -1211,10 +1298,12 @@ __attribute__((__overloadable__)) double8 _cl_fmod(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double8 _cl_fmod(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double16 _cl_fmod(double16 x0, double16 x1);
 __attribute__((__overloadable__)) double16 _cl_fmod(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // hypot: ['VF', 'VF'] -> VF
 #undef hypot
 #define hypot _cl_hypot
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_hypot(half x0, half x1);
 __attribute__((__overloadable__)) half _cl_hypot(half x0, half x1);
 __attribute__((__overloadable__)) half _cl_hypot(half x0, half x1);
@@ -1232,6 +1321,7 @@ __attribute__((__overloadable__)) half8 _cl_hypot(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half8 _cl_hypot(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half16 _cl_hypot(half16 x0, half16 x1);
 __attribute__((__overloadable__)) half16 _cl_hypot(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_hypot(float x0, float x1);
 __attribute__((__overloadable__)) float _cl_hypot(float x0, float x1);
 __attribute__((__overloadable__)) float _cl_hypot(float x0, float x1);
@@ -1249,6 +1339,7 @@ __attribute__((__overloadable__)) float8 _cl_hypot(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float8 _cl_hypot(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float16 _cl_hypot(float16 x0, float16 x1);
 __attribute__((__overloadable__)) float16 _cl_hypot(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_hypot(double x0, double x1);
 __attribute__((__overloadable__)) double _cl_hypot(double x0, double x1);
 __attribute__((__overloadable__)) double _cl_hypot(double x0, double x1);
@@ -1266,10 +1357,12 @@ __attribute__((__overloadable__)) double8 _cl_hypot(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double8 _cl_hypot(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double16 _cl_hypot(double16 x0, double16 x1);
 __attribute__((__overloadable__)) double16 _cl_hypot(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // ilogb_: ['VF'] -> VI
 #undef ilogb_
 #define ilogb_ _cl_ilogb_
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) extern "C" short _cl_ilogb_half(half x0);
 __attribute__((__overloadable__)) extern "C" short _cl_ilogb_half(half x0);
 __attribute__((__overloadable__)) extern "C" short _cl_ilogb_half(half x0);
@@ -1287,6 +1380,7 @@ __attribute__((__overloadable__)) extern "C" short8 _cl_ilogb_half8(half8 x0);
 __attribute__((__overloadable__)) extern "C" short8 _cl_ilogb_half8(half8 x0);
 __attribute__((__overloadable__)) extern "C" short16 _cl_ilogb_half16(half16 x0);
 __attribute__((__overloadable__)) extern "C" short16 _cl_ilogb_half16(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) extern "C" int _cl_ilogb_float(float x0);
 __attribute__((__overloadable__)) extern "C" int _cl_ilogb_float(float x0);
 __attribute__((__overloadable__)) extern "C" int _cl_ilogb_float(float x0);
@@ -1304,6 +1398,7 @@ __attribute__((__overloadable__)) extern "C" int8 _cl_ilogb_float8(float8 x0);
 __attribute__((__overloadable__)) extern "C" int8 _cl_ilogb_float8(float8 x0);
 __attribute__((__overloadable__)) extern "C" int16 _cl_ilogb_float16(float16 x0);
 __attribute__((__overloadable__)) extern "C" int16 _cl_ilogb_float16(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) extern "C" long _cl_ilogb_double(double x0);
 __attribute__((__overloadable__)) extern "C" long _cl_ilogb_double(double x0);
 __attribute__((__overloadable__)) extern "C" long _cl_ilogb_double(double x0);
@@ -1321,10 +1416,12 @@ __attribute__((__overloadable__)) extern "C" long8 _cl_ilogb_double8(double8 x0)
 __attribute__((__overloadable__)) extern "C" long8 _cl_ilogb_double8(double8 x0);
 __attribute__((__overloadable__)) extern "C" long16 _cl_ilogb_double16(double16 x0);
 __attribute__((__overloadable__)) extern "C" long16 _cl_ilogb_double16(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // ldexp_: ['VF', 'VI'] -> VF
 #undef ldexp_
 #define ldexp_ _cl_ldexp_
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) extern "C" half _cl_ldexp_half_short(half x0, short x1);
 __attribute__((__overloadable__)) extern "C" half _cl_ldexp_half_short(half x0, short x1);
 __attribute__((__overloadable__)) extern "C" half _cl_ldexp_half_short(half x0, short x1);
@@ -1342,6 +1439,7 @@ __attribute__((__overloadable__)) extern "C" half8 _cl_ldexp_half8_short8(half8
 __attribute__((__overloadable__)) extern "C" half8 _cl_ldexp_half8_short8(half8 x0, short8 x1);
 __attribute__((__overloadable__)) extern "C" half16 _cl_ldexp_half16_short16(half16 x0, short16 x1);
 __attribute__((__overloadable__)) extern "C" half16 _cl_ldexp_half16_short16(half16 x0, short16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) extern "C" float _cl_ldexp_float_int(float x0, int x1);
 __attribute__((__overloadable__)) extern "C" float _cl_ldexp_float_int(float x0, int x1);
 __attribute__((__overloadable__)) extern "C" float _cl_ldexp_float_int(float x0, int x1);
@@ -1359,6 +1457,7 @@ __attribute__((__overloadable__)) extern "C" float8 _cl_ldexp_float8_int8(float8
 __attribute__((__overloadable__)) extern "C" float8 _cl_ldexp_float8_int8(float8 x0, int8 x1);
 __attribute__((__overloadable__)) extern "C" float16 _cl_ldexp_float16_int16(float16 x0, int16 x1);
 __attribute__((__overloadable__)) extern "C" float16 _cl_ldexp_float16_int16(float16 x0, int16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) extern "C" double _cl_ldexp_double_long(double x0, long x1);
 __attribute__((__overloadable__)) extern "C" double _cl_ldexp_double_long(double x0, long x1);
 __attribute__((__overloadable__)) extern "C" double _cl_ldexp_double_long(double x0, long x1);
@@ -1376,10 +1475,12 @@ __attribute__((__overloadable__)) extern "C" double8 _cl_ldexp_double8_long8(dou
 __attribute__((__overloadable__)) extern "C" double8 _cl_ldexp_double8_long8(double8 x0, long8 x1);
 __attribute__((__overloadable__)) extern "C" double16 _cl_ldexp_double16_long16(double16 x0, long16 x1);
 __attribute__((__overloadable__)) extern "C" double16 _cl_ldexp_double16_long16(double16 x0, long16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // ldexp_: ['VF', 'SI'] -> VF
 #undef ldexp_
 #define ldexp_ _cl_ldexp_
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) extern "C" half2 _cl_ldexp_half2_short(half2 x0, short x1);
 __attribute__((__overloadable__)) extern "C" half2 _cl_ldexp_half2_short(half2 x0, short x1);
 __attribute__((__overloadable__)) extern "C" half2 _cl_ldexp_half2_short(half2 x0, short x1);
@@ -1394,6 +1495,7 @@ __attribute__((__overloadable__)) extern "C" half8 _cl_ldexp_half8_short(half8 x
 __attribute__((__overloadable__)) extern "C" half8 _cl_ldexp_half8_short(half8 x0, short x1);
 __attribute__((__overloadable__)) extern "C" half16 _cl_ldexp_half16_short(half16 x0, short x1);
 __attribute__((__overloadable__)) extern "C" half16 _cl_ldexp_half16_short(half16 x0, short x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) extern "C" float2 _cl_ldexp_float2_int(float2 x0, int x1);
 __attribute__((__overloadable__)) extern "C" float2 _cl_ldexp_float2_int(float2 x0, int x1);
 __attribute__((__overloadable__)) extern "C" float2 _cl_ldexp_float2_int(float2 x0, int x1);
@@ -1408,6 +1510,7 @@ __attribute__((__overloadable__)) extern "C" float8 _cl_ldexp_float8_int(float8
 __attribute__((__overloadable__)) extern "C" float8 _cl_ldexp_float8_int(float8 x0, int x1);
 __attribute__((__overloadable__)) extern "C" float16 _cl_ldexp_float16_int(float16 x0, int x1);
 __attribute__((__overloadable__)) extern "C" float16 _cl_ldexp_float16_int(float16 x0, int x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) extern "C" double2 _cl_ldexp_double2_long(double2 x0, long x1);
 __attribute__((__overloadable__)) extern "C" double2 _cl_ldexp_double2_long(double2 x0, long x1);
 __attribute__((__overloadable__)) extern "C" double2 _cl_ldexp_double2_long(double2 x0, long x1);
@@ -1422,10 +1525,12 @@ __attribute__((__overloadable__)) extern "C" double8 _cl_ldexp_double8_long(doub
 __attribute__((__overloadable__)) extern "C" double8 _cl_ldexp_double8_long(double8 x0, long x1);
 __attribute__((__overloadable__)) extern "C" double16 _cl_ldexp_double16_long(double16 x0, long x1);
 __attribute__((__overloadable__)) extern "C" double16 _cl_ldexp_double16_long(double16 x0, long x1);
+#endif // #ifdef cl_khr_fp64
 
 // log: ['VF'] -> VF
 #undef log
 #define log _cl_log
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_log(half x0);
 __attribute__((__overloadable__)) half _cl_log(half x0);
 __attribute__((__overloadable__)) half _cl_log(half x0);
@@ -1443,6 +1548,7 @@ __attribute__((__overloadable__)) half8 _cl_log(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_log(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_log(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_log(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_log(float x0);
 __attribute__((__overloadable__)) float _cl_log(float x0);
 __attribute__((__overloadable__)) float _cl_log(float x0);
@@ -1460,6 +1566,7 @@ __attribute__((__overloadable__)) float8 _cl_log(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_log(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_log(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_log(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_log(double x0);
 __attribute__((__overloadable__)) double _cl_log(double x0);
 __attribute__((__overloadable__)) double _cl_log(double x0);
@@ -1477,10 +1584,12 @@ __attribute__((__overloadable__)) double8 _cl_log(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_log(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_log(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_log(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // log2: ['VF'] -> VF
 #undef log2
 #define log2 _cl_log2
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_log2(half x0);
 __attribute__((__overloadable__)) half _cl_log2(half x0);
 __attribute__((__overloadable__)) half _cl_log2(half x0);
@@ -1498,6 +1607,7 @@ __attribute__((__overloadable__)) half8 _cl_log2(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_log2(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_log2(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_log2(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_log2(float x0);
 __attribute__((__overloadable__)) float _cl_log2(float x0);
 __attribute__((__overloadable__)) float _cl_log2(float x0);
@@ -1515,6 +1625,7 @@ __attribute__((__overloadable__)) float8 _cl_log2(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_log2(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_log2(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_log2(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_log2(double x0);
 __attribute__((__overloadable__)) double _cl_log2(double x0);
 __attribute__((__overloadable__)) double _cl_log2(double x0);
@@ -1532,10 +1643,12 @@ __attribute__((__overloadable__)) double8 _cl_log2(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_log2(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_log2(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_log2(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // log10: ['VF'] -> VF
 #undef log10
 #define log10 _cl_log10
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_log10(half x0);
 __attribute__((__overloadable__)) half _cl_log10(half x0);
 __attribute__((__overloadable__)) half _cl_log10(half x0);
@@ -1553,6 +1666,7 @@ __attribute__((__overloadable__)) half8 _cl_log10(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_log10(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_log10(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_log10(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_log10(float x0);
 __attribute__((__overloadable__)) float _cl_log10(float x0);
 __attribute__((__overloadable__)) float _cl_log10(float x0);
@@ -1570,6 +1684,7 @@ __attribute__((__overloadable__)) float8 _cl_log10(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_log10(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_log10(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_log10(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_log10(double x0);
 __attribute__((__overloadable__)) double _cl_log10(double x0);
 __attribute__((__overloadable__)) double _cl_log10(double x0);
@@ -1587,10 +1702,12 @@ __attribute__((__overloadable__)) double8 _cl_log10(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_log10(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_log10(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_log10(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // log1p: ['VF'] -> VF
 #undef log1p
 #define log1p _cl_log1p
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_log1p(half x0);
 __attribute__((__overloadable__)) half _cl_log1p(half x0);
 __attribute__((__overloadable__)) half _cl_log1p(half x0);
@@ -1608,6 +1725,7 @@ __attribute__((__overloadable__)) half8 _cl_log1p(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_log1p(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_log1p(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_log1p(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_log1p(float x0);
 __attribute__((__overloadable__)) float _cl_log1p(float x0);
 __attribute__((__overloadable__)) float _cl_log1p(float x0);
@@ -1625,6 +1743,7 @@ __attribute__((__overloadable__)) float8 _cl_log1p(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_log1p(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_log1p(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_log1p(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_log1p(double x0);
 __attribute__((__overloadable__)) double _cl_log1p(double x0);
 __attribute__((__overloadable__)) double _cl_log1p(double x0);
@@ -1642,10 +1761,12 @@ __attribute__((__overloadable__)) double8 _cl_log1p(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_log1p(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_log1p(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_log1p(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // pow: ['VF', 'VF'] -> VF
 #undef pow
 #define pow _cl_pow
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_pow(half x0, half x1);
 __attribute__((__overloadable__)) half _cl_pow(half x0, half x1);
 __attribute__((__overloadable__)) half _cl_pow(half x0, half x1);
@@ -1663,6 +1784,7 @@ __attribute__((__overloadable__)) half8 _cl_pow(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half8 _cl_pow(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half16 _cl_pow(half16 x0, half16 x1);
 __attribute__((__overloadable__)) half16 _cl_pow(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_pow(float x0, float x1);
 __attribute__((__overloadable__)) float _cl_pow(float x0, float x1);
 __attribute__((__overloadable__)) float _cl_pow(float x0, float x1);
@@ -1680,6 +1802,7 @@ __attribute__((__overloadable__)) float8 _cl_pow(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float8 _cl_pow(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float16 _cl_pow(float16 x0, float16 x1);
 __attribute__((__overloadable__)) float16 _cl_pow(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_pow(double x0, double x1);
 __attribute__((__overloadable__)) double _cl_pow(double x0, double x1);
 __attribute__((__overloadable__)) double _cl_pow(double x0, double x1);
@@ -1697,10 +1820,12 @@ __attribute__((__overloadable__)) double8 _cl_pow(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double8 _cl_pow(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double16 _cl_pow(double16 x0, double16 x1);
 __attribute__((__overloadable__)) double16 _cl_pow(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // remainder: ['VF', 'VF'] -> VF
 #undef remainder
 #define remainder _cl_remainder
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_remainder(half x0, half x1);
 __attribute__((__overloadable__)) half _cl_remainder(half x0, half x1);
 __attribute__((__overloadable__)) half _cl_remainder(half x0, half x1);
@@ -1718,6 +1843,7 @@ __attribute__((__overloadable__)) half8 _cl_remainder(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half8 _cl_remainder(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half16 _cl_remainder(half16 x0, half16 x1);
 __attribute__((__overloadable__)) half16 _cl_remainder(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_remainder(float x0, float x1);
 __attribute__((__overloadable__)) float _cl_remainder(float x0, float x1);
 __attribute__((__overloadable__)) float _cl_remainder(float x0, float x1);
@@ -1735,6 +1861,7 @@ __attribute__((__overloadable__)) float8 _cl_remainder(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float8 _cl_remainder(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float16 _cl_remainder(float16 x0, float16 x1);
 __attribute__((__overloadable__)) float16 _cl_remainder(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_remainder(double x0, double x1);
 __attribute__((__overloadable__)) double _cl_remainder(double x0, double x1);
 __attribute__((__overloadable__)) double _cl_remainder(double x0, double x1);
@@ -1752,10 +1879,12 @@ __attribute__((__overloadable__)) double8 _cl_remainder(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double8 _cl_remainder(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double16 _cl_remainder(double16 x0, double16 x1);
 __attribute__((__overloadable__)) double16 _cl_remainder(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // rint: ['VF'] -> VF
 #undef rint
 #define rint _cl_rint
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_rint(half x0);
 __attribute__((__overloadable__)) half _cl_rint(half x0);
 __attribute__((__overloadable__)) half _cl_rint(half x0);
@@ -1773,6 +1902,7 @@ __attribute__((__overloadable__)) half8 _cl_rint(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_rint(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_rint(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_rint(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_rint(float x0);
 __attribute__((__overloadable__)) float _cl_rint(float x0);
 __attribute__((__overloadable__)) float _cl_rint(float x0);
@@ -1790,6 +1920,7 @@ __attribute__((__overloadable__)) float8 _cl_rint(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_rint(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_rint(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_rint(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_rint(double x0);
 __attribute__((__overloadable__)) double _cl_rint(double x0);
 __attribute__((__overloadable__)) double _cl_rint(double x0);
@@ -1807,10 +1938,12 @@ __attribute__((__overloadable__)) double8 _cl_rint(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_rint(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_rint(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_rint(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // round: ['VF'] -> VF
 #undef round
 #define round _cl_round
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_round(half x0);
 __attribute__((__overloadable__)) half _cl_round(half x0);
 __attribute__((__overloadable__)) half _cl_round(half x0);
@@ -1828,6 +1961,7 @@ __attribute__((__overloadable__)) half8 _cl_round(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_round(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_round(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_round(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_round(float x0);
 __attribute__((__overloadable__)) float _cl_round(float x0);
 __attribute__((__overloadable__)) float _cl_round(float x0);
@@ -1845,6 +1979,7 @@ __attribute__((__overloadable__)) float8 _cl_round(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_round(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_round(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_round(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_round(double x0);
 __attribute__((__overloadable__)) double _cl_round(double x0);
 __attribute__((__overloadable__)) double _cl_round(double x0);
@@ -1862,10 +1997,12 @@ __attribute__((__overloadable__)) double8 _cl_round(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_round(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_round(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_round(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // rsqrt: ['VF'] -> VF
 #undef rsqrt
 #define rsqrt _cl_rsqrt
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_rsqrt(half x0);
 __attribute__((__overloadable__)) half _cl_rsqrt(half x0);
 __attribute__((__overloadable__)) half _cl_rsqrt(half x0);
@@ -1883,6 +2020,7 @@ __attribute__((__overloadable__)) half8 _cl_rsqrt(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_rsqrt(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_rsqrt(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_rsqrt(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_rsqrt(float x0);
 __attribute__((__overloadable__)) float _cl_rsqrt(float x0);
 __attribute__((__overloadable__)) float _cl_rsqrt(float x0);
@@ -1900,6 +2038,7 @@ __attribute__((__overloadable__)) float8 _cl_rsqrt(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_rsqrt(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_rsqrt(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_rsqrt(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_rsqrt(double x0);
 __attribute__((__overloadable__)) double _cl_rsqrt(double x0);
 __attribute__((__overloadable__)) double _cl_rsqrt(double x0);
@@ -1917,10 +2056,12 @@ __attribute__((__overloadable__)) double8 _cl_rsqrt(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_rsqrt(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_rsqrt(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_rsqrt(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // sin: ['VF'] -> VF
 #undef sin
 #define sin _cl_sin
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_sin(half x0);
 __attribute__((__overloadable__)) half _cl_sin(half x0);
 __attribute__((__overloadable__)) half _cl_sin(half x0);
@@ -1938,6 +2079,7 @@ __attribute__((__overloadable__)) half8 _cl_sin(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_sin(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_sin(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_sin(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_sin(float x0);
 __attribute__((__overloadable__)) float _cl_sin(float x0);
 __attribute__((__overloadable__)) float _cl_sin(float x0);
@@ -1955,6 +2097,7 @@ __attribute__((__overloadable__)) float8 _cl_sin(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_sin(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_sin(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_sin(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_sin(double x0);
 __attribute__((__overloadable__)) double _cl_sin(double x0);
 __attribute__((__overloadable__)) double _cl_sin(double x0);
@@ -1972,10 +2115,12 @@ __attribute__((__overloadable__)) double8 _cl_sin(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_sin(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_sin(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_sin(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // sinh: ['VF'] -> VF
 #undef sinh
 #define sinh _cl_sinh
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_sinh(half x0);
 __attribute__((__overloadable__)) half _cl_sinh(half x0);
 __attribute__((__overloadable__)) half _cl_sinh(half x0);
@@ -1993,6 +2138,7 @@ __attribute__((__overloadable__)) half8 _cl_sinh(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_sinh(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_sinh(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_sinh(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_sinh(float x0);
 __attribute__((__overloadable__)) float _cl_sinh(float x0);
 __attribute__((__overloadable__)) float _cl_sinh(float x0);
@@ -2010,6 +2156,7 @@ __attribute__((__overloadable__)) float8 _cl_sinh(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_sinh(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_sinh(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_sinh(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_sinh(double x0);
 __attribute__((__overloadable__)) double _cl_sinh(double x0);
 __attribute__((__overloadable__)) double _cl_sinh(double x0);
@@ -2027,10 +2174,12 @@ __attribute__((__overloadable__)) double8 _cl_sinh(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_sinh(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_sinh(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_sinh(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // sqrt: ['VF'] -> VF
 #undef sqrt
 #define sqrt _cl_sqrt
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_sqrt(half x0);
 __attribute__((__overloadable__)) half _cl_sqrt(half x0);
 __attribute__((__overloadable__)) half _cl_sqrt(half x0);
@@ -2048,6 +2197,7 @@ __attribute__((__overloadable__)) half8 _cl_sqrt(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_sqrt(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_sqrt(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_sqrt(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_sqrt(float x0);
 __attribute__((__overloadable__)) float _cl_sqrt(float x0);
 __attribute__((__overloadable__)) float _cl_sqrt(float x0);
@@ -2065,6 +2215,7 @@ __attribute__((__overloadable__)) float8 _cl_sqrt(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_sqrt(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_sqrt(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_sqrt(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_sqrt(double x0);
 __attribute__((__overloadable__)) double _cl_sqrt(double x0);
 __attribute__((__overloadable__)) double _cl_sqrt(double x0);
@@ -2082,10 +2233,12 @@ __attribute__((__overloadable__)) double8 _cl_sqrt(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_sqrt(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_sqrt(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_sqrt(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // tan: ['VF'] -> VF
 #undef tan
 #define tan _cl_tan
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_tan(half x0);
 __attribute__((__overloadable__)) half _cl_tan(half x0);
 __attribute__((__overloadable__)) half _cl_tan(half x0);
@@ -2103,6 +2256,7 @@ __attribute__((__overloadable__)) half8 _cl_tan(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_tan(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_tan(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_tan(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_tan(float x0);
 __attribute__((__overloadable__)) float _cl_tan(float x0);
 __attribute__((__overloadable__)) float _cl_tan(float x0);
@@ -2120,6 +2274,7 @@ __attribute__((__overloadable__)) float8 _cl_tan(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_tan(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_tan(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_tan(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_tan(double x0);
 __attribute__((__overloadable__)) double _cl_tan(double x0);
 __attribute__((__overloadable__)) double _cl_tan(double x0);
@@ -2137,10 +2292,12 @@ __attribute__((__overloadable__)) double8 _cl_tan(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_tan(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_tan(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_tan(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // tanh: ['VF'] -> VF
 #undef tanh
 #define tanh _cl_tanh
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_tanh(half x0);
 __attribute__((__overloadable__)) half _cl_tanh(half x0);
 __attribute__((__overloadable__)) half _cl_tanh(half x0);
@@ -2158,6 +2315,7 @@ __attribute__((__overloadable__)) half8 _cl_tanh(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_tanh(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_tanh(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_tanh(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_tanh(float x0);
 __attribute__((__overloadable__)) float _cl_tanh(float x0);
 __attribute__((__overloadable__)) float _cl_tanh(float x0);
@@ -2175,6 +2333,7 @@ __attribute__((__overloadable__)) float8 _cl_tanh(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_tanh(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_tanh(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_tanh(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_tanh(double x0);
 __attribute__((__overloadable__)) double _cl_tanh(double x0);
 __attribute__((__overloadable__)) double _cl_tanh(double x0);
@@ -2192,10 +2351,12 @@ __attribute__((__overloadable__)) double8 _cl_tanh(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_tanh(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_tanh(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_tanh(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // trunc: ['VF'] -> VF
 #undef trunc
 #define trunc _cl_trunc
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_trunc(half x0);
 __attribute__((__overloadable__)) half _cl_trunc(half x0);
 __attribute__((__overloadable__)) half _cl_trunc(half x0);
@@ -2213,6 +2374,7 @@ __attribute__((__overloadable__)) half8 _cl_trunc(half8 x0);
 __attribute__((__overloadable__)) half8 _cl_trunc(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_trunc(half16 x0);
 __attribute__((__overloadable__)) half16 _cl_trunc(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_trunc(float x0);
 __attribute__((__overloadable__)) float _cl_trunc(float x0);
 __attribute__((__overloadable__)) float _cl_trunc(float x0);
@@ -2230,6 +2392,7 @@ __attribute__((__overloadable__)) float8 _cl_trunc(float8 x0);
 __attribute__((__overloadable__)) float8 _cl_trunc(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_trunc(float16 x0);
 __attribute__((__overloadable__)) float16 _cl_trunc(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_trunc(double x0);
 __attribute__((__overloadable__)) double _cl_trunc(double x0);
 __attribute__((__overloadable__)) double _cl_trunc(double x0);
@@ -2247,10 +2410,12 @@ __attribute__((__overloadable__)) double8 _cl_trunc(double8 x0);
 __attribute__((__overloadable__)) double8 _cl_trunc(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_trunc(double16 x0);
 __attribute__((__overloadable__)) double16 _cl_trunc(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // isfinite: ['VF'] -> VJ
 #undef isfinite
 #define isfinite _cl_isfinite
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_isfinite(half x0);
 __attribute__((__overloadable__)) int _cl_isfinite(half x0);
 __attribute__((__overloadable__)) int _cl_isfinite(half x0);
@@ -2268,6 +2433,7 @@ __attribute__((__overloadable__)) short8 _cl_isfinite(half8 x0);
 __attribute__((__overloadable__)) short8 _cl_isfinite(half8 x0);
 __attribute__((__overloadable__)) short16 _cl_isfinite(half16 x0);
 __attribute__((__overloadable__)) short16 _cl_isfinite(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_isfinite(float x0);
 __attribute__((__overloadable__)) int _cl_isfinite(float x0);
 __attribute__((__overloadable__)) int _cl_isfinite(float x0);
@@ -2285,6 +2451,7 @@ __attribute__((__overloadable__)) int8 _cl_isfinite(float8 x0);
 __attribute__((__overloadable__)) int8 _cl_isfinite(float8 x0);
 __attribute__((__overloadable__)) int16 _cl_isfinite(float16 x0);
 __attribute__((__overloadable__)) int16 _cl_isfinite(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) int _cl_isfinite(double x0);
 __attribute__((__overloadable__)) int _cl_isfinite(double x0);
 __attribute__((__overloadable__)) int _cl_isfinite(double x0);
@@ -2302,10 +2469,12 @@ __attribute__((__overloadable__)) long8 _cl_isfinite(double8 x0);
 __attribute__((__overloadable__)) long8 _cl_isfinite(double8 x0);
 __attribute__((__overloadable__)) long16 _cl_isfinite(double16 x0);
 __attribute__((__overloadable__)) long16 _cl_isfinite(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // isinf: ['VF'] -> VJ
 #undef isinf
 #define isinf _cl_isinf
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_isinf(half x0);
 __attribute__((__overloadable__)) int _cl_isinf(half x0);
 __attribute__((__overloadable__)) int _cl_isinf(half x0);
@@ -2323,6 +2492,7 @@ __attribute__((__overloadable__)) short8 _cl_isinf(half8 x0);
 __attribute__((__overloadable__)) short8 _cl_isinf(half8 x0);
 __attribute__((__overloadable__)) short16 _cl_isinf(half16 x0);
 __attribute__((__overloadable__)) short16 _cl_isinf(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_isinf(float x0);
 __attribute__((__overloadable__)) int _cl_isinf(float x0);
 __attribute__((__overloadable__)) int _cl_isinf(float x0);
@@ -2340,6 +2510,7 @@ __attribute__((__overloadable__)) int8 _cl_isinf(float8 x0);
 __attribute__((__overloadable__)) int8 _cl_isinf(float8 x0);
 __attribute__((__overloadable__)) int16 _cl_isinf(float16 x0);
 __attribute__((__overloadable__)) int16 _cl_isinf(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) int _cl_isinf(double x0);
 __attribute__((__overloadable__)) int _cl_isinf(double x0);
 __attribute__((__overloadable__)) int _cl_isinf(double x0);
@@ -2357,10 +2528,12 @@ __attribute__((__overloadable__)) long8 _cl_isinf(double8 x0);
 __attribute__((__overloadable__)) long8 _cl_isinf(double8 x0);
 __attribute__((__overloadable__)) long16 _cl_isinf(double16 x0);
 __attribute__((__overloadable__)) long16 _cl_isinf(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // isnan: ['VF'] -> VJ
 #undef isnan
 #define isnan _cl_isnan
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_isnan(half x0);
 __attribute__((__overloadable__)) int _cl_isnan(half x0);
 __attribute__((__overloadable__)) int _cl_isnan(half x0);
@@ -2378,6 +2551,7 @@ __attribute__((__overloadable__)) short8 _cl_isnan(half8 x0);
 __attribute__((__overloadable__)) short8 _cl_isnan(half8 x0);
 __attribute__((__overloadable__)) short16 _cl_isnan(half16 x0);
 __attribute__((__overloadable__)) short16 _cl_isnan(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_isnan(float x0);
 __attribute__((__overloadable__)) int _cl_isnan(float x0);
 __attribute__((__overloadable__)) int _cl_isnan(float x0);
@@ -2395,6 +2569,7 @@ __attribute__((__overloadable__)) int8 _cl_isnan(float8 x0);
 __attribute__((__overloadable__)) int8 _cl_isnan(float8 x0);
 __attribute__((__overloadable__)) int16 _cl_isnan(float16 x0);
 __attribute__((__overloadable__)) int16 _cl_isnan(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) int _cl_isnan(double x0);
 __attribute__((__overloadable__)) int _cl_isnan(double x0);
 __attribute__((__overloadable__)) int _cl_isnan(double x0);
@@ -2412,10 +2587,12 @@ __attribute__((__overloadable__)) long8 _cl_isnan(double8 x0);
 __attribute__((__overloadable__)) long8 _cl_isnan(double8 x0);
 __attribute__((__overloadable__)) long16 _cl_isnan(double16 x0);
 __attribute__((__overloadable__)) long16 _cl_isnan(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // isnormal: ['VF'] -> VJ
 #undef isnormal
 #define isnormal _cl_isnormal
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_isnormal(half x0);
 __attribute__((__overloadable__)) int _cl_isnormal(half x0);
 __attribute__((__overloadable__)) int _cl_isnormal(half x0);
@@ -2433,6 +2610,7 @@ __attribute__((__overloadable__)) short8 _cl_isnormal(half8 x0);
 __attribute__((__overloadable__)) short8 _cl_isnormal(half8 x0);
 __attribute__((__overloadable__)) short16 _cl_isnormal(half16 x0);
 __attribute__((__overloadable__)) short16 _cl_isnormal(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_isnormal(float x0);
 __attribute__((__overloadable__)) int _cl_isnormal(float x0);
 __attribute__((__overloadable__)) int _cl_isnormal(float x0);
@@ -2450,6 +2628,7 @@ __attribute__((__overloadable__)) int8 _cl_isnormal(float8 x0);
 __attribute__((__overloadable__)) int8 _cl_isnormal(float8 x0);
 __attribute__((__overloadable__)) int16 _cl_isnormal(float16 x0);
 __attribute__((__overloadable__)) int16 _cl_isnormal(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) int _cl_isnormal(double x0);
 __attribute__((__overloadable__)) int _cl_isnormal(double x0);
 __attribute__((__overloadable__)) int _cl_isnormal(double x0);
@@ -2467,10 +2646,12 @@ __attribute__((__overloadable__)) long8 _cl_isnormal(double8 x0);
 __attribute__((__overloadable__)) long8 _cl_isnormal(double8 x0);
 __attribute__((__overloadable__)) long16 _cl_isnormal(double16 x0);
 __attribute__((__overloadable__)) long16 _cl_isnormal(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // signbit: ['VF'] -> VJ
 #undef signbit
 #define signbit _cl_signbit
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_signbit(half x0);
 __attribute__((__overloadable__)) int _cl_signbit(half x0);
 __attribute__((__overloadable__)) int _cl_signbit(half x0);
@@ -2488,6 +2669,7 @@ __attribute__((__overloadable__)) short8 _cl_signbit(half8 x0);
 __attribute__((__overloadable__)) short8 _cl_signbit(half8 x0);
 __attribute__((__overloadable__)) short16 _cl_signbit(half16 x0);
 __attribute__((__overloadable__)) short16 _cl_signbit(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_signbit(float x0);
 __attribute__((__overloadable__)) int _cl_signbit(float x0);
 __attribute__((__overloadable__)) int _cl_signbit(float x0);
@@ -2505,6 +2687,7 @@ __attribute__((__overloadable__)) int8 _cl_signbit(float8 x0);
 __attribute__((__overloadable__)) int8 _cl_signbit(float8 x0);
 __attribute__((__overloadable__)) int16 _cl_signbit(float16 x0);
 __attribute__((__overloadable__)) int16 _cl_signbit(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) int _cl_signbit(double x0);
 __attribute__((__overloadable__)) int _cl_signbit(double x0);
 __attribute__((__overloadable__)) int _cl_signbit(double x0);
@@ -2522,180 +2705,214 @@ __attribute__((__overloadable__)) long8 _cl_signbit(double8 x0);
 __attribute__((__overloadable__)) long8 _cl_signbit(double8 x0);
 __attribute__((__overloadable__)) long16 _cl_signbit(double16 x0);
 __attribute__((__overloadable__)) long16 _cl_signbit(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // acospi: ['VF'] -> VF
 #undef acospi
 #define acospi _cl_acospi
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_acospi(half x0);
 __attribute__((__overloadable__)) half2 _cl_acospi(half2 x0);
 __attribute__((__overloadable__)) half3 _cl_acospi(half3 x0);
 __attribute__((__overloadable__)) half4 _cl_acospi(half4 x0);
 __attribute__((__overloadable__)) half8 _cl_acospi(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_acospi(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_acospi(float x0);
 __attribute__((__overloadable__)) float2 _cl_acospi(float2 x0);
 __attribute__((__overloadable__)) float3 _cl_acospi(float3 x0);
 __attribute__((__overloadable__)) float4 _cl_acospi(float4 x0);
 __attribute__((__overloadable__)) float8 _cl_acospi(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_acospi(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_acospi(double x0);
 __attribute__((__overloadable__)) double2 _cl_acospi(double2 x0);
 __attribute__((__overloadable__)) double3 _cl_acospi(double3 x0);
 __attribute__((__overloadable__)) double4 _cl_acospi(double4 x0);
 __attribute__((__overloadable__)) double8 _cl_acospi(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_acospi(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // asinpi: ['VF'] -> VF
 #undef asinpi
 #define asinpi _cl_asinpi
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_asinpi(half x0);
 __attribute__((__overloadable__)) half2 _cl_asinpi(half2 x0);
 __attribute__((__overloadable__)) half3 _cl_asinpi(half3 x0);
 __attribute__((__overloadable__)) half4 _cl_asinpi(half4 x0);
 __attribute__((__overloadable__)) half8 _cl_asinpi(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_asinpi(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_asinpi(float x0);
 __attribute__((__overloadable__)) float2 _cl_asinpi(float2 x0);
 __attribute__((__overloadable__)) float3 _cl_asinpi(float3 x0);
 __attribute__((__overloadable__)) float4 _cl_asinpi(float4 x0);
 __attribute__((__overloadable__)) float8 _cl_asinpi(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_asinpi(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_asinpi(double x0);
 __attribute__((__overloadable__)) double2 _cl_asinpi(double2 x0);
 __attribute__((__overloadable__)) double3 _cl_asinpi(double3 x0);
 __attribute__((__overloadable__)) double4 _cl_asinpi(double4 x0);
 __attribute__((__overloadable__)) double8 _cl_asinpi(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_asinpi(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // atanpi: ['VF'] -> VF
 #undef atanpi
 #define atanpi _cl_atanpi
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_atanpi(half x0);
 __attribute__((__overloadable__)) half2 _cl_atanpi(half2 x0);
 __attribute__((__overloadable__)) half3 _cl_atanpi(half3 x0);
 __attribute__((__overloadable__)) half4 _cl_atanpi(half4 x0);
 __attribute__((__overloadable__)) half8 _cl_atanpi(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_atanpi(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_atanpi(float x0);
 __attribute__((__overloadable__)) float2 _cl_atanpi(float2 x0);
 __attribute__((__overloadable__)) float3 _cl_atanpi(float3 x0);
 __attribute__((__overloadable__)) float4 _cl_atanpi(float4 x0);
 __attribute__((__overloadable__)) float8 _cl_atanpi(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_atanpi(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_atanpi(double x0);
 __attribute__((__overloadable__)) double2 _cl_atanpi(double2 x0);
 __attribute__((__overloadable__)) double3 _cl_atanpi(double3 x0);
 __attribute__((__overloadable__)) double4 _cl_atanpi(double4 x0);
 __attribute__((__overloadable__)) double8 _cl_atanpi(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_atanpi(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // atan2: ['VF', 'VF'] -> VF
 #undef atan2
 #define atan2 _cl_atan2
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_atan2(half x0, half x1);
 __attribute__((__overloadable__)) half2 _cl_atan2(half2 x0, half2 x1);
 __attribute__((__overloadable__)) half3 _cl_atan2(half3 x0, half3 x1);
 __attribute__((__overloadable__)) half4 _cl_atan2(half4 x0, half4 x1);
 __attribute__((__overloadable__)) half8 _cl_atan2(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half16 _cl_atan2(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_atan2(float x0, float x1);
 __attribute__((__overloadable__)) float2 _cl_atan2(float2 x0, float2 x1);
 __attribute__((__overloadable__)) float3 _cl_atan2(float3 x0, float3 x1);
 __attribute__((__overloadable__)) float4 _cl_atan2(float4 x0, float4 x1);
 __attribute__((__overloadable__)) float8 _cl_atan2(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float16 _cl_atan2(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_atan2(double x0, double x1);
 __attribute__((__overloadable__)) double2 _cl_atan2(double2 x0, double2 x1);
 __attribute__((__overloadable__)) double3 _cl_atan2(double3 x0, double3 x1);
 __attribute__((__overloadable__)) double4 _cl_atan2(double4 x0, double4 x1);
 __attribute__((__overloadable__)) double8 _cl_atan2(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double16 _cl_atan2(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // atan2pi: ['VF', 'VF'] -> VF
 #undef atan2pi
 #define atan2pi _cl_atan2pi
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_atan2pi(half x0, half x1);
 __attribute__((__overloadable__)) half2 _cl_atan2pi(half2 x0, half2 x1);
 __attribute__((__overloadable__)) half3 _cl_atan2pi(half3 x0, half3 x1);
 __attribute__((__overloadable__)) half4 _cl_atan2pi(half4 x0, half4 x1);
 __attribute__((__overloadable__)) half8 _cl_atan2pi(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half16 _cl_atan2pi(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_atan2pi(float x0, float x1);
 __attribute__((__overloadable__)) float2 _cl_atan2pi(float2 x0, float2 x1);
 __attribute__((__overloadable__)) float3 _cl_atan2pi(float3 x0, float3 x1);
 __attribute__((__overloadable__)) float4 _cl_atan2pi(float4 x0, float4 x1);
 __attribute__((__overloadable__)) float8 _cl_atan2pi(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float16 _cl_atan2pi(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_atan2pi(double x0, double x1);
 __attribute__((__overloadable__)) double2 _cl_atan2pi(double2 x0, double2 x1);
 __attribute__((__overloadable__)) double3 _cl_atan2pi(double3 x0, double3 x1);
 __attribute__((__overloadable__)) double4 _cl_atan2pi(double4 x0, double4 x1);
 __attribute__((__overloadable__)) double8 _cl_atan2pi(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double16 _cl_atan2pi(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // cospi: ['VF'] -> VF
 #undef cospi
 #define cospi _cl_cospi
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_cospi(half x0);
 __attribute__((__overloadable__)) half2 _cl_cospi(half2 x0);
 __attribute__((__overloadable__)) half3 _cl_cospi(half3 x0);
 __attribute__((__overloadable__)) half4 _cl_cospi(half4 x0);
 __attribute__((__overloadable__)) half8 _cl_cospi(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_cospi(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_cospi(float x0);
 __attribute__((__overloadable__)) float2 _cl_cospi(float2 x0);
 __attribute__((__overloadable__)) float3 _cl_cospi(float3 x0);
 __attribute__((__overloadable__)) float4 _cl_cospi(float4 x0);
 __attribute__((__overloadable__)) float8 _cl_cospi(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_cospi(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_cospi(double x0);
 __attribute__((__overloadable__)) double2 _cl_cospi(double2 x0);
 __attribute__((__overloadable__)) double3 _cl_cospi(double3 x0);
 __attribute__((__overloadable__)) double4 _cl_cospi(double4 x0);
 __attribute__((__overloadable__)) double8 _cl_cospi(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_cospi(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // fmax: ['VF', 'SF'] -> VF
 #undef fmax
 #define fmax _cl_fmax
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half2 _cl_fmax(half2 x0, half x1);
 __attribute__((__overloadable__)) half3 _cl_fmax(half3 x0, half x1);
 __attribute__((__overloadable__)) half4 _cl_fmax(half4 x0, half x1);
 __attribute__((__overloadable__)) half8 _cl_fmax(half8 x0, half x1);
 __attribute__((__overloadable__)) half16 _cl_fmax(half16 x0, half x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float2 _cl_fmax(float2 x0, float x1);
 __attribute__((__overloadable__)) float3 _cl_fmax(float3 x0, float x1);
 __attribute__((__overloadable__)) float4 _cl_fmax(float4 x0, float x1);
 __attribute__((__overloadable__)) float8 _cl_fmax(float8 x0, float x1);
 __attribute__((__overloadable__)) float16 _cl_fmax(float16 x0, float x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double2 _cl_fmax(double2 x0, double x1);
 __attribute__((__overloadable__)) double3 _cl_fmax(double3 x0, double x1);
 __attribute__((__overloadable__)) double4 _cl_fmax(double4 x0, double x1);
 __attribute__((__overloadable__)) double8 _cl_fmax(double8 x0, double x1);
 __attribute__((__overloadable__)) double16 _cl_fmax(double16 x0, double x1);
+#endif // #ifdef cl_khr_fp64
 
 // fmin: ['VF', 'SF'] -> VF
 #undef fmin
 #define fmin _cl_fmin
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half2 _cl_fmin(half2 x0, half x1);
 __attribute__((__overloadable__)) half3 _cl_fmin(half3 x0, half x1);
 __attribute__((__overloadable__)) half4 _cl_fmin(half4 x0, half x1);
 __attribute__((__overloadable__)) half8 _cl_fmin(half8 x0, half x1);
 __attribute__((__overloadable__)) half16 _cl_fmin(half16 x0, half x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float2 _cl_fmin(float2 x0, float x1);
 __attribute__((__overloadable__)) float3 _cl_fmin(float3 x0, float x1);
 __attribute__((__overloadable__)) float4 _cl_fmin(float4 x0, float x1);
 __attribute__((__overloadable__)) float8 _cl_fmin(float8 x0, float x1);
 __attribute__((__overloadable__)) float16 _cl_fmin(float16 x0, float x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double2 _cl_fmin(double2 x0, double x1);
 __attribute__((__overloadable__)) double3 _cl_fmin(double3 x0, double x1);
 __attribute__((__overloadable__)) double4 _cl_fmin(double4 x0, double x1);
 __attribute__((__overloadable__)) double8 _cl_fmin(double8 x0, double x1);
 __attribute__((__overloadable__)) double16 _cl_fmin(double16 x0, double x1);
+#endif // #ifdef cl_khr_fp64
 
 // fract: ['VF', 'PVF'] -> VF
 #undef fract
 #define fract _cl_fract
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_fract(half x0, global half* x1);
 __attribute__((__overloadable__)) half _cl_fract(half x0, local half* x1);
 __attribute__((__overloadable__)) half _cl_fract(half x0, private half* x1);
@@ -2714,6 +2931,7 @@ __attribute__((__overloadable__)) half8 _cl_fract(half8 x0, private half8* x1);
 __attribute__((__overloadable__)) half16 _cl_fract(half16 x0, global half16* x1);
 __attribute__((__overloadable__)) half16 _cl_fract(half16 x0, local half16* x1);
 __attribute__((__overloadable__)) half16 _cl_fract(half16 x0, private half16* x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_fract(float x0, global float* x1);
 __attribute__((__overloadable__)) float _cl_fract(float x0, local float* x1);
 __attribute__((__overloadable__)) float _cl_fract(float x0, private float* x1);
@@ -2732,6 +2950,7 @@ __attribute__((__overloadable__)) float8 _cl_fract(float8 x0, private float8* x1
 __attribute__((__overloadable__)) float16 _cl_fract(float16 x0, global float16* x1);
 __attribute__((__overloadable__)) float16 _cl_fract(float16 x0, local float16* x1);
 __attribute__((__overloadable__)) float16 _cl_fract(float16 x0, private float16* x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_fract(double x0, global double* x1);
 __attribute__((__overloadable__)) double _cl_fract(double x0, local double* x1);
 __attribute__((__overloadable__)) double _cl_fract(double x0, private double* x1);
@@ -2750,10 +2969,12 @@ __attribute__((__overloadable__)) double8 _cl_fract(double8 x0, private double8*
 __attribute__((__overloadable__)) double16 _cl_fract(double16 x0, global double16* x1);
 __attribute__((__overloadable__)) double16 _cl_fract(double16 x0, local double16* x1);
 __attribute__((__overloadable__)) double16 _cl_fract(double16 x0, private double16* x1);
+#endif // #ifdef cl_khr_fp64
 
 // frexp: ['VF', 'PVK'] -> VF
 #undef frexp
 #define frexp _cl_frexp
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_frexp(half x0, global int* x1);
 __attribute__((__overloadable__)) half _cl_frexp(half x0, local int* x1);
 __attribute__((__overloadable__)) half _cl_frexp(half x0, private int* x1);
@@ -2772,6 +2993,7 @@ __attribute__((__overloadable__)) half8 _cl_frexp(half8 x0, private int8* x1);
 __attribute__((__overloadable__)) half16 _cl_frexp(half16 x0, global int16* x1);
 __attribute__((__overloadable__)) half16 _cl_frexp(half16 x0, local int16* x1);
 __attribute__((__overloadable__)) half16 _cl_frexp(half16 x0, private int16* x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_frexp(float x0, global int* x1);
 __attribute__((__overloadable__)) float _cl_frexp(float x0, local int* x1);
 __attribute__((__overloadable__)) float _cl_frexp(float x0, private int* x1);
@@ -2790,6 +3012,7 @@ __attribute__((__overloadable__)) float8 _cl_frexp(float8 x0, private int8* x1);
 __attribute__((__overloadable__)) float16 _cl_frexp(float16 x0, global int16* x1);
 __attribute__((__overloadable__)) float16 _cl_frexp(float16 x0, local int16* x1);
 __attribute__((__overloadable__)) float16 _cl_frexp(float16 x0, private int16* x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_frexp(double x0, global int* x1);
 __attribute__((__overloadable__)) double _cl_frexp(double x0, local int* x1);
 __attribute__((__overloadable__)) double _cl_frexp(double x0, private int* x1);
@@ -2808,161 +3031,191 @@ __attribute__((__overloadable__)) double8 _cl_frexp(double8 x0, private int8* x1
 __attribute__((__overloadable__)) double16 _cl_frexp(double16 x0, global int16* x1);
 __attribute__((__overloadable__)) double16 _cl_frexp(double16 x0, local int16* x1);
 __attribute__((__overloadable__)) double16 _cl_frexp(double16 x0, private int16* x1);
+#endif // #ifdef cl_khr_fp64
 
 // ilogb: ['VF'] -> VK
 #undef ilogb
 #define ilogb _cl_ilogb
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_ilogb(half x0);
 __attribute__((__overloadable__)) int2 _cl_ilogb(half2 x0);
 __attribute__((__overloadable__)) int3 _cl_ilogb(half3 x0);
 __attribute__((__overloadable__)) int4 _cl_ilogb(half4 x0);
 __attribute__((__overloadable__)) int8 _cl_ilogb(half8 x0);
 __attribute__((__overloadable__)) int16 _cl_ilogb(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_ilogb(float x0);
 __attribute__((__overloadable__)) int2 _cl_ilogb(float2 x0);
 __attribute__((__overloadable__)) int3 _cl_ilogb(float3 x0);
 __attribute__((__overloadable__)) int4 _cl_ilogb(float4 x0);
 __attribute__((__overloadable__)) int8 _cl_ilogb(float8 x0);
 __attribute__((__overloadable__)) int16 _cl_ilogb(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) int _cl_ilogb(double x0);
 __attribute__((__overloadable__)) int2 _cl_ilogb(double2 x0);
 __attribute__((__overloadable__)) int3 _cl_ilogb(double3 x0);
 __attribute__((__overloadable__)) int4 _cl_ilogb(double4 x0);
 __attribute__((__overloadable__)) int8 _cl_ilogb(double8 x0);
 __attribute__((__overloadable__)) int16 _cl_ilogb(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // ldexp: ['VF', 'VK'] -> VF
 #undef ldexp
 #define ldexp _cl_ldexp
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_ldexp(half x0, int x1);
 __attribute__((__overloadable__)) half2 _cl_ldexp(half2 x0, int2 x1);
 __attribute__((__overloadable__)) half3 _cl_ldexp(half3 x0, int3 x1);
 __attribute__((__overloadable__)) half4 _cl_ldexp(half4 x0, int4 x1);
 __attribute__((__overloadable__)) half8 _cl_ldexp(half8 x0, int8 x1);
 __attribute__((__overloadable__)) half16 _cl_ldexp(half16 x0, int16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_ldexp(float x0, int x1);
 __attribute__((__overloadable__)) float2 _cl_ldexp(float2 x0, int2 x1);
 __attribute__((__overloadable__)) float3 _cl_ldexp(float3 x0, int3 x1);
 __attribute__((__overloadable__)) float4 _cl_ldexp(float4 x0, int4 x1);
 __attribute__((__overloadable__)) float8 _cl_ldexp(float8 x0, int8 x1);
 __attribute__((__overloadable__)) float16 _cl_ldexp(float16 x0, int16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_ldexp(double x0, int x1);
 __attribute__((__overloadable__)) double2 _cl_ldexp(double2 x0, int2 x1);
 __attribute__((__overloadable__)) double3 _cl_ldexp(double3 x0, int3 x1);
 __attribute__((__overloadable__)) double4 _cl_ldexp(double4 x0, int4 x1);
 __attribute__((__overloadable__)) double8 _cl_ldexp(double8 x0, int8 x1);
 __attribute__((__overloadable__)) double16 _cl_ldexp(double16 x0, int16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // ldexp: ['VF', 'SK'] -> VF
 #undef ldexp
 #define ldexp _cl_ldexp
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half2 _cl_ldexp(half2 x0, int x1);
 __attribute__((__overloadable__)) half3 _cl_ldexp(half3 x0, int x1);
 __attribute__((__overloadable__)) half4 _cl_ldexp(half4 x0, int x1);
 __attribute__((__overloadable__)) half8 _cl_ldexp(half8 x0, int x1);
 __attribute__((__overloadable__)) half16 _cl_ldexp(half16 x0, int x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float2 _cl_ldexp(float2 x0, int x1);
 __attribute__((__overloadable__)) float3 _cl_ldexp(float3 x0, int x1);
 __attribute__((__overloadable__)) float4 _cl_ldexp(float4 x0, int x1);
 __attribute__((__overloadable__)) float8 _cl_ldexp(float8 x0, int x1);
 __attribute__((__overloadable__)) float16 _cl_ldexp(float16 x0, int x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double2 _cl_ldexp(double2 x0, int x1);
 __attribute__((__overloadable__)) double3 _cl_ldexp(double3 x0, int x1);
 __attribute__((__overloadable__)) double4 _cl_ldexp(double4 x0, int x1);
 __attribute__((__overloadable__)) double8 _cl_ldexp(double8 x0, int x1);
 __attribute__((__overloadable__)) double16 _cl_ldexp(double16 x0, int x1);
+#endif // #ifdef cl_khr_fp64
 
 // logb: ['VF'] -> VF
 #undef logb
 #define logb _cl_logb
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_logb(half x0);
 __attribute__((__overloadable__)) half2 _cl_logb(half2 x0);
 __attribute__((__overloadable__)) half3 _cl_logb(half3 x0);
 __attribute__((__overloadable__)) half4 _cl_logb(half4 x0);
 __attribute__((__overloadable__)) half8 _cl_logb(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_logb(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_logb(float x0);
 __attribute__((__overloadable__)) float2 _cl_logb(float2 x0);
 __attribute__((__overloadable__)) float3 _cl_logb(float3 x0);
 __attribute__((__overloadable__)) float4 _cl_logb(float4 x0);
 __attribute__((__overloadable__)) float8 _cl_logb(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_logb(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_logb(double x0);
 __attribute__((__overloadable__)) double2 _cl_logb(double2 x0);
 __attribute__((__overloadable__)) double3 _cl_logb(double3 x0);
 __attribute__((__overloadable__)) double4 _cl_logb(double4 x0);
 __attribute__((__overloadable__)) double8 _cl_logb(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_logb(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // mad: ['VF', 'VF', 'VF'] -> VF
 #undef mad
 #define mad _cl_mad
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_mad(half x0, half x1, half x2);
 __attribute__((__overloadable__)) half2 _cl_mad(half2 x0, half2 x1, half2 x2);
 __attribute__((__overloadable__)) half3 _cl_mad(half3 x0, half3 x1, half3 x2);
 __attribute__((__overloadable__)) half4 _cl_mad(half4 x0, half4 x1, half4 x2);
 __attribute__((__overloadable__)) half8 _cl_mad(half8 x0, half8 x1, half8 x2);
 __attribute__((__overloadable__)) half16 _cl_mad(half16 x0, half16 x1, half16 x2);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_mad(float x0, float x1, float x2);
 __attribute__((__overloadable__)) float2 _cl_mad(float2 x0, float2 x1, float2 x2);
 __attribute__((__overloadable__)) float3 _cl_mad(float3 x0, float3 x1, float3 x2);
 __attribute__((__overloadable__)) float4 _cl_mad(float4 x0, float4 x1, float4 x2);
 __attribute__((__overloadable__)) float8 _cl_mad(float8 x0, float8 x1, float8 x2);
 __attribute__((__overloadable__)) float16 _cl_mad(float16 x0, float16 x1, float16 x2);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_mad(double x0, double x1, double x2);
 __attribute__((__overloadable__)) double2 _cl_mad(double2 x0, double2 x1, double2 x2);
 __attribute__((__overloadable__)) double3 _cl_mad(double3 x0, double3 x1, double3 x2);
 __attribute__((__overloadable__)) double4 _cl_mad(double4 x0, double4 x1, double4 x2);
 __attribute__((__overloadable__)) double8 _cl_mad(double8 x0, double8 x1, double8 x2);
 __attribute__((__overloadable__)) double16 _cl_mad(double16 x0, double16 x1, double16 x2);
+#endif // #ifdef cl_khr_fp64
 
 // maxmag: ['VF', 'VF'] -> VF
 #undef maxmag
 #define maxmag _cl_maxmag
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_maxmag(half x0, half x1);
 __attribute__((__overloadable__)) half2 _cl_maxmag(half2 x0, half2 x1);
 __attribute__((__overloadable__)) half3 _cl_maxmag(half3 x0, half3 x1);
 __attribute__((__overloadable__)) half4 _cl_maxmag(half4 x0, half4 x1);
 __attribute__((__overloadable__)) half8 _cl_maxmag(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half16 _cl_maxmag(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_maxmag(float x0, float x1);
 __attribute__((__overloadable__)) float2 _cl_maxmag(float2 x0, float2 x1);
 __attribute__((__overloadable__)) float3 _cl_maxmag(float3 x0, float3 x1);
 __attribute__((__overloadable__)) float4 _cl_maxmag(float4 x0, float4 x1);
 __attribute__((__overloadable__)) float8 _cl_maxmag(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float16 _cl_maxmag(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_maxmag(double x0, double x1);
 __attribute__((__overloadable__)) double2 _cl_maxmag(double2 x0, double2 x1);
 __attribute__((__overloadable__)) double3 _cl_maxmag(double3 x0, double3 x1);
 __attribute__((__overloadable__)) double4 _cl_maxmag(double4 x0, double4 x1);
 __attribute__((__overloadable__)) double8 _cl_maxmag(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double16 _cl_maxmag(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // minmag: ['VF', 'VF'] -> VF
 #undef minmag
 #define minmag _cl_minmag
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_minmag(half x0, half x1);
 __attribute__((__overloadable__)) half2 _cl_minmag(half2 x0, half2 x1);
 __attribute__((__overloadable__)) half3 _cl_minmag(half3 x0, half3 x1);
 __attribute__((__overloadable__)) half4 _cl_minmag(half4 x0, half4 x1);
 __attribute__((__overloadable__)) half8 _cl_minmag(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half16 _cl_minmag(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_minmag(float x0, float x1);
 __attribute__((__overloadable__)) float2 _cl_minmag(float2 x0, float2 x1);
 __attribute__((__overloadable__)) float3 _cl_minmag(float3 x0, float3 x1);
 __attribute__((__overloadable__)) float4 _cl_minmag(float4 x0, float4 x1);
 __attribute__((__overloadable__)) float8 _cl_minmag(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float16 _cl_minmag(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_minmag(double x0, double x1);
 __attribute__((__overloadable__)) double2 _cl_minmag(double2 x0, double2 x1);
 __attribute__((__overloadable__)) double3 _cl_minmag(double3 x0, double3 x1);
 __attribute__((__overloadable__)) double4 _cl_minmag(double4 x0, double4 x1);
 __attribute__((__overloadable__)) double8 _cl_minmag(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double16 _cl_minmag(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // modf: ['VF', 'PVF'] -> VF
 #undef modf
 #define modf _cl_modf
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_modf(half x0, global half* x1);
 __attribute__((__overloadable__)) half _cl_modf(half x0, local half* x1);
 __attribute__((__overloadable__)) half _cl_modf(half x0, private half* x1);
@@ -2981,6 +3234,7 @@ __attribute__((__overloadable__)) half8 _cl_modf(half8 x0, private half8* x1);
 __attribute__((__overloadable__)) half16 _cl_modf(half16 x0, global half16* x1);
 __attribute__((__overloadable__)) half16 _cl_modf(half16 x0, local half16* x1);
 __attribute__((__overloadable__)) half16 _cl_modf(half16 x0, private half16* x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_modf(float x0, global float* x1);
 __attribute__((__overloadable__)) float _cl_modf(float x0, local float* x1);
 __attribute__((__overloadable__)) float _cl_modf(float x0, private float* x1);
@@ -2999,6 +3253,7 @@ __attribute__((__overloadable__)) float8 _cl_modf(float8 x0, private float8* x1)
 __attribute__((__overloadable__)) float16 _cl_modf(float16 x0, global float16* x1);
 __attribute__((__overloadable__)) float16 _cl_modf(float16 x0, local float16* x1);
 __attribute__((__overloadable__)) float16 _cl_modf(float16 x0, private float16* x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_modf(double x0, global double* x1);
 __attribute__((__overloadable__)) double _cl_modf(double x0, local double* x1);
 __attribute__((__overloadable__)) double _cl_modf(double x0, private double* x1);
@@ -3017,76 +3272,90 @@ __attribute__((__overloadable__)) double8 _cl_modf(double8 x0, private double8*
 __attribute__((__overloadable__)) double16 _cl_modf(double16 x0, global double16* x1);
 __attribute__((__overloadable__)) double16 _cl_modf(double16 x0, local double16* x1);
 __attribute__((__overloadable__)) double16 _cl_modf(double16 x0, private double16* x1);
+#endif // #ifdef cl_khr_fp64
 
 // nan: ['VU'] -> VF
 #undef nan
 #define nan _cl_nan
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_nan(ushort x0);
 __attribute__((__overloadable__)) half2 _cl_nan(ushort2 x0);
 __attribute__((__overloadable__)) half3 _cl_nan(ushort3 x0);
 __attribute__((__overloadable__)) half4 _cl_nan(ushort4 x0);
 __attribute__((__overloadable__)) half8 _cl_nan(ushort8 x0);
 __attribute__((__overloadable__)) half16 _cl_nan(ushort16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_nan(uint x0);
 __attribute__((__overloadable__)) float2 _cl_nan(uint2 x0);
 __attribute__((__overloadable__)) float3 _cl_nan(uint3 x0);
 __attribute__((__overloadable__)) float4 _cl_nan(uint4 x0);
 __attribute__((__overloadable__)) float8 _cl_nan(uint8 x0);
 __attribute__((__overloadable__)) float16 _cl_nan(uint16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_nan(ulong x0);
 __attribute__((__overloadable__)) double2 _cl_nan(ulong2 x0);
 __attribute__((__overloadable__)) double3 _cl_nan(ulong3 x0);
 __attribute__((__overloadable__)) double4 _cl_nan(ulong4 x0);
 __attribute__((__overloadable__)) double8 _cl_nan(ulong8 x0);
 __attribute__((__overloadable__)) double16 _cl_nan(ulong16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // pown: ['VF', 'VK'] -> VF
 #undef pown
 #define pown _cl_pown
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_pown(half x0, int x1);
 __attribute__((__overloadable__)) half2 _cl_pown(half2 x0, int2 x1);
 __attribute__((__overloadable__)) half3 _cl_pown(half3 x0, int3 x1);
 __attribute__((__overloadable__)) half4 _cl_pown(half4 x0, int4 x1);
 __attribute__((__overloadable__)) half8 _cl_pown(half8 x0, int8 x1);
 __attribute__((__overloadable__)) half16 _cl_pown(half16 x0, int16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_pown(float x0, int x1);
 __attribute__((__overloadable__)) float2 _cl_pown(float2 x0, int2 x1);
 __attribute__((__overloadable__)) float3 _cl_pown(float3 x0, int3 x1);
 __attribute__((__overloadable__)) float4 _cl_pown(float4 x0, int4 x1);
 __attribute__((__overloadable__)) float8 _cl_pown(float8 x0, int8 x1);
 __attribute__((__overloadable__)) float16 _cl_pown(float16 x0, int16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_pown(double x0, int x1);
 __attribute__((__overloadable__)) double2 _cl_pown(double2 x0, int2 x1);
 __attribute__((__overloadable__)) double3 _cl_pown(double3 x0, int3 x1);
 __attribute__((__overloadable__)) double4 _cl_pown(double4 x0, int4 x1);
 __attribute__((__overloadable__)) double8 _cl_pown(double8 x0, int8 x1);
 __attribute__((__overloadable__)) double16 _cl_pown(double16 x0, int16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // powr: ['VF', 'VF'] -> VF
 #undef powr
 #define powr _cl_powr
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_powr(half x0, half x1);
 __attribute__((__overloadable__)) half2 _cl_powr(half2 x0, half2 x1);
 __attribute__((__overloadable__)) half3 _cl_powr(half3 x0, half3 x1);
 __attribute__((__overloadable__)) half4 _cl_powr(half4 x0, half4 x1);
 __attribute__((__overloadable__)) half8 _cl_powr(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half16 _cl_powr(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_powr(float x0, float x1);
 __attribute__((__overloadable__)) float2 _cl_powr(float2 x0, float2 x1);
 __attribute__((__overloadable__)) float3 _cl_powr(float3 x0, float3 x1);
 __attribute__((__overloadable__)) float4 _cl_powr(float4 x0, float4 x1);
 __attribute__((__overloadable__)) float8 _cl_powr(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float16 _cl_powr(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_powr(double x0, double x1);
 __attribute__((__overloadable__)) double2 _cl_powr(double2 x0, double2 x1);
 __attribute__((__overloadable__)) double3 _cl_powr(double3 x0, double3 x1);
 __attribute__((__overloadable__)) double4 _cl_powr(double4 x0, double4 x1);
 __attribute__((__overloadable__)) double8 _cl_powr(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double16 _cl_powr(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // remquo: ['VF', 'VF', 'PVK'] -> VF
 #undef remquo
 #define remquo _cl_remquo
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_remquo(half x0, half x1, global int* x2);
 __attribute__((__overloadable__)) half _cl_remquo(half x0, half x1, local int* x2);
 __attribute__((__overloadable__)) half _cl_remquo(half x0, half x1, private int* x2);
@@ -3105,6 +3374,7 @@ __attribute__((__overloadable__)) half8 _cl_remquo(half8 x0, half8 x1, private i
 __attribute__((__overloadable__)) half16 _cl_remquo(half16 x0, half16 x1, global int16* x2);
 __attribute__((__overloadable__)) half16 _cl_remquo(half16 x0, half16 x1, local int16* x2);
 __attribute__((__overloadable__)) half16 _cl_remquo(half16 x0, half16 x1, private int16* x2);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_remquo(float x0, float x1, global int* x2);
 __attribute__((__overloadable__)) float _cl_remquo(float x0, float x1, local int* x2);
 __attribute__((__overloadable__)) float _cl_remquo(float x0, float x1, private int* x2);
@@ -3123,6 +3393,7 @@ __attribute__((__overloadable__)) float8 _cl_remquo(float8 x0, float8 x1, privat
 __attribute__((__overloadable__)) float16 _cl_remquo(float16 x0, float16 x1, global int16* x2);
 __attribute__((__overloadable__)) float16 _cl_remquo(float16 x0, float16 x1, local int16* x2);
 __attribute__((__overloadable__)) float16 _cl_remquo(float16 x0, float16 x1, private int16* x2);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_remquo(double x0, double x1, global int* x2);
 __attribute__((__overloadable__)) double _cl_remquo(double x0, double x1, local int* x2);
 __attribute__((__overloadable__)) double _cl_remquo(double x0, double x1, private int* x2);
@@ -3141,32 +3412,38 @@ __attribute__((__overloadable__)) double8 _cl_remquo(double8 x0, double8 x1, pri
 __attribute__((__overloadable__)) double16 _cl_remquo(double16 x0, double16 x1, global int16* x2);
 __attribute__((__overloadable__)) double16 _cl_remquo(double16 x0, double16 x1, local int16* x2);
 __attribute__((__overloadable__)) double16 _cl_remquo(double16 x0, double16 x1, private int16* x2);
+#endif // #ifdef cl_khr_fp64
 
 // rootn: ['VF', 'VK'] -> VF
 #undef rootn
 #define rootn _cl_rootn
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_rootn(half x0, int x1);
 __attribute__((__overloadable__)) half2 _cl_rootn(half2 x0, int2 x1);
 __attribute__((__overloadable__)) half3 _cl_rootn(half3 x0, int3 x1);
 __attribute__((__overloadable__)) half4 _cl_rootn(half4 x0, int4 x1);
 __attribute__((__overloadable__)) half8 _cl_rootn(half8 x0, int8 x1);
 __attribute__((__overloadable__)) half16 _cl_rootn(half16 x0, int16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_rootn(float x0, int x1);
 __attribute__((__overloadable__)) float2 _cl_rootn(float2 x0, int2 x1);
 __attribute__((__overloadable__)) float3 _cl_rootn(float3 x0, int3 x1);
 __attribute__((__overloadable__)) float4 _cl_rootn(float4 x0, int4 x1);
 __attribute__((__overloadable__)) float8 _cl_rootn(float8 x0, int8 x1);
 __attribute__((__overloadable__)) float16 _cl_rootn(float16 x0, int16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_rootn(double x0, int x1);
 __attribute__((__overloadable__)) double2 _cl_rootn(double2 x0, int2 x1);
 __attribute__((__overloadable__)) double3 _cl_rootn(double3 x0, int3 x1);
 __attribute__((__overloadable__)) double4 _cl_rootn(double4 x0, int4 x1);
 __attribute__((__overloadable__)) double8 _cl_rootn(double8 x0, int8 x1);
 __attribute__((__overloadable__)) double16 _cl_rootn(double16 x0, int16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // sincos: ['VF', 'PVF'] -> VF
 #undef sincos
 #define sincos _cl_sincos
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_sincos(half x0, global half* x1);
 __attribute__((__overloadable__)) half _cl_sincos(half x0, local half* x1);
 __attribute__((__overloadable__)) half _cl_sincos(half x0, private half* x1);
@@ -3185,6 +3462,7 @@ __attribute__((__overloadable__)) half8 _cl_sincos(half8 x0, private half8* x1);
 __attribute__((__overloadable__)) half16 _cl_sincos(half16 x0, global half16* x1);
 __attribute__((__overloadable__)) half16 _cl_sincos(half16 x0, local half16* x1);
 __attribute__((__overloadable__)) half16 _cl_sincos(half16 x0, private half16* x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_sincos(float x0, global float* x1);
 __attribute__((__overloadable__)) float _cl_sincos(float x0, local float* x1);
 __attribute__((__overloadable__)) float _cl_sincos(float x0, private float* x1);
@@ -3203,6 +3481,7 @@ __attribute__((__overloadable__)) float8 _cl_sincos(float8 x0, private float8* x
 __attribute__((__overloadable__)) float16 _cl_sincos(float16 x0, global float16* x1);
 __attribute__((__overloadable__)) float16 _cl_sincos(float16 x0, local float16* x1);
 __attribute__((__overloadable__)) float16 _cl_sincos(float16 x0, private float16* x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_sincos(double x0, global double* x1);
 __attribute__((__overloadable__)) double _cl_sincos(double x0, local double* x1);
 __attribute__((__overloadable__)) double _cl_sincos(double x0, private double* x1);
@@ -3221,50 +3500,59 @@ __attribute__((__overloadable__)) double8 _cl_sincos(double8 x0, private double8
 __attribute__((__overloadable__)) double16 _cl_sincos(double16 x0, global double16* x1);
 __attribute__((__overloadable__)) double16 _cl_sincos(double16 x0, local double16* x1);
 __attribute__((__overloadable__)) double16 _cl_sincos(double16 x0, private double16* x1);
+#endif // #ifdef cl_khr_fp64
 
 // sinpi: ['VF'] -> VF
 #undef sinpi
 #define sinpi _cl_sinpi
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_sinpi(half x0);
 __attribute__((__overloadable__)) half2 _cl_sinpi(half2 x0);
 __attribute__((__overloadable__)) half3 _cl_sinpi(half3 x0);
 __attribute__((__overloadable__)) half4 _cl_sinpi(half4 x0);
 __attribute__((__overloadable__)) half8 _cl_sinpi(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_sinpi(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_sinpi(float x0);
 __attribute__((__overloadable__)) float2 _cl_sinpi(float2 x0);
 __attribute__((__overloadable__)) float3 _cl_sinpi(float3 x0);
 __attribute__((__overloadable__)) float4 _cl_sinpi(float4 x0);
 __attribute__((__overloadable__)) float8 _cl_sinpi(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_sinpi(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_sinpi(double x0);
 __attribute__((__overloadable__)) double2 _cl_sinpi(double2 x0);
 __attribute__((__overloadable__)) double3 _cl_sinpi(double3 x0);
 __attribute__((__overloadable__)) double4 _cl_sinpi(double4 x0);
 __attribute__((__overloadable__)) double8 _cl_sinpi(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_sinpi(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // tanpi: ['VF'] -> VF
 #undef tanpi
 #define tanpi _cl_tanpi
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_tanpi(half x0);
 __attribute__((__overloadable__)) half2 _cl_tanpi(half2 x0);
 __attribute__((__overloadable__)) half3 _cl_tanpi(half3 x0);
 __attribute__((__overloadable__)) half4 _cl_tanpi(half4 x0);
 __attribute__((__overloadable__)) half8 _cl_tanpi(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_tanpi(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_tanpi(float x0);
 __attribute__((__overloadable__)) float2 _cl_tanpi(float2 x0);
 __attribute__((__overloadable__)) float3 _cl_tanpi(float3 x0);
 __attribute__((__overloadable__)) float4 _cl_tanpi(float4 x0);
 __attribute__((__overloadable__)) float8 _cl_tanpi(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_tanpi(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_tanpi(double x0);
 __attribute__((__overloadable__)) double2 _cl_tanpi(double2 x0);
 __attribute__((__overloadable__)) double3 _cl_tanpi(double3 x0);
 __attribute__((__overloadable__)) double4 _cl_tanpi(double4 x0);
 __attribute__((__overloadable__)) double8 _cl_tanpi(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_tanpi(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // half_cos: ['VF'] -> VF
 #undef half_cos
@@ -3549,511 +3837,607 @@ __attribute__((__overloadable__)) float16 _cl_native_tan(float16 x0);
 // clamp: ['VF', 'VF', 'VF'] -> VF
 #undef clamp
 #define clamp _cl_clamp
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_clamp(half x0, half x1, half x2);
 __attribute__((__overloadable__)) half2 _cl_clamp(half2 x0, half2 x1, half2 x2);
 __attribute__((__overloadable__)) half3 _cl_clamp(half3 x0, half3 x1, half3 x2);
 __attribute__((__overloadable__)) half4 _cl_clamp(half4 x0, half4 x1, half4 x2);
 __attribute__((__overloadable__)) half8 _cl_clamp(half8 x0, half8 x1, half8 x2);
 __attribute__((__overloadable__)) half16 _cl_clamp(half16 x0, half16 x1, half16 x2);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_clamp(float x0, float x1, float x2);
 __attribute__((__overloadable__)) float2 _cl_clamp(float2 x0, float2 x1, float2 x2);
 __attribute__((__overloadable__)) float3 _cl_clamp(float3 x0, float3 x1, float3 x2);
 __attribute__((__overloadable__)) float4 _cl_clamp(float4 x0, float4 x1, float4 x2);
 __attribute__((__overloadable__)) float8 _cl_clamp(float8 x0, float8 x1, float8 x2);
 __attribute__((__overloadable__)) float16 _cl_clamp(float16 x0, float16 x1, float16 x2);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_clamp(double x0, double x1, double x2);
 __attribute__((__overloadable__)) double2 _cl_clamp(double2 x0, double2 x1, double2 x2);
 __attribute__((__overloadable__)) double3 _cl_clamp(double3 x0, double3 x1, double3 x2);
 __attribute__((__overloadable__)) double4 _cl_clamp(double4 x0, double4 x1, double4 x2);
 __attribute__((__overloadable__)) double8 _cl_clamp(double8 x0, double8 x1, double8 x2);
 __attribute__((__overloadable__)) double16 _cl_clamp(double16 x0, double16 x1, double16 x2);
+#endif // #ifdef cl_khr_fp64
 
 // clamp: ['VF', 'SF', 'SF'] -> VF
 #undef clamp
 #define clamp _cl_clamp
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half2 _cl_clamp(half2 x0, half x1, half x2);
 __attribute__((__overloadable__)) half3 _cl_clamp(half3 x0, half x1, half x2);
 __attribute__((__overloadable__)) half4 _cl_clamp(half4 x0, half x1, half x2);
 __attribute__((__overloadable__)) half8 _cl_clamp(half8 x0, half x1, half x2);
 __attribute__((__overloadable__)) half16 _cl_clamp(half16 x0, half x1, half x2);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float2 _cl_clamp(float2 x0, float x1, float x2);
 __attribute__((__overloadable__)) float3 _cl_clamp(float3 x0, float x1, float x2);
 __attribute__((__overloadable__)) float4 _cl_clamp(float4 x0, float x1, float x2);
 __attribute__((__overloadable__)) float8 _cl_clamp(float8 x0, float x1, float x2);
 __attribute__((__overloadable__)) float16 _cl_clamp(float16 x0, float x1, float x2);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double2 _cl_clamp(double2 x0, double x1, double x2);
 __attribute__((__overloadable__)) double3 _cl_clamp(double3 x0, double x1, double x2);
 __attribute__((__overloadable__)) double4 _cl_clamp(double4 x0, double x1, double x2);
 __attribute__((__overloadable__)) double8 _cl_clamp(double8 x0, double x1, double x2);
 __attribute__((__overloadable__)) double16 _cl_clamp(double16 x0, double x1, double x2);
+#endif // #ifdef cl_khr_fp64
 
 // degrees: ['VF'] -> VF
 #undef degrees
 #define degrees _cl_degrees
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_degrees(half x0);
 __attribute__((__overloadable__)) half2 _cl_degrees(half2 x0);
 __attribute__((__overloadable__)) half3 _cl_degrees(half3 x0);
 __attribute__((__overloadable__)) half4 _cl_degrees(half4 x0);
 __attribute__((__overloadable__)) half8 _cl_degrees(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_degrees(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_degrees(float x0);
 __attribute__((__overloadable__)) float2 _cl_degrees(float2 x0);
 __attribute__((__overloadable__)) float3 _cl_degrees(float3 x0);
 __attribute__((__overloadable__)) float4 _cl_degrees(float4 x0);
 __attribute__((__overloadable__)) float8 _cl_degrees(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_degrees(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_degrees(double x0);
 __attribute__((__overloadable__)) double2 _cl_degrees(double2 x0);
 __attribute__((__overloadable__)) double3 _cl_degrees(double3 x0);
 __attribute__((__overloadable__)) double4 _cl_degrees(double4 x0);
 __attribute__((__overloadable__)) double8 _cl_degrees(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_degrees(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // max: ['VF', 'VF'] -> VF
 #undef max
 #define max _cl_max
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_max(half x0, half x1);
 __attribute__((__overloadable__)) half2 _cl_max(half2 x0, half2 x1);
 __attribute__((__overloadable__)) half3 _cl_max(half3 x0, half3 x1);
 __attribute__((__overloadable__)) half4 _cl_max(half4 x0, half4 x1);
 __attribute__((__overloadable__)) half8 _cl_max(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half16 _cl_max(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_max(float x0, float x1);
 __attribute__((__overloadable__)) float2 _cl_max(float2 x0, float2 x1);
 __attribute__((__overloadable__)) float3 _cl_max(float3 x0, float3 x1);
 __attribute__((__overloadable__)) float4 _cl_max(float4 x0, float4 x1);
 __attribute__((__overloadable__)) float8 _cl_max(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float16 _cl_max(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_max(double x0, double x1);
 __attribute__((__overloadable__)) double2 _cl_max(double2 x0, double2 x1);
 __attribute__((__overloadable__)) double3 _cl_max(double3 x0, double3 x1);
 __attribute__((__overloadable__)) double4 _cl_max(double4 x0, double4 x1);
 __attribute__((__overloadable__)) double8 _cl_max(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double16 _cl_max(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // max: ['VF', 'SF'] -> VF
 #undef max
 #define max _cl_max
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half2 _cl_max(half2 x0, half x1);
 __attribute__((__overloadable__)) half3 _cl_max(half3 x0, half x1);
 __attribute__((__overloadable__)) half4 _cl_max(half4 x0, half x1);
 __attribute__((__overloadable__)) half8 _cl_max(half8 x0, half x1);
 __attribute__((__overloadable__)) half16 _cl_max(half16 x0, half x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float2 _cl_max(float2 x0, float x1);
 __attribute__((__overloadable__)) float3 _cl_max(float3 x0, float x1);
 __attribute__((__overloadable__)) float4 _cl_max(float4 x0, float x1);
 __attribute__((__overloadable__)) float8 _cl_max(float8 x0, float x1);
 __attribute__((__overloadable__)) float16 _cl_max(float16 x0, float x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double2 _cl_max(double2 x0, double x1);
 __attribute__((__overloadable__)) double3 _cl_max(double3 x0, double x1);
 __attribute__((__overloadable__)) double4 _cl_max(double4 x0, double x1);
 __attribute__((__overloadable__)) double8 _cl_max(double8 x0, double x1);
 __attribute__((__overloadable__)) double16 _cl_max(double16 x0, double x1);
+#endif // #ifdef cl_khr_fp64
 
 // min: ['VF', 'VF'] -> VF
 #undef min
 #define min _cl_min
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_min(half x0, half x1);
 __attribute__((__overloadable__)) half2 _cl_min(half2 x0, half2 x1);
 __attribute__((__overloadable__)) half3 _cl_min(half3 x0, half3 x1);
 __attribute__((__overloadable__)) half4 _cl_min(half4 x0, half4 x1);
 __attribute__((__overloadable__)) half8 _cl_min(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half16 _cl_min(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_min(float x0, float x1);
 __attribute__((__overloadable__)) float2 _cl_min(float2 x0, float2 x1);
 __attribute__((__overloadable__)) float3 _cl_min(float3 x0, float3 x1);
 __attribute__((__overloadable__)) float4 _cl_min(float4 x0, float4 x1);
 __attribute__((__overloadable__)) float8 _cl_min(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float16 _cl_min(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_min(double x0, double x1);
 __attribute__((__overloadable__)) double2 _cl_min(double2 x0, double2 x1);
 __attribute__((__overloadable__)) double3 _cl_min(double3 x0, double3 x1);
 __attribute__((__overloadable__)) double4 _cl_min(double4 x0, double4 x1);
 __attribute__((__overloadable__)) double8 _cl_min(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double16 _cl_min(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // min: ['VF', 'SF'] -> VF
 #undef min
 #define min _cl_min
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half2 _cl_min(half2 x0, half x1);
 __attribute__((__overloadable__)) half3 _cl_min(half3 x0, half x1);
 __attribute__((__overloadable__)) half4 _cl_min(half4 x0, half x1);
 __attribute__((__overloadable__)) half8 _cl_min(half8 x0, half x1);
 __attribute__((__overloadable__)) half16 _cl_min(half16 x0, half x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float2 _cl_min(float2 x0, float x1);
 __attribute__((__overloadable__)) float3 _cl_min(float3 x0, float x1);
 __attribute__((__overloadable__)) float4 _cl_min(float4 x0, float x1);
 __attribute__((__overloadable__)) float8 _cl_min(float8 x0, float x1);
 __attribute__((__overloadable__)) float16 _cl_min(float16 x0, float x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double2 _cl_min(double2 x0, double x1);
 __attribute__((__overloadable__)) double3 _cl_min(double3 x0, double x1);
 __attribute__((__overloadable__)) double4 _cl_min(double4 x0, double x1);
 __attribute__((__overloadable__)) double8 _cl_min(double8 x0, double x1);
 __attribute__((__overloadable__)) double16 _cl_min(double16 x0, double x1);
+#endif // #ifdef cl_khr_fp64
 
 // mix: ['VF', 'VF', 'VF'] -> VF
 #undef mix
 #define mix _cl_mix
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_mix(half x0, half x1, half x2);
 __attribute__((__overloadable__)) half2 _cl_mix(half2 x0, half2 x1, half2 x2);
 __attribute__((__overloadable__)) half3 _cl_mix(half3 x0, half3 x1, half3 x2);
 __attribute__((__overloadable__)) half4 _cl_mix(half4 x0, half4 x1, half4 x2);
 __attribute__((__overloadable__)) half8 _cl_mix(half8 x0, half8 x1, half8 x2);
 __attribute__((__overloadable__)) half16 _cl_mix(half16 x0, half16 x1, half16 x2);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_mix(float x0, float x1, float x2);
 __attribute__((__overloadable__)) float2 _cl_mix(float2 x0, float2 x1, float2 x2);
 __attribute__((__overloadable__)) float3 _cl_mix(float3 x0, float3 x1, float3 x2);
 __attribute__((__overloadable__)) float4 _cl_mix(float4 x0, float4 x1, float4 x2);
 __attribute__((__overloadable__)) float8 _cl_mix(float8 x0, float8 x1, float8 x2);
 __attribute__((__overloadable__)) float16 _cl_mix(float16 x0, float16 x1, float16 x2);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_mix(double x0, double x1, double x2);
 __attribute__((__overloadable__)) double2 _cl_mix(double2 x0, double2 x1, double2 x2);
 __attribute__((__overloadable__)) double3 _cl_mix(double3 x0, double3 x1, double3 x2);
 __attribute__((__overloadable__)) double4 _cl_mix(double4 x0, double4 x1, double4 x2);
 __attribute__((__overloadable__)) double8 _cl_mix(double8 x0, double8 x1, double8 x2);
 __attribute__((__overloadable__)) double16 _cl_mix(double16 x0, double16 x1, double16 x2);
+#endif // #ifdef cl_khr_fp64
 
 // mix: ['VF', 'VF', 'SF'] -> VF
 #undef mix
 #define mix _cl_mix
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half2 _cl_mix(half2 x0, half2 x1, half x2);
 __attribute__((__overloadable__)) half3 _cl_mix(half3 x0, half3 x1, half x2);
 __attribute__((__overloadable__)) half4 _cl_mix(half4 x0, half4 x1, half x2);
 __attribute__((__overloadable__)) half8 _cl_mix(half8 x0, half8 x1, half x2);
 __attribute__((__overloadable__)) half16 _cl_mix(half16 x0, half16 x1, half x2);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float2 _cl_mix(float2 x0, float2 x1, float x2);
 __attribute__((__overloadable__)) float3 _cl_mix(float3 x0, float3 x1, float x2);
 __attribute__((__overloadable__)) float4 _cl_mix(float4 x0, float4 x1, float x2);
 __attribute__((__overloadable__)) float8 _cl_mix(float8 x0, float8 x1, float x2);
 __attribute__((__overloadable__)) float16 _cl_mix(float16 x0, float16 x1, float x2);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double2 _cl_mix(double2 x0, double2 x1, double x2);
 __attribute__((__overloadable__)) double3 _cl_mix(double3 x0, double3 x1, double x2);
 __attribute__((__overloadable__)) double4 _cl_mix(double4 x0, double4 x1, double x2);
 __attribute__((__overloadable__)) double8 _cl_mix(double8 x0, double8 x1, double x2);
 __attribute__((__overloadable__)) double16 _cl_mix(double16 x0, double16 x1, double x2);
+#endif // #ifdef cl_khr_fp64
 
 // radians: ['VF'] -> VF
 #undef radians
 #define radians _cl_radians
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_radians(half x0);
 __attribute__((__overloadable__)) half2 _cl_radians(half2 x0);
 __attribute__((__overloadable__)) half3 _cl_radians(half3 x0);
 __attribute__((__overloadable__)) half4 _cl_radians(half4 x0);
 __attribute__((__overloadable__)) half8 _cl_radians(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_radians(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_radians(float x0);
 __attribute__((__overloadable__)) float2 _cl_radians(float2 x0);
 __attribute__((__overloadable__)) float3 _cl_radians(float3 x0);
 __attribute__((__overloadable__)) float4 _cl_radians(float4 x0);
 __attribute__((__overloadable__)) float8 _cl_radians(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_radians(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_radians(double x0);
 __attribute__((__overloadable__)) double2 _cl_radians(double2 x0);
 __attribute__((__overloadable__)) double3 _cl_radians(double3 x0);
 __attribute__((__overloadable__)) double4 _cl_radians(double4 x0);
 __attribute__((__overloadable__)) double8 _cl_radians(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_radians(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // step: ['VF', 'VF'] -> VF
 #undef step
 #define step _cl_step
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_step(half x0, half x1);
 __attribute__((__overloadable__)) half2 _cl_step(half2 x0, half2 x1);
 __attribute__((__overloadable__)) half3 _cl_step(half3 x0, half3 x1);
 __attribute__((__overloadable__)) half4 _cl_step(half4 x0, half4 x1);
 __attribute__((__overloadable__)) half8 _cl_step(half8 x0, half8 x1);
 __attribute__((__overloadable__)) half16 _cl_step(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_step(float x0, float x1);
 __attribute__((__overloadable__)) float2 _cl_step(float2 x0, float2 x1);
 __attribute__((__overloadable__)) float3 _cl_step(float3 x0, float3 x1);
 __attribute__((__overloadable__)) float4 _cl_step(float4 x0, float4 x1);
 __attribute__((__overloadable__)) float8 _cl_step(float8 x0, float8 x1);
 __attribute__((__overloadable__)) float16 _cl_step(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_step(double x0, double x1);
 __attribute__((__overloadable__)) double2 _cl_step(double2 x0, double2 x1);
 __attribute__((__overloadable__)) double3 _cl_step(double3 x0, double3 x1);
 __attribute__((__overloadable__)) double4 _cl_step(double4 x0, double4 x1);
 __attribute__((__overloadable__)) double8 _cl_step(double8 x0, double8 x1);
 __attribute__((__overloadable__)) double16 _cl_step(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // step: ['SF', 'VF'] -> VF
 #undef step
 #define step _cl_step
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half2 _cl_step(half x0, half2 x1);
 __attribute__((__overloadable__)) half3 _cl_step(half x0, half3 x1);
 __attribute__((__overloadable__)) half4 _cl_step(half x0, half4 x1);
 __attribute__((__overloadable__)) half8 _cl_step(half x0, half8 x1);
 __attribute__((__overloadable__)) half16 _cl_step(half x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float2 _cl_step(float x0, float2 x1);
 __attribute__((__overloadable__)) float3 _cl_step(float x0, float3 x1);
 __attribute__((__overloadable__)) float4 _cl_step(float x0, float4 x1);
 __attribute__((__overloadable__)) float8 _cl_step(float x0, float8 x1);
 __attribute__((__overloadable__)) float16 _cl_step(float x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double2 _cl_step(double x0, double2 x1);
 __attribute__((__overloadable__)) double3 _cl_step(double x0, double3 x1);
 __attribute__((__overloadable__)) double4 _cl_step(double x0, double4 x1);
 __attribute__((__overloadable__)) double8 _cl_step(double x0, double8 x1);
 __attribute__((__overloadable__)) double16 _cl_step(double x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // smoothstep: ['VF', 'VF', 'VF'] -> VF
 #undef smoothstep
 #define smoothstep _cl_smoothstep
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_smoothstep(half x0, half x1, half x2);
 __attribute__((__overloadable__)) half2 _cl_smoothstep(half2 x0, half2 x1, half2 x2);
 __attribute__((__overloadable__)) half3 _cl_smoothstep(half3 x0, half3 x1, half3 x2);
 __attribute__((__overloadable__)) half4 _cl_smoothstep(half4 x0, half4 x1, half4 x2);
 __attribute__((__overloadable__)) half8 _cl_smoothstep(half8 x0, half8 x1, half8 x2);
 __attribute__((__overloadable__)) half16 _cl_smoothstep(half16 x0, half16 x1, half16 x2);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_smoothstep(float x0, float x1, float x2);
 __attribute__((__overloadable__)) float2 _cl_smoothstep(float2 x0, float2 x1, float2 x2);
 __attribute__((__overloadable__)) float3 _cl_smoothstep(float3 x0, float3 x1, float3 x2);
 __attribute__((__overloadable__)) float4 _cl_smoothstep(float4 x0, float4 x1, float4 x2);
 __attribute__((__overloadable__)) float8 _cl_smoothstep(float8 x0, float8 x1, float8 x2);
 __attribute__((__overloadable__)) float16 _cl_smoothstep(float16 x0, float16 x1, float16 x2);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_smoothstep(double x0, double x1, double x2);
 __attribute__((__overloadable__)) double2 _cl_smoothstep(double2 x0, double2 x1, double2 x2);
 __attribute__((__overloadable__)) double3 _cl_smoothstep(double3 x0, double3 x1, double3 x2);
 __attribute__((__overloadable__)) double4 _cl_smoothstep(double4 x0, double4 x1, double4 x2);
 __attribute__((__overloadable__)) double8 _cl_smoothstep(double8 x0, double8 x1, double8 x2);
 __attribute__((__overloadable__)) double16 _cl_smoothstep(double16 x0, double16 x1, double16 x2);
+#endif // #ifdef cl_khr_fp64
 
 // smoothstep: ['SF', 'SF', 'VF'] -> VF
 #undef smoothstep
 #define smoothstep _cl_smoothstep
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half2 _cl_smoothstep(half x0, half x1, half2 x2);
 __attribute__((__overloadable__)) half3 _cl_smoothstep(half x0, half x1, half3 x2);
 __attribute__((__overloadable__)) half4 _cl_smoothstep(half x0, half x1, half4 x2);
 __attribute__((__overloadable__)) half8 _cl_smoothstep(half x0, half x1, half8 x2);
 __attribute__((__overloadable__)) half16 _cl_smoothstep(half x0, half x1, half16 x2);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float2 _cl_smoothstep(float x0, float x1, float2 x2);
 __attribute__((__overloadable__)) float3 _cl_smoothstep(float x0, float x1, float3 x2);
 __attribute__((__overloadable__)) float4 _cl_smoothstep(float x0, float x1, float4 x2);
 __attribute__((__overloadable__)) float8 _cl_smoothstep(float x0, float x1, float8 x2);
 __attribute__((__overloadable__)) float16 _cl_smoothstep(float x0, float x1, float16 x2);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double2 _cl_smoothstep(double x0, double x1, double2 x2);
 __attribute__((__overloadable__)) double3 _cl_smoothstep(double x0, double x1, double3 x2);
 __attribute__((__overloadable__)) double4 _cl_smoothstep(double x0, double x1, double4 x2);
 __attribute__((__overloadable__)) double8 _cl_smoothstep(double x0, double x1, double8 x2);
 __attribute__((__overloadable__)) double16 _cl_smoothstep(double x0, double x1, double16 x2);
+#endif // #ifdef cl_khr_fp64
 
 // sign: ['VF'] -> VF
 #undef sign
 #define sign _cl_sign
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) half _cl_sign(half x0);
 __attribute__((__overloadable__)) half2 _cl_sign(half2 x0);
 __attribute__((__overloadable__)) half3 _cl_sign(half3 x0);
 __attribute__((__overloadable__)) half4 _cl_sign(half4 x0);
 __attribute__((__overloadable__)) half8 _cl_sign(half8 x0);
 __attribute__((__overloadable__)) half16 _cl_sign(half16 x0);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) float _cl_sign(float x0);
 __attribute__((__overloadable__)) float2 _cl_sign(float2 x0);
 __attribute__((__overloadable__)) float3 _cl_sign(float3 x0);
 __attribute__((__overloadable__)) float4 _cl_sign(float4 x0);
 __attribute__((__overloadable__)) float8 _cl_sign(float8 x0);
 __attribute__((__overloadable__)) float16 _cl_sign(float16 x0);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) double _cl_sign(double x0);
 __attribute__((__overloadable__)) double2 _cl_sign(double2 x0);
 __attribute__((__overloadable__)) double3 _cl_sign(double3 x0);
 __attribute__((__overloadable__)) double4 _cl_sign(double4 x0);
 __attribute__((__overloadable__)) double8 _cl_sign(double8 x0);
 __attribute__((__overloadable__)) double16 _cl_sign(double16 x0);
+#endif // #ifdef cl_khr_fp64
 
 // isequal: ['VF', 'VF'] -> VJ
 #undef isequal
 #define isequal _cl_isequal
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_isequal(half x0, half x1);
 __attribute__((__overloadable__)) short2 _cl_isequal(half2 x0, half2 x1);
 __attribute__((__overloadable__)) short3 _cl_isequal(half3 x0, half3 x1);
 __attribute__((__overloadable__)) short4 _cl_isequal(half4 x0, half4 x1);
 __attribute__((__overloadable__)) short8 _cl_isequal(half8 x0, half8 x1);
 __attribute__((__overloadable__)) short16 _cl_isequal(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_isequal(float x0, float x1);
 __attribute__((__overloadable__)) int2 _cl_isequal(float2 x0, float2 x1);
 __attribute__((__overloadable__)) int3 _cl_isequal(float3 x0, float3 x1);
 __attribute__((__overloadable__)) int4 _cl_isequal(float4 x0, float4 x1);
 __attribute__((__overloadable__)) int8 _cl_isequal(float8 x0, float8 x1);
 __attribute__((__overloadable__)) int16 _cl_isequal(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) int _cl_isequal(double x0, double x1);
 __attribute__((__overloadable__)) long2 _cl_isequal(double2 x0, double2 x1);
 __attribute__((__overloadable__)) long3 _cl_isequal(double3 x0, double3 x1);
 __attribute__((__overloadable__)) long4 _cl_isequal(double4 x0, double4 x1);
 __attribute__((__overloadable__)) long8 _cl_isequal(double8 x0, double8 x1);
 __attribute__((__overloadable__)) long16 _cl_isequal(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // isnotequal: ['VF', 'VF'] -> VJ
 #undef isnotequal
 #define isnotequal _cl_isnotequal
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_isnotequal(half x0, half x1);
 __attribute__((__overloadable__)) short2 _cl_isnotequal(half2 x0, half2 x1);
 __attribute__((__overloadable__)) short3 _cl_isnotequal(half3 x0, half3 x1);
 __attribute__((__overloadable__)) short4 _cl_isnotequal(half4 x0, half4 x1);
 __attribute__((__overloadable__)) short8 _cl_isnotequal(half8 x0, half8 x1);
 __attribute__((__overloadable__)) short16 _cl_isnotequal(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_isnotequal(float x0, float x1);
 __attribute__((__overloadable__)) int2 _cl_isnotequal(float2 x0, float2 x1);
 __attribute__((__overloadable__)) int3 _cl_isnotequal(float3 x0, float3 x1);
 __attribute__((__overloadable__)) int4 _cl_isnotequal(float4 x0, float4 x1);
 __attribute__((__overloadable__)) int8 _cl_isnotequal(float8 x0, float8 x1);
 __attribute__((__overloadable__)) int16 _cl_isnotequal(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) int _cl_isnotequal(double x0, double x1);
 __attribute__((__overloadable__)) long2 _cl_isnotequal(double2 x0, double2 x1);
 __attribute__((__overloadable__)) long3 _cl_isnotequal(double3 x0, double3 x1);
 __attribute__((__overloadable__)) long4 _cl_isnotequal(double4 x0, double4 x1);
 __attribute__((__overloadable__)) long8 _cl_isnotequal(double8 x0, double8 x1);
 __attribute__((__overloadable__)) long16 _cl_isnotequal(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // isgreater: ['VF', 'VF'] -> VJ
 #undef isgreater
 #define isgreater _cl_isgreater
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_isgreater(half x0, half x1);
 __attribute__((__overloadable__)) short2 _cl_isgreater(half2 x0, half2 x1);
 __attribute__((__overloadable__)) short3 _cl_isgreater(half3 x0, half3 x1);
 __attribute__((__overloadable__)) short4 _cl_isgreater(half4 x0, half4 x1);
 __attribute__((__overloadable__)) short8 _cl_isgreater(half8 x0, half8 x1);
 __attribute__((__overloadable__)) short16 _cl_isgreater(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_isgreater(float x0, float x1);
 __attribute__((__overloadable__)) int2 _cl_isgreater(float2 x0, float2 x1);
 __attribute__((__overloadable__)) int3 _cl_isgreater(float3 x0, float3 x1);
 __attribute__((__overloadable__)) int4 _cl_isgreater(float4 x0, float4 x1);
 __attribute__((__overloadable__)) int8 _cl_isgreater(float8 x0, float8 x1);
 __attribute__((__overloadable__)) int16 _cl_isgreater(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) int _cl_isgreater(double x0, double x1);
 __attribute__((__overloadable__)) long2 _cl_isgreater(double2 x0, double2 x1);
 __attribute__((__overloadable__)) long3 _cl_isgreater(double3 x0, double3 x1);
 __attribute__((__overloadable__)) long4 _cl_isgreater(double4 x0, double4 x1);
 __attribute__((__overloadable__)) long8 _cl_isgreater(double8 x0, double8 x1);
 __attribute__((__overloadable__)) long16 _cl_isgreater(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // isgreaterequal: ['VF', 'VF'] -> VJ
 #undef isgreaterequal
 #define isgreaterequal _cl_isgreaterequal
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_isgreaterequal(half x0, half x1);
 __attribute__((__overloadable__)) short2 _cl_isgreaterequal(half2 x0, half2 x1);
 __attribute__((__overloadable__)) short3 _cl_isgreaterequal(half3 x0, half3 x1);
 __attribute__((__overloadable__)) short4 _cl_isgreaterequal(half4 x0, half4 x1);
 __attribute__((__overloadable__)) short8 _cl_isgreaterequal(half8 x0, half8 x1);
 __attribute__((__overloadable__)) short16 _cl_isgreaterequal(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_isgreaterequal(float x0, float x1);
 __attribute__((__overloadable__)) int2 _cl_isgreaterequal(float2 x0, float2 x1);
 __attribute__((__overloadable__)) int3 _cl_isgreaterequal(float3 x0, float3 x1);
 __attribute__((__overloadable__)) int4 _cl_isgreaterequal(float4 x0, float4 x1);
 __attribute__((__overloadable__)) int8 _cl_isgreaterequal(float8 x0, float8 x1);
 __attribute__((__overloadable__)) int16 _cl_isgreaterequal(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) int _cl_isgreaterequal(double x0, double x1);
 __attribute__((__overloadable__)) long2 _cl_isgreaterequal(double2 x0, double2 x1);
 __attribute__((__overloadable__)) long3 _cl_isgreaterequal(double3 x0, double3 x1);
 __attribute__((__overloadable__)) long4 _cl_isgreaterequal(double4 x0, double4 x1);
 __attribute__((__overloadable__)) long8 _cl_isgreaterequal(double8 x0, double8 x1);
 __attribute__((__overloadable__)) long16 _cl_isgreaterequal(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // isless: ['VF', 'VF'] -> VJ
 #undef isless
 #define isless _cl_isless
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_isless(half x0, half x1);
 __attribute__((__overloadable__)) short2 _cl_isless(half2 x0, half2 x1);
 __attribute__((__overloadable__)) short3 _cl_isless(half3 x0, half3 x1);
 __attribute__((__overloadable__)) short4 _cl_isless(half4 x0, half4 x1);
 __attribute__((__overloadable__)) short8 _cl_isless(half8 x0, half8 x1);
 __attribute__((__overloadable__)) short16 _cl_isless(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_isless(float x0, float x1);
 __attribute__((__overloadable__)) int2 _cl_isless(float2 x0, float2 x1);
 __attribute__((__overloadable__)) int3 _cl_isless(float3 x0, float3 x1);
 __attribute__((__overloadable__)) int4 _cl_isless(float4 x0, float4 x1);
 __attribute__((__overloadable__)) int8 _cl_isless(float8 x0, float8 x1);
 __attribute__((__overloadable__)) int16 _cl_isless(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) int _cl_isless(double x0, double x1);
 __attribute__((__overloadable__)) long2 _cl_isless(double2 x0, double2 x1);
 __attribute__((__overloadable__)) long3 _cl_isless(double3 x0, double3 x1);
 __attribute__((__overloadable__)) long4 _cl_isless(double4 x0, double4 x1);
 __attribute__((__overloadable__)) long8 _cl_isless(double8 x0, double8 x1);
 __attribute__((__overloadable__)) long16 _cl_isless(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // islessequal: ['VF', 'VF'] -> VJ
 #undef islessequal
 #define islessequal _cl_islessequal
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_islessequal(half x0, half x1);
 __attribute__((__overloadable__)) short2 _cl_islessequal(half2 x0, half2 x1);
 __attribute__((__overloadable__)) short3 _cl_islessequal(half3 x0, half3 x1);
 __attribute__((__overloadable__)) short4 _cl_islessequal(half4 x0, half4 x1);
 __attribute__((__overloadable__)) short8 _cl_islessequal(half8 x0, half8 x1);
 __attribute__((__overloadable__)) short16 _cl_islessequal(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_islessequal(float x0, float x1);
 __attribute__((__overloadable__)) int2 _cl_islessequal(float2 x0, float2 x1);
 __attribute__((__overloadable__)) int3 _cl_islessequal(float3 x0, float3 x1);
 __attribute__((__overloadable__)) int4 _cl_islessequal(float4 x0, float4 x1);
 __attribute__((__overloadable__)) int8 _cl_islessequal(float8 x0, float8 x1);
 __attribute__((__overloadable__)) int16 _cl_islessequal(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) int _cl_islessequal(double x0, double x1);
 __attribute__((__overloadable__)) long2 _cl_islessequal(double2 x0, double2 x1);
 __attribute__((__overloadable__)) long3 _cl_islessequal(double3 x0, double3 x1);
 __attribute__((__overloadable__)) long4 _cl_islessequal(double4 x0, double4 x1);
 __attribute__((__overloadable__)) long8 _cl_islessequal(double8 x0, double8 x1);
 __attribute__((__overloadable__)) long16 _cl_islessequal(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // islessgreater: ['VF', 'VF'] -> VJ
 #undef islessgreater
 #define islessgreater _cl_islessgreater
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_islessgreater(half x0, half x1);
 __attribute__((__overloadable__)) short2 _cl_islessgreater(half2 x0, half2 x1);
 __attribute__((__overloadable__)) short3 _cl_islessgreater(half3 x0, half3 x1);
 __attribute__((__overloadable__)) short4 _cl_islessgreater(half4 x0, half4 x1);
 __attribute__((__overloadable__)) short8 _cl_islessgreater(half8 x0, half8 x1);
 __attribute__((__overloadable__)) short16 _cl_islessgreater(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_islessgreater(float x0, float x1);
 __attribute__((__overloadable__)) int2 _cl_islessgreater(float2 x0, float2 x1);
 __attribute__((__overloadable__)) int3 _cl_islessgreater(float3 x0, float3 x1);
 __attribute__((__overloadable__)) int4 _cl_islessgreater(float4 x0, float4 x1);
 __attribute__((__overloadable__)) int8 _cl_islessgreater(float8 x0, float8 x1);
 __attribute__((__overloadable__)) int16 _cl_islessgreater(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) int _cl_islessgreater(double x0, double x1);
 __attribute__((__overloadable__)) long2 _cl_islessgreater(double2 x0, double2 x1);
 __attribute__((__overloadable__)) long3 _cl_islessgreater(double3 x0, double3 x1);
 __attribute__((__overloadable__)) long4 _cl_islessgreater(double4 x0, double4 x1);
 __attribute__((__overloadable__)) long8 _cl_islessgreater(double8 x0, double8 x1);
 __attribute__((__overloadable__)) long16 _cl_islessgreater(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // isordered: ['VF', 'VF'] -> VJ
 #undef isordered
 #define isordered _cl_isordered
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_isordered(half x0, half x1);
 __attribute__((__overloadable__)) short2 _cl_isordered(half2 x0, half2 x1);
 __attribute__((__overloadable__)) short3 _cl_isordered(half3 x0, half3 x1);
 __attribute__((__overloadable__)) short4 _cl_isordered(half4 x0, half4 x1);
 __attribute__((__overloadable__)) short8 _cl_isordered(half8 x0, half8 x1);
 __attribute__((__overloadable__)) short16 _cl_isordered(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_isordered(float x0, float x1);
 __attribute__((__overloadable__)) int2 _cl_isordered(float2 x0, float2 x1);
 __attribute__((__overloadable__)) int3 _cl_isordered(float3 x0, float3 x1);
 __attribute__((__overloadable__)) int4 _cl_isordered(float4 x0, float4 x1);
 __attribute__((__overloadable__)) int8 _cl_isordered(float8 x0, float8 x1);
 __attribute__((__overloadable__)) int16 _cl_isordered(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) int _cl_isordered(double x0, double x1);
 __attribute__((__overloadable__)) long2 _cl_isordered(double2 x0, double2 x1);
 __attribute__((__overloadable__)) long3 _cl_isordered(double3 x0, double3 x1);
 __attribute__((__overloadable__)) long4 _cl_isordered(double4 x0, double4 x1);
 __attribute__((__overloadable__)) long8 _cl_isordered(double8 x0, double8 x1);
 __attribute__((__overloadable__)) long16 _cl_isordered(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 // isunordered: ['VF', 'VF'] -> VJ
 #undef isunordered
 #define isunordered _cl_isunordered
+#ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_isunordered(half x0, half x1);
 __attribute__((__overloadable__)) short2 _cl_isunordered(half2 x0, half2 x1);
 __attribute__((__overloadable__)) short3 _cl_isunordered(half3 x0, half3 x1);
 __attribute__((__overloadable__)) short4 _cl_isunordered(half4 x0, half4 x1);
 __attribute__((__overloadable__)) short8 _cl_isunordered(half8 x0, half8 x1);
 __attribute__((__overloadable__)) short16 _cl_isunordered(half16 x0, half16 x1);
+#endif // #ifdef cl_khr_fp16
 __attribute__((__overloadable__)) int _cl_isunordered(float x0, float x1);
 __attribute__((__overloadable__)) int2 _cl_isunordered(float2 x0, float2 x1);
 __attribute__((__overloadable__)) int3 _cl_isunordered(float3 x0, float3 x1);
 __attribute__((__overloadable__)) int4 _cl_isunordered(float4 x0, float4 x1);
 __attribute__((__overloadable__)) int8 _cl_isunordered(float8 x0, float8 x1);
 __attribute__((__overloadable__)) int16 _cl_isunordered(float16 x0, float16 x1);
+#ifdef cl_khr_fp64
 __attribute__((__overloadable__)) int _cl_isunordered(double x0, double x1);
 __attribute__((__overloadable__)) long2 _cl_isunordered(double2 x0, double2 x1);
 __attribute__((__overloadable__)) long3 _cl_isunordered(double3 x0, double3 x1);
 __attribute__((__overloadable__)) long4 _cl_isunordered(double4 x0, double4 x1);
 __attribute__((__overloadable__)) long8 _cl_isunordered(double8 x0, double8 x1);
 __attribute__((__overloadable__)) long16 _cl_isunordered(double16 x0, double16 x1);
+#endif // #ifdef cl_khr_fp64
 
 #endif // #ifndef KERNEL_VECMATHLIB_H
diff --git a/lib/kernel/vecmathlib-pocl/length.cl b/lib/kernel/vecmathlib-pocl/length.cl
index 87e728d..ecbb749 100644
--- a/lib/kernel/vecmathlib-pocl/length.cl
+++ b/lib/kernel/vecmathlib-pocl/length.cl
@@ -2,74 +2,119 @@
 __attribute__((__overloadable__))
 half length(half p)
 {
-  return sqrt(dot(p, p));
+  return fabs(p);
 }
 
 __attribute__((__overloadable__))
 half length(half2 p)
 {
-  return sqrt(dot(p, p));
+  p = fabs(p);
+  half maxp = max(p.s0, p.s1);
+  if (maxp == (half)0.0f) return (half)0.0f;
+  if (isinf(maxp)) return maxp;
+  p /= maxp;
+  return sqrt(dot(p, p)) * maxp;
 }
 
 __attribute__((__overloadable__))
 half length(half3 p)
 {
-  return sqrt(dot(p, p));
+  p = fabs(p);
+  half maxp = max(max(p.s0, p.s1), p.s2);
+  if (maxp == (half)0.0f) return (half)0.0f;
+  if (isinf(maxp)) return maxp;
+  p /= maxp;
+  return sqrt(dot(p, p)) * maxp;
 }
 
 __attribute__((__overloadable__))
 half length(half4 p)
 {
-  return sqrt(dot(p, p));
+  p = fabs(p);
+  half maxp = max(max(p.s0, p.s1), max(p.s2, p.s3));
+  if (maxp == (half)0.0f) return (half)0.0f;
+  if (isinf(maxp)) return maxp;
+  p /= maxp;
+  return sqrt(dot(p, p)) * maxp;
 }
 #endif
 
 __attribute__((__overloadable__))
 float length(float p)
 {
-  return sqrt(dot(p, p));
+  return fabs(p);
 }
 
 __attribute__((__overloadable__))
 float length(float2 p)
 {
-  return sqrt(dot(p, p));
+  p = fabs(p);
+  float maxp = max(p.s0, p.s1);
+  if (maxp == 0.0f) return 0.0f;
+  if (isinf(maxp)) return maxp;
+  p /= maxp;
+  return sqrt(dot(p, p)) * maxp;
 }
 
 __attribute__((__overloadable__))
 float length(float3 p)
 {
-  return sqrt(dot(p, p));
+  p = fabs(p);
+  float maxp = max(max(p.s0, p.s1), p.s2);
+  if (maxp == 0.0f) return 0.0f;
+  if (isinf(maxp)) return maxp;
+  p /= maxp;
+  return sqrt(dot(p, p)) * maxp;
 }
 
 __attribute__((__overloadable__))
 float length(float4 p)
 {
-  return sqrt(dot(p, p));
+  p = fabs(p);
+  float maxp = max(max(p.s0, p.s1), max(p.s2, p.s3));
+  if (maxp == 0.0f) return 0.0f;
+  if (isinf(maxp)) return maxp;
+  p /= maxp;
+  return sqrt(dot(p, p)) * maxp;
 }
 
 #ifdef cl_khr_fp64
 __attribute__((__overloadable__))
 double length(double p)
 {
-  return sqrt(dot(p, p));
+  return fabs(p);
 }
 
 __attribute__((__overloadable__))
 double length(double2 p)
 {
-  return sqrt(dot(p, p));
+  p = fabs(p);
+  double maxp = max(p.s0, p.s1);
+  if (maxp == 0.0) return 0.0;
+  if (isinf(maxp)) return maxp;
+  p /= maxp;
+  return sqrt(dot(p, p)) * maxp;
 }
 
 __attribute__((__overloadable__))
 double length(double3 p)
 {
-  return sqrt(dot(p, p));
+  p = fabs(p);
+  double maxp = max(max(p.s0, p.s1), p.s2);
+  if (maxp == 0.0) return 0.0;
+  if (isinf(maxp)) return maxp;
+  p /= maxp;
+  return sqrt(dot(p, p)) * maxp;
 }
 
 __attribute__((__overloadable__))
 double length(double4 p)
 {
-  return sqrt(dot(p, p));
+  p = fabs(p);
+  double maxp = max(max(p.s0, p.s1), max(p.s2, p.s3));
+  if (maxp == 0.0) return 0.0;
+  if (isinf(maxp)) return maxp;
+  p /= maxp;
+  return sqrt(dot(p, p)) * maxp;
 }
 #endif
diff --git a/lib/kernel/vecmathlib-pocl/normalize.cl b/lib/kernel/vecmathlib-pocl/normalize.cl
index 1176e56..d45dff1 100644
--- a/lib/kernel/vecmathlib-pocl/normalize.cl
+++ b/lib/kernel/vecmathlib-pocl/normalize.cl
@@ -2,24 +2,34 @@
 __attribute__((__overloadable__))
 half normalize(half p)
 {
-  return p * rsqrt(dot(p, p));
+  if (p == (half)0.0f) return p;
+  return copysign((half)1.0f, p);
 }
 
 __attribute__((__overloadable__))
 half2 normalize(half2 p)
 {
+  if (all(p == (half2)(half)0.0f)) return p;
+  half maxp = max(fabs(p.s0), fabs(p.s1));
+  p /= maxp;
   return p * rsqrt(dot(p, p));
 }
 
 __attribute__((__overloadable__))
 half3 normalize(half3 p)
 {
+  if (all(p == (half3)(half)0.0f)) return p;
+  half maxp = max(max(fabs(p.s0), fabs(p.s1)), fabs(p.s2));
+  p /= maxp;
   return p * rsqrt(dot(p, p));
 }
 
 __attribute__((__overloadable__))
 half4 normalize(half4 p)
 {
+  if (all(p == (half4)(half)0.0f)) return p;
+  half maxp = max(max(fabs(p.s0), fabs(p.s1)), max(fabs(p.s2), fabs(p.s3)));
+  p /= maxp;
   return p * rsqrt(dot(p, p));
 }
 #endif
@@ -27,24 +37,34 @@ half4 normalize(half4 p)
 __attribute__((__overloadable__))
 float normalize(float p)
 {
-  return p * rsqrt(dot(p, p));
+  if (p == 0.0f) return p;
+  return copysign(1.0f, p);
 }
 
 __attribute__((__overloadable__))
 float2 normalize(float2 p)
 {
+  if (all(p == (float2)0.0f)) return p;
+  float maxp = max(fabs(p.s0), fabs(p.s1));
+  p /= maxp;
   return p * rsqrt(dot(p, p));
 }
 
 __attribute__((__overloadable__))
 float3 normalize(float3 p)
 {
+  if (all(p == (float3)0.0f)) return p;
+  float maxp = max(max(fabs(p.s0), fabs(p.s1)), fabs(p.s2));
+  p /= maxp;
   return p * rsqrt(dot(p, p));
 }
 
 __attribute__((__overloadable__))
 float4 normalize(float4 p)
 {
+  if (all(p == (float4)0.0f)) return p;
+  float maxp = max(max(fabs(p.s0), fabs(p.s1)), max(fabs(p.s2), fabs(p.s3)));
+  p /= maxp;
   return p * rsqrt(dot(p, p));
 }
 
@@ -52,24 +72,34 @@ float4 normalize(float4 p)
 __attribute__((__overloadable__))
 double normalize(double p)
 {
-  return p * rsqrt(dot(p, p));
+  if (p == 0.0) return p;
+  return copysign(1.0, p);
 }
 
 __attribute__((__overloadable__))
 double2 normalize(double2 p)
 {
+  if (all(p == (double2)0.0)) return p;
+  double maxp = max(fabs(p.s0), fabs(p.s1));
+  p /= maxp;
   return p * rsqrt(dot(p, p));
 }
 
 __attribute__((__overloadable__))
 double3 normalize(double3 p)
 {
+  if (all(p == (double3)0.0)) return p;
+  double maxp = max(max(fabs(p.s0), fabs(p.s1)), fabs(p.s2));
+  p /= maxp;
   return p * rsqrt(dot(p, p));
 }
 
 __attribute__((__overloadable__))
 double4 normalize(double4 p)
 {
+  if (all(p == (double4)0.0)) return p;
+  double maxp = max(max(fabs(p.s0), fabs(p.s1)), max(fabs(p.s2), fabs(p.s3)));
+  p /= maxp;
   return p * rsqrt(dot(p, p));
 }
 #endif
diff --git a/lib/kernel/vecmathlib/vecmathlib.rst b/lib/kernel/vecmathlib/vecmathlib.rst
new file mode 100644
index 0000000..4f48f44
--- /dev/null
+++ b/lib/kernel/vecmathlib/vecmathlib.rst
@@ -0,0 +1,64 @@
+Vecmathlib
+==========
+
+:author: Erik Schnetter <eschnetter at perimeterinstitute.ca>
+
+Vecmathlib provides efficient, accurate, tunable, and most importantly
+vectorizable math functions such as sqrt, sin, or atan.
+
+The library is implemented in C++, and intended to be called on SIMD
+vectors, e.g. those provided by SSE, AVX, or available in Power7 and
+Blue Gene architectures. The same algorithms should also work
+efficiently on accelerators such as GPUs.
+
+
+
+Implementation
+--------------
+
+Vecmathlib consists of three parts:
+
+1. vecmathlib's math algorithms, i.e. the implementations of various
+   math functions (e.g. sqrt)
+2. SIMD vector classes, wrapping e.g. SSE or AVX vectors
+3. a test and benchmarking harness
+
+The algorithms themselves are written in a generic way. They assume an
+IEEE floating point layout (consisting of sign bit, exponent, and
+mantissa), but work for arbitrary precision and vector sizes. For
+example, there is a routine vml_sqrt() that calculates a square root
+via an iterative scheme based on Newton's root finding algorithm.
+Although not available yet, there can be different implementations
+with different performance characteristics for certain math functions.
+
+The SIMD vector classes wrap architecture-specific SIMD capabilities;
+for example, there is an implementation of a class realvec<double,4>
+based on Intel's AVX instruction set. These classes either provide
+math operations and math functions themselves, or implement them via
+calls to the generic algorithms. This way, vecmathlib can provide
+efficient implementations for all hardware architectures.
+
+It goes without saying that vecmathlib can also be used for scalar
+types, e.g. plain float or double, thus providing math functions for
+architectures where they are otherwise not available.
+
+
+
+Things To Do
+------------
+
+Vecmathlib is not finished. Contributions are welcome! There are
+several areas where it can be improved:
+
+1. make test harness more systematic, improve coverage
+2. research and implement improved algorithms for certain math
+   functions
+3. implement vector classes for additional hardware architectures
+4. make code more portable -- currently works with GCC 4.7, should
+   also support pother versions or compilers
+5. review C++ class hierarchy, improve design, reduce redundancy
+6. measure performance, compare to system library
+7. provide "vector" implementation of math functions by calculating
+   them element-wise via libc's scalar functions
+8. handle inf, nan, negative zero, rounding modes, and everything else
+   required for IEEE compliance (if -ffast-math is not used)
diff --git a/lib/llvmopencl/AutomaticLocals.cc b/lib/llvmopencl/AutomaticLocals.cc
index 7ada0d7..8342b2c 100644
--- a/lib/llvmopencl/AutomaticLocals.cc
+++ b/lib/llvmopencl/AutomaticLocals.cc
@@ -20,6 +20,9 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
+#include "CompilerWarnings.h"
+IGNORE_COMPILER_WARNING("-Wunused-parameter")
+
 #include "config.h"
 #include "pocl.h"
 #include "Workgroup.h"
@@ -55,6 +58,8 @@
 
 #include "LLVMUtils.h"
 
+POP_COMPILER_DIAGS
+
 using namespace std;
 using namespace llvm;
 using namespace pocl;
@@ -79,13 +84,12 @@ static RegisterPass<AutomaticLocals> X("automatic-locals",
 				      "Processes automatic locals");
 
 void
-AutomaticLocals::getAnalysisUsage(AnalysisUsage &AU) const
-{
-  #if (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
+AutomaticLocals::getAnalysisUsage(AnalysisUsage &AU) const {
+#if (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
   AU.addRequired<DataLayout>();
-  #else
+#elif (LLVM_OLDER_THAN_3_7)
   AU.addRequired<DataLayoutPass>();
-  #endif
+#endif
 }
 
 bool
diff --git a/lib/llvmopencl/Barrier.h b/lib/llvmopencl/Barrier.h
index 59d77a3..eb25ffc 100644
--- a/lib/llvmopencl/Barrier.h
+++ b/lib/llvmopencl/Barrier.h
@@ -29,6 +29,8 @@
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/Module.h"
+#include "llvm/IR/ValueSymbolTable.h"
+#include "llvm/IR/GlobalValue.h"
 #endif
 
 #include "llvm/Support/Casting.h"
@@ -65,6 +67,7 @@ namespace pocl {
         (M->getOrInsertFunction(BARRIER_FUNCTION_NAME,
                                 llvm::Type::getVoidTy(M->getContext()),
                                 NULL));
+      F->setLinkage(llvm::GlobalValue::LinkOnceAnyLinkage);
       return llvm::cast<pocl::Barrier>
         (llvm::CallInst::Create(F, "", InsertBefore));
     }
diff --git a/lib/llvmopencl/BarrierTailReplication.cc b/lib/llvmopencl/BarrierTailReplication.cc
index cfbc478..3a9b96b 100644
--- a/lib/llvmopencl/BarrierTailReplication.cc
+++ b/lib/llvmopencl/BarrierTailReplication.cc
@@ -21,6 +21,9 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
+#include "CompilerWarnings.h"
+IGNORE_COMPILER_WARNING("-Wunused-parameter")
+
 #include "config.h"
 #include "BarrierTailReplication.h"
 #include "Barrier.h"
@@ -40,6 +43,8 @@
 #include <iostream>
 #include <algorithm>
 
+POP_COMPILER_DIAGS
+
 using namespace llvm;
 using namespace pocl;
 
@@ -65,8 +70,13 @@ BarrierTailReplication::getAnalysisUsage(AnalysisUsage &AU) const
   AU.addRequired<DominatorTreeWrapperPass>();
   AU.addPreserved<DominatorTreeWrapperPass>();
 #endif
+#ifdef LLVM_OLDER_THAN_3_7
   AU.addRequired<LoopInfo>();
   AU.addPreserved<LoopInfo>();
+#else
+  AU.addRequired<LoopInfoWrapperPass>();
+  AU.addPreserved<LoopInfoWrapperPass>();
+#endif
 
   AU.addPreserved<VariableUniformityAnalysis>();
 }
@@ -87,7 +97,12 @@ BarrierTailReplication::runOnFunction(Function &F)
   DTP = &getAnalysis<DominatorTreeWrapperPass>();
   DT = &DTP->getDomTree();
 #endif
+
+#ifdef LLVM_OLDER_THAN_3_7
   LI = &getAnalysis<LoopInfo>();
+#else
+  LI = &getAnalysis<LoopInfoWrapperPass>();
+#endif
 
   bool changed = ProcessFunction(F);
 
@@ -96,8 +111,8 @@ BarrierTailReplication::runOnFunction(Function &F)
 #else
   DT->verifyDomTree();
 #endif
-  LI->verifyAnalysis();
 
+  LI->verifyAnalysis();
   /* The created tails might contain PHI nodes with operands 
      referring to the non-predecessor (split point) BB. 
      These must be cleaned to avoid breakage later on.
@@ -221,17 +236,17 @@ BarrierTailReplication::ReplicateJoinedSubgraphs(BasicBlock *dominator,
       {
         // We have modified the function. Possibly created new loops.
         // Update analysis passes.
-        #if (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
+#if (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
         DT->runOnFunction(*f);
-        #else
+#else
         DTP->runOnFunction(*f);
-        #endif
+#endif
 
-        #ifdef LLVM_3_1
+#ifdef LLVM_3_1
         LI->getBase().Calculate(DT->getBase());
-        #else
+#else
         LI->runOnFunction(*f);
-        #endif
+#endif
       }
   }
   processed_bbs.insert(subgraph_entry);
diff --git a/lib/llvmopencl/BarrierTailReplication.h b/lib/llvmopencl/BarrierTailReplication.h
index 608b886..08efcd6 100644
--- a/lib/llvmopencl/BarrierTailReplication.h
+++ b/lib/llvmopencl/BarrierTailReplication.h
@@ -1,6 +1,7 @@
 // Header for BarrierTailReplication.cc function pass.
 // 
 // Copyright (c) 2011 Universidad Rey Juan Carlos
+//               2012-2015 Pekka Jääskeläinen
 // 
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
@@ -24,6 +25,8 @@
 #define POCL_BARRIER_TAIL_REPLICATION
 
 #include "config.h"
+#include "pocl.h"
+
 #if (defined LLVM_3_1 || defined LLVM_3_2)
 #include "llvm/Function.h"
 #else
@@ -64,7 +67,12 @@ namespace pocl {
 #if ! (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
     llvm::DominatorTreeWrapperPass *DTP;
 #endif
+
+#ifdef LLVM_OLDER_THAN_3_7
     llvm::LoopInfo *LI;
+#else
+    llvm::LoopInfoWrapperPass *LI;
+#endif
 
     bool ProcessFunction(llvm::Function &F);
     bool FindBarriersDFS(llvm::BasicBlock *bb,
diff --git a/lib/llvmopencl/BreakConstantGEPs.cpp b/lib/llvmopencl/BreakConstantGEPs.cpp
index 7576050..8003772 100644
--- a/lib/llvmopencl/BreakConstantGEPs.cpp
+++ b/lib/llvmopencl/BreakConstantGEPs.cpp
@@ -18,7 +18,11 @@
 
 #define DEBUG_TYPE "break-constgeps"
 
+#include "CompilerWarnings.h"
+IGNORE_COMPILER_WARNING("-Wunused-parameter")
+
 #include "config.h"
+#include "pocl.h"
 #if (defined LLVM_3_1 || defined LLVM_3_2)
 #include "llvm/Constants.h"
 #include "llvm/InstrTypes.h"
@@ -53,6 +57,8 @@ char BreakConstantGEPs::ID = 0;
 STATISTIC (GEPChanges,   "Number of Converted GEP Constant Expressions");
 STATISTIC (TotalChanges, "Number of Converted Constant Expressions");
 
+POP_COMPILER_DIAGS
+
 // Register the pass
 static RegisterPass<BreakConstantGEPs> P ("break-constgeps",
                                           "Remove GEP Constant Expressions");
@@ -75,9 +81,14 @@ static RegisterPass<BreakConstantGEPs> P ("break-constgeps",
 static ConstantExpr *
 hasConstantGEP (Value * V) {
   if (ConstantExpr * CE = dyn_cast<ConstantExpr>(V)) {
-      if (CE->getOpcode() == Instruction::GetElementPtr ||
-          CE->getOpcode() == Instruction::BitCast) 
-      {
+    bool isGEPOrCast =
+        CE->getOpcode() == Instruction::GetElementPtr ||
+        CE->getOpcode() == Instruction::BitCast;
+
+#if !(defined(LLVM_3_2) || defined(LLVM_3_3))
+    isGEPOrCast |= CE->getOpcode() == Instruction::AddrSpaceCast;
+#endif
+    if (isGEPOrCast) {
       return CE;
     } else {
       for (unsigned index = 0; index < CE->getNumOperands(); ++index) {
@@ -121,10 +132,21 @@ convertGEP (ConstantExpr * CE, Instruction * InsertPt) {
   //
   // Make the new GEP instruction.
   //
+  #ifdef LLVM_OLDER_THAN_3_7
   return (GetElementPtrInst::Create (CE->getOperand(0),
                                      Indices,
                                      CE->getName(),
                                      InsertPt));
+  #else
+  /* The first NULL is the Type. It is not used at all, just asserted 
+   * against. And it asserts, no matter what is passed. Except NULL. 
+   * Seems this API is still "fluctuation in progress"*/
+  return (GetElementPtrInst::Create (NULL,
+                                     CE->getOperand(0),
+                                     Indices,
+                                     CE->getName(),
+                                     InsertPt));
+  #endif
 }
 
 //
@@ -182,6 +204,9 @@ convertExpression (ConstantExpr * CE, Instruction * InsertPt) {
     case Instruction::FPExt:
     case Instruction::PtrToInt:
     case Instruction::IntToPtr:
+#if !(defined(LLVM_3_2) || defined(LLVM_3_3))
+    case Instruction::AddrSpaceCast:
+#endif
     case Instruction::BitCast: {
       Instruction::CastOps Op = (Instruction::CastOps)(CE->getOpcode());
       NewInst = CastInst::Create (Op,
diff --git a/lib/llvmopencl/CMakeLists.txt b/lib/llvmopencl/CMakeLists.txt
index 20b6a2b..2bcabea 100644
--- a/lib/llvmopencl/CMakeLists.txt
+++ b/lib/llvmopencl/CMakeLists.txt
@@ -42,7 +42,7 @@ set(LLVMPASSES_SOURCES "Barrier.h"
             "WorkitemHandlerChooser.h" "WorkitemHandlerChooser.cc"
             "AllocasToEntry.h" "AllocasToEntry.cc"
             "TargetAddressSpaces.h" "TargetAddressSpaces.cc"
-            "LLVMUtils.cc" "LLVMUtils.h"
+            "LLVMUtils.cc" "LLVMUtils.h" "LLVMFileUtils.cc"
             "VariableUniformityAnalysis.h" "VariableUniformityAnalysis.cc"
             "AutomaticLocals.cc" "ImplicitConditionalBarriers.cc"
             "ImplicitConditionalBarriers.h"
diff --git a/lib/llvmopencl/CanonicalizeBarriers.cc b/lib/llvmopencl/CanonicalizeBarriers.cc
index bd712b3..89349d5 100644
--- a/lib/llvmopencl/CanonicalizeBarriers.cc
+++ b/lib/llvmopencl/CanonicalizeBarriers.cc
@@ -21,6 +21,10 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
+#include "CompilerWarnings.h"
+IGNORE_COMPILER_WARNING("-Wunused-parameter")
+
+#include "pocl.h"
 #include "config.h"
 #include "CanonicalizeBarriers.h"
 #include "BarrierBlock.h"
@@ -42,6 +46,7 @@
 #if ! (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
 #include "llvm/IR/Dominators.h"
 #endif
+POP_COMPILER_DIAGS
 
 using namespace llvm;
 using namespace pocl;
@@ -73,9 +78,15 @@ CanonicalizeBarriers::runOnFunction(Function &F)
 
   BasicBlock *entry = &F.getEntryBlock();
   if (!isa<BarrierBlock>(entry)) {
+#ifdef LLVM_OLDER_THAN_3_7
     BasicBlock *effective_entry = SplitBlock(entry, 
                                              &(entry->front()),
                                              this);
+#else
+    BasicBlock *effective_entry = SplitBlock(entry, 
+                                             &(entry->front()));
+#endif
+
     effective_entry->takeName(entry);
     entry->setName("entry.barrier");
     Barrier::Create(entry->getTerminator());
@@ -101,9 +112,17 @@ CanonicalizeBarriers::runOnFunction(Function &F)
          between the explicit barrier and the added one). */
       BasicBlock *exit; 
       if (Barrier::endsWithBarrier(b))
+#ifdef LLVM_OLDER_THAN_3_7
         exit = SplitBlock(b, t->getPrevNode(), this);
+#else
+        exit = SplitBlock(b, t->getPrevNode());
+#endif
       else
+#ifdef LLVM_OLDER_THAN_3_7
         exit = SplitBlock(b, t, this);
+#else
+        exit = SplitBlock(b, t);
+#endif
       exit->setName("exit.barrier");
       Barrier::Create(t);
     }
@@ -114,21 +133,7 @@ CanonicalizeBarriers::runOnFunction(Function &F)
 #else
   DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
 #endif
-  LI = getAnalysisIfAvailable<LoopInfo>();
-
-  bool changed = ProcessFunction(F);
-
-#if (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
-  if (DT)
-    DT->verifyAnalysis();
-#else
-  if (DT)
-    DT->verifyDomTree();
-#endif
-  if (LI)
-    LI->verifyAnalysis();
-
-  return changed;
+  return ProcessFunction(F);
 }
 
 

@@ -173,7 +178,11 @@ CanonicalizeBarriers::ProcessFunction(Function &F) {
       t->getPrevNode() != *i;
 
     if (HAS_NON_BRANCH_INSTRUCTIONS_AFTER_BARRIER) {
+#ifdef LLVM_OLDER_THAN_3_7
       BasicBlock *new_b = SplitBlock(b, (*i)->getNextNode(), this);
+#else
+      BasicBlock *new_b = SplitBlock(b, (*i)->getNextNode());
+#endif
       new_b->setName(b->getName() + ".postbarrier");
       changed = true;
     }
@@ -198,7 +207,11 @@ CanonicalizeBarriers::ProcessFunction(Function &F) {
     // (allow multiple predecessors, eases loop handling).
     // if (&b->front() == (*i))
     //   continue;
+#ifdef LLVM_OLDER_THAN_3_7
     BasicBlock *new_b = SplitBlock(b, *i, this);
+#else
+    BasicBlock *new_b = SplitBlock(b, *i);
+#endif
     new_b->takeName(b);
     b->setName(new_b->getName() + ".prebarrier");
     changed = true;
diff --git a/lib/llvmopencl/LoopBarriers.h b/lib/llvmopencl/CompilerWarnings.h
similarity index 55%
copy from lib/llvmopencl/LoopBarriers.h
copy to lib/llvmopencl/CompilerWarnings.h
index 6d80de6..41c8e8c 100644
--- a/lib/llvmopencl/LoopBarriers.h
+++ b/lib/llvmopencl/CompilerWarnings.h
@@ -1,6 +1,6 @@
-// Header for LoopBarriers.cc function pass.
+// Utility to suppress uninteresting compiler warnings.
 // 
-// Copyright (c) 2011 Universidad Rey Juan Carlos
+// Copyright (c) 2015 Pekka Jääskeläinen / TUT
 // 
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
@@ -19,29 +19,45 @@
 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
+#ifndef POCL_COMPILER_WARNINGS_HH
+#define POCL_COMPILER_WARNINGS_HH
 
-#ifndef POCL_LOOP_BARRIERS_H
-#define POCL_LOOP_BARRIERS_H
+#define DO_PRAGMA(x) _Pragma(#x)
 
-#include "llvm/Analysis/LoopPass.h"
-#include <set>
+#ifdef __clang__
 
-namespace pocl {
-  class LoopBarriers : public llvm::LoopPass {
-    
-  public:
-    static char ID;
-    
-  LoopBarriers() : LoopPass(ID) {}
-    
-    virtual void getAnalysisUsage(llvm::AnalysisUsage &AU) const;
-    virtual bool runOnLoop(llvm::Loop *L, llvm::LPPassManager &LPM);
+#define IGNORE_COMPILER_WARNING(X)                        \
+    DO_PRAGMA(clang diagnostic push)                      \
+    DO_PRAGMA(clang diagnostic ignored X)                 
 
-  private:
-    llvm::DominatorTree *DT;
+#elif defined(__GNUC__)
 
-    bool ProcessLoop(llvm::Loop *L, llvm::LPPassManager &LPM);
-  };
-}
+#define IGNORE_COMPILER_WARNING(X)                      \
+    DO_PRAGMA(GCC diagnostic push)                      \
+    DO_PRAGMA(GCC diagnostic ignored X)                 
+
+#else
+
+#define IGNORE_COMPILER_WARNING(X) 
+
+#endif
+
+
+#ifdef __clang__
+
+#define POP_COMPILER_DIAGS \
+    DO_PRAGMA(clang diagnostic pop)
+
+#elif defined(__GNUC__)
+
+#define POP_COMPILER_DIAGS \
+    DO_PRAGMA(GCC diagnostic pop)
+
+#else
+
+#define POP_COMPILER_DIAGS 
 
 #endif
+
+#endif
+
diff --git a/lib/llvmopencl/DebugHelpers.cc b/lib/llvmopencl/DebugHelpers.cc
index 9aba4ec..7e2444b 100644
--- a/lib/llvmopencl/DebugHelpers.cc
+++ b/lib/llvmopencl/DebugHelpers.cc
@@ -20,6 +20,9 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
+#include "CompilerWarnings.h"
+IGNORE_COMPILER_WARNING("-Wunused-parameter")
+
 #include <fstream>
 #include <iostream>
 #include <sstream>
@@ -28,6 +31,8 @@
 #include "DebugHelpers.h"
 
 #include "config.h"
+#include "pocl.h"
+
 #include "Barrier.h"
 #include "BarrierBlock.h"
 #include "Workgroup.h"
@@ -44,6 +49,8 @@
 
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
 
+POP_COMPILER_DIAGS
+
 using namespace llvm;
 
 namespace pocl {
@@ -204,7 +211,11 @@ bool chopBBs(llvm::Function &F, llvm::Pass &P) {
               ++splitPoint;
               ++count;
             }
+#ifdef LLVM_OLDER_THAN_3_7
           SplitBlock(b, splitPoint, &P);
+#else
+          SplitBlock(b, splitPoint);
+#endif
           fchanged = true;
           break;
         }
diff --git a/lib/llvmopencl/DebugHelpers.h b/lib/llvmopencl/DebugHelpers.h
index ab9b9ce..a5830cd 100644
--- a/lib/llvmopencl/DebugHelpers.h
+++ b/lib/llvmopencl/DebugHelpers.h
@@ -52,4 +52,13 @@ namespace pocl {
   bool chopBBs(llvm::Function& F, llvm::Pass &P);
 };
 
+// Controls the debug output from Kernel.cc parallel region generation:
+//#define DEBUG_PR_CREATION
+
+// Controls the debug output from ImplicitConditionalBarriers.cc:
+//#define DEBUG_COND_BARRIERS
+
+// Controls the debug output from PHIsToAllocas.cc
+//#define DEBUG_PHIS_TO_ALLOCAS
+
 #endif
diff --git a/lib/llvmopencl/Flatten.cc b/lib/llvmopencl/Flatten.cc
index 211a7de..1756df1 100644
--- a/lib/llvmopencl/Flatten.cc
+++ b/lib/llvmopencl/Flatten.cc
@@ -2,6 +2,7 @@
 // per-workgroup variables) into the kernel.
 // 
 // Copyright (c) 2011 Universidad Rey Juan Carlos
+//               2012-2015 Pekka Jääskeläinen
 // 
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
@@ -21,6 +22,9 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
+#include "CompilerWarnings.h"
+IGNORE_COMPILER_WARNING("-Wunused-parameter")
+
 #include "config.h"
 #include <iostream>
 #include <string>
@@ -34,6 +38,8 @@
 #include "llvm/IR/Module.h"
 #endif
 
+POP_COMPILER_DIAGS
+
 using namespace llvm;
 
 namespace {
diff --git a/lib/llvmopencl/GenerateHeader.cc b/lib/llvmopencl/GenerateHeader.cc
index f31f00b..a7f70e7 100644
--- a/lib/llvmopencl/GenerateHeader.cc
+++ b/lib/llvmopencl/GenerateHeader.cc
@@ -20,6 +20,9 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
+#include "CompilerWarnings.h"
+IGNORE_COMPILER_WARNING("-Wunused-parameter")
+
 #include "config.h"
 #include "pocl.h"
 #include "Workgroup.h"
@@ -57,6 +60,8 @@
 
 #include "LLVMUtils.h"
 
+POP_COMPILER_DIAGS
+
 using namespace std;
 using namespace llvm;
 using namespace pocl;
@@ -96,8 +101,11 @@ GenerateHeader::getAnalysisUsage(AnalysisUsage &AU) const
 {
 #if (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
   AU.addRequired<DataLayout>();
-#else
+#elif (defined LLVM_OLDER_THAN_3_7)
   AU.addRequired<DataLayoutPass>();
+#else
+  // In LLVM 3.7, DataLayout is not a pass anymore, it can be created from 
+  // a llvm::Module
 #endif
 }
 
@@ -205,23 +213,20 @@ GenerateHeader::ProcessPointers(Function *F,
                                 raw_fd_ostream &out)
 {
   int num_args = F->getFunctionType()->getNumParams();
-    
+
   out << "#define _" << F->getName() << "_NUM_ARGS " << num_args << '\n';
 
-  bool *is_pointer = (bool*) malloc(sizeof(bool) * num_args);
-  bool *is_local = (bool*)malloc(sizeof(bool)* num_args);
-  bool *is_image = (bool*)malloc(sizeof(bool)* num_args);
-  bool *is_sampler = (bool*)malloc(sizeof(bool)* num_args);
+  bool *is_pointer = (bool*)calloc(num_args, sizeof(bool));
+  bool *is_local = (bool*)calloc(num_args, sizeof(bool));
+  bool *is_image = (bool*)calloc(num_args, sizeof(bool));
+  bool *is_sampler = (bool*)calloc(num_args, sizeof(bool));
 
   int i = 0;
   for (Function::const_arg_iterator ii = F->arg_begin(),
          ee = F->arg_end();
        ii != ee; ++ii) {
     Type *t = ii->getType();
-  
-    is_image[i] = false;
-    is_sampler[i] = false;
- 
+
     const PointerType *p = dyn_cast<PointerType>(t);
     if (p && !ii->hasByValAttr()) {
       is_pointer[i] = true;
@@ -235,27 +240,22 @@ GenerateHeader::ProcessPointers(Function *F,
       is_pointer[i] = false;
       is_local[i] = false;
     }
-    
+
     if (t->isPointerTy()) {
-      if (t->getPointerElementType()->isStructTy()) {
-        string name = t->getPointerElementType()->getStructName().str();
-        if (name == "opencl.image2d_t" || name == "opencl.image3d_t" || 
-            name == "opencl.image1d_t" || name == "struct.dev_image_t") {
-          is_image[i] = true;
-          is_pointer[i] = false;
-          is_local[i] = false;
-        }
-        if (name == "opencl.sampler_t_") {
-          is_sampler[i] = true;
-          is_pointer[i] = false;
-          is_local[i] = false;
-        }
+      if (is_image_type(*t)) {
+        is_image[i] = true;
+        is_pointer[i] = false;
+        is_local[i] = false;
+      } else if (is_sampler_type(*t)) {
+        is_sampler[i] = true;
+        is_pointer[i] = false;
+        is_local[i] = false;
       }
     }
-    
+
     ++i;
   }
-    
+
   out << "#define _" << F->getName() << "_ARG_IS_POINTER {";
   if (num_args != 0) {
     out << is_pointer[0];
@@ -303,8 +303,11 @@ GenerateHeader::ProcessAutomaticLocals(Function *F,
 #if (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
   DataLayout &TDr = getAnalysis<DataLayout>();
   DataLayout *TD=&TDr;
-#else
+#elif (defined LLVM_OLDER_THAN_3_7)
   const DataLayout *TD = &getAnalysis<DataLayoutPass>().getDataLayout();
+#else
+  const DataLayout DLayout(F->getParent());
+  const DataLayout *TD = &DLayout;
 #endif
   
   SmallVector<GlobalVariable *, 8> locals;
diff --git a/lib/llvmopencl/ImplicitConditionalBarriers.cc b/lib/llvmopencl/ImplicitConditionalBarriers.cc
index 336baba..6b3c2c2 100644
--- a/lib/llvmopencl/ImplicitConditionalBarriers.cc
+++ b/lib/llvmopencl/ImplicitConditionalBarriers.cc
@@ -21,6 +21,9 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
+#include "CompilerWarnings.h"
+IGNORE_COMPILER_WARNING("-Wunused-parameter")
+
 #include "config.h"
 #include "ImplicitConditionalBarriers.h"
 #include "Barrier.h"
@@ -41,6 +44,8 @@
 
 #include "VariableUniformityAnalysis.h"
 
+POP_COMPILER_DIAGS
+
 //#define DEBUG_COND_BARRIERS
 
 using namespace llvm;
diff --git a/lib/llvmopencl/ImplicitConditionalBarriers.h b/lib/llvmopencl/ImplicitConditionalBarriers.h
index f4e7ae6..32920fa 100644
--- a/lib/llvmopencl/ImplicitConditionalBarriers.h
+++ b/lib/llvmopencl/ImplicitConditionalBarriers.h
@@ -78,7 +78,6 @@ namespace pocl {
     llvm::BasicBlock* firstNonBackedgePredecessor(llvm::BasicBlock *bb);
 
     llvm::PostDominatorTree *PDT;
-    llvm::PostDominatorTree *DT;
 
   };
 }
diff --git a/lib/llvmopencl/ImplicitLoopBarriers.h b/lib/llvmopencl/ImplicitLoopBarriers.h
index 1b99ef5..ff112dc 100644
--- a/lib/llvmopencl/ImplicitLoopBarriers.h
+++ b/lib/llvmopencl/ImplicitLoopBarriers.h
@@ -35,7 +35,6 @@ namespace pocl {
     virtual bool runOnLoop(llvm::Loop *L, llvm::LPPassManager &LPM);
 
   private:
-    llvm::DominatorTree *DT;
 
     bool ProcessLoop(llvm::Loop *L, llvm::LPPassManager &LPM);
     bool AddInnerLoopBarrier(llvm::Loop *L, llvm::LPPassManager &LPM);
diff --git a/lib/llvmopencl/IsolateRegions.cc b/lib/llvmopencl/IsolateRegions.cc
index e91d178..9120b7f 100644
--- a/lib/llvmopencl/IsolateRegions.cc
+++ b/lib/llvmopencl/IsolateRegions.cc
@@ -1,6 +1,6 @@
 // Header for IsolateRegions RegionPass.
 // 
-// Copyright (c) 2012 Pekka Jääskeläinen / TUT
+// Copyright (c) 2012-2015 Pekka Jääskeläinen / TUT
 // 
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
@@ -20,16 +20,22 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
+#include "CompilerWarnings.h"
+IGNORE_COMPILER_WARNING("-Wunused-parameter")
+
 #include "IsolateRegions.h"
 #include "Barrier.h"
 #include "Workgroup.h"
 #include "llvm/Analysis/RegionInfo.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
 #include "config.h"
+#include "pocl.h"
 
 #include <iostream>
 #include "VariableUniformityAnalysis.h"
 
+POP_COMPILER_DIAGS
+
 //#define DEBUG_ISOLATE_REGIONS
 using namespace llvm;
 using namespace pocl;
@@ -134,8 +140,13 @@ void IsolateRegions::addDummyAfter(llvm::Region *R, llvm::BasicBlock *bb) {
     if (R->contains(succ))
       regionSuccs.push_back(succ);
   }
+#ifdef LLVM_OLDER_THAN_3_7
   llvm::BasicBlock* newEntry = 
     SplitBlock(bb, bb->getTerminator(), this);
+#else
+  llvm::BasicBlock* newEntry = 
+    SplitBlock(bb, bb->getTerminator());
+#endif
   newEntry->setName(bb->getName() + ".r_entry");
   R->replaceEntry(newEntry);
 
@@ -162,9 +173,12 @@ IsolateRegions::addDummyBefore(llvm::Region *R, llvm::BasicBlock *bb) {
   llvm::BasicBlock* newExit = 
     SplitBlockPredecessors
     (bb, &regionPreds[0], regionPreds.size(), ".r_exit", this);
-#else
+#elif (defined LLVM_OLDER_THAN_3_7)
   llvm::BasicBlock* newExit = 
     SplitBlockPredecessors(bb, regionPreds, ".r_exit", this);
+#else
+  llvm::BasicBlock* newExit = 
+    SplitBlockPredecessors(bb, regionPreds, ".r_exit");
 #endif
   R->replaceExit(newExit);
 }
diff --git a/lib/llvmopencl/Kernel.cc b/lib/llvmopencl/Kernel.cc
index 4d2cabd..8fc8485 100644
--- a/lib/llvmopencl/Kernel.cc
+++ b/lib/llvmopencl/Kernel.cc
@@ -1,7 +1,7 @@
 // Class for kernels, llvm::Functions that represent OpenCL C kernels.
 // 
 // Copyright (c) 2011 Universidad Rey Juan Carlos and
-//               2012 Pekka Jääskeläinen / TUT
+//               2012-2015 Pekka Jääskeläinen / TUT
 // 
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
@@ -21,6 +21,9 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
+#include "CompilerWarnings.h"
+IGNORE_COMPILER_WARNING("-Wunused-parameter")
+
 #include "Kernel.h"
 #include "Barrier.h"
 #include <iostream>
@@ -35,8 +38,9 @@
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/InlineAsm.h"
 #endif
+POP_COMPILER_DIAGS
 
-//#define DEBUG_PR_CREATION
+#include "DebugHelpers.h"
 
 using namespace llvm;
 using namespace pocl;
@@ -142,11 +146,6 @@ add_predecessors(SmallVectorImpl<BasicBlock *> &v, BasicBlock *b)
 {
   for (pred_iterator i = pred_begin(b), e = pred_end(b);
        i != e; ++i) {
-    if ((isa<BarrierBlock> (*i)) && isa<BarrierBlock> (b)) {
-      // Ignore barrier-to-barrier edges * Why? --Pekka
-      add_predecessors(v, *i);
-      continue;
-    }
     v.push_back(*i);
   }
 }
@@ -264,6 +263,10 @@ Kernel::getParallelRegions(llvm::LoopInfo *LI) {
       assert ((exit != NULL) && "Parallel region without entry barrier!");
     }
   }
+
+#ifdef DEBUG_PR_CREATION
+  pocl::dumpCFG(*this, this->getName().str() + ".pregions.dot", parallel_regions);
+#endif
   return parallel_regions;
 
 }
@@ -280,9 +283,13 @@ Kernel::addLocalSizeInitCode(size_t LocalSizeX, size_t LocalSizeY, size_t LocalS
   int size_t_width = 32;
 #if (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
   if (M->getPointerSize() == llvm::Module::Pointer64)
-#else
-  //FIXME 0 here is the address space: this breaks (?) if _local_size_x is not stored in AS0
+#elif (defined LLVM_3_5 || defined LLVM_3_6) 
+  // This breaks (?) if _local_size_x is not stored in AS0,
+  // but it always will be as it's just a pseudo variable that
+  // will be scalarized.
   if (M->getDataLayout()->getPointerSize(0) == 8)
+#else
+  if (M->getDataLayout().getPointerSize(0) == 8)
 #endif
     size_t_width = 64;
 
diff --git a/lib/llvmopencl/LLVMFileUtils.cc b/lib/llvmopencl/LLVMFileUtils.cc
new file mode 100644
index 0000000..be63ccb
--- /dev/null
+++ b/lib/llvmopencl/LLVMFileUtils.cc
@@ -0,0 +1,335 @@
+#if !defined(_MSC_VER) && !defined(__MINGW32__)
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#else
+#include <io.h>
+#endif
+
+#include <assert.h>
+
+#include <iostream>
+#include <fstream>
+#include <vector>
+#include <sstream>
+#include <string>
+#include <cstdio>
+
+#include "pocl.h"
+#include "pocl_file_util.h"
+
+#include <llvm/Support/LockFileManager.h>
+
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FormattedStream.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/raw_os_ostream.h"
+
+#include "llvm/Bitcode/ReaderWriter.h"
+
+/* namespace of OpenFlags enum (F_Binary, F_Excl etc) */
+#if defined(LLVM_3_2) || defined(LLVM_3_3)
+#define OPEN_FLAGS_ENUM raw_fd_ostream
+#else
+#define OPEN_FLAGS_ENUM sys::fs
+#endif
+
+
+/* Older llvms:
+ * llvm::error_code instead of std::error_code
+ * "file existed" is an output argument, instead of "ignore if file existed"
+ * different OpenFlags (no F_Binary)
+ * File locking disabled: llvm::LockManager class doesn't exist in LLVM < 3.5
+ */
+#if LLVM_OLDER_THAN_3_5
+
+#define DISABLE_LOCKMANAGER
+
+#include <llvm/Support/system_error.h>
+#define STD_ERROR_CODE llvm::error_code
+static bool existed;
+#define EXIST_ARG existed
+#define DEFAULT_OPEN_FLAGS OPEN_FLAGS_ENUM::F_Binary
+
+#else
+
+#include <llvm/Support/Errc.h>
+#define STD_ERROR_CODE std::error_code
+#define EXIST_ARG true
+#define DEFAULT_OPEN_FLAGS OPEN_FLAGS_ENUM::F_RW
+
+#endif
+
+#define RETURN_IF_EC if (ec) return ec.default_error_condition().value()
+
+/* no openFile* functions in sys::fs before llvm 3.4, so fallback to open */
+#if defined(LLVM_3_2) || defined(LLVM_3_3)
+    #define OPEN_FOR_READ fd = open(path, O_RDONLY)
+    #define OPEN_CREATE fd = open(path, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR)
+    #define OPEN_FOR_APPEND fd = open(path, O_WRONLY | O_APPEND)
+    #define RETURN_IF_ERRNO if (fd < 0) return errno;
+#else
+    #define OPEN_FOR_READ ec = sys::fs::openFileForRead(p, fd)
+    #define OPEN_CREATE ec = sys::fs::openFileForWrite(p, fd, DEFAULT_OPEN_FLAGS | sys::fs::F_Excl)
+    #define OPEN_FOR_APPEND ec = sys::fs::openFileForWrite(p, fd, DEFAULT_OPEN_FLAGS | sys::fs::F_Append)
+    #define RETURN_IF_ERRNO RETURN_IF_EC
+#endif
+
+
+
+using namespace llvm;
+
+/*****************************************************************************/
+
+int
+pocl_rm_rf(const char* path) {
+    STD_ERROR_CODE ec;
+    SmallString<128> DirNative;
+
+    sys::path::native(Twine(path), DirNative);
+
+    std::vector<std::string> FileSet, DirSet;
+
+    for (sys::fs::recursive_directory_iterator Dir(DirNative.str(), ec), DirEnd;
+         Dir != DirEnd && !ec; Dir.increment(ec)) {
+        Twine p = Dir->path();
+        std::string s = p.str();
+#if defined(LLVM_3_2) || defined(LLVM_3_3)
+        sys::fs::file_status result;
+        sys::fs::status(p, result);
+        if (sys::fs::is_directory(result)) {
+#else
+        if (sys::fs::is_directory(p)) {
+#endif
+            DirSet.push_back(s);
+        } else
+            FileSet.push_back(s);
+    }
+    RETURN_IF_EC;
+
+    std::vector<std::string>::iterator it;
+    for (it = FileSet.begin(); it != FileSet.end(); ++it) {
+        ec = sys::fs::remove(*it, EXIST_ARG);
+        RETURN_IF_EC;
+    }
+
+    std::sort(DirSet.begin(), DirSet.end());
+    std::vector<std::string>::reverse_iterator it2;
+    for (it2 = DirSet.rbegin(); it2 != DirSet.rend(); ++it2) {
+        ec = sys::fs::remove(*it2, EXIST_ARG);
+        RETURN_IF_EC;
+    }
+
+    return 0;
+}
+
+
+int
+pocl_mkdir_p(const char* path) {
+    Twine p(path);
+    STD_ERROR_CODE ec = sys::fs::create_directories(p, EXIST_ARG);
+    return ec.default_error_condition().value();
+}
+
+int
+pocl_remove(const char* path) {
+    Twine p(path);
+    STD_ERROR_CODE ec = sys::fs::remove(p, EXIST_ARG);
+    return ec.default_error_condition().value();
+}
+
+int
+pocl_exists(const char* path) {
+    Twine p(path);
+    if (sys::fs::exists(p))
+        return 1;
+    else
+        return 0;
+}
+
+int
+pocl_filesize(const char* path, uint64_t* res) {
+    Twine p(path);
+    STD_ERROR_CODE ec = sys::fs::file_size(p, *res);
+    return ec.default_error_condition().value();
+}
+
+int pocl_touch_file(const char* path) {
+    Twine p(path);
+    STD_ERROR_CODE ec = sys::fs::remove(p, EXIST_ARG);
+    RETURN_IF_EC;
+
+    int fd;
+    OPEN_CREATE;
+    RETURN_IF_ERRNO;
+
+    return (close(fd) ? (-errno) : 0);
+
+}
+/****************************************************************************/
+
+int
+pocl_read_file(const char* path, char** content, uint64_t *filesize) {
+    assert(content);
+    assert(path);
+    assert(filesize);
+
+    *content = NULL;
+
+    int errcode = pocl_filesize(path, filesize);
+    ssize_t fsize = (ssize_t)(*filesize);
+    if (!errcode) {
+        int fd;
+        STD_ERROR_CODE ec;
+        Twine p(path);
+
+        OPEN_FOR_READ;
+        RETURN_IF_ERRNO;
+
+        // +1 so we can later simply turn it into a C string, if needed
+        *content = (char*)malloc(fsize+1);
+
+        size_t rsize = read(fd, *content, fsize);
+        (*content)[rsize] = '\0';
+        if (rsize < (size_t)fsize) {
+            errcode = errno ? -errno : -1;
+            close(fd);
+        } else {
+            if (close(fd))
+                errcode = errno ? -errno : -1;
+        }
+    }
+    return errcode;
+}
+
+
+
+int pocl_write_file(const char *path, const char* content,
+                                    uint64_t    count,
+                                    int         append,
+                                    int         dont_rewrite) {
+    int fd;
+    STD_ERROR_CODE ec;
+    Twine p(path);
+
+    assert(path);
+    assert(content);
+
+    if (pocl_exists(path)) {
+        if (dont_rewrite) {
+            if (!append)
+                return 0;
+        } else {
+            int res = pocl_remove(path);
+            if (res)
+                return res;
+        }
+    }
+
+    if (append)
+        OPEN_FOR_APPEND;
+    else
+        OPEN_CREATE;
+
+    RETURN_IF_ERRNO;
+
+    if (write(fd, content, (ssize_t)count) < (ssize_t)count)
+        return errno ? -errno : -1;
+
+    return (close(fd) ? (-errno) : 0);
+}
+
+
+
+
+
+int pocl_write_module(void *module, const char* path, int dont_rewrite) {
+
+    assert(module);
+    assert(path);
+
+    Twine p(path);
+#ifdef LLVM_OLDER_THAN_3_6
+    std::string ec;
+#else
+    STD_ERROR_CODE ec;
+#endif
+
+    if (pocl_exists(path)) {
+        if (dont_rewrite)
+            return 0;
+        else {
+            int res = pocl_remove(path);
+            if (res)
+                return res;
+        }
+    }
+
+    raw_fd_ostream os(path, ec, DEFAULT_OPEN_FLAGS | OPEN_FLAGS_ENUM::F_Excl);
+#ifdef LLVM_OLDER_THAN_3_6
+    if (!ec.empty())
+        return 2;
+#else
+    RETURN_IF_EC;
+#endif
+
+    WriteBitcodeToFile((llvm::Module*)module, os);
+    os.close();
+    return (os.has_error() ? 1 : 0);
+
+}
+
+
+
+/****************************************************************************/
+
+static void* acquire_lock_internal(const char* path, int shared) {
+#ifdef DISABLE_LOCKMANAGER
+    /* Can't return value that compares equal to NULL */
+    return (void*)4096;
+#else
+    assert(path);
+    LockFileManager *lfm = new LockFileManager(path);
+
+    switch (lfm->getState()) {
+    case LockFileManager::LockFileState::LFS_Owned:
+        return (void*)lfm;
+
+    case LockFileManager::LockFileState::LFS_Shared:
+        if (shared)
+            return (void*)lfm;
+        lfm->waitForUnlock();
+        delete lfm;
+        lfm = new LockFileManager(path);
+        if (lfm->getState() == LockFileManager::LockFileState::LFS_Owned)
+            return (void*)lfm;
+        else
+          {
+            delete lfm;
+            return NULL;
+          }
+
+    case LockFileManager::LockFileState::LFS_Error:
+        return NULL;
+    }
+    return NULL;
+#endif
+}
+
+
+void* acquire_lock(const char *path, int shared) {
+    return acquire_lock_internal(path, shared);
+}
+
+
+void release_lock(void* lock) {
+#ifdef DISABLE_LOCKMANAGER
+    return;
+#else
+    if (!lock)
+        return;
+    LockFileManager *l = (LockFileManager*)lock;
+    delete l;
+#endif
+}
diff --git a/lib/llvmopencl/LLVMUtils.h b/lib/llvmopencl/LLVMUtils.h
index 598dabe..ef86990 100644
--- a/lib/llvmopencl/LLVMUtils.h
+++ b/lib/llvmopencl/LLVMUtils.h
@@ -65,8 +65,8 @@ is_image_type(const llvm::Type& t)
 {
   if (t.isPointerTy() && t.getPointerElementType()->isStructTy()) {
     llvm::StringRef name = t.getPointerElementType()->getStructName().str();
-    if (name.startswith("opencl.image2d_t") || name.startswith("opencl.image3d_t") || 
-        name.startswith("opencl.image1d_t") || name.startswith("struct.dev_image_t"))
+    if (name.startswith("opencl.image2d_t") || name.startswith("opencl.image3d_t") ||
+        name.startswith("opencl.image1d_t") || name.startswith("struct._pocl_image"))
       return true;
   }
   return false;
diff --git a/lib/llvmopencl/LoopBarriers.cc b/lib/llvmopencl/LoopBarriers.cc
index 442aab0..566a725 100644
--- a/lib/llvmopencl/LoopBarriers.cc
+++ b/lib/llvmopencl/LoopBarriers.cc
@@ -21,7 +21,12 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
+#include "CompilerWarnings.h"
+IGNORE_COMPILER_WARNING("-Wunused-parameter")
+
 #include "config.h"
+#include "pocl.h"
+
 #if (defined LLVM_3_1 || defined LLVM_3_2)
 #include "llvm/Constants.h"
 #include "llvm/Instructions.h"
@@ -43,6 +48,8 @@
 #include "Barrier.h"
 #include "Workgroup.h"
 
+POP_COMPILER_DIAGS
+
 //#define DEBUG_LOOP_BARRIERS
 
 using namespace llvm;
@@ -97,7 +104,7 @@ LoopBarriers::runOnLoop(Loop *L, LPPassManager &LPM)
 
 

 bool
-LoopBarriers::ProcessLoop(Loop *L, LPPassManager &LPM)
+LoopBarriers::ProcessLoop(Loop *L, LPPassManager &)
 {
   bool isBLoop = false;
   bool changed = false;
@@ -204,12 +211,15 @@ LoopBarriers::ProcessLoop(Loop *L, LPPassManager &LPM)
   Instruction *prev = NULL;
   if (&preheader->front() != t)
     prev = t->getPrevNode();
-  if (prev && isa<Barrier>(prev))
-    {
+  if (prev && isa<Barrier>(prev)) {
+#ifdef LLVM_OLDER_THAN_3_7
       BasicBlock *new_b = SplitBlock(preheader, t, this);
+#else
+      BasicBlock *new_b = SplitBlock(preheader, t);
+#endif
       new_b->setName(preheader->getName() + ".postbarrier_dummy");
       return true;
-    }
+  }
 
   return changed;
 }
diff --git a/lib/llvmopencl/LoopBarriers.h b/lib/llvmopencl/LoopBarriers.h
index 6d80de6..404e3ce 100644
--- a/lib/llvmopencl/LoopBarriers.h
+++ b/lib/llvmopencl/LoopBarriers.h
@@ -23,9 +23,14 @@
 #ifndef POCL_LOOP_BARRIERS_H
 #define POCL_LOOP_BARRIERS_H
 
+#include "CompilerWarnings.h"
+IGNORE_COMPILER_WARNING("-Wunused-parameter")
+
 #include "llvm/Analysis/LoopPass.h"
 #include <set>
 
+POP_COMPILER_DIAGS
+
 namespace pocl {
   class LoopBarriers : public llvm::LoopPass {
     
diff --git a/lib/llvmopencl/Makefile.am b/lib/llvmopencl/Makefile.am
index 257dd33..41532e7 100644
--- a/lib/llvmopencl/Makefile.am
+++ b/lib/llvmopencl/Makefile.am
@@ -3,7 +3,7 @@
 # Makefile.am for pocl/lib/llvmopencl.
 # 
 # Copyright (c) 2011 Universidad Rey Juan Carlos
-#               2011-2014 Pekka Jääskeläinen 
+#               2011-2015 Pekka Jääskeläinen 
 #
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
@@ -56,12 +56,12 @@ PASSES_SOURCES = Barrier.h						\
 						WorkitemHandlerChooser.h WorkitemHandlerChooser.cc \
 						AllocasToEntry.h AllocasToEntry.cc \
 						TargetAddressSpaces.h TargetAddressSpaces.cc \
-						LLVMUtils.cc LLVMUtils.h \
+						LLVMUtils.cc LLVMUtils.h LLVMFileUtils.cc \
 						VariableUniformityAnalysis.h VariableUniformityAnalysis.cc \
 						AutomaticLocals.cc ImplicitConditionalBarriers.cc \
 						ImplicitConditionalBarriers.h \
 						DebugHelpers.h DebugHelpers.cc \
-						linker.h
+						linker.h CompilerWarnings.h
 
 #add compiler driver sources
 libllvmpasses_la_SOURCES = ${PASSES_SOURCES} linker.cpp
diff --git a/lib/llvmopencl/Makefile.in b/lib/llvmopencl/Makefile.in
index 43fb852..267cfa0 100644
--- a/lib/llvmopencl/Makefile.in
+++ b/lib/llvmopencl/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -19,7 +19,7 @@
 # Makefile.am for pocl/lib/llvmopencl.
 # 
 # Copyright (c) 2011 Universidad Rey Juan Carlos
-#               2011-2014 Pekka Jääskeläinen 
+#               2011-2015 Pekka Jääskeläinen 
 #
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
@@ -40,7 +40,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -105,8 +115,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = lib/llvmopencl
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -115,6 +123,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -157,8 +166,9 @@ am__objects_1 = BarrierBlock.lo Kernel.lo ParallelRegion.lo \
 	WorkitemHandler.lo WorkitemLoops.lo PHIsToAllocas.lo \
 	BreakConstantGEPs.lo WorkitemHandlerChooser.lo \
 	AllocasToEntry.lo TargetAddressSpaces.lo LLVMUtils.lo \
-	VariableUniformityAnalysis.lo AutomaticLocals.lo \
-	ImplicitConditionalBarriers.lo DebugHelpers.lo
+	LLVMFileUtils.lo VariableUniformityAnalysis.lo \
+	AutomaticLocals.lo ImplicitConditionalBarriers.lo \
+	DebugHelpers.lo
 am_libllvmpasses_la_OBJECTS = $(am__objects_1) linker.lo
 libllvmpasses_la_OBJECTS = $(am_libllvmpasses_la_OBJECTS)
 AM_V_lt = $(am__v_lt_ at AM_V@)
@@ -246,6 +256,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -297,6 +308,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -333,6 +347,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -478,12 +493,12 @@ PASSES_SOURCES = Barrier.h						\
 						WorkitemHandlerChooser.h WorkitemHandlerChooser.cc \
 						AllocasToEntry.h AllocasToEntry.cc \
 						TargetAddressSpaces.h TargetAddressSpaces.cc \
-						LLVMUtils.cc LLVMUtils.h \
+						LLVMUtils.cc LLVMUtils.h LLVMFileUtils.cc \
 						VariableUniformityAnalysis.h VariableUniformityAnalysis.cc \
 						AutomaticLocals.cc ImplicitConditionalBarriers.cc \
 						ImplicitConditionalBarriers.h \
 						DebugHelpers.h DebugHelpers.cc \
-						linker.h
+						linker.h CompilerWarnings.h
 
 
 #add compiler driver sources
@@ -509,7 +524,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/llvmopencl/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign lib/llvmopencl/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -599,6 +613,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ImplicitLoopBarriers.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/IsolateRegions.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Kernel.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LLVMFileUtils.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LLVMUtils.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LoopBarriers.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PHIsToAllocas.Plo at am__quote@
@@ -868,6 +883,8 @@ uninstall-am: uninstall-pkglibLTLIBRARIES
 	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
 	uninstall-am uninstall-pkglibLTLIBRARIES
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/lib/llvmopencl/PHIsToAllocas.cc b/lib/llvmopencl/PHIsToAllocas.cc
index e7fd2ca..9d0b118 100644
--- a/lib/llvmopencl/PHIsToAllocas.cc
+++ b/lib/llvmopencl/PHIsToAllocas.cc
@@ -45,6 +45,8 @@ namespace {
       "phistoallocas", "Convert all PHI nodes to allocas");
 }
 
+#include <iostream>
+
 namespace pocl {
 
 char PHIsToAllocas::ID = 0;
@@ -144,10 +146,21 @@ PHIsToAllocas::BreakPHIToAllocas(PHINode* phi) {
 
   llvm::Instruction *loadedValue = builder.CreateLoad(alloca);
   phi->replaceAllUsesWith(loadedValue);
-  phi->eraseFromParent();
 
-  if (OriginalPHIWasUniform)
+  if (OriginalPHIWasUniform) {
+#ifdef DEBUG_PHIS_TO_ALLOCAS
+      std::cout << "PHIsToAllocas: Original PHI was uniform" << std::endl
+                << "original:";
+      phi->dump();
+      std::cout << "alloca:";
+      alloca->dump();
+      std::cout << "loadedValue:";
+      loadedValue->dump();
+#endif
+      VUA.setUniform(function, alloca);
       VUA.setUniform(function, loadedValue);
+  }
+  phi->eraseFromParent();
 
   return loadedValue;
 }
diff --git a/lib/llvmopencl/ParallelRegion.cc b/lib/llvmopencl/ParallelRegion.cc
index a2cdcfd..b4b7537 100644
--- a/lib/llvmopencl/ParallelRegion.cc
+++ b/lib/llvmopencl/ParallelRegion.cc
@@ -2,7 +2,7 @@
 // each kernel should run in parallel.
 // 
 // Copyright (c) 2011 Universidad Rey Juan Carlos and
-//               2012-2014 Pekka Jääskeläinen / TUT
+//               2012-2015 Pekka Jääskeläinen / TUT
 // 
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
@@ -45,6 +45,8 @@
 #include <map>
 #include <algorithm>
 
+#include "DebugHelpers.h"
+
 using namespace std;
 using namespace llvm;
 using namespace pocl;
@@ -296,9 +298,13 @@ ParallelRegion::insertLocalIdInit(llvm::BasicBlock* entry,
   int size_t_width = 32;
 #if (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
   if (M->getPointerSize() == llvm::Module::Pointer64)
-#else
-  // FIXME 0 here is the address space: this breaks (?) if _local_size_x is not stored in AS0
+#elif (defined LLVM_3_5 || defined LLVM_3_6) 
+  // This breaks (?) if _local_size_x is not stored in AS0,
+  // but it always will be as it's just a pseudo variable that
+  // will be scalarized.
   if (M->getDataLayout()->getPointerSize(0) == 8)
+#else
+  if (M->getDataLayout().getPointerSize(0) == 8)
 #endif
     size_t_width = 64;
 
@@ -403,9 +409,14 @@ ParallelRegion::Verify()
           std::cerr << "suspicious block: " << (*i)->getName().str() << std::endl;
           std::cerr << "the entry is: " << entryBB()->getName().str() << std::endl;
 
-#if 0
-          (*i)->getParent()->viewCFG();
-#endif
+          ParallelRegion::ParallelRegionVector prvec;
+          prvec.push_back(this);
+          std::set<llvm::BasicBlock*> highlights;
+          highlights.insert(entryBB());
+          highlights.insert(*i);
+          pocl::dumpCFG(
+            *(*i)->getParent(), (*i)->getParent()->getName().str() + ".dot",
+            &prvec, &highlights);
           assert(0 && "Incoming edges to non-entry block!");
           return false;
         } else if (!Barrier::hasBarrier(*ii)) {
@@ -421,8 +432,17 @@ ParallelRegion::Verify()
     //   assert(0 && "Parallel regions must be single entry!");
     //   return false;
     // }
-
     if (exitBB()->getTerminator()->getNumSuccessors() != 1) {
+      ParallelRegion::ParallelRegionVector regions;
+      regions.push_back(this);
+
+      std::set<llvm::BasicBlock*> highlights;
+      highlights.insert((*i));
+      highlights.insert(exitBB());
+      exitBB()->dump();
+      dumpNames();
+      dumpCFG(*(*i)->getParent(), "broken.dot", &regions, &highlights);
+
       assert(0 && "Multiple outgoing edges from exit block!");
       return false;
     }
@@ -670,7 +690,7 @@ ParallelRegion::LocalIDXLoad()
 
 void
 ParallelRegion::InjectPrintF
-(llvm::Instruction *before, std::string formatStr, 
+(llvm::Instruction *before, std::string formatStr,
  std::vector<Value*>& params)
 {
   IRBuilder<> builder(before);
@@ -735,9 +755,15 @@ ParallelRegion::InjectPrintF
   const_ptr_8_indices.push_back(const_int64_9);
   const_ptr_8_indices.push_back(const_int64_9);
   assert (isa<Constant>(stringArg));
-  Constant* const_ptr_8 = 
+  #ifdef LLVM_OLDER_THAN_3_7
+  Constant* const_ptr_8 =
     ConstantExpr::getGetElementPtr
     (cast<Constant>(stringArg), const_ptr_8_indices);
+  #else
+  Constant* const_ptr_8 =
+    ConstantExpr::getGetElementPtr
+    (PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), cast<Constant>(stringArg), const_ptr_8_indices);
+  #endif
 
   std::vector<Value*> args;
   args.push_back(const_ptr_8);
diff --git a/lib/llvmopencl/ParallelRegion.h b/lib/llvmopencl/ParallelRegion.h
index 15388a0..6f32f3c 100644
--- a/lib/llvmopencl/ParallelRegion.h
+++ b/lib/llvmopencl/ParallelRegion.h
@@ -57,7 +57,7 @@ class Kernel;
   // It now exposes too much to the clients and leads to hard
   // to track errors when the API is changed.
   class ParallelRegion : public std::vector<llvm::BasicBlock *> {    
-  public:    
+  public:
     typedef llvm::SmallVector<ParallelRegion *, 8> ParallelRegionVector;
 
     ParallelRegion(int forcedRegionId=-1);
@@ -96,7 +96,7 @@ class Kernel;
     void InjectVariablePrintouts();
 
     void InjectPrintF
-        (llvm::Instruction *before, std::string formatStr, 
+        (llvm::Instruction *before, std::string formatStr,
          std::vector<llvm::Value*>& params);
 
     static ParallelRegion *
diff --git a/lib/llvmopencl/TargetAddressSpaces.cc b/lib/llvmopencl/TargetAddressSpaces.cc
index 73faa32..b94e218 100644
--- a/lib/llvmopencl/TargetAddressSpaces.cc
+++ b/lib/llvmopencl/TargetAddressSpaces.cc
@@ -1,7 +1,7 @@
-// TargetAddressSpaces.cc - map the fixed "logical" address-space ids to
+// TargetAddressSpaces.cc - map the fixed "logical" address-space ids to,
 //                          the target-specific ones, if needed
 // 
-// Copyright (c) 2013 Pekka Jääskeläinen / TUT
+// Copyright (c) 2013-2015 Pekka Jääskeläinen / TUT
 // 
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
@@ -24,14 +24,18 @@
 #include "config.h"
 #include <iostream>
 #include <string>
+#include <set>
 
 #ifdef LLVM_3_2
 # include <llvm/Instructions.h>
+# include <llvm/IntrinsicInst.h>
 #else
 # include <llvm/IR/Instructions.h>
 # include <llvm/IR/Module.h>
-
+# include <llvm/IR/IntrinsicInst.h>
 #endif
+
+#include <llvm/IR/IRBuilder.h>
 #include <llvm/Transforms/Utils/ValueMapper.h>
 #include <llvm/Transforms/Utils/Cloning.h>
 #include <llvm/Transforms/Utils/BasicBlockUtils.h>
@@ -86,23 +90,69 @@ UpdateAddressSpace(llvm::Value& val, std::map<unsigned, unsigned> &addrSpaceMap)
   return true;
 }
 
+/**
+ * After converting the pointer address spaces, there
+ * might be llvm.memcpy.* or llvm.memset.* calls to wrong
+ * intrinsics with wrong address spaces which this function
+ * fixes.
+ */
+static void
+FixMemIntrinsics(llvm::Function& F) {
+
+  // Collect the intrinsics first to avoid breaking the
+  // iterators.
+  std::vector<llvm::MemIntrinsic*> intrinsics;
+  for (llvm::Function::iterator bbi = F.begin(), bbe = F.end(); bbi != bbe;
+       ++bbi) {
+    llvm::BasicBlock* bb = bbi;
+    for (llvm::BasicBlock::iterator ii = bb->begin(), ie = bb->end();
+         ii != ie; ++ii) {
+      llvm::Instruction *instr = ii;
+      if (!isa<llvm::MemIntrinsic>(instr)) continue;
+      intrinsics.push_back(dyn_cast<llvm::MemIntrinsic>(instr));
+    }
+  }
+
+  for (llvm::MemIntrinsic* i : intrinsics) {
+
+    llvm::IRBuilder<> Builder(i);
+    // The pointer arguments to the intrinsics are already converted
+    // to the correct address spaces. All we need to do here is to
+    // "refresh" the intrinsics so it gets correct address spaces
+    // in the name (e.g. llvm.memcpy.p0i8.p0i8).
+    if (llvm::MemCpyInst* old = dyn_cast<llvm::MemCpyInst>(i)) {
+      Builder.CreateMemCpy(
+        old->getRawDest(), old->getRawSource(), old->getLength(),
+        old->getAlignment(), old->isVolatile());
+      old->eraseFromParent();
+    } else if (llvm::MemSetInst* old = dyn_cast<llvm::MemSetInst>(i)) {
+      Builder.CreateMemSet(
+        old->getRawDest(), old->getValue(), old->getLength(),
+        old->getAlignment(), old->isVolatile());
+      old->eraseFromParent();
+    } else if (llvm::MemMoveInst* old = dyn_cast<llvm::MemMoveInst>(i)) {
+      Builder.CreateMemMove(
+        old->getRawDest(), old->getRawSource(), old->getLength(),
+        old->getAlignment(), old->isVolatile());
+      old->eraseFromParent();
+    } else {
+        assert (false && "Unknown MemIntrinsic.");
+    }
+  }
+}
 
 bool
 TargetAddressSpaces::runOnModule(llvm::Module &M) {
 
   llvm::StringRef arch(M.getTargetTriple());
- 
+
   std::map<unsigned, unsigned> addrSpaceMap;
 
   if (arch.startswith("x86_64")) {
-#if defined LLVM_3_1 || defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4
-    /* For x86_64 the default isel seems to work with the
-       fake address spaces. Skip the processing as it causes 
-       an overhead and is not fully implemented.
-    */
-    return false;
-#else
-    /* LLVM 3.5 exposes an issue with pocl's printf or another LLVM pass:
+    /* x86_64 supports flattening the address spaces at the backend, but
+       we still flatten them in pocl due to a couple of reasons.
+
+       At least LLVM 3.5 exposes an issue with pocl's printf or another LLVM pass:
        After the code emission optimizations there appears a
        PHI node where the two alternative pointer assignments have different
        address spaces:
@@ -114,8 +164,11 @@ TargetAddressSpaces::runOnModule(llvm::Module &M) {
        while it won't be such due to the address space difference (I assume).
        Workaround this by flattening the address spaces to 0 here also for
        x86_64 until the real culprit is found.
+
+       Another reason is that LoopVectorizer of LLVM 3.7 crashes when it
+       tries to create a masked store intrinsics with the fake address space
+       ids, so we need to flatten them out before vectorizing.
     */
-#endif
     addrSpaceMap[POCL_ADDRESS_SPACE_GLOBAL] =
         addrSpaceMap[POCL_ADDRESS_SPACE_LOCAL] =
         addrSpaceMap[POCL_ADDRESS_SPACE_CONSTANT] = 0;
@@ -142,6 +195,10 @@ TargetAddressSpaces::runOnModule(llvm::Module &M) {
     addrSpaceMap[POCL_ADDRESS_SPACE_GLOBAL] =
         addrSpaceMap[POCL_ADDRESS_SPACE_LOCAL] =
         addrSpaceMap[POCL_ADDRESS_SPACE_CONSTANT] = 0;
+  } else if (arch.startswith("amdgcn") || arch.startswith("hsail")) {
+    addrSpaceMap[POCL_ADDRESS_SPACE_GLOBAL] = 1;
+    addrSpaceMap[POCL_ADDRESS_SPACE_LOCAL] = 3;
+    addrSpaceMap[POCL_ADDRESS_SPACE_CONSTANT] = 2;
   } else {
     /* Assume the fake address space map works directly in case not
        overridden here.  */
@@ -149,13 +206,6 @@ TargetAddressSpaces::runOnModule(llvm::Module &M) {
   }
 
   bool changed = false;
-  /* Handle global variables. */
-  llvm::Module::global_iterator globalI = M.global_begin();
-  llvm::Module::global_iterator globalE = M.global_end();
-  for (; globalI != globalE; ++globalI) {
-    llvm::Value &global = *globalI;
-    changed |= UpdateAddressSpace(global, addrSpaceMap);
-  }
 
   FunctionMapping funcReplacements;
   std::vector<llvm::Function*> unhandledFuncs;
@@ -215,8 +265,23 @@ TargetAddressSpaces::runOnModule(llvm::Module &M) {
     } asvtm(addrSpaceMap);
 
     CloneFunctionInto(newFunc, &F, vv, true, ri, "", NULL, &asvtm);
+    FixMemIntrinsics(*newFunc);
     funcReplacements[&F] = newFunc;
   }
+
+  /* Handle global variables. These should be fixed *after*
+     fixing the instruction referring to them.  If we fix
+     the address spaces before, there might be possible
+     illegal bitcasts casting the LLVM's global pointer to
+     another one, causing the CloneFunctionInto to crash when
+     it encounters such.
+   */
+  llvm::Module::global_iterator globalI = M.global_begin();
+  llvm::Module::global_iterator globalE = M.global_end();
+  for (; globalI != globalE; ++globalI) {
+    llvm::Value &global = *globalI;
+    changed |= UpdateAddressSpace(global, addrSpaceMap);
+  }
   
   /* Replace all references to the old function to the new one.
      Also, for LLVM 3.4, replace the pointercasts to bitcasts in
@@ -253,6 +318,7 @@ TargetAddressSpaces::runOnModule(llvm::Module &M) {
 #endif
         
         if (!isa<CallInst>(instr)) continue;
+
         llvm::CallInst *call = dyn_cast<CallInst>(instr);
         llvm::Function *calledF = call->getCalledFunction();
         if (funcReplacements.find(calledF) == funcReplacements.end()) continue;
@@ -280,10 +346,8 @@ TargetAddressSpaces::runOnModule(llvm::Module &M) {
         User* user = (*ui).getUser();
 #endif
         user->dump();
-                   
       }
-      
-      assert ("All users of the function were not fixed?" && 
+      assert ("All users of the function were not fixed?" &&
               i->first->getNumUses() == 0);
       break;
     }
diff --git a/lib/llvmopencl/VariableUniformityAnalysis.cc b/lib/llvmopencl/VariableUniformityAnalysis.cc
index d62d586..f9565ab 100644
--- a/lib/llvmopencl/VariableUniformityAnalysis.cc
+++ b/lib/llvmopencl/VariableUniformityAnalysis.cc
@@ -20,7 +20,12 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
+#include "CompilerWarnings.h"
+IGNORE_COMPILER_WARNING("-Wunused-parameter")
+
 #include "config.h"
+#include "pocl.h"
+
 #include <sstream>
 #include <iostream>
 
@@ -47,6 +52,8 @@
 #include "VariableUniformityAnalysis.h"
 #include "Barrier.h"
 
+POP_COMPILER_DIAGS
+
 //#define DEBUG_UNIFORMITY_ANALYSIS
 
 namespace pocl {
@@ -69,8 +76,13 @@ void
 VariableUniformityAnalysis::getAnalysisUsage(llvm::AnalysisUsage &AU) const {
   AU.addRequired<PostDominatorTree>();
   AU.addPreserved<PostDominatorTree>();
+#ifdef LLVM_OLDER_THAN_3_7
   AU.addRequired<LoopInfo>();
   AU.addPreserved<LoopInfo>();
+#else
+  AU.addRequired<LoopInfoWrapperPass>();
+  AU.addPreserved<LoopInfoWrapperPass>();
+#endif
   // required by LoopInfo:
 #if (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
   AU.addRequired<DominatorTree>();
@@ -86,7 +98,7 @@ VariableUniformityAnalysis::getAnalysisUsage(llvm::AnalysisUsage &AU) const {
 #elif (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
   AU.addRequired<DataLayout>();
   AU.addPreserved<DataLayout>();
-#else
+#elif (defined OLDER_THAN_LLVM_3_7)
   AU.addRequired<DataLayoutPass>();
   AU.addPreserved<DataLayoutPass>();
 #endif
@@ -107,7 +119,11 @@ VariableUniformityAnalysis::runOnFunction(Function &F) {
      If there's a canonical induction variable in loops, the variable
      update for each iteration should be uniform. Note: this does not yet imply
      all the work-items execute the loop same number of times! */
+#ifdef LLVM_OLDER_THAN_3_7
   llvm::LoopInfo &LI = getAnalysis<LoopInfo>();
+#else
+  llvm::LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
+#endif
   for (llvm::LoopInfo::iterator i = LI.begin(), e = LI.end(); i != e; ++i) {
     llvm::Loop *L = *i;
     if (llvm::PHINode *inductionVar = L->getCanonicalInductionVariable()) {
@@ -339,7 +355,7 @@ VariableUniformityAnalysis::isUniform(llvm::Function *f, llvm::Value* v) {
           isUniformAlloca = false;
           break;
         }
-      } else if (dyn_cast<llvm::LoadInst>(user) != NULL) {
+      } else if (isa<llvm::LoadInst>(user) || isa<llvm::BitCastInst>(user)) {
       } else {
 #ifdef DEBUG_UNIFORMITY_ANALYSIS
         std::cerr << "### alloca has a suspicious user" << std::endl;
diff --git a/lib/llvmopencl/WorkItemAliasAnalysis.cc b/lib/llvmopencl/WorkItemAliasAnalysis.cc
index adbb0d8..a46a79f 100644
--- a/lib/llvmopencl/WorkItemAliasAnalysis.cc
+++ b/lib/llvmopencl/WorkItemAliasAnalysis.cc
@@ -26,6 +26,10 @@
  *
  * @author Vladimír Guzma 2012
  */
+
+#include "CompilerWarnings.h"
+IGNORE_COMPILER_WARNING("-Wunused-parameter")
+
 #include "config.h"
 #include "pocl.h"
 #include <iostream>
@@ -39,18 +43,31 @@
 #else
 #include "llvm/IR/Metadata.h"
 #include "llvm/IR/Constants.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Module.h"
 #endif
 
+POP_COMPILER_DIAGS
+
+
 using namespace llvm;
 
 namespace {
+
+#ifdef LLVM_OLDER_THAN_3_7
+typedef AliasAnalysis::AliasResult AliasResult;
+#else
+typedef llvm::MemoryLocation Location;
+typedef llvm::AliasResult AliasResult;
+#endif
+
 /// WorkItemAliasAnalysis - This is a simple alias analysis
 /// implementation that uses pocl metadata to make sure memory accesses from
 /// different work items are not aliasing.
-class WorkItemAliasAnalysis : public ImmutablePass, public AliasAnalysis {
+class WorkItemAliasAnalysis : public FunctionPass, public AliasAnalysis {
 public:
     static char ID; 
-    WorkItemAliasAnalysis() : ImmutablePass(ID) {}
+    WorkItemAliasAnalysis() : FunctionPass(ID) {}
 
     /// getAdjustedAnalysisPointer - This method is used when a pass implements
     /// an analysis interface through multiple inheritance.  If needed, it
@@ -61,14 +78,26 @@ public:
             return (AliasAnalysis*)this;
         return this;
     }
+
+
+#ifdef LLVM_OLDER_THAN_3_7
     virtual void initializePass() {
         InitializeAliasAnalysis(this);
     }
+    virtual bool runOnFunction(llvm::Function &) {
+      InitializeAliasAnalysis(this);
+      return false;
+    }
+#else
+    virtual bool runOnFunction(llvm::Function &F) {
+      InitializeAliasAnalysis(this, &F.getParent()->getDataLayout());
+      return false;
+    }
+#endif
     
     private:
         virtual void getAnalysisUsage(AnalysisUsage &AU) const;
         virtual AliasResult alias(const Location &LocA, const Location &LocB);
-
     };
 }
 
@@ -79,12 +108,12 @@ RegisterPass<WorkItemAliasAnalysis>
 // Register it also to pass group
 RegisterAnalysisGroup<AliasAnalysis> Y(X);  
 
-ImmutablePass *createWorkItemAliasAnalysisPass() {
+FunctionPass *createWorkItemAliasAnalysisPass() {
     return new WorkItemAliasAnalysis();
 }
 
 extern "C" {                                
-    ImmutablePass*
+    FunctionPass*
     create_workitem_aa_plugin() {
         return new WorkItemAliasAnalysis();
     }
@@ -101,9 +130,9 @@ WorkItemAliasAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
  * Test if memory locations are from different work items from same region.
  * Then they can not alias.
  */
-AliasAnalysis::AliasResult
+AliasResult
 WorkItemAliasAnalysis::alias(const Location &LocA,
-                                    const Location &LocB) {
+                             const Location &LocB) {
     // If either of the memory references is empty, it doesn't matter what the
     // pointer values are. This allows the code below to ignore this special
     // case.
diff --git a/lib/llvmopencl/Workgroup.cc b/lib/llvmopencl/Workgroup.cc
index 5c3f886..d06bd71 100644
--- a/lib/llvmopencl/Workgroup.cc
+++ b/lib/llvmopencl/Workgroup.cc
@@ -2,6 +2,7 @@
 // and parallelized kernel for an OpenCL workgroup.
 // 
 // Copyright (c) 2011 Universidad Rey Juan Carlos
+//               2012-2015 Pekka Jääskeläinen
 // 
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
@@ -21,6 +22,9 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
+#include "CompilerWarnings.h"
+IGNORE_COMPILER_WARNING("-Wunused-parameter")
+
 #include "Barrier.h"
 #include "Workgroup.h"
 
@@ -71,6 +75,8 @@
 
 #define STRING_LENGTH 32
 
+POP_COMPILER_DIAGS
+
 using namespace std;
 using namespace llvm;
 using namespace pocl;
@@ -81,7 +87,6 @@ static void createWorkgroup(Module &M, Function *F);
 static void createWorkgroupFast(Module &M, Function *F);
 
 // extern cl::opt<string> Header;
-// extern cl::list<int> LocalSize;
 
 /* The kernel to process in this kernel compiler launch. */
 cl::opt<string>
@@ -171,8 +176,7 @@ Workgroup::runOnModule(Module &M)
     {
       assert (false && "Target has an unsupported pointer width.");
     }  
-#else
-// FIXME 0 here is the address space - this breaks (?) if _local_size_x is not stored in AS0
+#elif (defined LLVM_3_5 || defined LLVM_3_6)
   if (M.getDataLayout()->getPointerSize(0) == 8)
     {
       TypeBuilder<PoclContext, true>::setSizeTWidth(64);
@@ -185,6 +189,19 @@ Workgroup::runOnModule(Module &M)
     {
       assert (false && "Target has an unsupported pointer width.");
     }
+#else
+  if (M.getDataLayout().getPointerSize(0) == 8)
+    {
+      TypeBuilder<PoclContext, true>::setSizeTWidth(64);
+    }
+  else if (M.getDataLayout().getPointerSize(0) == 4)
+    {
+      TypeBuilder<PoclContext, true>::setSizeTWidth(32);
+    }
+  else 
+    {
+      assert (false && "Target has an unsupported pointer width.");
+    }
 #endif
 
   for (Module::iterator i = M.begin(), e = M.end(); i != e; ++i) {
@@ -237,7 +254,7 @@ createLauncher(Module &M, Function *F)
 
   Function *L = Function::Create(ft,
 				 Function::ExternalLinkage,
-				 "_" + funcName,
+				 "_pocl_launcher_" + funcName,
 				 &M);
 
   SmallVector<Value *, 8> arguments;
@@ -257,8 +274,13 @@ createLauncher(Module &M, Function *F)
 
   IRBuilder<> builder(BasicBlock::Create(M.getContext(), "", L));
 
+#if defined LLVM_OLDER_THAN_3_7
   ptr = builder.CreateStructGEP(ai,
 				TypeBuilder<PoclContext, true>::WORK_DIM);
+#else
+  ptr = builder.CreateStructGEP(ai->getType()->getPointerElementType(), ai,
+                                TypeBuilder<PoclContext, true>::WORK_DIM);
+#endif
   gv = M.getGlobalVariable("_work_dim");
   if (gv != NULL) {
     v = builder.CreateLoad(builder.CreateConstGEP1_32(ptr, 0));
@@ -269,14 +291,20 @@ createLauncher(Module &M, Function *F)
   int size_t_width = 32;
 #if (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
   if (M.getPointerSize() == llvm::Module::Pointer64)
-#else
-  //FIXME 0 here is the address space: this breaks (?) if _local_size_x is not stored in AS0
+#elif (defined LLVM_OLDER_THAN_3_7)
   if (M.getDataLayout()->getPointerSize(0) == 8)
+#else
+  if (M.getDataLayout().getPointerSize(0) == 8)
 #endif
     size_t_width = 64;
 
+#if defined LLVM_OLDER_THAN_3_7
   ptr = builder.CreateStructGEP(ai,
 				TypeBuilder<PoclContext, true>::GROUP_ID);
+#else
+  ptr = builder.CreateStructGEP(ai->getType()->getPointerElementType(), ai,
+                                TypeBuilder<PoclContext, true>::GROUP_ID);
+#endif
   for (int i = 0; i < 3; ++i) {
     snprintf(s, STRING_LENGTH, "_group_id_%c", 'x' + i);
     gv = M.getGlobalVariable(s);
@@ -287,14 +315,23 @@ createLauncher(Module &M, Function *F)
         }
       else
         {
+#ifdef LLVM_OLDER_THAN_3_7
           v = builder.CreateLoad(builder.CreateConstGEP2_32(ptr, 0, i));
+#else
+          v = builder.CreateLoad(builder.CreateConstGEP2_32(ptr->getType()->getPointerElementType(), ptr, 0, i));
+#endif
         }
       builder.CreateStore(v, gv);
     }
   }
 
+#ifdef LLVM_OLDER_THAN_3_7
   ptr = builder.CreateStructGEP(ai,
 				TypeBuilder<PoclContext, true>::NUM_GROUPS);
+#else
+  ptr = builder.CreateStructGEP(ai->getType()->getPointerElementType(), ai,
+                                TypeBuilder<PoclContext, true>::NUM_GROUPS);
+#endif
   for (int i = 0; i < 3; ++i) {
     snprintf(s, STRING_LENGTH, "_num_groups_%c", 'x' + i);
     gv = M.getGlobalVariable(s);
@@ -305,14 +342,23 @@ createLauncher(Module &M, Function *F)
         }
       else 
         {
+#ifdef LLVM_OLDER_THAN_3_7
           v = builder.CreateLoad(builder.CreateConstGEP2_32(ptr, 0, i));
+#else
+          v = builder.CreateLoad(builder.CreateConstGEP2_32(ptr->getType()->getPointerElementType(), ptr, 0, i));
+#endif
         }
       builder.CreateStore(v, gv);
     }
   }
 
+#ifdef LLVM_OLDER_THAN_3_7
   ptr = builder.CreateStructGEP(ai,
 				TypeBuilder<PoclContext, true>::GLOBAL_OFFSET);
+#else
+  ptr = builder.CreateStructGEP(ai->getType()->getPointerElementType(), ai,
+                                TypeBuilder<PoclContext, true>::GLOBAL_OFFSET);
+#endif
   for (int i = 0; i < 3; ++i) {
     snprintf(s, STRING_LENGTH, "_global_offset_%c", 'x' + i);
     gv = M.getGlobalVariable(s);
@@ -323,7 +369,11 @@ createLauncher(Module &M, Function *F)
         }
       else
         {
+#ifdef LLVM_OLDER_THAN_3_7
           v = builder.CreateLoad(builder.CreateConstGEP2_32(ptr, 0, i));
+#else
+          v = builder.CreateLoad(builder.CreateConstGEP2_32(ptr->getType()->getPointerElementType(), ptr, 0, i));
+#endif
         }
       builder.CreateStore(v, gv);
     }
@@ -561,6 +611,12 @@ createWorkgroupFast(Module &M, Function *F)
     dyn_cast<Function>(M.getOrInsertFunction(funcName + "_workgroup_fast", ft));
   assert(workgroup != NULL);
 
+#if defined LLVM_3_2
+  workgroup->addFnAttr(Attributes::NoInline);
+#else
+  workgroup->addFnAttr(Attribute::NoInline);
+#endif
+
   builder.SetInsertPoint(BasicBlock::Create(M.getContext(), "", workgroup));
 
   Function::arg_iterator ai = workgroup->arg_begin();
@@ -592,15 +648,24 @@ createWorkgroupFast(Module &M, Function *F)
 
     /* If it's a pass by value pointer argument, we just pass the pointer
      * as is to the function, no need to load from it first. */
+    Value *value;
 #if defined(LLVM_3_2) || defined(LLVM_3_3)
-    Value *value = builder.CreateBitCast
-      (pointer, t->getPointerTo(POCL_ADDRESS_SPACE_GLOBAL));
+    if (!ii->hasByValAttr() || ((PointerType*)t)->getAddressSpace() == 1)
+      value = builder.CreateBitCast
+        (pointer, t->getPointerTo(POCL_ADDRESS_SPACE_GLOBAL));
+    else
+      value = builder.CreateBitCast(pointer, t->getPointerTo());
 #else
-    Value *value = builder.CreatePointerCast
-      (pointer, t->getPointerTo(POCL_ADDRESS_SPACE_GLOBAL));
+
+    if (!ii->hasByValAttr() || ((PointerType*)t)->getAddressSpace() == 1)
+      value = builder.CreatePointerCast
+        (pointer, t->getPointerTo(POCL_ADDRESS_SPACE_GLOBAL));
+    else
+      value = builder.CreatePointerCast(pointer, t->getPointerTo());
+
 #endif
     if (!ii->hasByValAttr()) {
-        value = builder.CreateLoad(value);
+      value = builder.CreateLoad(value);
     }
     
     arguments.push_back(value);
diff --git a/lib/llvmopencl/WorkitemHandler.cc b/lib/llvmopencl/WorkitemHandler.cc
index 3c6d56e..544d52f 100644
--- a/lib/llvmopencl/WorkitemHandler.cc
+++ b/lib/llvmopencl/WorkitemHandler.cc
@@ -2,7 +2,7 @@
 // in a work group.
 // 
 // Copyright (c) 2011-2012 Carlos Sánchez de La Lama / URJC and
-//               2012-2014 Pekka Jääskeläinen / TUT
+//               2012-2015 Pekka Jääskeläinen / TUT
 // 
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
@@ -22,6 +22,9 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
+#include "CompilerWarnings.h"
+IGNORE_COMPILER_WARNING("-Wunused-parameter")
+
 #include "config.h"
 #include <sstream>
 #include <iostream>
@@ -45,16 +48,21 @@
 #include "DebugHelpers.h"
 #include "pocl.h"
 
+POP_COMPILER_DIAGS
+
 //#define DEBUG_REFERENCE_FIXING
 
 namespace pocl {
 
 using namespace llvm;
 
-llvm::cl::list<int>
-LocalSize("local-size",
-          llvm::cl::desc("Local size (x y z)"),
-          llvm::cl::multi_val(3));
+/* This is used to communicate the work-group dimensions of the currently
+   compiled kernel command to the workitem loop. 
+
+   TODO: Something cleaner than a global value. */
+size_t WGLocalSizeX = 1;
+size_t WGLocalSizeY = 1;
+size_t WGLocalSizeZ = 1;
 
 cl::opt<bool>
 AddWIMetadata("add-wi-metadata", cl::init(false), cl::Hidden,
@@ -65,7 +73,7 @@ WorkitemHandler::WorkitemHandler(char& ID) : FunctionPass(ID) {
 }
 
 bool
-WorkitemHandler::runOnFunction(Function &F) {
+WorkitemHandler::runOnFunction(Function &) {
   return false;
 }
 
@@ -74,11 +82,13 @@ WorkitemHandler::Initialize(Kernel *K) {
 
   llvm::Module *M = K->getParent();
   
-  LocalSizeX = LocalSize[0];
-  LocalSizeY = LocalSize[1];
-  LocalSizeZ = LocalSize[2];
-  
-  llvm::NamedMDNode *size_info = M->getNamedMetadata("opencl.kernel_wg_size_info");
+  // Check that the dynamically set local size and a possible
+  // required WG size match.
+  size_t LocalSizeX = WGLocalSizeX, LocalSizeY = WGLocalSizeY, 
+      LocalSizeZ = WGLocalSizeZ;
+ 
+  llvm::NamedMDNode *size_info = 
+    M->getNamedMetadata("opencl.kernel_wg_size_info");
   if (size_info) {
     for (unsigned i = 0, e = size_info->getNumOperands(); i != e; ++i) {
       llvm::MDNode *KernelSizeInfo = size_info->getOperand(i);
@@ -107,6 +117,15 @@ WorkitemHandler::Initialize(Kernel *K) {
     }
   }
 
+  // This funny looking check is to silence a compiler warning that we 
+  // do not ignore the LocalSize* variables. Even in a NDEBUG build.
+  // TODO: how to handle the case in a NDEBUG build when they don't match?
+  if( !(LocalSizeX == WGLocalSizeX && LocalSizeY == WGLocalSizeY && 
+          LocalSizeZ == WGLocalSizeZ) ){
+     assert(false && "Local sizes don't match");
+     return;
+  }
+
   llvm::Type *localIdType; 
   size_t_width = 0;
 #if (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
@@ -116,13 +135,20 @@ WorkitemHandler::Initialize(Kernel *K) {
     size_t_width = 32;
   else
     assert (false && "Only 32 and 64 bit size_t widths supported.");
-#else
+#elif (defined LLVM_OLDER_THAN_3_7)
   if (M->getDataLayout()->getPointerSize(0) == 8)
     size_t_width = 64;
   else if (M->getDataLayout()->getPointerSize(0) == 4)
     size_t_width = 32;
   else
     assert (false && "Only 32 and 64 bit size_t widths supported.");
+#else
+  if (M->getDataLayout().getPointerSize(0) == 8)
+    size_t_width = 64;
+  else if (M->getDataLayout().getPointerSize(0) == 4)
+    size_t_width = 32;
+  else
+    assert (false && "Only 32 and 64 bit size_t widths supported.");
 #endif
 
   localIdType = IntegerType::get(K->getContext(), size_t_width);
diff --git a/lib/llvmopencl/WorkitemHandler.h b/lib/llvmopencl/WorkitemHandler.h
index 2e67f72..b42682c 100644
--- a/lib/llvmopencl/WorkitemHandler.h
+++ b/lib/llvmopencl/WorkitemHandler.h
@@ -24,6 +24,9 @@
 #ifndef _POCL_WORKITEM_HANDLER_H
 #define _POCL_WORKITEM_HANDLER_H
 
+#include "CompilerWarnings.h"
+IGNORE_COMPILER_WARNING("-Wunused-parameter")
+
 #include "config.h"
 #if (defined LLVM_3_1 || defined LLVM_3_2)
 #include "llvm/Function.h"
@@ -38,6 +41,8 @@
 #include "llvm/Pass.h"
 #include "llvm/Support/CommandLine.h"
 
+POP_COMPILER_DIAGS
+
 namespace llvm {
   class DominatorTree;
 }
@@ -67,8 +72,6 @@ namespace pocl {
     bool dominatesUse(llvm::DominatorTreeWrapperPass *DT, llvm::Instruction &I, unsigned i);
     #endif
 
-    int LocalSizeX, LocalSizeY, LocalSizeZ;
-
     unsigned size_t_width;
 
     /* The global variables that store the current local id. */
@@ -78,6 +81,10 @@ namespace pocl {
 
   extern llvm::cl::opt<bool> AddWIMetadata;
   extern llvm::cl::opt<int> LockStepSIMDWidth;
+
+  extern size_t WGLocalSizeX;
+  extern size_t WGLocalSizeY;
+  extern size_t WGLocalSizeZ;
 }
 
 #endif
diff --git a/lib/llvmopencl/WorkitemHandlerChooser.cc b/lib/llvmopencl/WorkitemHandlerChooser.cc
index ee723ca..8fac3b2 100644
--- a/lib/llvmopencl/WorkitemHandlerChooser.cc
+++ b/lib/llvmopencl/WorkitemHandlerChooser.cc
@@ -91,13 +91,13 @@ WorkitemHandlerChooser::runOnFunction(Function &F)
 
   if (method == "auto") 
     {
-      int ReplThreshold = 2;
+      unsigned ReplThreshold = 2;
       if (getenv("POCL_FULL_REPLICATION_THRESHOLD") != NULL) 
       {
         ReplThreshold = atoi(getenv("POCL_FULL_REPLICATION_THRESHOLD"));
       }
       
-      if (LocalSizeX*LocalSizeY*LocalSizeZ <= ReplThreshold)
+      if (WGLocalSizeX*WGLocalSizeY*WGLocalSizeZ <= ReplThreshold)
         {
           chosenHandler_ = POCL_WIH_FULL_REPLICATION;
         }
diff --git a/lib/llvmopencl/WorkitemLoops.cc b/lib/llvmopencl/WorkitemLoops.cc
index fb81d65..859bbc1 100644
--- a/lib/llvmopencl/WorkitemLoops.cc
+++ b/lib/llvmopencl/WorkitemLoops.cc
@@ -43,7 +43,6 @@
 #elif defined LLVM_3_2
 #include "llvm/IRBuilder.h"
 #include "llvm/TypeBuilder.h"
-#include "llvm/DataLayout.h"
 #include "llvm/Instructions.h"
 #include "llvm/Module.h"
 #include "llvm/ValueSymbolTable.h"
@@ -91,16 +90,18 @@ WorkitemLoops::getAnalysisUsage(AnalysisUsage &AU) const
 {
 
   AU.addRequired<PostDominatorTree>();
+#ifdef LLVM_OLDER_THAN_3_7
   AU.addRequired<LoopInfo>();
+#else
+  AU.addRequired<LoopInfoWrapperPass>();
+#endif
 #ifdef LLVM_3_1
   AU.addRequired<TargetData>();
 #endif
 #if (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
   AU.addRequired<DominatorTree>();
-  AU.addRequired<DataLayout>();
 #else
   AU.addRequired<DominatorTreeWrapperPass>();
-  AU.addRequired<DataLayoutPass>();
 #endif
 
   AU.addRequired<VariableUniformityAnalysis>();
@@ -127,7 +128,11 @@ WorkitemLoops::runOnFunction(Function &F)
   DTP = &getAnalysis<DominatorTreeWrapperPass>();
   DT = &DTP->getDomTree();
   #endif
+#ifdef LLVM_OLDER_THAN_3_7
   LI = &getAnalysis<LoopInfo>();
+#else
+  LI = &getAnalysis<LoopInfoWrapperPass>();
+#endif
   PDT = &getAnalysis<PostDominatorTree>();
 
   tempInstructionIndex = 0;
@@ -309,11 +314,14 @@ WorkitemLoops::CreateLoopAround
 
   /* This creation of the identifier metadata is copied from
      LLVM's MDBuilder::createAnonymousTBAARoot(). */
-#ifdef LLVM_OLDER_THAN_3_6
+#ifdef LLVM_3_7
+  MDNode *Dummy = MDNode::getTemporary(C, ArrayRef<Metadata*>()).release();
+#elif LLVM_OLDER_THAN_3_6
   MDNode *Dummy = MDNode::getTemporary(C, ArrayRef<Value*>());
-#else
+#elif LLVM_OLDER_THAN_3_7
   MDNode *Dummy = MDNode::getTemporary(C, ArrayRef<Metadata*>());
 #endif
+
   MDNode *Root = MDNode::get(C, Dummy);
   // At this point we have
   //   !0 = metadata !{}            <- dummy
@@ -331,6 +339,7 @@ WorkitemLoops::CreateLoopAround
 #endif
   region.AddParallelLoopMetadata(Root);
 
+
   builder.SetInsertPoint(loopEndBB);
   builder.CreateBr(oldExit);
 
@@ -356,17 +365,20 @@ WorkitemLoops::ProcessFunction(Function &F)
 {
   Kernel *K = cast<Kernel> (&F);
   Initialize(K);
-  unsigned workItemCount = LocalSizeX*LocalSizeY*LocalSizeZ;
+  unsigned workItemCount = WGLocalSizeX*WGLocalSizeY*WGLocalSizeZ;
 
   if (workItemCount == 1)
     {
-      K->addLocalSizeInitCode(LocalSizeX, LocalSizeY, LocalSizeZ);
+      K->addLocalSizeInitCode(WGLocalSizeX, WGLocalSizeY, WGLocalSizeZ);
       ParallelRegion::insertLocalIdInit(&F.getEntryBlock(), 0, 0, 0);
       return true;
     }
 
-  original_parallel_regions =
-    K->getParallelRegions(LI);
+#ifdef LLVM_OLDER_THAN_3_7
+  original_parallel_regions = K->getParallelRegions(LI);
+#else
+  original_parallel_regions = K->getParallelRegions(&LI->getLoopInfo());
+#endif
 
 #ifdef DUMP_CFGS
   F.dump();
@@ -484,7 +496,7 @@ WorkitemLoops::ProcessFunction(Function &F)
             preds.push_back(bb);
           }
 
-        int unrollCount;
+        unsigned unrollCount;
         if (getenv("POCL_WILOOPS_MAX_UNROLL_COUNT") != NULL)
             unrollCount = atoi(getenv("POCL_WILOOPS_MAX_UNROLL_COUNT"));
         else
@@ -492,8 +504,8 @@ WorkitemLoops::ProcessFunction(Function &F)
         /* Find a two's exponent unroll count, if available. */
         while (unrollCount >= 1)
           {
-            if (LocalSizeX % unrollCount == 0 &&
-                unrollCount <= LocalSizeX)
+            if (WGLocalSizeX % unrollCount == 0 &&
+                unrollCount <= WGLocalSizeX)
               {
                 break;
               }
@@ -510,7 +522,7 @@ WorkitemLoops::ProcessFunction(Function &F)
             if (AddWIMetadata)
                 original->AddIDMetadata(F.getContext(), 0);
 
-            for (int c = 1; c < unrollCount; ++c) 
+            for (unsigned c = 1; c < unrollCount; ++c) 
             {
                 ParallelRegion *unrolled = 
                     original->replicate(reference_map, ".unrolled_wi");
@@ -527,14 +539,20 @@ WorkitemLoops::ProcessFunction(Function &F)
         }
       }
 
-    if (LocalSizeX > 1)
-      l = CreateLoopAround(*original, l.first, l.second, peelFirst, localIdX, LocalSizeX, !unrolled);
+    if (WGLocalSizeX > 1)
+      l = CreateLoopAround(
+        *original, l.first, l.second, peelFirst, 
+        localIdX, WGLocalSizeX, !unrolled);
 
-    if (LocalSizeY > 1)
-      l = CreateLoopAround(*original, l.first, l.second, false, localIdY, LocalSizeY);
+    if (WGLocalSizeY > 1)
+      l = CreateLoopAround(
+        *original, l.first, l.second, 
+        false, localIdY, WGLocalSizeY);
 
-    if (LocalSizeZ > 1)
-      l = CreateLoopAround(*original, l.first, l.second, false, localIdZ, LocalSizeZ);
+    if (WGLocalSizeZ > 1)
+      l = CreateLoopAround(
+          *original, l.first, l.second, 
+          false, localIdZ, WGLocalSizeZ);
 
     /* Loop edges coming from another region mean B-loops which means 
        we have to fix the loop edge to jump to the beginning of the wi-loop 
@@ -571,7 +589,7 @@ WorkitemLoops::ProcessFunction(Function &F)
        localIdXFirstVar);       
   }
 
-  K->addLocalSizeInitCode(LocalSizeX, LocalSizeY, LocalSizeZ);
+  K->addLocalSizeInitCode(WGLocalSizeX, WGLocalSizeY, WGLocalSizeZ);
   ParallelRegion::insertLocalIdInit(&F.getEntryBlock(), 0, 0, 0);
 
 #if 0
@@ -809,8 +827,8 @@ WorkitemLoops::GetContextArray(llvm::Instruction *instruction)
     ArrayType::get(
         ArrayType::get(
             ArrayType::get(
-                elementType, LocalSizeX), 
-            LocalSizeY), LocalSizeZ);
+                elementType, WGLocalSizeX), 
+            WGLocalSizeY), WGLocalSizeZ);
 
   /* Allocate the context data array for the variable. */
   llvm::AllocaInst *alloca = 
diff --git a/lib/llvmopencl/WorkitemLoops.h b/lib/llvmopencl/WorkitemLoops.h
index 8a77b9f..7c4429d 100644
--- a/lib/llvmopencl/WorkitemLoops.h
+++ b/lib/llvmopencl/WorkitemLoops.h
@@ -23,6 +23,8 @@
 #ifndef _POCL_WORKITEM_LOOPS_H
 #define _POCL_WORKITEM_LOOPS_H
 
+#include "pocl.h"
+
 #if (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
 #include "llvm/Analysis/Dominators.h"
 #endif
@@ -60,7 +62,11 @@ namespace pocl {
     typedef std::map<std::string, llvm::Instruction*> StrInstructionMap;
 
     llvm::DominatorTree *DT;
+#ifdef LLVM_OLDER_THAN_3_7
     llvm::LoopInfo *LI;
+#else
+    llvm::LoopInfoWrapperPass *LI;
+#endif
     llvm::PostDominatorTree *PDT;
 #if ! (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
     llvm::DominatorTreeWrapperPass *DTP;
diff --git a/lib/llvmopencl/WorkitemReplication.cc b/lib/llvmopencl/WorkitemReplication.cc
index 19e6f1e..2c52acf 100644
--- a/lib/llvmopencl/WorkitemReplication.cc
+++ b/lib/llvmopencl/WorkitemReplication.cc
@@ -2,7 +2,7 @@
 // in a work group.
 // 
 // Copyright (c) 2011-2012 Carlos Sánchez de La Lama / URJC and
-//               2011-2014 Pekka Jääskeläinen / TUT
+//               2011-2015 Pekka Jääskeläinen / TUT
 // 
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
@@ -24,6 +24,9 @@
 
 #define DEBUG_TYPE "workitem"
 
+#include "CompilerWarnings.h"
+IGNORE_COMPILER_WARNING("-Wunused-parameter")
+
 #include "WorkitemReplication.h"
 #include "Workgroup.h"
 #include "Barrier.h"
@@ -32,6 +35,8 @@
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Support/CommandLine.h"
 #include "config.h"
+#include "pocl.h"
+
 #ifdef LLVM_3_1
 #include "llvm/Support/IRBuilder.h"
 #include "llvm/Target/TargetData.h"
@@ -69,6 +74,8 @@
 #include "llvm/Analysis/CFGPrinter.h"
 #endif
 
+POP_COMPILER_DIAGS
+
 using namespace llvm;
 using namespace pocl;
 
@@ -91,12 +98,16 @@ WorkitemReplication::getAnalysisUsage(AnalysisUsage &AU) const
   AU.addRequired<DominatorTreeWrapperPass>();
 #endif
 
+#ifdef LLVM_OLDER_THAN_3_7
   AU.addRequired<LoopInfo>();
+#else
+  AU.addRequired<LoopInfoWrapperPass>();
+#endif
 #ifdef LLVM_3_1
   AU.addRequired<TargetData>();
 #elif (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
   AU.addRequired<DataLayout>();
-#else
+#elif (defined LLVM_OLDER_THAN_3_7)
   AU.addRequired<DataLayoutPass>();
 #endif
   AU.addRequired<pocl::WorkitemHandlerChooser>();
@@ -120,7 +131,11 @@ WorkitemReplication::runOnFunction(Function &F)
   DT = &DTP->getDomTree();
   #endif
 
+#ifdef LLVM_OLDER_THAN_3_7
   LI = &getAnalysis<LoopInfo>();
+#else
+  LI = &getAnalysis<LoopInfoWrapperPass>();
+#endif
 
   bool changed = ProcessFunction(F);
 #ifdef DUMP_RESULT_CFG
@@ -148,7 +163,9 @@ WorkitemReplication::ProcessFunction(Function &F)
 
   // Allocate space for workitem reference maps. Workitem 0 does
   // not need it.
-  unsigned workitem_count = LocalSizeZ * LocalSizeY * LocalSizeX;
+  unsigned workitem_count = WGLocalSizeZ * WGLocalSizeY * WGLocalSizeX;
+
+  assert (workitem_count > 0);
 
   BasicBlockVector original_bbs;
   for (Function::iterator i = F.begin(), e = F.end(); i != e; ++i) {
@@ -156,8 +173,13 @@ WorkitemReplication::ProcessFunction(Function &F)
         original_bbs.push_back(i);
   }
 
+#ifdef LLVM_OLDER_THAN_3_7
   ParallelRegion::ParallelRegionVector* original_parallel_regions =
     K->getParallelRegions(LI);
+#else
+  ParallelRegion::ParallelRegionVector* original_parallel_regions =
+    K->getParallelRegions(&LI->getLoopInfo());
+#endif
 
   std::vector<ParallelRegion::ParallelRegionVector> parallel_regions(
       workitem_count);
@@ -184,8 +206,10 @@ WorkitemReplication::ProcessFunction(Function &F)
   TargetData &TD = getAnalysis<TargetData>();
 #elif (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
   DataLayout &TD = getAnalysis<DataLayout>();
-#else
+#elif (defined LLVM_OLDER_THAN_3_7)
   const DataLayout &TD = getAnalysis<DataLayoutPass>().getDataLayout();
+#else
+  const DataLayout &TD = F.getParent()->getDataLayout();
 #endif
 
   for (SmallVector<ParallelRegion *, 8>::iterator
@@ -222,13 +246,14 @@ WorkitemReplication::ProcessFunction(Function &F)
   }
 
   // Then replicate the ParallelRegions.  
-  ValueToValueMapTy *const reference_map = new ValueToValueMapTy[workitem_count - 1];
-  for (int z = 0; z < LocalSizeZ; ++z) {
-    for (int y = 0; y < LocalSizeY; ++y) {
-      for (int x = 0; x < LocalSizeX ; ++x) {
+  ValueToValueMapTy *const reference_map = 
+    new ValueToValueMapTy[workitem_count - 1];
+  for (unsigned z = 0; z < WGLocalSizeZ; ++z) {
+    for (unsigned y = 0; y < WGLocalSizeY; ++y) {
+      for (unsigned x = 0; x < WGLocalSizeX ; ++x) {
               
         int index = 
-          (LocalSizeY * LocalSizeX * z + LocalSizeX * y + x);
+          (WGLocalSizeY * WGLocalSizeX * z + WGLocalSizeX * y + x);
 	  
         if (index == 0)
           continue;
@@ -263,12 +288,12 @@ WorkitemReplication::ProcessFunction(Function &F)
     }
   }  
   
-  for (int z = 0; z < LocalSizeZ; ++z) {
-    for (int y = 0; y < LocalSizeY; ++y) {
-      for (int x = 0; x < LocalSizeX ; ++x) {
+  for (unsigned z = 0; z < WGLocalSizeZ; ++z) {
+    for (unsigned y = 0; y < WGLocalSizeY; ++y) {
+      for (unsigned x = 0; x < WGLocalSizeX ; ++x) {
 	  
         int index = 
-          (LocalSizeY * LocalSizeX * z + LocalSizeX * y + x);
+          (WGLocalSizeY * WGLocalSizeX * z + WGLocalSizeX * y + x);
         
         for (unsigned i = 0, e = parallel_regions[index].size(); i != e; ++i) {
           ParallelRegion *region = parallel_regions[index][i];
@@ -294,12 +319,12 @@ WorkitemReplication::ProcessFunction(Function &F)
   // region copys to the entry BB of the first copy to retain
   // their semantics for branches from outside the parallel
   // region to the beginning of the region copy chain.
-  for (int z = LocalSizeZ - 1; z >= 0; --z) {
-    for (int y = LocalSizeY - 1; y >= 0; --y) {
-      for (int x = LocalSizeX - 1; x >= 0; --x) {
+  for (int z = WGLocalSizeZ - 1; z >= 0; --z) {
+    for (int y = WGLocalSizeY - 1; y >= 0; --y) {
+      for (int x = WGLocalSizeX - 1; x >= 0; --x) {
           
         int index = 
-          (LocalSizeY * LocalSizeX * z + LocalSizeX * y + x);
+          (WGLocalSizeY * WGLocalSizeX * z + WGLocalSizeX * y + x);
 
         if (index == 0)
           continue;
@@ -330,7 +355,7 @@ WorkitemReplication::ProcessFunction(Function &F)
 
   // Initialize local size variables (done at the end to avoid unnecessary
   // replication).
-  K->addLocalSizeInitCode(LocalSizeX, LocalSizeY, LocalSizeZ);
+  K->addLocalSizeInitCode(WGLocalSizeX, WGLocalSizeY, WGLocalSizeZ);
 
   delete [] reference_map;
 
diff --git a/lib/llvmopencl/WorkitemReplication.h b/lib/llvmopencl/WorkitemReplication.h
index 9c17953..843ec4a 100644
--- a/lib/llvmopencl/WorkitemReplication.h
+++ b/lib/llvmopencl/WorkitemReplication.h
@@ -1,7 +1,7 @@
 // Header for WorkitemReplication function pass.
 // 
 // Copyright (c) 2011 Universidad Rey Juan Carlos and
-//               2012 Pekka Jääskeläinen / TUT
+//               2012-2015 Pekka Jääskeläinen / TUT
 // 
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
@@ -25,6 +25,8 @@
 #define _POCL_WORKITEM_REPLICATION_H
 
 #include "config.h"
+#include "pocl.h"
+
 #if (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
 #include "llvm/Analysis/Dominators.h"
 #else
@@ -54,10 +56,15 @@ namespace pocl {
   private:
 
     llvm::DominatorTree *DT;
-    #if ! (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
+#if ! (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
     llvm::DominatorTreeWrapperPass *DTP;
-    #endif
+#endif
+
+#ifdef LLVM_OLDER_THAN_3_7
     llvm::LoopInfo *LI;
+#else
+    llvm::LoopInfoWrapperPass *LI;
+#endif
 
     typedef std::set<llvm::BasicBlock *> BasicBlockSet;
     typedef std::vector<llvm::BasicBlock *> BasicBlockVector;
diff --git a/lib/llvmopencl/linker.cpp b/lib/llvmopencl/linker.cpp
index b2c5f20..3208b1b 100644
--- a/lib/llvmopencl/linker.cpp
+++ b/lib/llvmopencl/linker.cpp
@@ -241,20 +241,22 @@ link(llvm::Module *krn, const llvm::Module *lib)
 
     // copy any aliases to krn
     DB_PRINT("cloning the aliases:\n");
-    llvm::Module::const_alias_iterator ai,ae;
-    for (ai=lib->alias_begin(), ae=lib->alias_end();
+    llvm::Module::const_alias_iterator ai, ae;
+    for (ai = lib->alias_begin(), ae = lib->alias_end();
          ai != ae;
          ai++) {
         DB_PRINT(" %s\n", ai->getName().data());
-        GlobalAlias *GA=
+        GlobalAlias *GA =
 #if (defined LLVM_3_2 || defined LLVM_3_3 || defined LLVM_3_4)
             new GlobalAlias(ai->getType(), ai->getLinkage(),
                             ai->getName(), NULL, krn);
-#else
-
+#elif (defined LLVM_OLDER_THAN_3_7)
             GlobalAlias::create(ai->getType(),
                                 ai->getType()->getAddressSpace(),
                                 ai->getLinkage(), ai->getName(), NULL, krn);
+#else
+            GlobalAlias::create(ai->getType(),
+                                ai->getLinkage(), ai->getName(), NULL, krn);
 #endif
 
         GA->copyAttributesFrom(ai);
diff --git a/lib/poclu/CMakeLists.txt b/lib/poclu/CMakeLists.txt
index f7faf45..17fc6a1 100644
--- a/lib/poclu/CMakeLists.txt
+++ b/lib/poclu/CMakeLists.txt
@@ -31,8 +31,7 @@ add_library("poclu" bswap.c misc.c cl_half.c)
 set_target_properties("poclu" PROPERTIES SOVERSION "${LIB_API_VERSION}" VERSION "${LIB_BUILD_VERSION}")
 
 #libpoclu_la_LIBADD = @OPENCL_LIBS@
-# not sure about -lm
-target_link_libraries("poclu" "-lm" ${OPENCL_LIBS})
+target_link_libraries("poclu" ${LIBMATH} ${OPENCL_LIBS})
 
 
 install(TARGETS "poclu"
diff --git a/lib/poclu/Makefile.in b/lib/poclu/Makefile.in
index 0150b37..368ac01 100644
--- a/lib/poclu/Makefile.in
+++ b/lib/poclu/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -40,7 +40,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -105,8 +115,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = lib/poclu
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -115,6 +123,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -219,6 +228,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -270,6 +280,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -306,6 +319,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -442,7 +456,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/poclu/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign lib/poclu/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -763,6 +776,8 @@ uninstall-am: uninstall-libLTLIBRARIES
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/lib/poclu/bswap.c b/lib/poclu/bswap.c
index 8885acb..be63212 100644
--- a/lib/poclu/bswap.c
+++ b/lib/poclu/bswap.c
@@ -27,7 +27,7 @@
 
 #define GENERIC_BYTESWAP(__DTYPE, __WORD)                         \
   do {                                                            \
-    int __i;                                                      \
+    unsigned __i;                                                 \
     union _word_union                                             \
     {                                                             \
       __DTYPE full_word;                                          \
diff --git a/lib/poclu/misc.c b/lib/poclu/misc.c
index e4e9241..a0cc9e8 100644
--- a/lib/poclu/misc.c
+++ b/lib/poclu/misc.c
@@ -111,6 +111,24 @@ poclu_read_file(char *filename)
   return src;
 }
 
+int
+poclu_write_file(char* filemane, char* content, size_t size)
+{
+  FILE *file;
+
+  file = fopen(filemane, "w");
+  if (file == NULL)
+    return -1;
+
+  if (fwrite(content, sizeof(char), size, file) < size)
+    return -1;
+
+  if (fclose(file))
+    return -1;
+
+  return 0;
+}
+
 #define OPENCL_ERROR_CASE(ERR) \
   case ERR: \
     { fprintf(stderr, "" #ERR " in %s on line %i\n", func_name, line); return 1; }
diff --git a/m4/libtool.m4 b/m4/libtool.m4
index d7c043f..a3bc337 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -1,8 +1,6 @@
 # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
 #
-#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-#                 Foundation, Inc.
+#   Copyright (C) 1996-2001, 2003-2015 Free Software Foundation, Inc.
 #   Written by Gordon Matzigkeit, 1996
 #
 # This file is free software; the Free Software Foundation gives
@@ -10,36 +8,30 @@
 # modifications, as long as this notice is preserved.
 
 m4_define([_LT_COPYING], [dnl
-#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-#                 Foundation, Inc.
-#   Written by Gordon Matzigkeit, 1996
-#
-#   This file is part of GNU Libtool.
-#
-# GNU Libtool is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 2 of
-# the License, or (at your option) any later version.
+# Copyright (C) 2014 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# GNU Libtool is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of of the License, or
+# (at your option) any later version.
 #
-# As a special exception to the GNU General Public License,
-# if you distribute this file as part of a program or library that
-# is built using GNU Libtool, you may include this file under the
-# same distribution terms that you use for the rest of that program.
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program or library that is built
+# using GNU Libtool, you may include this file under the  same
+# distribution terms that you use for the rest of that program.
 #
-# GNU Libtool is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# GNU Libtool is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with GNU Libtool; see the file COPYING.  If not, a copy
-# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
-# obtained by writing to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ])
 
-# serial 57 LT_INIT
+# serial 58 LT_INIT
 
 
 # LT_PREREQ(VERSION)
@@ -67,7 +59,7 @@ esac
 # LT_INIT([OPTIONS])
 # ------------------
 AC_DEFUN([LT_INIT],
-[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
+[AC_PREREQ([2.62])dnl We use AC_PATH_PROGS_FEATURE_CHECK
 AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
 AC_BEFORE([$0], [LT_LANG])dnl
 AC_BEFORE([$0], [LT_OUTPUT])dnl
@@ -91,7 +83,7 @@ dnl Parse OPTIONS
 _LT_SET_OPTIONS([$0], [$1])
 
 # This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ltmain"
+LIBTOOL_DEPS=$ltmain
 
 # Always use our own libtool.
 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
@@ -111,26 +103,43 @@ dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
 dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
 
 
+# _LT_PREPARE_CC_BASENAME
+# -----------------------
+m4_defun([_LT_PREPARE_CC_BASENAME], [
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+func_cc_basename ()
+{
+    for cc_temp in @S|@*""; do
+      case $cc_temp in
+        compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+        distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+        \-*) ;;
+        *) break;;
+      esac
+    done
+    func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+}
+])# _LT_PREPARE_CC_BASENAME
+
+
 # _LT_CC_BASENAME(CC)
 # -------------------
-# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+# It would be clearer to call AC_REQUIREs from _LT_PREPARE_CC_BASENAME,
+# but that macro is also expanded into generated libtool script, which
+# arranges for $SED and $ECHO to be set by different means.
 m4_defun([_LT_CC_BASENAME],
-[for cc_temp in $1""; do
-  case $cc_temp in
-    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
-    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+[m4_require([_LT_PREPARE_CC_BASENAME])dnl
+AC_REQUIRE([_LT_DECL_SED])dnl
+AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl
+func_cc_basename $1
+cc_basename=$func_cc_basename_result
 ])
 
 
 # _LT_FILEUTILS_DEFAULTS
 # ----------------------
 # It is okay to use these file commands and assume they have been set
-# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
+# sensibly after 'm4_require([_LT_FILEUTILS_DEFAULTS])'.
 m4_defun([_LT_FILEUTILS_DEFAULTS],
 [: ${CP="cp -f"}
 : ${MV="mv -f"}
@@ -177,15 +186,16 @@ m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl
 m4_require([_LT_CMD_OLD_ARCHIVE])dnl
 m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
 m4_require([_LT_WITH_SYSROOT])dnl
+m4_require([_LT_CMD_TRUNCATE])dnl
 
 _LT_CONFIG_LIBTOOL_INIT([
-# See if we are running on zsh, and set the options which allow our
+# See if we are running on zsh, and set the options that allow our
 # commands through without removal of \ escapes INIT.
-if test -n "\${ZSH_VERSION+set}" ; then
+if test -n "\${ZSH_VERSION+set}"; then
    setopt NO_GLOB_SUBST
 fi
 ])
-if test -n "${ZSH_VERSION+set}" ; then
+if test -n "${ZSH_VERSION+set}"; then
    setopt NO_GLOB_SUBST
 fi
 
@@ -198,7 +208,7 @@ aix3*)
   # AIX sometimes has problems with the GCC collect2 program.  For some
   # reason, if we set the COLLECT_NAMES environment variable, the problems
   # vanish in a puff of smoke.
-  if test "X${COLLECT_NAMES+set}" != Xset; then
+  if test set != "${COLLECT_NAMES+set}"; then
     COLLECT_NAMES=
     export COLLECT_NAMES
   fi
@@ -209,14 +219,14 @@ esac
 ofile=libtool
 can_build_shared=yes
 
-# All known linkers require a `.a' archive for static linking (except MSVC,
+# All known linkers require a '.a' archive for static linking (except MSVC,
 # which needs '.lib').
 libext=a
 
-with_gnu_ld="$lt_cv_prog_gnu_ld"
+with_gnu_ld=$lt_cv_prog_gnu_ld
 
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
+old_CC=$CC
+old_CFLAGS=$CFLAGS
 
 # Set sane defaults for various variables
 test -z "$CC" && CC=cc
@@ -269,14 +279,14 @@ no_glob_subst='s/\*/\\\*/g'
 
 # _LT_PROG_LTMAIN
 # ---------------
-# Note that this code is called both from `configure', and `config.status'
+# Note that this code is called both from 'configure', and 'config.status'
 # now that we use AC_CONFIG_COMMANDS to generate libtool.  Notably,
-# `config.status' has no value for ac_aux_dir unless we are using Automake,
+# 'config.status' has no value for ac_aux_dir unless we are using Automake,
 # so we pass a copy along to make sure it has a sensible value anyway.
 m4_defun([_LT_PROG_LTMAIN],
 [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
 _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
-ltmain="$ac_aux_dir/ltmain.sh"
+ltmain=$ac_aux_dir/ltmain.sh
 ])# _LT_PROG_LTMAIN
 
 
@@ -286,7 +296,7 @@ ltmain="$ac_aux_dir/ltmain.sh"
 
 # So that we can recreate a full libtool script including additional
 # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
-# in macros and then make a single call at the end using the `libtool'
+# in macros and then make a single call at the end using the 'libtool'
 # label.
 
 
@@ -421,8 +431,8 @@ m4_define([_lt_decl_all_varnames],
 
 # _LT_CONFIG_STATUS_DECLARE([VARNAME])
 # ------------------------------------
-# Quote a variable value, and forward it to `config.status' so that its
-# declaration there will have the same value as in `configure'.  VARNAME
+# Quote a variable value, and forward it to 'config.status' so that its
+# declaration there will have the same value as in 'configure'.  VARNAME
 # must have a single quote delimited value for this to work.
 m4_define([_LT_CONFIG_STATUS_DECLARE],
 [$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`'])
@@ -446,7 +456,7 @@ m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
 # Output comment and list of tags supported by the script
 m4_defun([_LT_LIBTOOL_TAGS],
 [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
-available_tags="_LT_TAGS"dnl
+available_tags='_LT_TAGS'dnl
 ])
 
 
@@ -474,7 +484,7 @@ m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
 # _LT_LIBTOOL_CONFIG_VARS
 # -----------------------
 # Produce commented declarations of non-tagged libtool config variables
-# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
+# suitable for insertion in the LIBTOOL CONFIG section of the 'libtool'
 # script.  Tagged libtool config variables (even for the LIBTOOL CONFIG
 # section) are produced by _LT_LIBTOOL_TAG_VARS.
 m4_defun([_LT_LIBTOOL_CONFIG_VARS],
@@ -500,8 +510,8 @@ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
 # Send accumulated output to $CONFIG_STATUS.  Thanks to the lists of
 # variables for single and double quote escaping we saved from calls
 # to _LT_DECL, we can put quote escaped variables declarations
-# into `config.status', and then the shell code to quote escape them in
-# for loops in `config.status'.  Finally, any additional code accumulated
+# into 'config.status', and then the shell code to quote escape them in
+# for loops in 'config.status'.  Finally, any additional code accumulated
 # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
 m4_defun([_LT_CONFIG_COMMANDS],
 [AC_PROVIDE_IFELSE([LT_OUTPUT],
@@ -547,7 +557,7 @@ for var in lt_decl_all_varnames([[ \
 ]], lt_decl_quote_varnames); do
     case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
     *[[\\\\\\\`\\"\\\$]]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
       ;;
     *)
       eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -560,7 +570,7 @@ for var in lt_decl_all_varnames([[ \
 ]], lt_decl_dquote_varnames); do
     case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
     *[[\\\\\\\`\\"\\\$]]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
       ;;
     *)
       eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -576,7 +586,7 @@ _LT_OUTPUT_LIBTOOL_INIT
 # Generate a child script FILE with all initialization necessary to
 # reuse the environment learned by the parent script, and make the
 # file executable.  If COMMENT is supplied, it is inserted after the
-# `#!' sequence but before initialization text begins.  After this
+# '#!' sequence but before initialization text begins.  After this
 # macro, additional text can be appended to FILE to form the body of
 # the child script.  The macro ends with non-zero status if the
 # file could not be fully written (such as if the disk is full).
@@ -598,7 +608,7 @@ AS_SHELL_SANITIZE
 _AS_PREPARE
 exec AS_MESSAGE_FD>&1
 _ASEOF
-test $lt_write_fail = 0 && chmod +x $1[]dnl
+test 0 = "$lt_write_fail" && chmod +x $1[]dnl
 m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT
 
 # LT_OUTPUT
@@ -621,7 +631,7 @@ exec AS_MESSAGE_LOG_FD>>config.log
 } >&AS_MESSAGE_LOG_FD
 
 lt_cl_help="\
-\`$as_me' creates a local libtool stub from the current configuration,
+'$as_me' creates a local libtool stub from the current configuration,
 for use in further configure time tests before the real libtool is
 generated.
 
@@ -643,7 +653,7 @@ Copyright (C) 2011 Free Software Foundation, Inc.
 This config.lt script is free software; the Free Software Foundation
 gives unlimited permision to copy, distribute and modify it."
 
-while test $[#] != 0
+while test 0 != $[#]
 do
   case $[1] in
     --version | --v* | -V )
@@ -656,10 +666,10 @@ do
       lt_cl_silent=: ;;
 
     -*) AC_MSG_ERROR([unrecognized option: $[1]
-Try \`$[0] --help' for more information.]) ;;
+Try '$[0] --help' for more information.]) ;;
 
     *) AC_MSG_ERROR([unrecognized argument: $[1]
-Try \`$[0] --help' for more information.]) ;;
+Try '$[0] --help' for more information.]) ;;
   esac
   shift
 done
@@ -685,7 +695,7 @@ chmod +x "$CONFIG_LT"
 # open by configure.  Here we exec the FD to /dev/null, effectively closing
 # config.log, so it can be properly (re)opened and appended to by config.lt.
 lt_cl_success=:
-test "$silent" = yes &&
+test yes = "$silent" &&
   lt_config_lt_args="$lt_config_lt_args --quiet"
 exec AS_MESSAGE_LOG_FD>/dev/null
 $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
@@ -705,27 +715,31 @@ m4_defun([_LT_CONFIG],
 _LT_CONFIG_SAVE_COMMANDS([
   m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
   m4_if(_LT_TAG, [C], [
-    # See if we are running on zsh, and set the options which allow our
+    # See if we are running on zsh, and set the options that allow our
     # commands through without removal of \ escapes.
-    if test -n "${ZSH_VERSION+set}" ; then
+    if test -n "${ZSH_VERSION+set}"; then
       setopt NO_GLOB_SUBST
     fi
 
-    cfgfile="${ofile}T"
+    cfgfile=${ofile}T
     trap "$RM \"$cfgfile\"; exit 1" 1 2 15
     $RM "$cfgfile"
 
     cat <<_LT_EOF >> "$cfgfile"
 #! $SHELL
-
-# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Generated automatically by $as_me ($PACKAGE) $VERSION
 # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
-#
+
+# Provide generalized library-building support services.
+# Written by Gordon Matzigkeit, 1996
+
 _LT_COPYING
 _LT_LIBTOOL_TAGS
 
+# Configured defaults for sys_lib_dlsearch_path munging.
+: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"}
+
 # ### BEGIN LIBTOOL CONFIG
 _LT_LIBTOOL_CONFIG_VARS
 _LT_LIBTOOL_TAG_VARS
@@ -733,13 +747,24 @@ _LT_LIBTOOL_TAG_VARS
 
 _LT_EOF
 
+    cat <<'_LT_EOF' >> "$cfgfile"
+
+# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE
+
+_LT_PREPARE_MUNGE_PATH_LIST
+_LT_PREPARE_CC_BASENAME
+
+# ### END FUNCTIONS SHARED WITH CONFIGURE
+
+_LT_EOF
+
   case $host_os in
   aix3*)
     cat <<\_LT_EOF >> "$cfgfile"
 # AIX sometimes has problems with the GCC collect2 program.  For some
 # reason, if we set the COLLECT_NAMES environment variable, the problems
 # vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
+if test set != "${COLLECT_NAMES+set}"; then
   COLLECT_NAMES=
   export COLLECT_NAMES
 fi
@@ -756,8 +781,6 @@ _LT_EOF
   sed '$q' "$ltmain" >> "$cfgfile" \
      || (rm -f "$cfgfile"; exit 1)
 
-  _LT_PROG_REPLACE_SHELLFNS
-
    mv -f "$cfgfile" "$ofile" ||
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
@@ -775,7 +798,6 @@ _LT_EOF
 [m4_if([$1], [], [
     PACKAGE='$PACKAGE'
     VERSION='$VERSION'
-    TIMESTAMP='$TIMESTAMP'
     RM='$RM'
     ofile='$ofile'], [])
 ])dnl /_LT_CONFIG_SAVE_COMMANDS
@@ -974,7 +996,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
 
     AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
       [lt_cv_apple_cc_single_mod=no
-      if test -z "${LT_MULTI_MODULE}"; then
+      if test -z "$LT_MULTI_MODULE"; then
 	# By default we will add the -single_module flag. You can override
 	# by either setting the environment variable LT_MULTI_MODULE
 	# non-empty at configure time, or by adding -multi_module to the
@@ -992,7 +1014,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
 	  cat conftest.err >&AS_MESSAGE_LOG_FD
 	# Otherwise, if the output was created with a 0 exit code from
 	# the compiler, it worked.
-	elif test -f libconftest.dylib && test $_lt_result -eq 0; then
+	elif test -f libconftest.dylib && test 0 = "$_lt_result"; then
 	  lt_cv_apple_cc_single_mod=yes
 	else
 	  cat conftest.err >&AS_MESSAGE_LOG_FD
@@ -1010,7 +1032,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
       AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
 	[lt_cv_ld_exported_symbols_list=yes],
 	[lt_cv_ld_exported_symbols_list=no])
-	LDFLAGS="$save_LDFLAGS"
+	LDFLAGS=$save_LDFLAGS
     ])
 
     AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load],
@@ -1032,7 +1054,7 @@ _LT_EOF
       _lt_result=$?
       if test -s conftest.err && $GREP force_load conftest.err; then
 	cat conftest.err >&AS_MESSAGE_LOG_FD
-      elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
+      elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then
 	lt_cv_ld_force_load=yes
       else
 	cat conftest.err >&AS_MESSAGE_LOG_FD
@@ -1042,32 +1064,32 @@ _LT_EOF
     ])
     case $host_os in
     rhapsody* | darwin1.[[012]])
-      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+      _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;;
     darwin1.*)
-      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+      _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
     darwin*) # darwin 5.x on
       # if running on 10.5 or later, the deployment target defaults
       # to the OS version, if on x86, and 10.4, the deployment
       # target defaults to 10.4. Don't you love it?
       case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
 	10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
-	10.[[012]]*)
-	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
+	10.[[012]][[,.]]*)
+	  _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
 	10.*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
       esac
     ;;
   esac
-    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+    if test yes = "$lt_cv_apple_cc_single_mod"; then
       _lt_dar_single_mod='$single_module'
     fi
-    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
-      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    if test yes = "$lt_cv_ld_exported_symbols_list"; then
+      _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym'
     else
-      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib'
     fi
-    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
+    if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then
       _lt_dsymutil='~$DSYMUTIL $lib || :'
     else
       _lt_dsymutil=
@@ -1087,29 +1109,29 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES],
   _LT_TAGVAR(hardcode_direct, $1)=no
   _LT_TAGVAR(hardcode_automatic, $1)=yes
   _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
-  if test "$lt_cv_ld_force_load" = "yes"; then
-    _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+  if test yes = "$lt_cv_ld_force_load"; then
+    _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
     m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes],
                   [FC],  [_LT_TAGVAR(compiler_needs_object, $1)=yes])
   else
     _LT_TAGVAR(whole_archive_flag_spec, $1)=''
   fi
   _LT_TAGVAR(link_all_deplibs, $1)=yes
-  _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
+  _LT_TAGVAR(allow_undefined_flag, $1)=$_lt_dar_allow_undefined
   case $cc_basename in
-     ifort*) _lt_dar_can_shared=yes ;;
+     ifort*|nagfor*) _lt_dar_can_shared=yes ;;
      *) _lt_dar_can_shared=$GCC ;;
   esac
-  if test "$_lt_dar_can_shared" = "yes"; then
+  if test yes = "$_lt_dar_can_shared"; then
     output_verbose_link_cmd=func_echo_all
-    _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-    _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-    _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-    _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+    _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil"
+    _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil"
+    _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil"
+    _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil"
     m4_if([$1], [CXX],
-[   if test "$lt_cv_apple_cc_single_mod" != "yes"; then
-      _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
-      _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+[   if test yes != "$lt_cv_apple_cc_single_mod"; then
+      _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil"
+      _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil"
     fi
 ],[])
   else
@@ -1129,7 +1151,7 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES],
 # Allow to override them for all tags through lt_cv_aix_libpath.
 m4_defun([_LT_SYS_MODULE_PATH_AIX],
 [m4_require([_LT_DECL_SED])dnl
-if test "${lt_cv_aix_libpath+set}" = set; then
+if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
   AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])],
@@ -1147,7 +1169,7 @@ else
     _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
   fi],[])
   if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
-    _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib"
+    _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=/usr/lib:/lib
   fi
   ])
   aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])
@@ -1167,8 +1189,8 @@ m4_define([_LT_SHELL_INIT],
 # -----------------------
 # Find how we can fake an echo command that does not interpret backslash.
 # In particular, with Autoconf 2.60 or later we add some code to the start
-# of the generated configure script which will find a shell with a builtin
-# printf (which we can use as an echo command).
+# of the generated configure script that will find a shell with a builtin
+# printf (that we can use as an echo command).
 m4_defun([_LT_PROG_ECHO_BACKSLASH],
 [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
 ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
@@ -1196,10 +1218,10 @@ fi
 # Invoke $ECHO with all args, space-separated.
 func_echo_all ()
 {
-    $ECHO "$*" 
+    $ECHO "$*"
 }
 
-case "$ECHO" in
+case $ECHO in
   printf*) AC_MSG_RESULT([printf]) ;;
   print*) AC_MSG_RESULT([print -r]) ;;
   *) AC_MSG_RESULT([cat]) ;;
@@ -1225,16 +1247,17 @@ _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes])
 AC_DEFUN([_LT_WITH_SYSROOT],
 [AC_MSG_CHECKING([for sysroot])
 AC_ARG_WITH([sysroot],
-[  --with-sysroot[=DIR] Search for dependent libraries within DIR
-                        (or the compiler's sysroot if not specified).],
+[AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@],
+  [Search for dependent libraries within DIR (or the compiler's sysroot
+   if not specified).])],
 [], [with_sysroot=no])
 
 dnl lt_sysroot will always be passed unquoted.  We quote it here
 dnl in case the user passed a directory name.
 lt_sysroot=
-case ${with_sysroot} in #(
+case $with_sysroot in #(
  yes)
-   if test "$GCC" = yes; then
+   if test yes = "$GCC"; then
      lt_sysroot=`$CC --print-sysroot 2>/dev/null`
    fi
    ;; #(
@@ -1244,14 +1267,14 @@ case ${with_sysroot} in #(
  no|'')
    ;; #(
  *)
-   AC_MSG_RESULT([${with_sysroot}])
+   AC_MSG_RESULT([$with_sysroot])
    AC_MSG_ERROR([The sysroot must be an absolute path.])
    ;;
 esac
 
  AC_MSG_RESULT([${lt_sysroot:-no}])
 _LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl
-[dependent libraries, and in which our libraries should be installed.])])
+[dependent libraries, and where our libraries should be installed.])])
 
 # _LT_ENABLE_LOCK
 # ---------------
@@ -1259,31 +1282,33 @@ m4_defun([_LT_ENABLE_LOCK],
 [AC_ARG_ENABLE([libtool-lock],
   [AS_HELP_STRING([--disable-libtool-lock],
     [avoid locking (might break parallel builds)])])
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+test no = "$enable_libtool_lock" || enable_libtool_lock=yes
 
 # Some flags need to be propagated to the compiler or linker for good
 # libtool support.
 case $host in
 ia64-*-hpux*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set mode
+  # options accordingly.
   echo 'int i;' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
     case `/usr/bin/file conftest.$ac_objext` in
       *ELF-32*)
-	HPUX_IA64_MODE="32"
+	HPUX_IA64_MODE=32
 	;;
       *ELF-64*)
-	HPUX_IA64_MODE="64"
+	HPUX_IA64_MODE=64
 	;;
     esac
   fi
   rm -rf conftest*
   ;;
 *-*-irix6*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
   echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
-    if test "$lt_cv_prog_gnu_ld" = yes; then
+    if test yes = "$lt_cv_prog_gnu_ld"; then
       case `/usr/bin/file conftest.$ac_objext` in
 	*32-bit*)
 	  LD="${LD-ld} -melf32bsmip"
@@ -1312,9 +1337,46 @@ ia64-*-hpux*)
   rm -rf conftest*
   ;;
 
+mips64*-*linux*)
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
+  echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    emul=elf
+    case `/usr/bin/file conftest.$ac_objext` in
+      *32-bit*)
+	emul="${emul}32"
+	;;
+      *64-bit*)
+	emul="${emul}64"
+	;;
+    esac
+    case `/usr/bin/file conftest.$ac_objext` in
+      *MSB*)
+	emul="${emul}btsmip"
+	;;
+      *LSB*)
+	emul="${emul}ltsmip"
+	;;
+    esac
+    case `/usr/bin/file conftest.$ac_objext` in
+      *N32*)
+	emul="${emul}n32"
+	;;
+    esac
+    LD="${LD-ld} -m $emul"
+  fi
+  rm -rf conftest*
+  ;;
+
 x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.  Note that the listed cases only cover the
+  # situations where additional linker options are needed (such as when
+  # doing 32-bit compilation for a host where ld defaults to 64-bit, or
+  # vice versa); the common cases where no linker options are needed do
+  # not appear in the list.
   echo 'int i;' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
     case `/usr/bin/file conftest.o` in
@@ -1333,10 +1395,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 		;;
 	    esac
 	    ;;
-	  powerpc64le-*)
+	  powerpc64le-*linux*)
 	    LD="${LD-ld} -m elf32lppclinux"
 	    ;;
-	  powerpc64-*)
+	  powerpc64-*linux*)
 	    LD="${LD-ld} -m elf32ppclinux"
 	    ;;
 	  s390x-*linux*)
@@ -1355,10 +1417,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 	  x86_64-*linux*)
 	    LD="${LD-ld} -m elf_x86_64"
 	    ;;
-	  powerpcle-*)
+	  powerpcle-*linux*)
 	    LD="${LD-ld} -m elf64lppc"
 	    ;;
-	  powerpc-*)
+	  powerpc-*linux*)
 	    LD="${LD-ld} -m elf64ppc"
 	    ;;
 	  s390*-*linux*|s390*-*tpf*)
@@ -1376,19 +1438,20 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
 *-*-sco3.2v5*)
   # On SCO OpenServer 5, we need -belf to get full-featured binaries.
-  SAVE_CFLAGS="$CFLAGS"
+  SAVE_CFLAGS=$CFLAGS
   CFLAGS="$CFLAGS -belf"
   AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
     [AC_LANG_PUSH(C)
      AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
      AC_LANG_POP])
-  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+  if test yes != "$lt_cv_cc_needs_belf"; then
     # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
-    CFLAGS="$SAVE_CFLAGS"
+    CFLAGS=$SAVE_CFLAGS
   fi
   ;;
 *-*solaris*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
   echo 'int i;' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
     case `/usr/bin/file conftest.o` in
@@ -1396,7 +1459,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
       case $lt_cv_prog_gnu_ld in
       yes*)
         case $host in
-        i?86-*-solaris*)
+        i?86-*-solaris*|x86_64-*-solaris*)
           LD="${LD-ld} -m elf_x86_64"
           ;;
         sparc*-*-solaris*)
@@ -1405,7 +1468,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
         esac
         # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.
         if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
-          LD="${LD-ld}_sol2"
+          LD=${LD-ld}_sol2
         fi
         ;;
       *)
@@ -1421,7 +1484,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
   ;;
 esac
 
-need_locks="$enable_libtool_lock"
+need_locks=$enable_libtool_lock
 ])# _LT_ENABLE_LOCK
 
 
@@ -1440,11 +1503,11 @@ AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file],
      [echo conftest.$ac_objext > conftest.lst
       lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD'
       AC_TRY_EVAL([lt_ar_try])
-      if test "$ac_status" -eq 0; then
+      if test 0 -eq "$ac_status"; then
 	# Ensure the archiver fails upon bogus file names.
 	rm -f conftest.$ac_objext libconftest.a
 	AC_TRY_EVAL([lt_ar_try])
-	if test "$ac_status" -ne 0; then
+	if test 0 -ne "$ac_status"; then
           lt_cv_ar_at_file=@
         fi
       fi
@@ -1452,7 +1515,7 @@ AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file],
      ])
   ])
 
-if test "x$lt_cv_ar_at_file" = xno; then
+if test no = "$lt_cv_ar_at_file"; then
   archiver_list_spec=
 else
   archiver_list_spec=$lt_cv_ar_at_file
@@ -1483,7 +1546,7 @@ old_postuninstall_cmds=
 
 if test -n "$RANLIB"; then
   case $host_os in
-  openbsd*)
+  bitrig* | openbsd*)
     old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
     ;;
   *)
@@ -1519,7 +1582,7 @@ AC_CACHE_CHECK([$1], [$2],
   [$2=no
    m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$3"
+   lt_compiler_flag="$3"  ## exclude from sc_useless_quotes_in_assignment
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
    # Note that $ac_compile itself does not contain backslashes and begins
@@ -1546,7 +1609,7 @@ AC_CACHE_CHECK([$1], [$2],
    $RM conftest*
 ])
 
-if test x"[$]$2" = xyes; then
+if test yes = "[$]$2"; then
     m4_if([$5], , :, [$5])
 else
     m4_if([$6], , :, [$6])
@@ -1568,7 +1631,7 @@ AC_DEFUN([_LT_LINKER_OPTION],
 m4_require([_LT_DECL_SED])dnl
 AC_CACHE_CHECK([$1], [$2],
   [$2=no
-   save_LDFLAGS="$LDFLAGS"
+   save_LDFLAGS=$LDFLAGS
    LDFLAGS="$LDFLAGS $3"
    echo "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
@@ -1587,10 +1650,10 @@ AC_CACHE_CHECK([$1], [$2],
      fi
    fi
    $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
+   LDFLAGS=$save_LDFLAGS
 ])
 
-if test x"[$]$2" = xyes; then
+if test yes = "[$]$2"; then
     m4_if([$4], , :, [$4])
 else
     m4_if([$5], , :, [$5])
@@ -1611,7 +1674,7 @@ AC_DEFUN([LT_CMD_MAX_LEN],
 AC_MSG_CHECKING([the maximum length of command line arguments])
 AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
   i=0
-  teststring="ABCD"
+  teststring=ABCD
 
   case $build_os in
   msdosdjgpp*)
@@ -1651,7 +1714,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
     lt_cv_sys_max_cmd_len=8192;
     ;;
 
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+  bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*)
     # This has been around since 386BSD, at least.  Likely further.
     if test -x /sbin/sysctl; then
       lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
@@ -1702,22 +1765,22 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
   *)
     lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
     if test -n "$lt_cv_sys_max_cmd_len" && \
-	test undefined != "$lt_cv_sys_max_cmd_len"; then
+       test undefined != "$lt_cv_sys_max_cmd_len"; then
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
     else
       # Make teststring a little bigger before we do anything with it.
       # a 1K string should be a reasonable start.
-      for i in 1 2 3 4 5 6 7 8 ; do
+      for i in 1 2 3 4 5 6 7 8; do
         teststring=$teststring$teststring
       done
       SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
       # If test is not a shell built-in, we'll probably end up computing a
       # maximum length that is only half of the actual maximum length, but
       # we can't tell.
-      while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
+      while { test X`env echo "$teststring$teststring" 2>/dev/null` \
 	         = "X$teststring$teststring"; } >/dev/null 2>&1 &&
-	      test $i != 17 # 1/2 MB should be enough
+	      test 17 != "$i" # 1/2 MB should be enough
       do
         i=`expr $i + 1`
         teststring=$teststring$teststring
@@ -1733,7 +1796,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
     ;;
   esac
 ])
-if test -n $lt_cv_sys_max_cmd_len ; then
+if test -n "$lt_cv_sys_max_cmd_len"; then
   AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
 else
   AC_MSG_RESULT(none)
@@ -1761,7 +1824,7 @@ m4_defun([_LT_HEADER_DLFCN],
 # ----------------------------------------------------------------
 m4_defun([_LT_TRY_DLOPEN_SELF],
 [m4_require([_LT_HEADER_DLFCN])dnl
-if test "$cross_compiling" = yes; then :
+if test yes = "$cross_compiling"; then :
   [$4]
 else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
@@ -1808,9 +1871,9 @@ else
 #  endif
 #endif
 
-/* When -fvisbility=hidden is used, assume the code has been annotated
+/* When -fvisibility=hidden is used, assume the code has been annotated
    correspondingly for the symbols needed.  */
-#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
 int fnord () __attribute__((visibility("default")));
 #endif
 
@@ -1836,7 +1899,7 @@ int main ()
   return status;
 }]
 _LT_EOF
-  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+  if AC_TRY_EVAL(ac_link) && test -s "conftest$ac_exeext" 2>/dev/null; then
     (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
     lt_status=$?
     case x$lt_status in
@@ -1857,7 +1920,7 @@ rm -fr conftest*
 # ------------------
 AC_DEFUN([LT_SYS_DLOPEN_SELF],
 [m4_require([_LT_HEADER_DLFCN])dnl
-if test "x$enable_dlopen" != xyes; then
+if test yes != "$enable_dlopen"; then
   enable_dlopen=unknown
   enable_dlopen_self=unknown
   enable_dlopen_self_static=unknown
@@ -1867,44 +1930,52 @@ else
 
   case $host_os in
   beos*)
-    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen=load_add_on
     lt_cv_dlopen_libs=
     lt_cv_dlopen_self=yes
     ;;
 
   mingw* | pw32* | cegcc*)
-    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen=LoadLibrary
     lt_cv_dlopen_libs=
     ;;
 
   cygwin*)
-    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen=dlopen
     lt_cv_dlopen_libs=
     ;;
 
   darwin*)
-  # if libdl is installed we need to link against it
+    # if libdl is installed we need to link against it
     AC_CHECK_LIB([dl], [dlopen],
-		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
-    lt_cv_dlopen="dyld"
+		[lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],[
+    lt_cv_dlopen=dyld
     lt_cv_dlopen_libs=
     lt_cv_dlopen_self=yes
     ])
     ;;
 
+  tpf*)
+    # Don't try to run any link tests for TPF.  We know it's impossible
+    # because TPF is a cross-compiler, and we know how we open DSOs.
+    lt_cv_dlopen=dlopen
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=no
+    ;;
+
   *)
     AC_CHECK_FUNC([shl_load],
-	  [lt_cv_dlopen="shl_load"],
+	  [lt_cv_dlopen=shl_load],
       [AC_CHECK_LIB([dld], [shl_load],
-	    [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
+	    [lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld],
 	[AC_CHECK_FUNC([dlopen],
-	      [lt_cv_dlopen="dlopen"],
+	      [lt_cv_dlopen=dlopen],
 	  [AC_CHECK_LIB([dl], [dlopen],
-		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+		[lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],
 	    [AC_CHECK_LIB([svld], [dlopen],
-		  [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+		  [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld],
 	      [AC_CHECK_LIB([dld], [dld_link],
-		    [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
+		    [lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld])
 	      ])
 	    ])
 	  ])
@@ -1913,21 +1984,21 @@ else
     ;;
   esac
 
-  if test "x$lt_cv_dlopen" != xno; then
-    enable_dlopen=yes
-  else
+  if test no = "$lt_cv_dlopen"; then
     enable_dlopen=no
+  else
+    enable_dlopen=yes
   fi
 
   case $lt_cv_dlopen in
   dlopen)
-    save_CPPFLAGS="$CPPFLAGS"
-    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+    save_CPPFLAGS=$CPPFLAGS
+    test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
 
-    save_LDFLAGS="$LDFLAGS"
+    save_LDFLAGS=$LDFLAGS
     wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
 
-    save_LIBS="$LIBS"
+    save_LIBS=$LIBS
     LIBS="$lt_cv_dlopen_libs $LIBS"
 
     AC_CACHE_CHECK([whether a program can dlopen itself],
@@ -1937,7 +2008,7 @@ else
 	    lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
     ])
 
-    if test "x$lt_cv_dlopen_self" = xyes; then
+    if test yes = "$lt_cv_dlopen_self"; then
       wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
       AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
 	  lt_cv_dlopen_self_static, [dnl
@@ -1947,9 +2018,9 @@ else
       ])
     fi
 
-    CPPFLAGS="$save_CPPFLAGS"
-    LDFLAGS="$save_LDFLAGS"
-    LIBS="$save_LIBS"
+    CPPFLAGS=$save_CPPFLAGS
+    LDFLAGS=$save_LDFLAGS
+    LIBS=$save_LIBS
     ;;
   esac
 
@@ -2041,8 +2112,8 @@ m4_defun([_LT_COMPILER_FILE_LOCKS],
 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
 _LT_COMPILER_C_O([$1])
 
-hard_links="nottested"
-if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+hard_links=nottested
+if test no = "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" && test no != "$need_locks"; then
   # do not overwrite the value of need_locks provided by the user
   AC_MSG_CHECKING([if we can lock with hard links])
   hard_links=yes
@@ -2052,8 +2123,8 @@ if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" !=
   ln conftest.a conftest.b 2>&5 || hard_links=no
   ln conftest.a conftest.b 2>/dev/null && hard_links=no
   AC_MSG_RESULT([$hard_links])
-  if test "$hard_links" = no; then
-    AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+  if test no = "$hard_links"; then
+    AC_MSG_WARN(['$CC' does not support '-c -o', so 'make -j' may be unsafe])
     need_locks=warn
   fi
 else
@@ -2080,8 +2151,8 @@ objdir=$lt_cv_objdir
 _LT_DECL([], [objdir], [0],
          [The name of the directory that contains temporary libtool files])dnl
 m4_pattern_allow([LT_OBJDIR])dnl
-AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
-  [Define to the sub-directory in which libtool stores uninstalled libraries.])
+AC_DEFINE_UNQUOTED([LT_OBJDIR], "$lt_cv_objdir/",
+  [Define to the sub-directory where libtool stores uninstalled libraries.])
 ])# _LT_CHECK_OBJDIR
 
 
@@ -2093,15 +2164,15 @@ m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
 _LT_TAGVAR(hardcode_action, $1)=
 if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
    test -n "$_LT_TAGVAR(runpath_var, $1)" ||
-   test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+   test yes = "$_LT_TAGVAR(hardcode_automatic, $1)"; then
 
   # We can hardcode non-existent directories.
-  if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
+  if test no != "$_LT_TAGVAR(hardcode_direct, $1)" &&
      # If the only mechanism to avoid hardcoding is shlibpath_var, we
      # have to relink, otherwise we might link with an installed library
      # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
-     test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
+     ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" &&
+     test no != "$_LT_TAGVAR(hardcode_minus_L, $1)"; then
     # Linking always hardcodes the temporary library directory.
     _LT_TAGVAR(hardcode_action, $1)=relink
   else
@@ -2115,12 +2186,12 @@ else
 fi
 AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
 
-if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
-   test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
+if test relink = "$_LT_TAGVAR(hardcode_action, $1)" ||
+   test yes = "$_LT_TAGVAR(inherit_rpath, $1)"; then
   # Fast installation is not supported
   enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
+elif test yes = "$shlibpath_overrides_runpath" ||
+     test no = "$enable_shared"; then
   # Fast installation is not necessary
   enable_fast_install=needless
 fi
@@ -2144,7 +2215,7 @@ else
 # FIXME - insert some real tests, host_os isn't really good enough
   case $host_os in
   darwin*)
-    if test -n "$STRIP" ; then
+    if test -n "$STRIP"; then
       striplib="$STRIP -x"
       old_striplib="$STRIP -S"
       AC_MSG_RESULT([yes])
@@ -2162,6 +2233,47 @@ _LT_DECL([], [striplib], [1])
 ])# _LT_CMD_STRIPLIB
 
 
+# _LT_PREPARE_MUNGE_PATH_LIST
+# ---------------------------
+# Make sure func_munge_path_list() is defined correctly.
+m4_defun([_LT_PREPARE_MUNGE_PATH_LIST],
+[[# func_munge_path_list VARIABLE PATH
+# -----------------------------------
+# VARIABLE is name of variable containing _space_ separated list of
+# directories to be munged by the contents of PATH, which is string
+# having a format:
+# "DIR[:DIR]:"
+#       string "DIR[ DIR]" will be prepended to VARIABLE
+# ":DIR[:DIR]"
+#       string "DIR[ DIR]" will be appended to VARIABLE
+# "DIRP[:DIRP]::[DIRA:]DIRA"
+#       string "DIRP[ DIRP]" will be prepended to VARIABLE and string
+#       "DIRA[ DIRA]" will be appended to VARIABLE
+# "DIR[:DIR]"
+#       VARIABLE will be replaced by "DIR[ DIR]"
+func_munge_path_list ()
+{
+    case x at S|@2 in
+    x)
+        ;;
+    *:)
+        eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'` \@S|@@S|@1\"
+        ;;
+    x:*)
+        eval @S|@1=\"\@S|@@S|@1 `$ECHO @S|@2 | $SED 's/:/ /g'`\"
+        ;;
+    *::*)
+        eval @S|@1=\"\@S|@@S|@1\ `$ECHO @S|@2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"
+        eval @S|@1=\"`$ECHO @S|@2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \@S|@@S|@1\"
+        ;;
+    *)
+        eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'`\"
+        ;;
+    esac
+}
+]])# _LT_PREPARE_PATH_LIST
+
+
 # _LT_SYS_DYNAMIC_LINKER([TAG])
 # -----------------------------
 # PORTME Fill in your ld.so characteristics
@@ -2172,17 +2284,18 @@ m4_require([_LT_FILEUTILS_DEFAULTS])dnl
 m4_require([_LT_DECL_OBJDUMP])dnl
 m4_require([_LT_DECL_SED])dnl
 m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+m4_require([_LT_PREPARE_MUNGE_PATH_LIST])dnl
 AC_MSG_CHECKING([dynamic linker characteristics])
 m4_if([$1],
 	[], [
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   case $host_os in
-    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
-    *) lt_awk_arg="/^libraries:/" ;;
+    darwin*) lt_awk_arg='/^libraries:/,/LR/' ;;
+    *) lt_awk_arg='/^libraries:/' ;;
   esac
   case $host_os in
-    mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;;
-    *) lt_sed_strip_eq="s,=/,/,g" ;;
+    mingw* | cegcc*) lt_sed_strip_eq='s|=\([[A-Za-z]]:\)|\1|g' ;;
+    *) lt_sed_strip_eq='s|=/|/|g' ;;
   esac
   lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
   case $lt_search_path_spec in
@@ -2198,28 +2311,35 @@ if test "$GCC" = yes; then
     ;;
   esac
   # Ok, now we have the path, separated by spaces, we can step through it
-  # and add multilib dir if necessary.
+  # and add multilib dir if necessary...
   lt_tmp_lt_search_path_spec=
-  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  # ...but if some path component already ends with the multilib dir we assume
+  # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer).
+  case "$lt_multi_os_dir; $lt_search_path_spec " in
+  "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*)
+    lt_multi_os_dir=
+    ;;
+  esac
   for lt_sys_path in $lt_search_path_spec; do
-    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
-      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
-    else
+    if test -d "$lt_sys_path$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir"
+    elif test -n "$lt_multi_os_dir"; then
       test -d "$lt_sys_path" && \
 	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
     fi
   done
   lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
-BEGIN {RS=" "; FS="/|\n";} {
-  lt_foo="";
-  lt_count=0;
+BEGIN {RS = " "; FS = "/|\n";} {
+  lt_foo = "";
+  lt_count = 0;
   for (lt_i = NF; lt_i > 0; lt_i--) {
     if ($lt_i != "" && $lt_i != ".") {
       if ($lt_i == "..") {
         lt_count++;
       } else {
         if (lt_count == 0) {
-          lt_foo="/" $lt_i lt_foo;
+          lt_foo = "/" $lt_i lt_foo;
         } else {
           lt_count--;
         }
@@ -2233,7 +2353,7 @@ BEGIN {RS=" "; FS="/|\n";} {
   # for these hosts.
   case $host_os in
     mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
-      $SED 's,/\([[A-Za-z]]:\),\1,g'` ;;
+      $SED 's|/\([[A-Za-z]]:\)|\1|g'` ;;
   esac
   sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
 else
@@ -2242,7 +2362,7 @@ fi])
 library_names_spec=
 libname_spec='lib$name'
 soname_spec=
-shrext_cmds=".so"
+shrext_cmds=.so
 postinstall_cmds=
 postuninstall_cmds=
 finish_cmds=
@@ -2259,14 +2379,17 @@ hardcode_into_libs=no
 # flags to be left without arguments
 need_version=unknown
 
+AC_ARG_VAR([LT_SYS_LIBRARY_PATH],
+[User-defined run-time library search path.])
+
 case $host_os in
 aix3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname.a'
   shlibpath_var=LIBPATH
 
   # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
+  soname_spec='$libname$release$shared_ext$major'
   ;;
 
 aix[[4-9]]*)
@@ -2274,41 +2397,91 @@ aix[[4-9]]*)
   need_lib_prefix=no
   need_version=no
   hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext'
     shlibpath_var=LD_LIBRARY_PATH
   else
     # With GCC up to 2.95.x, collect2 would create an import file
     # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
+    # the line '#! .'.  This would cause the generated library to
+    # depend on '.', always an invalid library.  This was fixed in
     # development snapshots of GCC prior to 3.0.
     case $host_os in
       aix4 | aix4.[[01]] | aix4.[[01]].*)
       if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
 	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	   echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then
 	:
       else
 	can_build_shared=no
       fi
       ;;
     esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # Using Import Files as archive members, it is possible to support
+    # filename-based versioning of shared library archives on AIX. While
+    # this would work for both with and without runtime linking, it will
+    # prevent static linking of such archives. So we do filename-based
+    # shared library versioning with .so extension only, which is used
+    # when both runtime linking and shared linking is enabled.
+    # Unfortunately, runtime linking may impact performance, so we do
+    # not want this to be the default eventually. Also, we use the
+    # versioned .so libs for executables only if there is the -brtl
+    # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only.
+    # To allow for filename-based versioning support, we need to create
+    # libNAME.so.V as an archive file, containing:
+    # *) an Import File, referring to the versioned filename of the
+    #    archive as well as the shared archive member, telling the
+    #    bitwidth (32 or 64) of that shared object, and providing the
+    #    list of exported symbols of that shared object, eventually
+    #    decorated with the 'weak' keyword
+    # *) the shared object with the F_LOADONLY flag set, to really avoid
+    #    it being seen by the linker.
+    # At run time we better use the real file rather than another symlink,
+    # but for link time we create the symlink libNAME.so -> libNAME.so.V
+
+    case $with_aix_soname,$aix_use_runtimelinking in
+    # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct
     # soname into executable. Probably we can add versioning support to
     # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
+    aix,yes) # traditional libtool
+      dynamic_linker='AIX unversionable lib.so'
       # If using run time linking (on AIX 4.2 or later) use lib<name>.so
       # instead of lib<name>.a to let people know that these are not
       # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      ;;
+    aix,no) # traditional AIX only
+      dynamic_linker='AIX lib.a[(]lib.so.V[)]'
       # We preserve .a as extension for shared libraries through AIX4.2
       # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      ;;
+    svr4,*) # full svr4 only
+      dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)]"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,yes) # both, prefer svr4
+      dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)], lib.a[(]lib.so.V[)]"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # unpreferred sharedlib libNAME.a needs extra handling
+      postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"'
+      postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,no) # both, prefer aix
+      dynamic_linker="AIX lib.a[(]lib.so.V[)], lib.so.V[(]$shared_archive_member_spec.o[)]"
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling
+      postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)'
+      postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"'
+      ;;
+    esac
     shlibpath_var=LIBPATH
   fi
   ;;
@@ -2318,18 +2491,18 @@ amigaos*)
   powerpc)
     # Since July 2007 AmigaOS4 officially supports .so libraries.
     # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
     ;;
   m68k)
     library_names_spec='$libname.ixlibrary $libname.a'
     # Create ${libname}_ixlibrary.a entries in /sys/libs.
-    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
     ;;
   esac
   ;;
 
 beos*)
-  library_names_spec='${libname}${shared_ext}'
+  library_names_spec='$libname$shared_ext'
   dynamic_linker="$host_os ld.so"
   shlibpath_var=LIBRARY_PATH
   ;;
@@ -2337,8 +2510,8 @@ beos*)
 bsdi[[45]]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
@@ -2350,7 +2523,7 @@ bsdi[[45]]*)
 
 cygwin* | mingw* | pw32* | cegcc*)
   version_type=windows
-  shrext_cmds=".dll"
+  shrext_cmds=.dll
   need_version=no
   need_lib_prefix=no
 
@@ -2359,8 +2532,8 @@ cygwin* | mingw* | pw32* | cegcc*)
     # gcc
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname~
@@ -2376,17 +2549,17 @@ cygwin* | mingw* | pw32* | cegcc*)
     case $host_os in
     cygwin*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
 m4_if([$1], [],[
       sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
       ;;
     mingw* | cegcc*)
       # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
       ;;
     esac
     dynamic_linker='Win32 ld.exe'
@@ -2395,8 +2568,8 @@ m4_if([$1], [],[
   *,cl*)
     # Native MSVC
     libname_spec='$name'
-    soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
-    library_names_spec='${libname}.dll.lib'
+    soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
+    library_names_spec='$libname.dll.lib'
 
     case $build_os in
     mingw*)
@@ -2423,7 +2596,7 @@ m4_if([$1], [],[
       sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
       ;;
     *)
-      sys_lib_search_path_spec="$LIB"
+      sys_lib_search_path_spec=$LIB
       if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
         # It is most probably a Windows format PATH.
         sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
@@ -2436,8 +2609,8 @@ m4_if([$1], [],[
     esac
 
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname'
@@ -2450,7 +2623,7 @@ m4_if([$1], [],[
 
   *)
     # Assume MSVC wrapper
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    library_names_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext $libname.lib'
     dynamic_linker='Win32 ld.exe'
     ;;
   esac
@@ -2463,8 +2636,8 @@ darwin* | rhapsody*)
   version_type=darwin
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
+  library_names_spec='$libname$release$major$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$major$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
   shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
@@ -2477,8 +2650,8 @@ dgux*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -2496,12 +2669,13 @@ freebsd* | dragonfly*)
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      soname_spec='$libname$release$shared_ext$major'
       need_version=no
       need_lib_prefix=no
       ;;
     freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
       need_version=yes
       ;;
   esac
@@ -2531,10 +2705,10 @@ haiku*)
   need_lib_prefix=no
   need_version=no
   dynamic_linker="$host_os runtime_loader"
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
+  shlibpath_overrides_runpath=no
   sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
   hardcode_into_libs=yes
   ;;
@@ -2552,14 +2726,15 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.so"
     shlibpath_var=LD_LIBRARY_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
+    if test 32 = "$HPUX_IA64_MODE"; then
       sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux32
     else
       sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux64
     fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
   hppa*64*)
     shrext_cmds='.sl'
@@ -2567,8 +2742,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
@@ -2577,8 +2752,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=SHLIB_PATH
     shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     ;;
   esac
   # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
@@ -2591,8 +2766,8 @@ interix[[3-9]]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -2603,7 +2778,7 @@ irix5* | irix6* | nonstopux*)
   case $host_os in
     nonstopux*) version_type=nonstopux ;;
     *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
+	if test yes = "$lt_cv_prog_gnu_ld"; then
 		version_type=linux # correct to gnu/linux during the next big refactor
 	else
 		version_type=irix
@@ -2611,8 +2786,8 @@ irix5* | irix6* | nonstopux*)
   esac
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext'
   case $host_os in
   irix5* | nonstopux*)
     libsuff= shlibsuff=
@@ -2631,8 +2806,8 @@ irix5* | irix6* | nonstopux*)
   esac
   shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
   shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff"
+  sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff"
   hardcode_into_libs=yes
   ;;
 
@@ -2641,13 +2816,33 @@ linux*oldld* | linux*aout* | linux*coff*)
   dynamic_linker=no
   ;;
 
+linux*android*)
+  version_type=none # Android doesn't support versioned libraries.
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='$libname$release$shared_ext'
+  soname_spec='$libname$release$shared_ext'
+  finish_cmds=
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  dynamic_linker='Android linker'
+  # Don't embed -rpath directories since the linker doesn't support them.
+  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+  ;;
+
 # This must be glibc/ELF.
 linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -2672,7 +2867,12 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   # before this can be enabled.
   hardcode_into_libs=yes
 
-  # Append ld.so.conf contents to the search path
+  # Ideally, we could use ldconfig to report *all* directores which are
+  # searched for libraries, however this is still not possible.  Aside from not
+  # being certain /sbin/ldconfig is available, command
+  # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64,
+  # even though it is searched at run-time.  Try to do the best guess by
+  # appending ld.so.conf contents (and includes) to the search path.
   if test -f /etc/ld.so.conf; then
     lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
     sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
@@ -2687,29 +2887,17 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   dynamic_linker='GNU/Linux ld.so'
   ;;
 
-netbsdelf*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='NetBSD ld.elf_so'
-  ;;
-
 netbsd*)
   version_type=sunos
   need_lib_prefix=no
   need_version=no
   if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
     finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
     dynamic_linker='NetBSD (a.out) ld.so'
   else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     dynamic_linker='NetBSD ld.elf_so'
   fi
   shlibpath_var=LD_LIBRARY_PATH
@@ -2719,7 +2907,7 @@ netbsd*)
 
 newsos6)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   ;;
@@ -2728,58 +2916,68 @@ newsos6)
   version_type=qnx
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
   dynamic_linker='ldqnx.so'
   ;;
 
-openbsd*)
+openbsd* | bitrig*)
   version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
+  sys_lib_dlsearch_path_spec=/usr/lib
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
-    *)				need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[[89]] | openbsd2.[[89]].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
-      esac
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
+    need_version=no
   else
-    shlibpath_overrides_runpath=yes
+    need_version=yes
   fi
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
   ;;
 
 os2*)
   libname_spec='$name'
-  shrext_cmds=".dll"
+  version_type=windows
+  shrext_cmds=.dll
+  need_version=no
   need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
+  # OS/2 can only load a DLL with a base name of 8 characters or less.
+  soname_spec='`test -n "$os2dllname" && libname="$os2dllname";
+    v=$($ECHO $release$versuffix | tr -d .-);
+    n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _);
+    $ECHO $n$v`$shared_ext'
+  library_names_spec='${libname}_dll.$libext'
   dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
+  shlibpath_var=BEGINLIBPATH
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+  postinstall_cmds='base_file=`basename \$file`~
+    dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~
+    dldir=$destdir/`dirname \$dlpath`~
+    test -d \$dldir || mkdir -p \$dldir~
+    $install_prog $dir/$dlname \$dldir/$dlname~
+    chmod a+x \$dldir/$dlname~
+    if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+      eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+    fi'
+  postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~
+    dlpath=$dir/\$dldll~
+    $RM \$dlpath'
   ;;
 
 osf3* | osf4* | osf5*)
   version_type=osf
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
   ;;
 
 rdos*)
@@ -2790,8 +2988,8 @@ solaris*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
@@ -2801,11 +2999,11 @@ solaris*)
 
 sunos4*)
   version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
   finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     need_lib_prefix=no
   fi
   need_version=yes
@@ -2813,8 +3011,8 @@ sunos4*)
 
 sysv4 | sysv4.3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   case $host_vendor in
     sni)
@@ -2835,24 +3033,24 @@ sysv4 | sysv4.3*)
   ;;
 
 sysv4*MP*)
-  if test -d /usr/nec ;then
+  if test -d /usr/nec; then
     version_type=linux # correct to gnu/linux during the next big refactor
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
+    library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext'
+    soname_spec='$libname$shared_ext.$major'
     shlibpath_var=LD_LIBRARY_PATH
   fi
   ;;
 
 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
+  version_type=sco
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
   else
     sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
@@ -2870,7 +3068,7 @@ tpf*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
@@ -2878,8 +3076,8 @@ tpf*)
 
 uts4*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -2888,20 +3086,30 @@ uts4*)
   ;;
 esac
 AC_MSG_RESULT([$dynamic_linker])
-test "$dynamic_linker" = no && can_build_shared=no
+test no = "$dynamic_linker" && can_build_shared=no
 
 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
 fi
 
-if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
-  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then
+  sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec
 fi
-if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
-  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then
+  sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec
 fi
 
+# remember unaugmented sys_lib_dlsearch_path content for libtool script decls...
+configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec
+
+# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code
+func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH"
+
+# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool
+configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH
+
 _LT_DECL([], [variables_saved_for_relink], [1],
     [Variables whose values should be saved in libtool wrapper scripts and
     restored at link time])
@@ -2934,39 +3142,41 @@ _LT_DECL([], [hardcode_into_libs], [0],
     [Whether we should hardcode library paths into libraries])
 _LT_DECL([], [sys_lib_search_path_spec], [2],
     [Compile-time system search path for libraries])
-_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
-    [Run-time system search path for libraries])
+_LT_DECL([sys_lib_dlsearch_path_spec], [configure_time_dlsearch_path], [2],
+    [Detected run-time system search path for libraries])
+_LT_DECL([], [configure_time_lt_sys_library_path], [2],
+    [Explicit LT_SYS_LIBRARY_PATH set during ./configure time])
 ])# _LT_SYS_DYNAMIC_LINKER
 
 
 # _LT_PATH_TOOL_PREFIX(TOOL)
 # --------------------------
-# find a file program which can recognize shared library
+# find a file program that can recognize shared library
 AC_DEFUN([_LT_PATH_TOOL_PREFIX],
 [m4_require([_LT_DECL_EGREP])dnl
 AC_MSG_CHECKING([for $1])
 AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
 [case $MAGIC_CMD in
 [[\\/*] |  ?:[\\/]*])
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.
   ;;
 *)
-  lt_save_MAGIC_CMD="$MAGIC_CMD"
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_MAGIC_CMD=$MAGIC_CMD
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
 dnl $ac_dummy forces splitting on constant user-supplied paths.
 dnl POSIX.2 word splitting is done only on the output of word expansions,
 dnl not every word.  This closes a longstanding sh security hole.
   ac_dummy="m4_if([$2], , $PATH, [$2])"
   for ac_dir in $ac_dummy; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$1; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+    if test -f "$ac_dir/$1"; then
+      lt_cv_path_MAGIC_CMD=$ac_dir/"$1"
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
 	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
 	    :
@@ -2989,11 +3199,11 @@ _LT_EOF
       break
     fi
   done
-  IFS="$lt_save_ifs"
-  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  IFS=$lt_save_ifs
+  MAGIC_CMD=$lt_save_MAGIC_CMD
   ;;
 esac])
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 if test -n "$MAGIC_CMD"; then
   AC_MSG_RESULT($MAGIC_CMD)
 else
@@ -3011,7 +3221,7 @@ dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
 
 # _LT_PATH_MAGIC
 # --------------
-# find a file program which can recognize a shared library
+# find a file program that can recognize a shared library
 m4_defun([_LT_PATH_MAGIC],
 [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
 if test -z "$lt_cv_path_MAGIC_CMD"; then
@@ -3038,16 +3248,16 @@ m4_require([_LT_PROG_ECHO_BACKSLASH])dnl
 AC_ARG_WITH([gnu-ld],
     [AS_HELP_STRING([--with-gnu-ld],
 	[assume the C compiler uses GNU ld @<:@default=no@:>@])],
-    [test "$withval" = no || with_gnu_ld=yes],
+    [test no = "$withval" || with_gnu_ld=yes],
     [with_gnu_ld=no])dnl
 
 ac_prog=ld
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   # Check if gcc -print-prog-name=ld gives a path.
   AC_MSG_CHECKING([for ld used by $CC])
   case $host in
   *-*-mingw*)
-    # gcc leaves a trailing carriage return which upsets mingw
+    # gcc leaves a trailing carriage return, which upsets mingw
     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
   *)
     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
@@ -3061,7 +3271,7 @@ if test "$GCC" = yes; then
       while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
 	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
       done
-      test -z "$LD" && LD="$ac_prog"
+      test -z "$LD" && LD=$ac_prog
       ;;
   "")
     # If it fails, then pretend we aren't using GCC.
@@ -3072,37 +3282,37 @@ if test "$GCC" = yes; then
     with_gnu_ld=unknown
     ;;
   esac
-elif test "$with_gnu_ld" = yes; then
+elif test yes = "$with_gnu_ld"; then
   AC_MSG_CHECKING([for GNU ld])
 else
   AC_MSG_CHECKING([for non-GNU ld])
 fi
 AC_CACHE_VAL(lt_cv_path_LD,
 [if test -z "$LD"; then
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   for ac_dir in $PATH; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-      lt_cv_path_LD="$ac_dir/$ac_prog"
+      lt_cv_path_LD=$ac_dir/$ac_prog
       # Check to see if the program is GNU ld.  I'd rather use --version,
       # but apparently some variants of GNU ld only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
       *GNU* | *'with BFD'*)
-	test "$with_gnu_ld" != no && break
+	test no != "$with_gnu_ld" && break
 	;;
       *)
-	test "$with_gnu_ld" != yes && break
+	test yes != "$with_gnu_ld" && break
 	;;
       esac
     fi
   done
-  IFS="$lt_save_ifs"
+  IFS=$lt_save_ifs
 else
-  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+  lt_cv_path_LD=$LD # Let the user override the test with a path.
 fi])
-LD="$lt_cv_path_LD"
+LD=$lt_cv_path_LD
 if test -n "$LD"; then
   AC_MSG_RESULT($LD)
 else
@@ -3156,13 +3366,13 @@ esac
 reload_cmds='$LD$reload_flag -o $output$reload_objs'
 case $host_os in
   cygwin* | mingw* | pw32* | cegcc*)
-    if test "$GCC" != yes; then
+    if test yes != "$GCC"; then
       reload_cmds=false
     fi
     ;;
   darwin*)
-    if test "$GCC" = yes; then
-      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    if test yes = "$GCC"; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs'
     else
       reload_cmds='$LD$reload_flag -o $output$reload_objs'
     fi
@@ -3173,6 +3383,43 @@ _LT_TAGDECL([], [reload_cmds], [2])dnl
 ])# _LT_CMD_RELOAD
 
 
+# _LT_PATH_DD
+# -----------
+# find a working dd
+m4_defun([_LT_PATH_DD],
+[AC_CACHE_CHECK([for a working dd], [ac_cv_path_lt_DD],
+[printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+: ${lt_DD:=$DD}
+AC_PATH_PROGS_FEATURE_CHECK([lt_DD], [dd],
+[if "$ac_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+  cmp -s conftest.i conftest.out \
+  && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=:
+fi])
+rm -f conftest.i conftest2.i conftest.out])
+])# _LT_PATH_DD
+
+
+# _LT_CMD_TRUNCATE
+# ----------------
+# find command to truncate a binary pipe
+m4_defun([_LT_CMD_TRUNCATE],
+[m4_require([_LT_PATH_DD])
+AC_CACHE_CHECK([how to truncate binary pipes], [lt_cv_truncate_bin],
+[printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+lt_cv_truncate_bin=
+if "$ac_cv_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+  cmp -s conftest.i conftest.out \
+  && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1"
+fi
+rm -f conftest.i conftest2.i conftest.out
+test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"])
+_LT_DECL([lt_truncate_bin], [lt_cv_truncate_bin], [1],
+  [Command to truncate a binary pipe])
+])# _LT_CMD_TRUNCATE
+
+
 # _LT_CHECK_MAGIC_METHOD
 # ----------------------
 # how to check for library dependencies
@@ -3188,13 +3435,13 @@ lt_cv_deplibs_check_method='unknown'
 # Need to set the preceding variable on all platforms that support
 # interlibrary dependencies.
 # 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
+# 'unknown' -- same as none, but documents that we really don't know.
 # 'pass_all' -- all dependencies passed with no checks.
 # 'test_compile' -- check by making test program.
 # 'file_magic [[regex]]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given extended regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
+# that responds to the $file_magic_cmd with a given extended regex.
+# If you have 'file' or equivalent on your system and you're not sure
+# whether 'pass_all' will *always* work, you probably want this one.
 
 case $host_os in
 aix[[4-9]]*)
@@ -3221,8 +3468,7 @@ mingw* | pw32*)
   # Base MSYS/MinGW do not provide the 'file' command needed by
   # func_win32_libid shell function, so use a weaker test based on 'objdump',
   # unless we find 'file', for example because we are cross-compiling.
-  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
-  if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
+  if ( file / ) >/dev/null 2>&1; then
     lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
     lt_cv_file_magic_cmd='func_win32_libid'
   else
@@ -3300,7 +3546,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-netbsd* | netbsdelf*-gnu)
+netbsd*)
   if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
     lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
   else
@@ -3318,8 +3564,8 @@ newos6*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-openbsd*)
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+openbsd* | bitrig*)
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
     lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
   else
     lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
@@ -3372,6 +3618,9 @@ sysv4 | sysv4.3*)
 tpf*)
   lt_cv_deplibs_check_method=pass_all
   ;;
+os2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 esac
 ])
 
@@ -3412,33 +3661,38 @@ AC_DEFUN([LT_PATH_NM],
 AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
 [if test -n "$NM"; then
   # Let the user override the test.
-  lt_cv_path_NM="$NM"
+  lt_cv_path_NM=$NM
 else
-  lt_nm_to_check="${ac_tool_prefix}nm"
+  lt_nm_to_check=${ac_tool_prefix}nm
   if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
     lt_nm_to_check="$lt_nm_to_check nm"
   fi
   for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
     for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+      tmp_nm=$ac_dir/$lt_tmp_nm
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then
 	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
+	# Adding the 'sed 1q' prevents false positives on HP-UX, which says:
 	#   nm: unknown option "B" ignored
 	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
+	# MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty
+	case $build_os in
+	mingw*) lt_bad_file=conftest.nm/nofile ;;
+	*) lt_bad_file=/dev/null ;;
+	esac
+	case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in
+	*$lt_bad_file* | *'Invalid file or object type'*)
 	  lt_cv_path_NM="$tmp_nm -B"
-	  break
+	  break 2
 	  ;;
 	*)
 	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
 	  */dev/null*)
 	    lt_cv_path_NM="$tmp_nm -p"
-	    break
+	    break 2
 	    ;;
 	  *)
 	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
@@ -3449,21 +3703,21 @@ else
 	esac
       fi
     done
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
   done
   : ${lt_cv_path_NM=no}
 fi])
-if test "$lt_cv_path_NM" != "no"; then
-  NM="$lt_cv_path_NM"
+if test no != "$lt_cv_path_NM"; then
+  NM=$lt_cv_path_NM
 else
   # Didn't find any BSD compatible name lister, look for dumpbin.
   if test -n "$DUMPBIN"; then :
     # Let the user override the test.
   else
     AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :)
-    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
+    case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in
     *COFF*)
-      DUMPBIN="$DUMPBIN -symbols"
+      DUMPBIN="$DUMPBIN -symbols -headers"
       ;;
     *)
       DUMPBIN=:
@@ -3471,8 +3725,8 @@ else
     esac
   fi
   AC_SUBST([DUMPBIN])
-  if test "$DUMPBIN" != ":"; then
-    NM="$DUMPBIN"
+  if test : != "$DUMPBIN"; then
+    NM=$DUMPBIN
   fi
 fi
 test -z "$NM" && NM=nm
@@ -3518,8 +3772,8 @@ lt_cv_sharedlib_from_linklib_cmd,
 
 case $host_os in
 cygwin* | mingw* | pw32* | cegcc*)
-  # two different shell functions defined in ltmain.sh
-  # decide which to use based on capabilities of $DLLTOOL
+  # two different shell functions defined in ltmain.sh;
+  # decide which one to use based on capabilities of $DLLTOOL
   case `$DLLTOOL --help 2>&1` in
   *--identify-strict*)
     lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
@@ -3531,7 +3785,7 @@ cygwin* | mingw* | pw32* | cegcc*)
   ;;
 *)
   # fallback: assume linklib IS sharedlib
-  lt_cv_sharedlib_from_linklib_cmd="$ECHO"
+  lt_cv_sharedlib_from_linklib_cmd=$ECHO
   ;;
 esac
 ])
@@ -3558,13 +3812,28 @@ AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool
     lt_cv_path_mainfest_tool=yes
   fi
   rm -f conftest*])
-if test "x$lt_cv_path_mainfest_tool" != xyes; then
+if test yes != "$lt_cv_path_mainfest_tool"; then
   MANIFEST_TOOL=:
 fi
 _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl
 ])# _LT_PATH_MANIFEST_TOOL
 
 
+# _LT_DLL_DEF_P([FILE])
+# ---------------------
+# True iff FILE is a Windows DLL '.def' file.
+# Keep in sync with func_dll_def_p in the libtool script
+AC_DEFUN([_LT_DLL_DEF_P],
+[dnl
+  test DEF = "`$SED -n dnl
+    -e '\''s/^[[	 ]]*//'\'' dnl Strip leading whitespace
+    -e '\''/^\(;.*\)*$/d'\'' dnl      Delete empty lines and comments
+    -e '\''s/^\(EXPORTS\|LIBRARY\)\([[	 ]].*\)*$/DEF/p'\'' dnl
+    -e q dnl                          Only consider the first "real" line
+    $1`" dnl
+])# _LT_DLL_DEF_P
+
+
 # LT_LIB_M
 # --------
 # check for math library
@@ -3576,11 +3845,11 @@ case $host in
   # These system don't have libm, or don't need it
   ;;
 *-ncr-sysv4.3*)
-  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM=-lmw)
   AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
   ;;
 *)
-  AC_CHECK_LIB(m, cos, LIBM="-lm")
+  AC_CHECK_LIB(m, cos, LIBM=-lm)
   ;;
 esac
 AC_SUBST([LIBM])
@@ -3599,7 +3868,7 @@ m4_defun([_LT_COMPILER_NO_RTTI],
 
 _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
 
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   case $cc_basename in
   nvcc*)
     _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;;
@@ -3651,7 +3920,7 @@ cygwin* | mingw* | pw32* | cegcc*)
   symcode='[[ABCDGISTW]]'
   ;;
 hpux*)
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     symcode='[[ABCDEGRST]]'
   fi
   ;;
@@ -3684,14 +3953,44 @@ case `$NM -V 2>&1` in
   symcode='[[ABCDGIRSTW]]' ;;
 esac
 
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+  # Gets list of data symbols to import.
+  lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'"
+  # Adjust the below global symbol transforms to fixup imported variables.
+  lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'"
+  lt_c_name_hook=" -e 's/^I .* \(.*\)$/  {\"\1\", (void *) 0},/p'"
+  lt_c_name_lib_hook="\
+  -e 's/^I .* \(lib.*\)$/  {\"\1\", (void *) 0},/p'\
+  -e 's/^I .* \(.*\)$/  {\"lib\1\", (void *) 0},/p'"
+else
+  # Disable hooks by default.
+  lt_cv_sys_global_symbol_to_import=
+  lt_cdecl_hook=
+  lt_c_name_hook=
+  lt_c_name_lib_hook=
+fi
+
 # Transform an extracted symbol line into a proper C declaration.
 # Some systems (esp. on ia64) link data and code symbols differently,
 # so use this general approach.
-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+lt_cv_sys_global_symbol_to_cdecl="sed -n"\
+$lt_cdecl_hook\
+" -e 's/^T .* \(.*\)$/extern int \1();/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'"
 
 # Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p'"
-lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address="sed -n"\
+$lt_c_name_hook\
+" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/p'"
+
+# Transform an extracted symbol line into symbol name with lib prefix and
+# symbol address.
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\
+$lt_c_name_lib_hook\
+" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(lib.*\)$/  {\"\1\", (void *) \&\1},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"lib\1\", (void *) \&\1},/p'"
 
 # Handle CRLF in mingw tool chain
 opt_cr=
@@ -3709,21 +4008,24 @@ for ac_symprfx in "" "_"; do
 
   # Write the raw and C identifiers.
   if test "$lt_cv_nm_interface" = "MS dumpbin"; then
-    # Fake it for dumpbin and say T for any non-static function
-    # and D for any global variable.
+    # Fake it for dumpbin and say T for any non-static function,
+    # D for any global variable and I for any imported variable.
     # Also find C++ and __fastcall symbols from MSVC++,
     # which start with @ or ?.
     lt_cv_sys_global_symbol_pipe="$AWK ['"\
 "     {last_section=section; section=\$ 3};"\
 "     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
 "     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+"     /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\
+"     /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\
+"     /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\
 "     \$ 0!~/External *\|/{next};"\
 "     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
 "     {if(hide[section]) next};"\
-"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
-"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
-"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
-"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+"     {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\
+"     {split(\$ 0,a,/\||\r/); split(a[2],s)};"\
+"     s[1]~/^[@?]/{print f,s[1],s[1]; next};"\
+"     s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\
 "     ' prfx=^$ac_symprfx]"
   else
     lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[	 ]]\($symcode$symcode*\)[[	 ]][[	 ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
@@ -3763,11 +4065,11 @@ _LT_EOF
 	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
 	  cat <<_LT_EOF > conftest.$ac_ext
 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
-#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
-/* DATA imports from DLLs on WIN32 con't be const, because runtime
+#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
+/* DATA imports from DLLs on WIN32 can't be const, because runtime
    relocations are performed -- see ld's documentation on pseudo-relocs.  */
 # define LT@&t at _DLSYM_CONST
-#elif defined(__osf__)
+#elif defined __osf__
 /* This system does not cope well with relocations in const data.  */
 # define LT@&t at _DLSYM_CONST
 #else
@@ -3793,7 +4095,7 @@ lt__PROGRAM__LTX_preloaded_symbols[[]] =
 {
   { "@PROGRAM@", (void *) 0 },
 _LT_EOF
-	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+	  $SED "s/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
 	  cat <<\_LT_EOF >> conftest.$ac_ext
   {0, (void *) 0}
 };
@@ -3813,9 +4115,9 @@ _LT_EOF
 	  mv conftest.$ac_objext conftstm.$ac_objext
 	  lt_globsym_save_LIBS=$LIBS
 	  lt_globsym_save_CFLAGS=$CFLAGS
-	  LIBS="conftstm.$ac_objext"
+	  LIBS=conftstm.$ac_objext
 	  CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
-	  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+	  if AC_TRY_EVAL(ac_link) && test -s conftest$ac_exeext; then
 	    pipe_works=yes
 	  fi
 	  LIBS=$lt_globsym_save_LIBS
@@ -3836,7 +4138,7 @@ _LT_EOF
   rm -rf conftest* conftst*
 
   # Do not use the global_symbol_pipe unless it works.
-  if test "$pipe_works" = yes; then
+  if test yes = "$pipe_works"; then
     break
   else
     lt_cv_sys_global_symbol_pipe=
@@ -3863,12 +4165,16 @@ _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
     [Take the output of nm and produce a listing of raw symbols and C names])
 _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
     [Transform the output of nm in a proper C declaration])
+_LT_DECL([global_symbol_to_import], [lt_cv_sys_global_symbol_to_import], [1],
+    [Transform the output of nm into a list of symbols to manually relocate])
 _LT_DECL([global_symbol_to_c_name_address],
     [lt_cv_sys_global_symbol_to_c_name_address], [1],
     [Transform the output of nm in a C name address pair])
 _LT_DECL([global_symbol_to_c_name_address_lib_prefix],
     [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
     [Transform the output of nm in a C name address pair when lib prefix is needed])
+_LT_DECL([nm_interface], [lt_cv_nm_interface], [1],
+    [The name lister interface])
 _LT_DECL([], [nm_file_list_spec], [1],
     [Specify filename containing input files for $NM])
 ]) # _LT_CMD_GLOBAL_SYMBOLS
@@ -3884,17 +4190,18 @@ _LT_TAGVAR(lt_prog_compiler_static, $1)=
 
 m4_if([$1], [CXX], [
   # C++ specific cases for pic, static, wl, etc.
-  if test "$GXX" = yes; then
+  if test yes = "$GXX"; then
     _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
     _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
 
     case $host_os in
     aix*)
       # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       fi
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
       ;;
 
     amigaos*)
@@ -3905,8 +4212,8 @@ m4_if([$1], [CXX], [
         ;;
       m68k)
             # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
+            # adding the '-m68020' flag to GCC prevents building anything better,
+            # like '-m68040'.
             _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
         ;;
       esac
@@ -3922,6 +4229,11 @@ m4_if([$1], [CXX], [
       # (--disable-auto-import) libraries
       m4_if([$1], [GCJ], [],
 	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      case $host_os in
+      os2*)
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static'
+	;;
+      esac
       ;;
     darwin* | rhapsody*)
       # PIC is the default on this platform
@@ -3971,7 +4283,7 @@ m4_if([$1], [CXX], [
     case $host_os in
       aix[[4-9]]*)
 	# All AIX code is PIC.
-	if test "$host_cpu" = ia64; then
+	if test ia64 = "$host_cpu"; then
 	  # AIX 5 now supports IA64 processor
 	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
 	else
@@ -4012,14 +4324,14 @@ m4_if([$1], [CXX], [
 	case $cc_basename in
 	  CC*)
 	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
-	    if test "$host_cpu" != ia64; then
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive'
+	    if test ia64 != "$host_cpu"; then
 	      _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
 	    fi
 	    ;;
 	  aCC*)
 	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive'
 	    case $host_cpu in
 	    hppa*64*|ia64*)
 	      # +Z the default
@@ -4056,7 +4368,7 @@ m4_if([$1], [CXX], [
 	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
 	    ;;
 	  ecpc* )
-	    # old Intel C++ for x86_64 which still supported -KPIC.
+	    # old Intel C++ for x86_64, which still supported -KPIC.
 	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
@@ -4112,7 +4424,7 @@ m4_if([$1], [CXX], [
 	    ;;
 	esac
 	;;
-      netbsd* | netbsdelf*-gnu)
+      netbsd*)
 	;;
       *qnx* | *nto*)
         # QNX uses GNU C++, but need to define -shared option too, otherwise
@@ -4201,17 +4513,18 @@ m4_if([$1], [CXX], [
   fi
 ],
 [
-  if test "$GCC" = yes; then
+  if test yes = "$GCC"; then
     _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
     _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
 
     case $host_os in
       aix*)
       # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       fi
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
       ;;
 
     amigaos*)
@@ -4222,8 +4535,8 @@ m4_if([$1], [CXX], [
         ;;
       m68k)
             # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
+            # adding the '-m68020' flag to GCC prevents building anything better,
+            # like '-m68040'.
             _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
         ;;
       esac
@@ -4240,6 +4553,11 @@ m4_if([$1], [CXX], [
       # (--disable-auto-import) libraries
       m4_if([$1], [GCJ], [],
 	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      case $host_os in
+      os2*)
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static'
+	;;
+      esac
       ;;
 
     darwin* | rhapsody*)
@@ -4310,7 +4628,7 @@ m4_if([$1], [CXX], [
     case $host_os in
     aix*)
       _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       else
@@ -4318,11 +4636,30 @@ m4_if([$1], [CXX], [
       fi
       ;;
 
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+      case $cc_basename in
+      nagfor*)
+        # NAG Fortran compiler
+        _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,'
+        _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+        _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+        ;;
+      esac
+      ;;
+
     mingw* | cygwin* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       m4_if([$1], [GCJ], [],
 	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      case $host_os in
+      os2*)
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static'
+	;;
+      esac
       ;;
 
     hpux9* | hpux10* | hpux11*)
@@ -4338,7 +4675,7 @@ m4_if([$1], [CXX], [
 	;;
       esac
       # Is there a better lt_prog_compiler_static that works with the bundled CC?
-      _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive'
       ;;
 
     irix5* | irix6* | nonstopux*)
@@ -4349,7 +4686,7 @@ m4_if([$1], [CXX], [
 
     linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
       case $cc_basename in
-      # old Intel for x86_64 which still supported -KPIC.
+      # old Intel for x86_64, which still supported -KPIC.
       ecc*)
 	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
@@ -4374,6 +4711,12 @@ m4_if([$1], [CXX], [
 	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
 	;;
+      tcc*)
+	# Fabrice Bellard et al's Tiny C Compiler
+	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+	;;
       pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
         # Portland Group compilers (*not* the Pentium gcc compiler,
 	# which looks to be a dead project)
@@ -4471,7 +4814,7 @@ m4_if([$1], [CXX], [
       ;;
 
     sysv4*MP*)
-      if test -d /usr/nec ;then
+      if test -d /usr/nec; then
 	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       fi
@@ -4500,7 +4843,7 @@ m4_if([$1], [CXX], [
   fi
 ])
 case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
+  # For platforms that do not support PIC, -DPIC is meaningless:
   *djgpp*)
     _LT_TAGVAR(lt_prog_compiler_pic, $1)=
     ;;
@@ -4566,17 +4909,21 @@ m4_if([$1], [CXX], [
   case $host_os in
   aix[[4-9]]*)
     # If we're using GNU nm, then we don't want the "-C" option.
-    # -C means demangle to AIX nm, but means don't demangle with GNU nm
-    # Also, AIX nm treats weak defined symbols like other global defined
-    # symbols, whereas GNU nm marks them as "W".
+    # -C means demangle to GNU nm, but means don't demangle to AIX nm.
+    # Without the "-l" option, or with the "-B" option, AIX nm treats
+    # weak defined symbols like other global defined symbols, whereas
+    # GNU nm marks them as "W".
+    # While the 'weak' keyword is ignored in the Export File, we need
+    # it in the Import File for the 'aix-soname' feature, so we have
+    # to replace the "-B" option with "-P" for AIX nm.
     if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
     else
-      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+      _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
     fi
     ;;
   pw32*)
-    _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+    _LT_TAGVAR(export_symbols_cmds, $1)=$ltdll_cmds
     ;;
   cygwin* | mingw* | cegcc*)
     case $cc_basename in
@@ -4589,9 +4936,6 @@ m4_if([$1], [CXX], [
       ;;
     esac
     ;;
-  linux* | k*bsd*-gnu | gnu*)
-    _LT_TAGVAR(link_all_deplibs, $1)=no
-    ;;
   *)
     _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
     ;;
@@ -4625,9 +4969,9 @@ m4_if([$1], [CXX], [
   # included in the symbol list
   _LT_TAGVAR(include_expsyms, $1)=
   # exclude_expsyms can be an extended regexp of symbols to exclude
-  # it will be wrapped by ` (' and `)$', so one must not match beginning or
-  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
-  # as well as any symbol that contains `d'.
+  # it will be wrapped by ' (' and ')$', so one must not match beginning or
+  # end of line.  Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc',
+  # as well as any symbol that contains 'd'.
   _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
   # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
   # platforms (ab)use it in PIC code, but their linkers get confused if
@@ -4643,7 +4987,7 @@ dnl Note also adjust exclude_expsyms for C++ above.
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
-    if test "$GCC" != yes; then
+    if test yes != "$GCC"; then
       with_gnu_ld=no
     fi
     ;;
@@ -4651,12 +4995,9 @@ dnl Note also adjust exclude_expsyms for C++ above.
     # we just hope/assume this is gcc and not c89 (= MSVC++)
     with_gnu_ld=yes
     ;;
-  openbsd*)
+  openbsd* | bitrig*)
     with_gnu_ld=no
     ;;
-  linux* | k*bsd*-gnu | gnu*)
-    _LT_TAGVAR(link_all_deplibs, $1)=no
-    ;;
   esac
 
   _LT_TAGVAR(ld_shlibs, $1)=yes
@@ -4664,7 +5005,7 @@ dnl Note also adjust exclude_expsyms for C++ above.
   # On some targets, GNU ld is compatible enough with the native linker
   # that we're better off using the native interface for both.
   lt_use_gnu_ld_interface=no
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     case $host_os in
       aix*)
 	# The AIX port of GNU ld has always aspired to compatibility
@@ -4686,24 +5027,24 @@ dnl Note also adjust exclude_expsyms for C++ above.
     esac
   fi
 
-  if test "$lt_use_gnu_ld_interface" = yes; then
+  if test yes = "$lt_use_gnu_ld_interface"; then
     # If archive_cmds runs LD, not CC, wlarc should be empty
-    wlarc='${wl}'
+    wlarc='$wl'
 
     # Set some defaults for GNU ld with shared library support. These
     # are reset later if shared libraries are not supported. Putting them
     # here allows them to be overridden if necessary.
     runpath_var=LD_RUN_PATH
-    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
     # ancient GNU ld didn't support --whole-archive et. al.
     if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
-      _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
     else
       _LT_TAGVAR(whole_archive_flag_spec, $1)=
     fi
     supports_anon_versioning=no
-    case `$LD -v 2>&1` in
+    case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in
       *GNU\ gold*) supports_anon_versioning=yes ;;
       *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
       *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
@@ -4716,7 +5057,7 @@ dnl Note also adjust exclude_expsyms for C++ above.
     case $host_os in
     aix[[3-9]]*)
       # On AIX/PPC, the GNU linker is very broken
-      if test "$host_cpu" != ia64; then
+      if test ia64 != "$host_cpu"; then
 	_LT_TAGVAR(ld_shlibs, $1)=no
 	cat <<_LT_EOF 1>&2
 
@@ -4735,7 +5076,7 @@ _LT_EOF
       case $host_cpu in
       powerpc)
             # see comment about AmigaOS4 .so support
-            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
             _LT_TAGVAR(archive_expsym_cmds, $1)=''
         ;;
       m68k)
@@ -4751,7 +5092,7 @@ _LT_EOF
 	_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
 	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
 	# support --undefined.  This deserves some investigation.  FIXME
-	_LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
       fi
@@ -4761,7 +5102,7 @@ _LT_EOF
       # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
       # as there is no search path for DLLs.
       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols'
       _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
       _LT_TAGVAR(always_export_symbols, $1)=no
       _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
@@ -4769,61 +5110,89 @@ _LT_EOF
       _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
 
       if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	# If the export-symbols file already is a .def file (1st line
-	# is EXPORTS), use it as is; otherwise, prepend...
-	_LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	  cp $export_symbols $output_objdir/$soname.def;
-	else
-	  echo EXPORTS > $output_objdir/$soname.def;
-	  cat $export_symbols >> $output_objdir/$soname.def;
-	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file, use it as
+	# is; otherwise, prepend EXPORTS...
+	_LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+          cp $export_symbols $output_objdir/$soname.def;
+        else
+          echo EXPORTS > $output_objdir/$soname.def;
+          cat $export_symbols >> $output_objdir/$soname.def;
+        fi~
+        $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
       fi
       ;;
 
     haiku*)
-      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
       _LT_TAGVAR(link_all_deplibs, $1)=yes
       ;;
 
+    os2*)
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+      shrext_cmds=.dll
+      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	prefix_cmds="$SED"~
+	if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	  prefix_cmds="$prefix_cmds -e 1d";
+	fi~
+	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+      ;;
+
     interix[[3-9]]*)
       _LT_TAGVAR(hardcode_direct, $1)=no
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
       # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
       # Instead, shared libraries are loaded at an image base (0x10000000 by
       # default) and relocated if they conflict, which is a slow very memory
       # consuming and fragmenting process.  To avoid this, we pick a random,
       # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
       # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
       ;;
 
     gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
       tmp_diet=no
-      if test "$host_os" = linux-dietlibc; then
+      if test linux-dietlibc = "$host_os"; then
 	case $cc_basename in
 	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
 	esac
       fi
       if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
-	 && test "$tmp_diet" = no
+	 && test no = "$tmp_diet"
       then
 	tmp_addflag=' $pic_flag'
 	tmp_sharedflag='-shared'
 	case $cc_basename,$host_cpu in
         pgcc*)				# Portland Group C compiler
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  tmp_addflag=' $pic_flag'
 	  ;;
 	pgf77* | pgf90* | pgf95* | pgfortran*)
 					# Portland Group f77 and f90 compilers
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  tmp_addflag=' $pic_flag -Mnomain' ;;
 	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
 	  tmp_addflag=' -i_dynamic' ;;
@@ -4834,42 +5203,47 @@ _LT_EOF
 	lf95*)				# Lahey Fortran 8.1
 	  _LT_TAGVAR(whole_archive_flag_spec, $1)=
 	  tmp_sharedflag='--shared' ;;
+        nagfor*)                        # NAGFOR 5.3
+          tmp_sharedflag='-Wl,-shared' ;;
 	xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
 	  tmp_sharedflag='-qmkshrobj'
 	  tmp_addflag= ;;
 	nvcc*)	# Cuda Compiler Driver 2.2
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  _LT_TAGVAR(compiler_needs_object, $1)=yes
 	  ;;
 	esac
 	case `$CC -V 2>&1 | sed 5q` in
 	*Sun\ C*)			# Sun C 5.9
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  _LT_TAGVAR(compiler_needs_object, $1)=yes
 	  tmp_sharedflag='-G' ;;
 	*Sun\ F*)			# Sun Fortran 8.3
 	  tmp_sharedflag='-G' ;;
 	esac
-	_LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
 
-        if test "x$supports_anon_versioning" = xyes; then
+        if test yes = "$supports_anon_versioning"; then
           _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
-	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	    echo "local: *; };" >> $output_objdir/$libname.ver~
-	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+            cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+            echo "local: *; };" >> $output_objdir/$libname.ver~
+            $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
         fi
 
 	case $cc_basename in
+	tcc*)
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='-rdynamic'
+	  ;;
 	xlf* | bgf* | bgxlf* | mpixlf*)
 	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
 	  _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
 	  _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
-	  if test "x$supports_anon_versioning" = xyes; then
+	  if test yes = "$supports_anon_versioning"; then
 	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
-	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	      echo "local: *; };" >> $output_objdir/$libname.ver~
-	      $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+              cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+              echo "local: *; };" >> $output_objdir/$libname.ver~
+              $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
 	  fi
 	  ;;
 	esac
@@ -4878,13 +5252,13 @@ _LT_EOF
       fi
       ;;
 
-    netbsd* | netbsdelf*-gnu)
+    netbsd*)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
 	wlarc=
       else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       fi
       ;;
 
@@ -4902,8 +5276,8 @@ _LT_EOF
 
 _LT_EOF
       elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
       fi
@@ -4915,7 +5289,7 @@ _LT_EOF
 	_LT_TAGVAR(ld_shlibs, $1)=no
 	cat <<_LT_EOF 1>&2
 
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot
 *** reliably create shared libraries on SCO systems.  Therefore, libtool
 *** is disabling shared libraries support.  We urge you to upgrade GNU
 *** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
@@ -4930,9 +5304,9 @@ _LT_EOF
 	  # DT_RUNPATH tag from executables and libraries.  But doing so
 	  # requires that you compile everything twice, which is a pain.
 	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	  else
 	    _LT_TAGVAR(ld_shlibs, $1)=no
 	  fi
@@ -4949,15 +5323,15 @@ _LT_EOF
 
     *)
       if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
       fi
       ;;
     esac
 
-    if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
+    if test no = "$_LT_TAGVAR(ld_shlibs, $1)"; then
       runpath_var=
       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
       _LT_TAGVAR(export_dynamic_flag_spec, $1)=
@@ -4973,7 +5347,7 @@ _LT_EOF
       # Note: this linker hardcodes the directories in LIBPATH if there
       # are no directories specified by -L.
       _LT_TAGVAR(hardcode_minus_L, $1)=yes
-      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+      if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then
 	# Neither direct hardcoding nor static linking is supported with a
 	# broken collect2.
 	_LT_TAGVAR(hardcode_direct, $1)=unsupported
@@ -4981,34 +5355,57 @@ _LT_EOF
       ;;
 
     aix[[4-9]]*)
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# On IA64, the linker does run time linking by default, so we don't
 	# have to do anything special.
 	aix_use_runtimelinking=no
 	exp_sym_flag='-Bexport'
-	no_entry_flag=""
+	no_entry_flag=
       else
 	# If we're using GNU nm, then we don't want the "-C" option.
-	# -C means demangle to AIX nm, but means don't demangle with GNU nm
-	# Also, AIX nm treats weak defined symbols like other global
-	# defined symbols, whereas GNU nm marks them as "W".
+	# -C means demangle to GNU nm, but means don't demangle to AIX nm.
+	# Without the "-l" option, or with the "-B" option, AIX nm treats
+	# weak defined symbols like other global defined symbols, whereas
+	# GNU nm marks them as "W".
+	# While the 'weak' keyword is ignored in the Export File, we need
+	# it in the Import File for the 'aix-soname' feature, so we have
+	# to replace the "-B" option with "-P" for AIX nm.
 	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
 	else
-	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	  _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
 	fi
 	aix_use_runtimelinking=no
 
 	# Test if we are trying to use run time linking or normal
 	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
-	# need to do runtime linking.
+	# have runtime linking enabled, and use it for executables.
+	# For shared libraries, we enable/disable runtime linking
+	# depending on the kind of the shared library created -
+	# when "with_aix_soname,aix_use_runtimelinking" is:
+	# "aix,no"   lib.a(lib.so.V) shared, rtl:no,  for executables
+	# "aix,yes"  lib.so          shared, rtl:yes, for executables
+	#            lib.a           static archive
+	# "both,no"  lib.so.V(shr.o) shared, rtl:yes
+	#            lib.a(lib.so.V) shared, rtl:no,  for executables
+	# "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+	#            lib.a(lib.so.V) shared, rtl:no
+	# "svr4,*"   lib.so.V(shr.o) shared, rtl:yes, for executables
+	#            lib.a           static archive
 	case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
 	  for ld_flag in $LDFLAGS; do
-	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+	  if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then
 	    aix_use_runtimelinking=yes
 	    break
 	  fi
 	  done
+	  if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+	    # With aix-soname=svr4, we create the lib.so.V shared archives only,
+	    # so we don't have lib.a shared libs to link our executables.
+	    # We have to force runtime linking in this case.
+	    aix_use_runtimelinking=yes
+	    LDFLAGS="$LDFLAGS -Wl,-brtl"
+	  fi
 	  ;;
 	esac
 
@@ -5027,13 +5424,21 @@ _LT_EOF
       _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
       _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
       _LT_TAGVAR(link_all_deplibs, $1)=yes
-      _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+      _LT_TAGVAR(file_list_spec, $1)='$wl-f,'
+      case $with_aix_soname,$aix_use_runtimelinking in
+      aix,*) ;; # traditional, no import file
+      svr4,* | *,yes) # use import file
+	# The Import File defines what to hardcode.
+	_LT_TAGVAR(hardcode_direct, $1)=no
+	_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+	;;
+      esac
 
-      if test "$GCC" = yes; then
+      if test yes = "$GCC"; then
 	case $host_os in aix4.[[012]]|aix4.[[012]].*)
 	# We only want to do this on AIX 4.2 and lower, the check
 	# below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
+	  collect2name=`$CC -print-prog-name=collect2`
 	  if test -f "$collect2name" &&
 	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
 	  then
@@ -5052,62 +5457,80 @@ _LT_EOF
 	  ;;
 	esac
 	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
+	if test yes = "$aix_use_runtimelinking"; then
+	  shared_flag="$shared_flag "'$wl-G'
 	fi
-	_LT_TAGVAR(link_all_deplibs, $1)=no
+	# Need to ensure runtime linking is disabled for the traditional
+	# shared library, or the linker may eventually find shared libraries
+	# /with/ Import File - we do not want to mix them.
+	shared_flag_aix='-shared'
+	shared_flag_svr4='-shared $wl-G'
       else
 	# not using gcc
-	if test "$host_cpu" = ia64; then
+	if test ia64 = "$host_cpu"; then
 	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
 	# chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
 	else
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag='${wl}-G'
+	  if test yes = "$aix_use_runtimelinking"; then
+	    shared_flag='$wl-G'
 	  else
-	    shared_flag='${wl}-bM:SRE'
+	    shared_flag='$wl-bM:SRE'
 	  fi
+	  shared_flag_aix='$wl-bM:SRE'
+	  shared_flag_svr4='$wl-G'
 	fi
       fi
 
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall'
       # It seems that -bexpall does not export symbols beginning with
       # underscore (_), so it is better to generate a list of symbols to export.
       _LT_TAGVAR(always_export_symbols, $1)=yes
-      if test "$aix_use_runtimelinking" = yes; then
+      if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
 	# Warning - without using the other runtime loading flags (-brtl),
 	# -berok will link without error, but may produce a broken library.
 	_LT_TAGVAR(allow_undefined_flag, $1)='-berok'
         # Determine the default libpath from the value encoded in an
         # empty executable.
         _LT_SYS_MODULE_PATH_AIX([$1])
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
-        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
+        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
       else
-	if test "$host_cpu" = ia64; then
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+	if test ia64 = "$host_cpu"; then
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib'
 	  _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
-	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
 	else
 	 # Determine the default libpath from the value encoded in an
 	 # empty executable.
 	 _LT_SYS_MODULE_PATH_AIX([$1])
-	 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+	 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
 	  # Warning - without using the other run time loading flags,
 	  # -berok will link without error, but may produce a broken library.
-	  _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
-	  _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
-	  if test "$with_gnu_ld" = yes; then
+	  _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok'
+	  _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok'
+	  if test yes = "$with_gnu_ld"; then
 	    # We only use this code for GNU lds that support --whole-archive.
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive'
 	  else
 	    # Exported symbols can be pulled into shared objects from archives
 	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
 	  fi
 	  _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
-	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+	  # -brtl affects multiple linker settings, -berok does not and is overridden later
+	  compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`'
+	  if test svr4 != "$with_aix_soname"; then
+	    # This is similar to how AIX traditionally builds its shared libraries.
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+	  fi
+	  if test aix != "$with_aix_soname"; then
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 3 [...]
+	  else
+	    # used by -dlpreopen to get the symbols
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV  $output_objdir/$realname.d/$soname $output_objdir'
+	  fi
+	  _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d'
 	fi
       fi
       ;;
@@ -5116,7 +5539,7 @@ _LT_EOF
       case $host_cpu in
       powerpc)
             # see comment about AmigaOS4 .so support
-            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
             _LT_TAGVAR(archive_expsym_cmds, $1)=''
         ;;
       m68k)
@@ -5146,16 +5569,17 @@ _LT_EOF
 	# Tell ltmain to make .lib files, not .a files.
 	libext=lib
 	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
+	shrext_cmds=.dll
 	# FIXME: Setting linknames here is a bad hack.
-	_LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	_LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	    sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	  else
-	    sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	  fi~
-	  $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	  linknames='
+	_LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+	_LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+            cp "$export_symbols" "$output_objdir/$soname.def";
+            echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+          else
+            $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+          fi~
+          $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+          linknames='
 	# The linker will not automatically build a static lib if we build a DLL.
 	# _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
 	_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
@@ -5164,18 +5588,18 @@ _LT_EOF
 	# Don't use ranlib
 	_LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
 	_LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
-	  lt_tool_outputfile="@TOOL_OUTPUT@"~
-	  case $lt_outputfile in
-	    *.exe|*.EXE) ;;
-	    *)
-	      lt_outputfile="$lt_outputfile.exe"
-	      lt_tool_outputfile="$lt_tool_outputfile.exe"
-	      ;;
-	  esac~
-	  if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	    $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	    $RM "$lt_outputfile.manifest";
-	  fi'
+          lt_tool_outputfile="@TOOL_OUTPUT@"~
+          case $lt_outputfile in
+            *.exe|*.EXE) ;;
+            *)
+              lt_outputfile=$lt_outputfile.exe
+              lt_tool_outputfile=$lt_tool_outputfile.exe
+              ;;
+          esac~
+          if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+            $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+            $RM "$lt_outputfile.manifest";
+          fi'
 	;;
       *)
 	# Assume MSVC wrapper
@@ -5184,7 +5608,7 @@ _LT_EOF
 	# Tell ltmain to make .lib files, not .a files.
 	libext=lib
 	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
+	shrext_cmds=.dll
 	# FIXME: Setting linknames here is a bad hack.
 	_LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
 	# The linker will automatically build a .lib file if we build a DLL.
@@ -5234,33 +5658,33 @@ _LT_EOF
       ;;
 
     hpux9*)
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
       else
-	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
       fi
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
       _LT_TAGVAR(hardcode_direct, $1)=yes
 
       # hardcode_minus_L: Not really in the search PATH,
       # but as the default location of the library.
       _LT_TAGVAR(hardcode_minus_L, $1)=yes
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
       ;;
 
     hpux10*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes,no = "$GCC,$with_gnu_ld"; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
       else
 	_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
       fi
-      if test "$with_gnu_ld" = no; then
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      if test no = "$with_gnu_ld"; then
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
 	_LT_TAGVAR(hardcode_libdir_separator, $1)=:
 	_LT_TAGVAR(hardcode_direct, $1)=yes
 	_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
 	# hardcode_minus_L: Not really in the search PATH,
 	# but as the default location of the library.
 	_LT_TAGVAR(hardcode_minus_L, $1)=yes
@@ -5268,25 +5692,25 @@ _LT_EOF
       ;;
 
     hpux11*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+      if test yes,no = "$GCC,$with_gnu_ld"; then
 	case $host_cpu in
 	hppa*64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	ia64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	esac
       else
 	case $host_cpu in
 	hppa*64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	ia64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
 	m4_if($1, [], [
@@ -5294,14 +5718,14 @@ _LT_EOF
 	  # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
 	  _LT_LINKER_OPTION([if $CC understands -b],
 	    _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b],
-	    [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'],
+	    [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'],
 	    [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])],
-	  [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'])
+	  [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'])
 	  ;;
 	esac
       fi
-      if test "$with_gnu_ld" = no; then
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      if test no = "$with_gnu_ld"; then
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
 	_LT_TAGVAR(hardcode_libdir_separator, $1)=:
 
 	case $host_cpu in
@@ -5312,7 +5736,7 @@ _LT_EOF
 	*)
 	  _LT_TAGVAR(hardcode_direct, $1)=yes
 	  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
 
 	  # hardcode_minus_L: Not really in the search PATH,
 	  # but as the default location of the library.
@@ -5323,16 +5747,16 @@ _LT_EOF
       ;;
 
     irix5* | irix6* | nonstopux*)
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 	# Try to use the -exported_symbol ld option, if it does not
 	# work, assume that -exports_file does not work either and
 	# implicitly export all symbols.
 	# This should be the same for all languages, so no per-tag cache variable.
 	AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol],
 	  [lt_cv_irix_exported_symbol],
-	  [save_LDFLAGS="$LDFLAGS"
-	   LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+	  [save_LDFLAGS=$LDFLAGS
+	   LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null"
 	   AC_LINK_IFELSE(
 	     [AC_LANG_SOURCE(
 	        [AC_LANG_CASE([C], [[int foo (void) { return 0; }]],
@@ -5345,22 +5769,32 @@ _LT_EOF
       end]])])],
 	      [lt_cv_irix_exported_symbol=yes],
 	      [lt_cv_irix_exported_symbol=no])
-           LDFLAGS="$save_LDFLAGS"])
-	if test "$lt_cv_irix_exported_symbol" = yes; then
-          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+           LDFLAGS=$save_LDFLAGS])
+	if test yes = "$lt_cv_irix_exported_symbol"; then
+          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'
 	fi
       else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'
       fi
       _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
       _LT_TAGVAR(inherit_rpath, $1)=yes
       _LT_TAGVAR(link_all_deplibs, $1)=yes
       ;;
 
-    netbsd* | netbsdelf*-gnu)
+    linux*)
+      case $cc_basename in
+      tcc*)
+	# Fabrice Bellard et al's Tiny C Compiler
+	_LT_TAGVAR(ld_shlibs, $1)=yes
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+      esac
+      ;;
+
+    netbsd*)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
       else
@@ -5374,7 +5808,7 @@ _LT_EOF
     newsos6)
       _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
       _LT_TAGVAR(hardcode_direct, $1)=yes
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
       ;;
@@ -5382,27 +5816,19 @@ _LT_EOF
     *nto* | *qnx*)
       ;;
 
-    openbsd*)
+    openbsd* | bitrig*)
       if test -f /usr/libexec/ld.so; then
 	_LT_TAGVAR(hardcode_direct, $1)=yes
 	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
 	_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
 	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
 	else
-	  case $host_os in
-	   openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
-	     _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-	     _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-	     ;;
-	   *)
-	     _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	     _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	     ;;
-	  esac
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
 	fi
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
@@ -5413,33 +5839,53 @@ _LT_EOF
       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
       _LT_TAGVAR(hardcode_minus_L, $1)=yes
       _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
-      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
-      _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      shrext_cmds=.dll
+      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	prefix_cmds="$SED"~
+	if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	  prefix_cmds="$prefix_cmds -e 1d";
+	fi~
+	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
       ;;
 
     osf3*)
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
       else
 	_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
       fi
       _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
       ;;
 
     osf4* | osf5*)	# as osf3* with the addition of -msym flag
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
       else
 	_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 	_LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
-	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+          $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp'
 
 	# Both c and cxx compiler support -rpath directly
 	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
@@ -5450,24 +5896,24 @@ _LT_EOF
 
     solaris*)
       _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
-      if test "$GCC" = yes; then
-	wlarc='${wl}'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	wlarc='$wl'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+          $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
       else
 	case `$CC -V 2>&1` in
 	*"Compilers 5.0"*)
 	  wlarc=''
-	  _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags'
 	  _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+            $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
 	  ;;
 	*)
-	  wlarc='${wl}'
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	  wlarc='$wl'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags'
 	  _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+            $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
 	  ;;
 	esac
       fi
@@ -5477,11 +5923,11 @@ _LT_EOF
       solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
       *)
 	# The compiler driver will combine and reorder linker options,
-	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but understands '-z linker_flag'.  GCC discards it without '$wl',
 	# but is careful enough not to reorder.
 	# Supported since Solaris 2.6 (maybe 2.5.1?)
-	if test "$GCC" = yes; then
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	if test yes = "$GCC"; then
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
 	else
 	  _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
 	fi
@@ -5491,10 +5937,10 @@ _LT_EOF
       ;;
 
     sunos4*)
-      if test "x$host_vendor" = xsequent; then
+      if test sequent = "$host_vendor"; then
 	# Use $CC to link under sequent, because it throws in some extra .o
 	# files that make .init and .fini sections work.
-	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags'
       else
 	_LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
       fi
@@ -5543,43 +5989,43 @@ _LT_EOF
       ;;
 
     sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
-      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
       _LT_TAGVAR(archive_cmds_need_lc, $1)=no
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
       runpath_var='LD_RUN_PATH'
 
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
       ;;
 
     sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We can NOT use -z defs as we might desire, because we do not
+      # Note: We CANNOT use -z defs as we might desire, because we do not
       # link with -lc, and that would cause any symbols used from libc to
       # always be unresolved, which means just about no library would
       # ever link correctly.  If we're not using GNU ld we use -z text
       # though, which does catch some bad symbols but isn't as heavy-handed
       # as -z defs.
-      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-      _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+      _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
+      _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs'
       _LT_TAGVAR(archive_cmds_need_lc, $1)=no
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
       _LT_TAGVAR(link_all_deplibs, $1)=yes
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport'
       runpath_var='LD_RUN_PATH'
 
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
       ;;
 
@@ -5594,17 +6040,17 @@ _LT_EOF
       ;;
     esac
 
-    if test x$host_vendor = xsni; then
+    if test sni = "$host_vendor"; then
       case $host in
       sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Blargedynsym'
 	;;
       esac
     fi
   fi
 ])
 AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
-test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no
 
 _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
 
@@ -5621,7 +6067,7 @@ x|xyes)
   # Assume -lc should be added
   _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
 
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
+  if test yes,yes = "$GCC,$enable_shared"; then
     case $_LT_TAGVAR(archive_cmds, $1) in
     *'~'*)
       # FIXME: we may have to deal with multi-command sequences.
@@ -5701,12 +6147,12 @@ _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
 _LT_TAGDECL([], [hardcode_libdir_separator], [1],
     [Whether we need a single "-rpath" flag with a separated argument])
 _LT_TAGDECL([], [hardcode_direct], [0],
-    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+    [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes
     DIR into the resulting binary])
 _LT_TAGDECL([], [hardcode_direct_absolute], [0],
-    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+    [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes
     DIR into the resulting binary and the resulting library dependency is
-    "absolute", i.e impossible to change by setting ${shlibpath_var} if the
+    "absolute", i.e impossible to change by setting $shlibpath_var if the
     library is relocated])
 _LT_TAGDECL([], [hardcode_minus_L], [0],
     [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
@@ -5747,10 +6193,10 @@ dnl    [Compiler flag to generate thread safe objects])
 # ------------------------
 # Ensure that the configuration variables for a C compiler are suitably
 # defined.  These variables are subsequently used by _LT_CONFIG to write
-# the compiler configuration to `libtool'.
+# the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_C_CONFIG],
 [m4_require([_LT_DECL_EGREP])dnl
-lt_save_CC="$CC"
+lt_save_CC=$CC
 AC_LANG_PUSH(C)
 
 # Source file extension for C test sources.
@@ -5790,18 +6236,18 @@ if test -n "$compiler"; then
   LT_SYS_DLOPEN_SELF
   _LT_CMD_STRIPLIB
 
-  # Report which library types will actually be built
+  # Report what library types will actually be built
   AC_MSG_CHECKING([if libtool supports shared libraries])
   AC_MSG_RESULT([$can_build_shared])
 
   AC_MSG_CHECKING([whether to build shared libraries])
-  test "$can_build_shared" = "no" && enable_shared=no
+  test no = "$can_build_shared" && enable_shared=no
 
   # On AIX, shared libraries and static libraries use the same namespace, and
   # are all built from PIC.
   case $host_os in
   aix3*)
-    test "$enable_shared" = yes && enable_static=no
+    test yes = "$enable_shared" && enable_static=no
     if test -n "$RANLIB"; then
       archive_cmds="$archive_cmds~\$RANLIB \$lib"
       postinstall_cmds='$RANLIB $lib'
@@ -5809,8 +6255,12 @@ if test -n "$compiler"; then
     ;;
 
   aix[[4-9]]*)
-    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-      test "$enable_shared" = yes && enable_static=no
+    if test ia64 != "$host_cpu"; then
+      case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+      yes,aix,yes) ;;			# shared object as lib.so file only
+      yes,svr4,*) ;;			# shared object as lib.so archive member only
+      yes,*) enable_static=no ;;	# shared object in lib.a archive as well
+      esac
     fi
     ;;
   esac
@@ -5818,13 +6268,13 @@ if test -n "$compiler"; then
 
   AC_MSG_CHECKING([whether to build static libraries])
   # Make sure either enable_shared or enable_static is yes.
-  test "$enable_shared" = yes || enable_static=yes
+  test yes = "$enable_shared" || enable_static=yes
   AC_MSG_RESULT([$enable_static])
 
   _LT_CONFIG($1)
 fi
 AC_LANG_POP
-CC="$lt_save_CC"
+CC=$lt_save_CC
 ])# _LT_LANG_C_CONFIG
 
 
@@ -5832,14 +6282,14 @@ CC="$lt_save_CC"
 # --------------------------
 # Ensure that the configuration variables for a C++ compiler are suitably
 # defined.  These variables are subsequently used by _LT_CONFIG to write
-# the compiler configuration to `libtool'.
+# the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_CXX_CONFIG],
 [m4_require([_LT_FILEUTILS_DEFAULTS])dnl
 m4_require([_LT_DECL_EGREP])dnl
 m4_require([_LT_PATH_MANIFEST_TOOL])dnl
-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-    (test "X$CXX" != "Xg++"))) ; then
+if test -n "$CXX" && ( test no != "$CXX" &&
+    ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) ||
+    (test g++ != "$CXX"))); then
   AC_PROG_CXXCPP
 else
   _lt_caught_CXX_error=yes
@@ -5881,7 +6331,7 @@ _LT_TAGVAR(objext, $1)=$objext
 # the CXX compiler isn't working.  Some variables (like enable_shared)
 # are currently assumed to apply to all compilers on this platform,
 # and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_caught_CXX_error" != yes; then
+if test yes != "$_lt_caught_CXX_error"; then
   # Code to be used in simple compile tests
   lt_simple_compile_test_code="int some_variable = 0;"
 
@@ -5923,35 +6373,35 @@ if test "$_lt_caught_CXX_error" != yes; then
   if test -n "$compiler"; then
     # We don't want -fno-exception when compiling C++ code, so set the
     # no_builtin_flag separately
-    if test "$GXX" = yes; then
+    if test yes = "$GXX"; then
       _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
     else
       _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
     fi
 
-    if test "$GXX" = yes; then
+    if test yes = "$GXX"; then
       # Set up default GNU C++ configuration
 
       LT_PATH_LD
 
       # Check if GNU C++ uses GNU ld as the underlying linker, since the
       # archiving commands below assume that GNU ld is being used.
-      if test "$with_gnu_ld" = yes; then
-        _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      if test yes = "$with_gnu_ld"; then
+        _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
 
         # If archive_cmds runs LD, not CC, wlarc should be empty
         # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
         #     investigate it a little bit more. (MM)
-        wlarc='${wl}'
+        wlarc='$wl'
 
         # ancient GNU ld didn't support --whole-archive et. al.
         if eval "`$CC -print-prog-name=ld` --help 2>&1" |
 	  $GREP 'no-whole-archive' > /dev/null; then
-          _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+          _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
         else
           _LT_TAGVAR(whole_archive_flag_spec, $1)=
         fi
@@ -5987,18 +6437,30 @@ if test "$_lt_caught_CXX_error" != yes; then
         _LT_TAGVAR(ld_shlibs, $1)=no
         ;;
       aix[[4-9]]*)
-        if test "$host_cpu" = ia64; then
+        if test ia64 = "$host_cpu"; then
           # On IA64, the linker does run time linking by default, so we don't
           # have to do anything special.
           aix_use_runtimelinking=no
           exp_sym_flag='-Bexport'
-          no_entry_flag=""
+          no_entry_flag=
         else
           aix_use_runtimelinking=no
 
           # Test if we are trying to use run time linking or normal
           # AIX style linking. If -brtl is somewhere in LDFLAGS, we
-          # need to do runtime linking.
+          # have runtime linking enabled, and use it for executables.
+          # For shared libraries, we enable/disable runtime linking
+          # depending on the kind of the shared library created -
+          # when "with_aix_soname,aix_use_runtimelinking" is:
+          # "aix,no"   lib.a(lib.so.V) shared, rtl:no,  for executables
+          # "aix,yes"  lib.so          shared, rtl:yes, for executables
+          #            lib.a           static archive
+          # "both,no"  lib.so.V(shr.o) shared, rtl:yes
+          #            lib.a(lib.so.V) shared, rtl:no,  for executables
+          # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+          #            lib.a(lib.so.V) shared, rtl:no
+          # "svr4,*"   lib.so.V(shr.o) shared, rtl:yes, for executables
+          #            lib.a           static archive
           case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
 	    for ld_flag in $LDFLAGS; do
 	      case $ld_flag in
@@ -6008,6 +6470,13 @@ if test "$_lt_caught_CXX_error" != yes; then
 	        ;;
 	      esac
 	    done
+	    if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+	      # With aix-soname=svr4, we create the lib.so.V shared archives only,
+	      # so we don't have lib.a shared libs to link our executables.
+	      # We have to force runtime linking in this case.
+	      aix_use_runtimelinking=yes
+	      LDFLAGS="$LDFLAGS -Wl,-brtl"
+	    fi
 	    ;;
           esac
 
@@ -6026,13 +6495,21 @@ if test "$_lt_caught_CXX_error" != yes; then
         _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
         _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
         _LT_TAGVAR(link_all_deplibs, $1)=yes
-        _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+        _LT_TAGVAR(file_list_spec, $1)='$wl-f,'
+        case $with_aix_soname,$aix_use_runtimelinking in
+        aix,*) ;;	# no import file
+        svr4,* | *,yes) # use import file
+          # The Import File defines what to hardcode.
+          _LT_TAGVAR(hardcode_direct, $1)=no
+          _LT_TAGVAR(hardcode_direct_absolute, $1)=no
+          ;;
+        esac
 
-        if test "$GXX" = yes; then
+        if test yes = "$GXX"; then
           case $host_os in aix4.[[012]]|aix4.[[012]].*)
           # We only want to do this on AIX 4.2 and lower, the check
           # below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
+	  collect2name=`$CC -print-prog-name=collect2`
 	  if test -f "$collect2name" &&
 	     strings "$collect2name" | $GREP resolve_lib_name >/dev/null
 	  then
@@ -6050,64 +6527,84 @@ if test "$_lt_caught_CXX_error" != yes; then
 	  fi
           esac
           shared_flag='-shared'
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag="$shared_flag "'${wl}-G'
+	  if test yes = "$aix_use_runtimelinking"; then
+	    shared_flag=$shared_flag' $wl-G'
 	  fi
+	  # Need to ensure runtime linking is disabled for the traditional
+	  # shared library, or the linker may eventually find shared libraries
+	  # /with/ Import File - we do not want to mix them.
+	  shared_flag_aix='-shared'
+	  shared_flag_svr4='-shared $wl-G'
         else
           # not using gcc
-          if test "$host_cpu" = ia64; then
+          if test ia64 = "$host_cpu"; then
 	  # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
 	  # chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
           else
-	    if test "$aix_use_runtimelinking" = yes; then
-	      shared_flag='${wl}-G'
+	    if test yes = "$aix_use_runtimelinking"; then
+	      shared_flag='$wl-G'
 	    else
-	      shared_flag='${wl}-bM:SRE'
+	      shared_flag='$wl-bM:SRE'
 	    fi
+	    shared_flag_aix='$wl-bM:SRE'
+	    shared_flag_svr4='$wl-G'
           fi
         fi
 
-        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall'
         # It seems that -bexpall does not export symbols beginning with
         # underscore (_), so it is better to generate a list of symbols to
 	# export.
         _LT_TAGVAR(always_export_symbols, $1)=yes
-        if test "$aix_use_runtimelinking" = yes; then
+	if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
           # Warning - without using the other runtime loading flags (-brtl),
           # -berok will link without error, but may produce a broken library.
-          _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+          # The "-G" linker flag allows undefined symbols.
+          _LT_TAGVAR(no_undefined_flag, $1)='-bernotok'
           # Determine the default libpath from the value encoded in an empty
           # executable.
           _LT_SYS_MODULE_PATH_AIX([$1])
-          _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+          _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
 
-          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
         else
-          if test "$host_cpu" = ia64; then
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+          if test ia64 = "$host_cpu"; then
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib'
 	    _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
-	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
           else
 	    # Determine the default libpath from the value encoded in an
 	    # empty executable.
 	    _LT_SYS_MODULE_PATH_AIX([$1])
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
 	    # Warning - without using the other run time loading flags,
 	    # -berok will link without error, but may produce a broken library.
-	    _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
-	    _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
-	    if test "$with_gnu_ld" = yes; then
+	    _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok'
+	    _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok'
+	    if test yes = "$with_gnu_ld"; then
 	      # We only use this code for GNU lds that support --whole-archive.
-	      _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	      _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive'
 	    else
 	      # Exported symbols can be pulled into shared objects from archives
 	      _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
 	    fi
 	    _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
-	    # This is similar to how AIX traditionally builds its shared
-	    # libraries.
-	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+	    # -brtl affects multiple linker settings, -berok does not and is overridden later
+	    compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`'
+	    if test svr4 != "$with_aix_soname"; then
+	      # This is similar to how AIX traditionally builds its shared
+	      # libraries. Need -bnortl late, we may have -brtl in LDFLAGS.
+	      _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+	    fi
+	    if test aix != "$with_aix_soname"; then
+	      _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# [...]
+	    else
+	      # used by -dlpreopen to get the symbols
+	      _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV  $output_objdir/$realname.d/$soname $output_objdir'
+	    fi
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d'
           fi
         fi
         ;;
@@ -6117,7 +6614,7 @@ if test "$_lt_caught_CXX_error" != yes; then
 	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
 	  # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
 	  # support --undefined.  This deserves some investigation.  FIXME
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
 	else
 	  _LT_TAGVAR(ld_shlibs, $1)=no
 	fi
@@ -6145,57 +6642,58 @@ if test "$_lt_caught_CXX_error" != yes; then
 	  # Tell ltmain to make .lib files, not .a files.
 	  libext=lib
 	  # Tell ltmain to make .dll files, not .so files.
-	  shrext_cmds=".dll"
+	  shrext_cmds=.dll
 	  # FIXME: Setting linknames here is a bad hack.
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	    else
-	      $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	    fi~
-	    $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	    linknames='
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+              cp "$export_symbols" "$output_objdir/$soname.def";
+              echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+            else
+              $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+            fi~
+            $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+            linknames='
 	  # The linker will not automatically build a static lib if we build a DLL.
 	  # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
 	  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
 	  # Don't use ranlib
 	  _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
 	  _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
-	    lt_tool_outputfile="@TOOL_OUTPUT@"~
-	    case $lt_outputfile in
-	      *.exe|*.EXE) ;;
-	      *)
-		lt_outputfile="$lt_outputfile.exe"
-		lt_tool_outputfile="$lt_tool_outputfile.exe"
-		;;
-	    esac~
-	    func_to_tool_file "$lt_outputfile"~
-	    if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	      $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	      $RM "$lt_outputfile.manifest";
-	    fi'
+            lt_tool_outputfile="@TOOL_OUTPUT@"~
+            case $lt_outputfile in
+              *.exe|*.EXE) ;;
+              *)
+                lt_outputfile=$lt_outputfile.exe
+                lt_tool_outputfile=$lt_tool_outputfile.exe
+                ;;
+            esac~
+            func_to_tool_file "$lt_outputfile"~
+            if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+              $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+              $RM "$lt_outputfile.manifest";
+            fi'
 	  ;;
 	*)
 	  # g++
 	  # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
 	  # as there is no search path for DLLs.
 	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols'
 	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
 	  _LT_TAGVAR(always_export_symbols, $1)=no
 	  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
 
 	  if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	    # If the export-symbols file already is a .def file (1st line
-	    # is EXPORTS), use it as is; otherwise, prepend...
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      cp $export_symbols $output_objdir/$soname.def;
-	    else
-	      echo EXPORTS > $output_objdir/$soname.def;
-	      cat $export_symbols >> $output_objdir/$soname.def;
-	    fi~
-	    $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	    # If the export-symbols file already is a .def file, use it as
+	    # is; otherwise, prepend EXPORTS...
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+              cp $export_symbols $output_objdir/$soname.def;
+            else
+              echo EXPORTS > $output_objdir/$soname.def;
+              cat $export_symbols >> $output_objdir/$soname.def;
+            fi~
+            $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
 	  else
 	    _LT_TAGVAR(ld_shlibs, $1)=no
 	  fi
@@ -6206,6 +6704,34 @@ if test "$_lt_caught_CXX_error" != yes; then
         _LT_DARWIN_LINKER_FEATURES($1)
 	;;
 
+      os2*)
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+	_LT_TAGVAR(hardcode_minus_L, $1)=yes
+	_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+	shrext_cmds=.dll
+	_LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	  $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	  $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	  $ECHO EXPORTS >> $output_objdir/$libname.def~
+	  emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	  $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	  emximp -o $lib $output_objdir/$libname.def'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	  $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	  $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	  $ECHO EXPORTS >> $output_objdir/$libname.def~
+	  prefix_cmds="$SED"~
+	  if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	    prefix_cmds="$prefix_cmds -e 1d";
+	  fi~
+	  prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	  cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	  $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	  emximp -o $lib $output_objdir/$libname.def'
+	_LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+	_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+	;;
+
       dgux*)
         case $cc_basename in
           ec++*)
@@ -6241,14 +6767,14 @@ if test "$_lt_caught_CXX_error" != yes; then
         ;;
 
       haiku*)
-        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
         _LT_TAGVAR(link_all_deplibs, $1)=yes
         ;;
 
       hpux9*)
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
         _LT_TAGVAR(hardcode_libdir_separator, $1)=:
-        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
         _LT_TAGVAR(hardcode_direct, $1)=yes
         _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
 				             # but as the default
@@ -6260,7 +6786,7 @@ if test "$_lt_caught_CXX_error" != yes; then
             _LT_TAGVAR(ld_shlibs, $1)=no
             ;;
           aCC*)
-            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
             # Commands to make compiler produce verbose output that lists
             # what "hidden" libraries, object files and flags are used when
             # linking a shared library.
@@ -6269,11 +6795,11 @@ if test "$_lt_caught_CXX_error" != yes; then
             # explicitly linking system object files so we need to strip them
             # from the output so that they don't get included in the library
             # dependencies.
-            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
             ;;
           *)
-            if test "$GXX" = yes; then
-              _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            if test yes = "$GXX"; then
+              _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
             else
               # FIXME: insert proper C++ library support
               _LT_TAGVAR(ld_shlibs, $1)=no
@@ -6283,15 +6809,15 @@ if test "$_lt_caught_CXX_error" != yes; then
         ;;
 
       hpux10*|hpux11*)
-        if test $with_gnu_ld = no; then
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+        if test no = "$with_gnu_ld"; then
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
 	  _LT_TAGVAR(hardcode_libdir_separator, $1)=:
 
           case $host_cpu in
             hppa*64*|ia64*)
               ;;
             *)
-	      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
               ;;
           esac
         fi
@@ -6317,13 +6843,13 @@ if test "$_lt_caught_CXX_error" != yes; then
           aCC*)
 	    case $host_cpu in
 	      hppa*64*)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	      ia64*)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	      *)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	    esac
 	    # Commands to make compiler produce verbose output that lists
@@ -6334,20 +6860,20 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 	    ;;
           *)
-	    if test "$GXX" = yes; then
-	      if test $with_gnu_ld = no; then
+	    if test yes = "$GXX"; then
+	      if test no = "$with_gnu_ld"; then
 	        case $host_cpu in
 	          hppa*64*)
-	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	          ia64*)
-	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	          *)
-	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	        esac
 	      fi
@@ -6362,22 +6888,22 @@ if test "$_lt_caught_CXX_error" != yes; then
       interix[[3-9]]*)
 	_LT_TAGVAR(hardcode_direct, $1)=no
 	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
 	# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
 	# Instead, shared libraries are loaded at an image base (0x10000000 by
 	# default) and relocated if they conflict, which is a slow very memory
 	# consuming and fragmenting process.  To avoid this, we pick a random,
 	# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
 	# time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
 	;;
       irix5* | irix6*)
         case $cc_basename in
           CC*)
 	    # SGI C++
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 
 	    # Archives containing C++ object files must be created using
 	    # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
@@ -6386,17 +6912,17 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
 	    ;;
           *)
-	    if test "$GXX" = yes; then
-	      if test "$with_gnu_ld" = no; then
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	    if test yes = "$GXX"; then
+	      if test no = "$with_gnu_ld"; then
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 	      else
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib'
 	      fi
 	    fi
 	    _LT_TAGVAR(link_all_deplibs, $1)=yes
 	    ;;
         esac
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
         _LT_TAGVAR(hardcode_libdir_separator, $1)=:
         _LT_TAGVAR(inherit_rpath, $1)=yes
         ;;
@@ -6409,8 +6935,8 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # KCC will only create a shared library if the output file
 	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
 	    # to its proper name (with version) after linking.
-	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib'
 	    # Commands to make compiler produce verbose output that lists
 	    # what "hidden" libraries, object files and flags are used when
 	    # linking a shared library.
@@ -6419,10 +6945,10 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
 
 	    # Archives containing C++ object files must be created using
 	    # "CC -Bstatic", where "CC" is the KAI C++ compiler.
@@ -6436,59 +6962,59 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # earlier do not add the objects themselves.
 	    case `$CC -V 2>&1` in
 	      *"Version 7."*)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 		;;
 	      *)  # Version 8.0 or newer
 	        tmp_idyn=
 	        case $host_cpu in
 		  ia64*) tmp_idyn=' -i_dynamic';;
 		esac
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 		;;
 	    esac
 	    _LT_TAGVAR(archive_cmds_need_lc, $1)=no
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive'
 	    ;;
           pgCC* | pgcpp*)
             # Portland Group C++ compiler
 	    case `$CC -V` in
 	    *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*)
 	      _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
-		compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
+               rm -rf $tpldir~
+               $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+               compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
 	      _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
-		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
-		$RANLIB $oldlib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+                $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
+                $RANLIB $oldlib'
 	      _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+                $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
 	      _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+                $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	      ;;
 	    *) # Version 6 and above use weak symbols
-	      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+	      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	      ;;
 	    esac
 
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl--rpath $wl$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
             ;;
 	  cxx*)
 	    # Compaq C++
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname  -o $lib $wl-retain-symbols-file $wl$export_symbols'
 
 	    runpath_var=LD_RUN_PATH
 	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
@@ -6502,18 +7028,18 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
 	    ;;
 	  xl* | mpixl* | bgxl*)
 	    # IBM XL 8.0 on PPC, with GNU ld
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    if test "x$supports_anon_versioning" = xyes; then
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	    if test yes = "$supports_anon_versioning"; then
 	      _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
-		cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-		echo "local: *; };" >> $output_objdir/$libname.ver~
-		$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+                cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+                echo "local: *; };" >> $output_objdir/$libname.ver~
+                $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
 	    fi
 	    ;;
 	  *)
@@ -6521,10 +7047,10 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    *Sun\ C*)
 	      # Sun C++ 5.9
 	      _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
-	      _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+	      _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols'
 	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-	      _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	      _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	      _LT_TAGVAR(compiler_needs_object, $1)=yes
 
 	      # Not sure whether something based on
@@ -6582,22 +7108,17 @@ if test "$_lt_caught_CXX_error" != yes; then
         _LT_TAGVAR(ld_shlibs, $1)=yes
 	;;
 
-      openbsd2*)
-        # C++ shared libraries are fairly broken
-	_LT_TAGVAR(ld_shlibs, $1)=no
-	;;
-
-      openbsd*)
+      openbsd* | bitrig*)
 	if test -f /usr/libexec/ld.so; then
 	  _LT_TAGVAR(hardcode_direct, $1)=yes
 	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
 	  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
 	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
 	  fi
 	  output_verbose_link_cmd=func_echo_all
 	else
@@ -6613,9 +7134,9 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # KCC will only create a shared library if the output file
 	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
 	    # to its proper name (with version) after linking.
-	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
 
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
 	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
 
 	    # Archives containing C++ object files must be created using
@@ -6633,17 +7154,17 @@ if test "$_lt_caught_CXX_error" != yes; then
           cxx*)
 	    case $host in
 	      osf3*)
-	        _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	        _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
 		;;
 	      *)
 	        _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 	        _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
-	          echo "-hidden">> $lib.exp~
-	          $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
-	          $RM $lib.exp'
+                  echo "-hidden">> $lib.exp~
+                  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~
+                  $RM $lib.exp'
 	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
 		;;
 	    esac
@@ -6658,21 +7179,21 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 	    ;;
 	  *)
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	    if test yes,no = "$GXX,$with_gnu_ld"; then
+	      _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
 	      case $host in
 	        osf3*)
-	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 		  ;;
 	        *)
-	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 		  ;;
 	      esac
 
-	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
 	      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
 
 	      # Commands to make compiler produce verbose output that lists
@@ -6718,9 +7239,9 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # Sun C++ 4.2, 5.x and Centerline C++
             _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
 	    _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	      $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+              $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
 	    _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
@@ -6728,7 +7249,7 @@ if test "$_lt_caught_CXX_error" != yes; then
 	      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
 	      *)
 		# The compiler driver will combine and reorder linker options,
-		# but understands `-z linker_flag'.
+		# but understands '-z linker_flag'.
 	        # Supported since Solaris 2.6 (maybe 2.5.1?)
 		_LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
 	        ;;
@@ -6745,30 +7266,30 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    ;;
           gcx*)
 	    # Green Hills C++ Compiler
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 
 	    # The C++ compiler must be used to create the archive.
 	    _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
 	    ;;
           *)
 	    # GNU C++ compiler with Solaris linker
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+	    if test yes,no = "$GXX,$with_gnu_ld"; then
+	      _LT_TAGVAR(no_undefined_flag, $1)=' $wl-z ${wl}defs'
 	      if $CC --version | $GREP -v '^2\.7' > /dev/null; then
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+                  $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	        # Commands to make compiler produce verbose output that lists
 	        # what "hidden" libraries, object files and flags are used when
 	        # linking a shared library.
 	        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
 	      else
-	        # g++ 2.7 appears to require `-G' NOT `-shared' on this
+	        # g++ 2.7 appears to require '-G' NOT '-shared' on this
 	        # platform.
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+                  $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	        # Commands to make compiler produce verbose output that lists
 	        # what "hidden" libraries, object files and flags are used when
@@ -6776,11 +7297,11 @@ if test "$_lt_caught_CXX_error" != yes; then
 	        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
 	      fi
 
-	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir'
 	      case $host_os in
 		solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
 		*)
-		  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+		  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
 		  ;;
 	      esac
 	    fi
@@ -6789,52 +7310,52 @@ if test "$_lt_caught_CXX_error" != yes; then
         ;;
 
     sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
-      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
       _LT_TAGVAR(archive_cmds_need_lc, $1)=no
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
       runpath_var='LD_RUN_PATH'
 
       case $cc_basename in
         CC*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
       esac
       ;;
 
       sysv5* | sco3.2v5* | sco5v6*)
-	# Note: We can NOT use -z defs as we might desire, because we do not
+	# Note: We CANNOT use -z defs as we might desire, because we do not
 	# link with -lc, and that would cause any symbols used from libc to
 	# always be unresolved, which means just about no library would
 	# ever link correctly.  If we're not using GNU ld we use -z text
 	# though, which does catch some bad symbols but isn't as heavy-handed
 	# as -z defs.
-	_LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-	_LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+	_LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
+	_LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs'
 	_LT_TAGVAR(archive_cmds_need_lc, $1)=no
 	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir'
 	_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
 	_LT_TAGVAR(link_all_deplibs, $1)=yes
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport'
 	runpath_var='LD_RUN_PATH'
 
 	case $cc_basename in
           CC*)
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~
-	      '"$_LT_TAGVAR(old_archive_cmds, $1)"
+              '"$_LT_TAGVAR(old_archive_cmds, $1)"
 	    _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~
-	      '"$_LT_TAGVAR(reload_cmds, $1)"
+              '"$_LT_TAGVAR(reload_cmds, $1)"
 	    ;;
 	  *)
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	    ;;
 	esac
       ;;
@@ -6865,10 +7386,10 @@ if test "$_lt_caught_CXX_error" != yes; then
     esac
 
     AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
-    test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+    test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no
 
-    _LT_TAGVAR(GCC, $1)="$GXX"
-    _LT_TAGVAR(LD, $1)="$LD"
+    _LT_TAGVAR(GCC, $1)=$GXX
+    _LT_TAGVAR(LD, $1)=$LD
 
     ## CAVEAT EMPTOR:
     ## There is no encapsulation within the following macros, do not change
@@ -6895,7 +7416,7 @@ if test "$_lt_caught_CXX_error" != yes; then
   lt_cv_path_LD=$lt_save_path_LD
   lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
   lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
-fi # test "$_lt_caught_CXX_error" != yes
+fi # test yes != "$_lt_caught_CXX_error"
 
 AC_LANG_POP
 ])# _LT_LANG_CXX_CONFIG
@@ -6917,13 +7438,14 @@ AC_REQUIRE([_LT_DECL_SED])
 AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])
 func_stripname_cnf ()
 {
-  case ${2} in
-  .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
-  *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+  case @S|@2 in
+  .*) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%\\\\@S|@2\$%%"`;;
+  *)  func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%@S|@2\$%%"`;;
   esac
 } # func_stripname_cnf
 ])# _LT_FUNC_STRIPNAME_CNF
 
+
 # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
 # ---------------------------------
 # Figure out "hidden" library dependencies from verbose
@@ -7007,13 +7529,13 @@ if AC_TRY_EVAL(ac_compile); then
   pre_test_object_deps_done=no
 
   for p in `eval "$output_verbose_link_cmd"`; do
-    case ${prev}${p} in
+    case $prev$p in
 
     -L* | -R* | -l*)
        # Some compilers place space between "-{L,R}" and the path.
        # Remove the space.
-       if test $p = "-L" ||
-          test $p = "-R"; then
+       if test x-L = "$p" ||
+          test x-R = "$p"; then
 	 prev=$p
 	 continue
        fi
@@ -7029,16 +7551,16 @@ if AC_TRY_EVAL(ac_compile); then
        case $p in
        =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
        esac
-       if test "$pre_test_object_deps_done" = no; then
-	 case ${prev} in
+       if test no = "$pre_test_object_deps_done"; then
+	 case $prev in
 	 -L | -R)
 	   # Internal compiler library paths should come after those
 	   # provided the user.  The postdeps already come after the
 	   # user supplied libs so there is no need to process them.
 	   if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
-	     _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+	     _LT_TAGVAR(compiler_lib_search_path, $1)=$prev$p
 	   else
-	     _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+	     _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} $prev$p"
 	   fi
 	   ;;
 	 # The "-l" case would never come before the object being
@@ -7046,9 +7568,9 @@ if AC_TRY_EVAL(ac_compile); then
 	 esac
        else
 	 if test -z "$_LT_TAGVAR(postdeps, $1)"; then
-	   _LT_TAGVAR(postdeps, $1)="${prev}${p}"
+	   _LT_TAGVAR(postdeps, $1)=$prev$p
 	 else
-	   _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
+	   _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} $prev$p"
 	 fi
        fi
        prev=
@@ -7063,15 +7585,15 @@ if AC_TRY_EVAL(ac_compile); then
 	 continue
        fi
 
-       if test "$pre_test_object_deps_done" = no; then
+       if test no = "$pre_test_object_deps_done"; then
 	 if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
-	   _LT_TAGVAR(predep_objects, $1)="$p"
+	   _LT_TAGVAR(predep_objects, $1)=$p
 	 else
 	   _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
 	 fi
        else
 	 if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
-	   _LT_TAGVAR(postdep_objects, $1)="$p"
+	   _LT_TAGVAR(postdep_objects, $1)=$p
 	 else
 	   _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
 	 fi
@@ -7102,51 +7624,6 @@ interix[[3-9]]*)
   _LT_TAGVAR(postdep_objects,$1)=
   _LT_TAGVAR(postdeps,$1)=
   ;;
-
-linux*)
-  case `$CC -V 2>&1 | sed 5q` in
-  *Sun\ C*)
-    # Sun C++ 5.9
-
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
-    esac
-
-    if test "$solaris_use_stlport4" != yes; then
-      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
-
-solaris*)
-  case $cc_basename in
-  CC* | sunCC*)
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
-    esac
-
-    # Adding this requires a known-good setup of shared libraries for
-    # Sun compiler versions before 5.6, else PIC objects from an old
-    # archive will be linked into the output, leading to subtle bugs.
-    if test "$solaris_use_stlport4" != yes; then
-      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
 esac
 ])
 
@@ -7155,7 +7632,7 @@ case " $_LT_TAGVAR(postdeps, $1) " in
 esac
  _LT_TAGVAR(compiler_lib_search_dirs, $1)=
 if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
- _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | $SED -e 's! -L! !g' -e 's!^ !!'`
 fi
 _LT_TAGDECL([], [compiler_lib_search_dirs], [1],
     [The directories searched by this compiler when creating a shared library])
@@ -7175,10 +7652,10 @@ _LT_TAGDECL([], [compiler_lib_search_path], [1],
 # --------------------------
 # Ensure that the configuration variables for a Fortran 77 compiler are
 # suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_F77_CONFIG],
 [AC_LANG_PUSH(Fortran 77)
-if test -z "$F77" || test "X$F77" = "Xno"; then
+if test -z "$F77" || test no = "$F77"; then
   _lt_disable_F77=yes
 fi
 
@@ -7215,7 +7692,7 @@ _LT_TAGVAR(objext, $1)=$objext
 # the F77 compiler isn't working.  Some variables (like enable_shared)
 # are currently assumed to apply to all compilers on this platform,
 # and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_disable_F77" != yes; then
+if test yes != "$_lt_disable_F77"; then
   # Code to be used in simple compile tests
   lt_simple_compile_test_code="\
       subroutine t
@@ -7237,7 +7714,7 @@ if test "$_lt_disable_F77" != yes; then
   _LT_LINKER_BOILERPLATE
 
   # Allow CC to be a program name with arguments.
-  lt_save_CC="$CC"
+  lt_save_CC=$CC
   lt_save_GCC=$GCC
   lt_save_CFLAGS=$CFLAGS
   CC=${F77-"f77"}
@@ -7251,21 +7728,25 @@ if test "$_lt_disable_F77" != yes; then
     AC_MSG_RESULT([$can_build_shared])
 
     AC_MSG_CHECKING([whether to build shared libraries])
-    test "$can_build_shared" = "no" && enable_shared=no
+    test no = "$can_build_shared" && enable_shared=no
 
     # On AIX, shared libraries and static libraries use the same namespace, and
     # are all built from PIC.
     case $host_os in
       aix3*)
-        test "$enable_shared" = yes && enable_static=no
+        test yes = "$enable_shared" && enable_static=no
         if test -n "$RANLIB"; then
           archive_cmds="$archive_cmds~\$RANLIB \$lib"
           postinstall_cmds='$RANLIB $lib'
         fi
         ;;
       aix[[4-9]]*)
-	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-	  test "$enable_shared" = yes && enable_static=no
+	if test ia64 != "$host_cpu"; then
+	  case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+	  yes,aix,yes) ;;		# shared object as lib.so file only
+	  yes,svr4,*) ;;		# shared object as lib.so archive member only
+	  yes,*) enable_static=no ;;	# shared object in lib.a archive as well
+	  esac
 	fi
         ;;
     esac
@@ -7273,11 +7754,11 @@ if test "$_lt_disable_F77" != yes; then
 
     AC_MSG_CHECKING([whether to build static libraries])
     # Make sure either enable_shared or enable_static is yes.
-    test "$enable_shared" = yes || enable_static=yes
+    test yes = "$enable_shared" || enable_static=yes
     AC_MSG_RESULT([$enable_static])
 
-    _LT_TAGVAR(GCC, $1)="$G77"
-    _LT_TAGVAR(LD, $1)="$LD"
+    _LT_TAGVAR(GCC, $1)=$G77
+    _LT_TAGVAR(LD, $1)=$LD
 
     ## CAVEAT EMPTOR:
     ## There is no encapsulation within the following macros, do not change
@@ -7294,9 +7775,9 @@ if test "$_lt_disable_F77" != yes; then
   fi # test -n "$compiler"
 
   GCC=$lt_save_GCC
-  CC="$lt_save_CC"
-  CFLAGS="$lt_save_CFLAGS"
-fi # test "$_lt_disable_F77" != yes
+  CC=$lt_save_CC
+  CFLAGS=$lt_save_CFLAGS
+fi # test yes != "$_lt_disable_F77"
 
 AC_LANG_POP
 ])# _LT_LANG_F77_CONFIG
@@ -7306,11 +7787,11 @@ AC_LANG_POP
 # -------------------------
 # Ensure that the configuration variables for a Fortran compiler are
 # suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_FC_CONFIG],
 [AC_LANG_PUSH(Fortran)
 
-if test -z "$FC" || test "X$FC" = "Xno"; then
+if test -z "$FC" || test no = "$FC"; then
   _lt_disable_FC=yes
 fi
 
@@ -7347,7 +7828,7 @@ _LT_TAGVAR(objext, $1)=$objext
 # the FC compiler isn't working.  Some variables (like enable_shared)
 # are currently assumed to apply to all compilers on this platform,
 # and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_disable_FC" != yes; then
+if test yes != "$_lt_disable_FC"; then
   # Code to be used in simple compile tests
   lt_simple_compile_test_code="\
       subroutine t
@@ -7369,7 +7850,7 @@ if test "$_lt_disable_FC" != yes; then
   _LT_LINKER_BOILERPLATE
 
   # Allow CC to be a program name with arguments.
-  lt_save_CC="$CC"
+  lt_save_CC=$CC
   lt_save_GCC=$GCC
   lt_save_CFLAGS=$CFLAGS
   CC=${FC-"f95"}
@@ -7385,21 +7866,25 @@ if test "$_lt_disable_FC" != yes; then
     AC_MSG_RESULT([$can_build_shared])
 
     AC_MSG_CHECKING([whether to build shared libraries])
-    test "$can_build_shared" = "no" && enable_shared=no
+    test no = "$can_build_shared" && enable_shared=no
 
     # On AIX, shared libraries and static libraries use the same namespace, and
     # are all built from PIC.
     case $host_os in
       aix3*)
-        test "$enable_shared" = yes && enable_static=no
+        test yes = "$enable_shared" && enable_static=no
         if test -n "$RANLIB"; then
           archive_cmds="$archive_cmds~\$RANLIB \$lib"
           postinstall_cmds='$RANLIB $lib'
         fi
         ;;
       aix[[4-9]]*)
-	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-	  test "$enable_shared" = yes && enable_static=no
+	if test ia64 != "$host_cpu"; then
+	  case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+	  yes,aix,yes) ;;		# shared object as lib.so file only
+	  yes,svr4,*) ;;		# shared object as lib.so archive member only
+	  yes,*) enable_static=no ;;	# shared object in lib.a archive as well
+	  esac
 	fi
         ;;
     esac
@@ -7407,11 +7892,11 @@ if test "$_lt_disable_FC" != yes; then
 
     AC_MSG_CHECKING([whether to build static libraries])
     # Make sure either enable_shared or enable_static is yes.
-    test "$enable_shared" = yes || enable_static=yes
+    test yes = "$enable_shared" || enable_static=yes
     AC_MSG_RESULT([$enable_static])
 
-    _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
-    _LT_TAGVAR(LD, $1)="$LD"
+    _LT_TAGVAR(GCC, $1)=$ac_cv_fc_compiler_gnu
+    _LT_TAGVAR(LD, $1)=$LD
 
     ## CAVEAT EMPTOR:
     ## There is no encapsulation within the following macros, do not change
@@ -7431,7 +7916,7 @@ if test "$_lt_disable_FC" != yes; then
   GCC=$lt_save_GCC
   CC=$lt_save_CC
   CFLAGS=$lt_save_CFLAGS
-fi # test "$_lt_disable_FC" != yes
+fi # test yes != "$_lt_disable_FC"
 
 AC_LANG_POP
 ])# _LT_LANG_FC_CONFIG
@@ -7441,7 +7926,7 @@ AC_LANG_POP
 # --------------------------
 # Ensure that the configuration variables for the GNU Java Compiler compiler
 # are suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_GCJ_CONFIG],
 [AC_REQUIRE([LT_PROG_GCJ])dnl
 AC_LANG_SAVE
@@ -7475,7 +7960,7 @@ CC=${GCJ-"gcj"}
 CFLAGS=$GCJFLAGS
 compiler=$CC
 _LT_TAGVAR(compiler, $1)=$CC
-_LT_TAGVAR(LD, $1)="$LD"
+_LT_TAGVAR(LD, $1)=$LD
 _LT_CC_BASENAME([$compiler])
 
 # GCJ did not exist at the time GCC didn't implicitly link libc in.
@@ -7512,7 +7997,7 @@ CFLAGS=$lt_save_CFLAGS
 # --------------------------
 # Ensure that the configuration variables for the GNU Go compiler
 # are suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_GO_CONFIG],
 [AC_REQUIRE([LT_PROG_GO])dnl
 AC_LANG_SAVE
@@ -7546,7 +8031,7 @@ CC=${GOC-"gccgo"}
 CFLAGS=$GOFLAGS
 compiler=$CC
 _LT_TAGVAR(compiler, $1)=$CC
-_LT_TAGVAR(LD, $1)="$LD"
+_LT_TAGVAR(LD, $1)=$LD
 _LT_CC_BASENAME([$compiler])
 
 # Go did not exist at the time GCC didn't implicitly link libc in.
@@ -7583,7 +8068,7 @@ CFLAGS=$lt_save_CFLAGS
 # -------------------------
 # Ensure that the configuration variables for the Windows resource compiler
 # are suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_RC_CONFIG],
 [AC_REQUIRE([LT_PROG_RC])dnl
 AC_LANG_SAVE
@@ -7599,7 +8084,7 @@ _LT_TAGVAR(objext, $1)=$objext
 lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
 
 # Code to be used in simple link tests
-lt_simple_link_test_code="$lt_simple_compile_test_code"
+lt_simple_link_test_code=$lt_simple_compile_test_code
 
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 _LT_TAG_COMPILER
@@ -7609,7 +8094,7 @@ _LT_COMPILER_BOILERPLATE
 _LT_LINKER_BOILERPLATE
 
 # Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
+lt_save_CC=$CC
 lt_save_CFLAGS=$CFLAGS
 lt_save_GCC=$GCC
 GCC=
@@ -7638,7 +8123,7 @@ AC_DEFUN([LT_PROG_GCJ],
 [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
   [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
     [AC_CHECK_TOOL(GCJ, gcj,)
-      test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+      test set = "${GCJFLAGS+set}" || GCJFLAGS="-g -O2"
       AC_SUBST(GCJFLAGS)])])[]dnl
 ])
 
@@ -7749,7 +8234,7 @@ lt_ac_count=0
 # Add /usr/xpg4/bin/sed as it is typically found on Solaris
 # along with /bin/sed that truncates output.
 for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
-  test ! -f $lt_ac_sed && continue
+  test ! -f "$lt_ac_sed" && continue
   cat /dev/null > conftest.in
   lt_ac_count=0
   echo $ECHO_N "0123456789$ECHO_C" >conftest.in
@@ -7766,9 +8251,9 @@ for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
     $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
     cmp -s conftest.out conftest.nl || break
     # 10000 chars as input seems more than enough
-    test $lt_ac_count -gt 10 && break
+    test 10 -lt "$lt_ac_count" && break
     lt_ac_count=`expr $lt_ac_count + 1`
-    if test $lt_ac_count -gt $lt_ac_max; then
+    if test "$lt_ac_count" -gt "$lt_ac_max"; then
       lt_ac_max=$lt_ac_count
       lt_cv_path_SED=$lt_ac_sed
     fi
@@ -7792,27 +8277,7 @@ dnl AC_DEFUN([LT_AC_PROG_SED], [])
 # Find out whether the shell is Bourne or XSI compatible,
 # or has some other useful features.
 m4_defun([_LT_CHECK_SHELL_FEATURES],
-[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
-# Try some XSI features
-xsi_shell=no
-( _lt_dummy="a/b/c"
-  test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
-      = c,a/b,b/c, \
-    && eval 'test $(( 1 + 1 )) -eq 2 \
-    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
-  && xsi_shell=yes
-AC_MSG_RESULT([$xsi_shell])
-_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
-
-AC_MSG_CHECKING([whether the shell understands "+="])
-lt_shell_append=no
-( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
-    >/dev/null 2>&1 \
-  && lt_shell_append=yes
-AC_MSG_RESULT([$lt_shell_append])
-_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
-
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+[if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
   lt_unset=unset
 else
   lt_unset=false
@@ -7836,102 +8301,9 @@ _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
 ])# _LT_CHECK_SHELL_FEATURES
 
 
-# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY)
-# ------------------------------------------------------
-# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and
-# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY.
-m4_defun([_LT_PROG_FUNCTION_REPLACE],
-[dnl {
-sed -e '/^$1 ()$/,/^} # $1 /c\
-$1 ()\
-{\
-m4_bpatsubsts([$2], [$], [\\], [^\([	 ]\)], [\\\1])
-} # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-])
-
-
-# _LT_PROG_REPLACE_SHELLFNS
-# -------------------------
-# Replace existing portable implementations of several shell functions with
-# equivalent extended shell implementations where those features are available..
-m4_defun([_LT_PROG_REPLACE_SHELLFNS],
-[if test x"$xsi_shell" = xyes; then
-  _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl
-    case ${1} in
-      */*) func_dirname_result="${1%/*}${2}" ;;
-      *  ) func_dirname_result="${3}" ;;
-    esac])
-
-  _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl
-    func_basename_result="${1##*/}"])
-
-  _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl
-    case ${1} in
-      */*) func_dirname_result="${1%/*}${2}" ;;
-      *  ) func_dirname_result="${3}" ;;
-    esac
-    func_basename_result="${1##*/}"])
-
-  _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl
-    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
-    # positional parameters, so assign one to ordinary parameter first.
-    func_stripname_result=${3}
-    func_stripname_result=${func_stripname_result#"${1}"}
-    func_stripname_result=${func_stripname_result%"${2}"}])
-
-  _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl
-    func_split_long_opt_name=${1%%=*}
-    func_split_long_opt_arg=${1#*=}])
-
-  _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl
-    func_split_short_opt_arg=${1#??}
-    func_split_short_opt_name=${1%"$func_split_short_opt_arg"}])
-
-  _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl
-    case ${1} in
-      *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
-      *)    func_lo2o_result=${1} ;;
-    esac])
-
-  _LT_PROG_FUNCTION_REPLACE([func_xform], [    func_xform_result=${1%.*}.lo])
-
-  _LT_PROG_FUNCTION_REPLACE([func_arith], [    func_arith_result=$(( $[*] ))])
-
-  _LT_PROG_FUNCTION_REPLACE([func_len], [    func_len_result=${#1}])
-fi
-
-if test x"$lt_shell_append" = xyes; then
-  _LT_PROG_FUNCTION_REPLACE([func_append], [    eval "${1}+=\\${2}"])
-
-  _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl
-    func_quote_for_eval "${2}"
-dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \
-    eval "${1}+=\\\\ \\$func_quote_for_eval_result"])
-
-  # Save a `func_append' function call where possible by direct use of '+='
-  sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-else
-  # Save a `func_append' function call even when '+=' is not available
-  sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-fi
-
-if test x"$_lt_function_replace_fail" = x":"; then
-  AC_MSG_WARN([Unable to substitute extended shell functions in $ofile])
-fi
-])
-
 # _LT_PATH_CONVERSION_FUNCTIONS
 # -----------------------------
-# Determine which file name conversion functions should be used by
+# Determine what file name conversion functions should be used by
 # func_to_host_file (and, implicitly, by func_to_host_path).  These are needed
 # for certain cross-compile configurations and native mingw.
 m4_defun([_LT_PATH_CONVERSION_FUNCTIONS],
diff --git a/m4/ltoptions.m4 b/m4/ltoptions.m4
index 5d9acd8..94b0829 100644
--- a/m4/ltoptions.m4
+++ b/m4/ltoptions.m4
@@ -1,14 +1,14 @@
 # Helper functions for option handling.                    -*- Autoconf -*-
 #
-#   Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
-#   Inc.
+#   Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software
+#   Foundation, Inc.
 #   Written by Gary V. Vaughan, 2004
 #
 # This file is free software; the Free Software Foundation gives
 # unlimited permission to copy and/or distribute it, with or without
 # modifications, as long as this notice is preserved.
 
-# serial 7 ltoptions.m4
+# serial 8 ltoptions.m4
 
 # This is to help aclocal find these macros, as it can't see m4_define.
 AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
@@ -29,7 +29,7 @@ m4_define([_LT_SET_OPTION],
 [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
 m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
         _LT_MANGLE_DEFUN([$1], [$2]),
-    [m4_warning([Unknown $1 option `$2'])])[]dnl
+    [m4_warning([Unknown $1 option '$2'])])[]dnl
 ])
 
 
@@ -75,13 +75,15 @@ m4_if([$1],[LT_INIT],[
   dnl
   dnl If no reference was made to various pairs of opposing options, then
   dnl we run the default mode handler for the pair.  For example, if neither
-  dnl `shared' nor `disable-shared' was passed, we enable building of shared
+  dnl 'shared' nor 'disable-shared' was passed, we enable building of shared
   dnl archives by default:
   _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
   _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
   _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
   _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
-  		   [_LT_ENABLE_FAST_INSTALL])
+		   [_LT_ENABLE_FAST_INSTALL])
+  _LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4],
+		   [_LT_WITH_AIX_SONAME([aix])])
   ])
 ])# _LT_SET_OPTIONS
 
@@ -112,7 +114,7 @@ AU_DEFUN([AC_LIBTOOL_DLOPEN],
 [_LT_SET_OPTION([LT_INIT], [dlopen])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `dlopen' option into LT_INIT's first parameter.])
+put the 'dlopen' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:
@@ -148,7 +150,7 @@ AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
 _LT_SET_OPTION([LT_INIT], [win32-dll])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `win32-dll' option into LT_INIT's first parameter.])
+put the 'win32-dll' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:
@@ -157,9 +159,9 @@ dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
 
 # _LT_ENABLE_SHARED([DEFAULT])
 # ----------------------------
-# implement the --enable-shared flag, and supports the `shared' and
-# `disable-shared' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+# implement the --enable-shared flag, and supports the 'shared' and
+# 'disable-shared' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'.  If omitted, it defaults to 'yes'.
 m4_define([_LT_ENABLE_SHARED],
 [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
 AC_ARG_ENABLE([shared],
@@ -172,14 +174,14 @@ AC_ARG_ENABLE([shared],
     *)
       enable_shared=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_shared=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
     [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
@@ -211,9 +213,9 @@ dnl AC_DEFUN([AM_DISABLE_SHARED], [])
 
 # _LT_ENABLE_STATIC([DEFAULT])
 # ----------------------------
-# implement the --enable-static flag, and support the `static' and
-# `disable-static' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+# implement the --enable-static flag, and support the 'static' and
+# 'disable-static' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'.  If omitted, it defaults to 'yes'.
 m4_define([_LT_ENABLE_STATIC],
 [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
 AC_ARG_ENABLE([static],
@@ -226,14 +228,14 @@ AC_ARG_ENABLE([static],
     *)
      enable_static=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_static=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
     [enable_static=]_LT_ENABLE_STATIC_DEFAULT)
@@ -265,9 +267,9 @@ dnl AC_DEFUN([AM_DISABLE_STATIC], [])
 
 # _LT_ENABLE_FAST_INSTALL([DEFAULT])
 # ----------------------------------
-# implement the --enable-fast-install flag, and support the `fast-install'
-# and `disable-fast-install' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+# implement the --enable-fast-install flag, and support the 'fast-install'
+# and 'disable-fast-install' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'.  If omitted, it defaults to 'yes'.
 m4_define([_LT_ENABLE_FAST_INSTALL],
 [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
 AC_ARG_ENABLE([fast-install],
@@ -280,14 +282,14 @@ AC_ARG_ENABLE([fast-install],
     *)
       enable_fast_install=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_fast_install=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
     [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
@@ -304,14 +306,14 @@ AU_DEFUN([AC_ENABLE_FAST_INSTALL],
 [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you put
-the `fast-install' option into LT_INIT's first parameter.])
+the 'fast-install' option into LT_INIT's first parameter.])
 ])
 
 AU_DEFUN([AC_DISABLE_FAST_INSTALL],
 [_LT_SET_OPTION([LT_INIT], [disable-fast-install])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you put
-the `disable-fast-install' option into LT_INIT's first parameter.])
+the 'disable-fast-install' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:
@@ -319,11 +321,64 @@ dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
 dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
 
 
+# _LT_WITH_AIX_SONAME([DEFAULT])
+# ----------------------------------
+# implement the --with-aix-soname flag, and support the `aix-soname=aix'
+# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT
+# is either `aix', `both' or `svr4'.  If omitted, it defaults to `aix'.
+m4_define([_LT_WITH_AIX_SONAME],
+[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl
+shared_archive_member_spec=
+case $host,$enable_shared in
+power*-*-aix[[5-9]]*,yes)
+  AC_MSG_CHECKING([which variant of shared library versioning to provide])
+  AC_ARG_WITH([aix-soname],
+    [AS_HELP_STRING([--with-aix-soname=aix|svr4|both],
+      [shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])],
+    [case $withval in
+    aix|svr4|both)
+      ;;
+    *)
+      AC_MSG_ERROR([Unknown argument to --with-aix-soname])
+      ;;
+    esac
+    lt_cv_with_aix_soname=$with_aix_soname],
+    [AC_CACHE_VAL([lt_cv_with_aix_soname],
+      [lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT)
+    with_aix_soname=$lt_cv_with_aix_soname])
+  AC_MSG_RESULT([$with_aix_soname])
+  if test aix != "$with_aix_soname"; then
+    # For the AIX way of multilib, we name the shared archive member
+    # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
+    # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.
+    # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,
+    # the AIX toolchain works better with OBJECT_MODE set (default 32).
+    if test 64 = "${OBJECT_MODE-32}"; then
+      shared_archive_member_spec=shr_64
+    else
+      shared_archive_member_spec=shr
+    fi
+  fi
+  ;;
+*)
+  with_aix_soname=aix
+  ;;
+esac
+
+_LT_DECL([], [shared_archive_member_spec], [0],
+    [Shared archive member basename, for filename based shared library versioning on AIX])dnl
+])# _LT_WITH_AIX_SONAME
+
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])])
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])])
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])])
+
+
 # _LT_WITH_PIC([MODE])
 # --------------------
-# implement the --with-pic flag, and support the `pic-only' and `no-pic'
+# implement the --with-pic flag, and support the 'pic-only' and 'no-pic'
 # LT_INIT options.
-# MODE is either `yes' or `no'.  If omitted, it defaults to `both'.
+# MODE is either 'yes' or 'no'.  If omitted, it defaults to 'both'.
 m4_define([_LT_WITH_PIC],
 [AC_ARG_WITH([pic],
     [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
@@ -334,19 +389,17 @@ m4_define([_LT_WITH_PIC],
     *)
       pic_mode=default
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for lt_pkg in $withval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$lt_pkg" = "X$lt_p"; then
 	  pic_mode=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
-    [pic_mode=default])
-
-test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
+    [pic_mode=m4_default([$1], [default])])
 
 _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
 ])# _LT_WITH_PIC
@@ -359,7 +412,7 @@ AU_DEFUN([AC_LIBTOOL_PICMODE],
 [_LT_SET_OPTION([LT_INIT], [pic-only])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `pic-only' option into LT_INIT's first parameter.])
+put the 'pic-only' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:
diff --git a/m4/ltsugar.m4 b/m4/ltsugar.m4
index 9000a05..48bc934 100644
--- a/m4/ltsugar.m4
+++ b/m4/ltsugar.m4
@@ -1,6 +1,7 @@
 # ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-
 #
-# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software
+# Foundation, Inc.
 # Written by Gary V. Vaughan, 2004
 #
 # This file is free software; the Free Software Foundation gives
@@ -33,7 +34,7 @@ m4_define([_lt_join],
 # ------------
 # Manipulate m4 lists.
 # These macros are necessary as long as will still need to support
-# Autoconf-2.59 which quotes differently.
+# Autoconf-2.59, which quotes differently.
 m4_define([lt_car], [[$1]])
 m4_define([lt_cdr],
 [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
@@ -44,7 +45,7 @@ m4_define([lt_unquote], $1)
 
 # lt_append(MACRO-NAME, STRING, [SEPARATOR])
 # ------------------------------------------
-# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
+# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'.
 # Note that neither SEPARATOR nor STRING are expanded; they are appended
 # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
 # No SEPARATOR is output if MACRO-NAME was previously undefined (different
diff --git a/m4/ltversion.m4 b/m4/ltversion.m4
index 07a8602..fa04b52 100644
--- a/m4/ltversion.m4
+++ b/m4/ltversion.m4
@@ -1,6 +1,6 @@
 # ltversion.m4 -- version numbers			-*- Autoconf -*-
 #
-#   Copyright (C) 2004 Free Software Foundation, Inc.
+#   Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc.
 #   Written by Scott James Remnant, 2004
 #
 # This file is free software; the Free Software Foundation gives
@@ -9,15 +9,15 @@
 
 # @configure_input@
 
-# serial 3337 ltversion.m4
+# serial 4179 ltversion.m4
 # This file is part of GNU Libtool
 
-m4_define([LT_PACKAGE_VERSION], [2.4.2])
-m4_define([LT_PACKAGE_REVISION], [1.3337])
+m4_define([LT_PACKAGE_VERSION], [2.4.6])
+m4_define([LT_PACKAGE_REVISION], [2.4.6])
 
 AC_DEFUN([LTVERSION_VERSION],
-[macro_version='2.4.2'
-macro_revision='1.3337'
+[macro_version='2.4.6'
+macro_revision='2.4.6'
 _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
 _LT_DECL(, macro_revision, 0)
 ])
diff --git a/m4/lt~obsolete.m4 b/m4/lt~obsolete.m4
index c573da9..c6b26f8 100644
--- a/m4/lt~obsolete.m4
+++ b/m4/lt~obsolete.m4
@@ -1,6 +1,7 @@
 # lt~obsolete.m4 -- aclocal satisfying obsolete definitions.    -*-Autoconf-*-
 #
-#   Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
+#   Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software
+#   Foundation, Inc.
 #   Written by Scott James Remnant, 2004.
 #
 # This file is free software; the Free Software Foundation gives
@@ -11,7 +12,7 @@
 
 # These exist entirely to fool aclocal when bootstrapping libtool.
 #
-# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
+# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN),
 # which have later been changed to m4_define as they aren't part of the
 # exported API, or moved to Autoconf or Automake where they belong.
 #
@@ -25,7 +26,7 @@
 # included after everything else.  This provides aclocal with the
 # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
 # because those macros already exist, or will be overwritten later.
-# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. 
+# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
 #
 # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
 # Yes, that means every name once taken will need to remain here until
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
index 2c3689e..319f445 100644
--- a/scripts/CMakeLists.txt
+++ b/scripts/CMakeLists.txt
@@ -31,15 +31,15 @@ if(UNIX)
   set(ADD_INCLUDE "-I${CMAKE_BINARY_DIR}")
   set(FULL_TARGET_DIR "${CMAKE_BINARY_DIR}/lib/kernel/\${target_dir}")
   configure_file("${CMAKE_SOURCE_DIR}/scripts/pocl-standalone.in.cmake" "${CMAKE_BINARY_DIR}/scripts/pocl-standalone.in" ESCAPE_QUOTES @ONLY)
-  file(GENERATE OUTPUT "scripts/pocl-standalone" INPUT "scripts/pocl-standalone.in")
+  file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/scripts/pocl-standalone" INPUT "${CMAKE_BINARY_DIR}/scripts/pocl-standalone.in")
 
   # install script
   set(LLVMOPENCL_LOCATION "${POCL_INSTALL_PRIVATE_LIBDIR}/$<TARGET_FILE_NAME:llvmopencl>")
   set(KERNEL_INCLUDE_DIR "${POCL_INSTALL_PRIVATE_HEADER_DIR}")
   set(ADD_INCLUDE "")
   set(FULL_TARGET_DIR "${POCL_INSTALL_PRIVATE_DATADIR}")
-  configure_file("pocl-standalone.in.cmake" "pocl-standalone.install.in" ESCAPE_QUOTES @ONLY)
-  file(GENERATE OUTPUT "scripts/pocl-standalone.install" INPUT "scripts/pocl-standalone.install.in")
+  configure_file("${CMAKE_SOURCE_DIR}/scripts/pocl-standalone.in.cmake" "${CMAKE_BINARY_DIR}/scripts/pocl-standalone.install.in" ESCAPE_QUOTES @ONLY)
+  file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/scripts/pocl-standalone.install" INPUT "${CMAKE_BINARY_DIR}/scripts/pocl-standalone.install.in")
 
   install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pocl-standalone.install" RENAME "pocl-standalone"
         DESTINATION ${POCL_INSTALL_PUBLIC_BINDIR})
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
index f7a602e..f967e8e 100644
--- a/scripts/Makefile.in
+++ b/scripts/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -104,7 +114,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = scripts
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -113,6 +122,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -166,6 +176,7 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -217,6 +228,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -253,6 +267,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -410,7 +425,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign scripts/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign scripts/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -626,6 +640,8 @@ uninstall-am: uninstall-binSCRIPTS
 	mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \
 	uninstall-am uninstall-binSCRIPTS
 
+.PRECIOUS: Makefile
+
 
 pocl-standalone: %: %.in Makefile ../install-paths.h
 	$(do_subst) < $< > $@
diff --git a/scripts/pocl-standalone.in b/scripts/pocl-standalone.in
index f994976..e527568 100644
--- a/scripts/pocl-standalone.in
+++ b/scripts/pocl-standalone.in
@@ -73,7 +73,6 @@ case $target in
               LD_FLAGS="@TARGET_LD_FLAGS@";;
 esac
 CLANG_FLAGS="$CLANG_FLAGS -fasm -fsigned-char -Xclang -ffake-address-space-map"
-echo $target
 # With fp-contract we get calls to fma with processors which do not
 # have fma instructions. These ruin the performance. Better to have
 # the mul+add separated in the IR.
@@ -127,7 +126,7 @@ EXTRA_OPTS=""
     -load=${pocl_kernel_compiler_lib} -domtree -workitem-handler-chooser -break-constgeps -generate-header -flatten -always-inline \
     -globaldce -simplifycfg -loop-simplify -uniformity -phistoallocas -isolate-regions -implicit-loop-barriers -implicit-cond-barriers \
     -loop-barriers -barriertails -barriers -isolate-regions -add-wi-metadata -wi-aa -workitemrepl -workitemloops \
-    -allocastoentry -workgroup -kernel=${kernel} -local-size=1 1 1 -disable-simplify-libcalls \
+    -allocastoentry -workgroup -kernel=${kernel} -disable-simplify-libcalls \
     -target-address-spaces \
     ${EXTRA_OPTS} ${OPT_SWITCH} -instcombine -header=/dev/null ${FP_CONTRACT} -o ${output_file} ${linked_bc}
 
diff --git a/scripts/pocl-standalone.in.cmake b/scripts/pocl-standalone.in.cmake
index 59fdeda..2ce711c 100644
--- a/scripts/pocl-standalone.in.cmake
+++ b/scripts/pocl-standalone.in.cmake
@@ -115,7 +115,7 @@ fi
     -load=${pocl_kernel_compiler_lib} -domtree -workitem-handler-chooser -break-constgeps -generate-header -flatten -always-inline \
     -globaldce -simplifycfg -loop-simplify -uniformity -phistoallocas -isolate-regions -implicit-loop-barriers -implicit-cond-barriers \
     -loop-barriers -barriertails -barriers -isolate-regions -add-wi-metadata -wi-aa -workitemrepl -workitemloops \
-    -allocastoentry -workgroup -kernel=${kernel} -local-size=1 1 1 -disable-simplify-libcalls \
+    -allocastoentry -workgroup -kernel=${kernel} -disable-simplify-libcalls \
     -target-address-spaces \
     ${EXTRA_OPTS} ${OPT_SWITCH} -instcombine -header=/dev/null ${FP_CONTRACT} -o ${output_file} ${linked_bc}
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a60ac34..5a1f539 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -52,9 +52,8 @@ EXTRA_DIST = testsuite.at testsuite-samples.at testsuite-viennacl.at testsuite-r
 	testsuite-rodinia.at testsuite-tce.at testsuite-runtime.at \
 	testsuite-workgroup.at testsuite-parboil.at testsuite-amd.at \
 	testsuite-vexcl.at testsuite-piglit.at testsuite-halide.at testsuite-cloverleaf.at \
-	$(srcdir)/package.m4 $(TESTSUITE) atlocal.in testsuite-amdsdk2_9.at \
-	example_expout.txt scalarwave_expout.txt test_printf_expout.txt CMakeLists.txt
-
+	$(srcdir)/package.m4 $(TESTSUITE) atlocal.in testsuite-amdsdk2_9.at testsuite-opencv.at \
+        example_expout.txt test_printf_expout.txt scalarwave_expout.txt CMakeLists.txt
 
 DISTCLEANFILES = atconfig
 
@@ -77,7 +76,7 @@ $(TESTSUITE): $(srcdir)/testsuite.at $(srcdir)/testsuite-samples.at $(srcdir)/te
 	$(srcdir)/testsuite-amd.at \
 	$(srcdir)/testsuite-runtime.at $(srcdir)/testsuite-workgroup.at \
 	$(srcdir)/testsuite-vexcl.at $(srcdir)/testsuite-piglit.at \
-	$(srcdir)/testsuite-halide.at $(srcdir)/testsuite-cloverleaf.at \
-	$(srcdir)/package.m4 
+	$(srcdir)/testsuite-halide.at $(srcdir)/package.m4 \
+	$(srcdir)/testsuite-opencv.at $(srcdir)/testsuite-cloverleaf.at
 	$(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at
 	mv $@.tmp $@
diff --git a/tests/Makefile.in b/tests/Makefile.in
index d845e96..68a4a03 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -38,7 +38,17 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -104,8 +114,6 @@ host_triplet = @host@
 target_triplet = @target@
 @TCE_AVAILABLE_TRUE at am__append_1 = tce
 subdir = tests
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(srcdir)/atlocal.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -114,6 +122,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES = atlocal
@@ -172,6 +181,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/atlocal.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 am__relativize = \
   dir0=`pwd`; \
@@ -248,6 +258,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -284,6 +297,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -405,8 +419,8 @@ EXTRA_DIST = testsuite.at testsuite-samples.at testsuite-viennacl.at testsuite-r
 	testsuite-rodinia.at testsuite-tce.at testsuite-runtime.at \
 	testsuite-workgroup.at testsuite-parboil.at testsuite-amd.at \
 	testsuite-vexcl.at testsuite-piglit.at testsuite-halide.at testsuite-cloverleaf.at \
-	$(srcdir)/package.m4 $(TESTSUITE) atlocal.in testsuite-amdsdk2_9.at \
-	example_expout.txt scalarwave_expout.txt test_printf_expout.txt CMakeLists.txt
+	$(srcdir)/package.m4 $(TESTSUITE) atlocal.in testsuite-amdsdk2_9.at testsuite-opencv.at \
+        example_expout.txt test_printf_expout.txt scalarwave_expout.txt CMakeLists.txt
 
 DISTCLEANFILES = atconfig
 AUTOM4TE = $(SHELL) $(top_srcdir)/config/missing --run autom4te
@@ -426,7 +440,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign tests/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -726,6 +739,8 @@ uninstall-am:
 	mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
 	ps ps-am tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # The `:;' works around a Bash 3.2 bug when the output is not writeable.
 $(srcdir)/package.m4: $(top_srcdir)/configure.ac
@@ -761,8 +776,8 @@ $(TESTSUITE): $(srcdir)/testsuite.at $(srcdir)/testsuite-samples.at $(srcdir)/te
 	$(srcdir)/testsuite-amd.at \
 	$(srcdir)/testsuite-runtime.at $(srcdir)/testsuite-workgroup.at \
 	$(srcdir)/testsuite-vexcl.at $(srcdir)/testsuite-piglit.at \
-	$(srcdir)/testsuite-halide.at $(srcdir)/testsuite-cloverleaf.at \
-	$(srcdir)/package.m4 
+	$(srcdir)/testsuite-halide.at $(srcdir)/package.m4 \
+	$(srcdir)/testsuite-opencv.at $(srcdir)/testsuite-cloverleaf.at
 	$(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at
 	mv $@.tmp $@
 
diff --git a/tests/atlocal.in b/tests/atlocal.in
index 3f9775b..4f95b7d 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -2,6 +2,9 @@
 OCL_ICD_VENDORS="@abs_top_builddir@/ocl-vendors"
 export OCL_ICD_VENDORS
 
+OPENCL_VENDOR_PATH="@abs_top_builddir@/ocl-vendors"
+export OPENCL_VENDOR_PATH
+
 POCL_BUILDING=1
 export POCL_BUILDING
 
diff --git a/tests/cell/Makefile.in b/tests/cell/Makefile.in
index b6c71b8..97f6459 100644
--- a/tests/cell/Makefile.in
+++ b/tests/cell/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -38,7 +38,17 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -103,7 +113,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = tests/cell
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -112,6 +121,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -171,6 +181,7 @@ am__define_uniq_tagged_files = \
 ETAGS = etags
 CTAGS = ctags
 DIST_SUBDIRS = $(SUBDIRS)
+am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 am__relativize = \
   dir0=`pwd`; \
@@ -247,6 +258,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -283,6 +297,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -413,7 +428,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/cell/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign tests/cell/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -708,6 +722,8 @@ uninstall-am:
 	mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
 	ps ps-am tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/tests/cell/hello/Makefile.am b/tests/cell/hello/Makefile.am
index 33997c3..ce2627b 100644
--- a/tests/cell/hello/Makefile.am
+++ b/tests/cell/hello/Makefile.am
@@ -25,7 +25,7 @@ noinst_PROGRAMS = host
 
 host_SOURCES = host.cpp 
 host_LDADD = ../../../lib/CL/libpocl.la ../../../lib/poclu/libpoclu.la @LD_FLAGS_BIN@
-host_CXXFLAGS = @PTHREAD_CFLAGS@ -Wno-deprecated -Wno-deprecated-declarations
+host_CXXFLAGS = @PTHREAD_CFLAGS@ -std=c++11 -Wno-deprecated -Wno-deprecated-declarations
 
 AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/lib/CL \
 	-DSRCDIR='"$(abs_srcdir)"'
diff --git a/tests/cell/hello/Makefile.in b/tests/cell/hello/Makefile.in
index 30a5fc0..446dc63 100644
--- a/tests/cell/hello/Makefile.in
+++ b/tests/cell/hello/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -38,7 +38,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -104,8 +114,6 @@ host_triplet = @host@
 target_triplet = @target@
 noinst_PROGRAMS = host$(EXEEXT)
 subdir = tests/cell/hello
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -114,6 +122,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -190,6 +199,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -241,6 +251,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -277,6 +290,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -393,7 +407,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 host_SOURCES = host.cpp 
 host_LDADD = ../../../lib/CL/libpocl.la ../../../lib/poclu/libpoclu.la @LD_FLAGS_BIN@
-host_CXXFLAGS = @PTHREAD_CFLAGS@ -Wno-deprecated -Wno-deprecated-declarations
+host_CXXFLAGS = @PTHREAD_CFLAGS@ -std=c++11 -Wno-deprecated -Wno-deprecated-declarations
 AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/lib/CL \
 	-DSRCDIR='"$(abs_srcdir)"'
 
@@ -413,7 +427,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/cell/hello/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign tests/cell/hello/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -697,6 +710,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 run: host
 	@POCL_DEVICES="cellspu" ./host
diff --git a/tests/cell/hello/host.cpp b/tests/cell/hello/host.cpp
index e7247de..ef6cdc1 100644
--- a/tests/cell/hello/host.cpp
+++ b/tests/cell/hello/host.cpp
@@ -22,8 +22,10 @@
 */
 
 // Enable OpenCL C++ exceptions
-#define __CL_ENABLE_EXCEPTIONS
-#include <CL/cl.hpp>
+#define CL_HPP_ENABLE_EXCEPTIONS
+#define CL_HPP_MINIMUM_OPENCL_VERSION 120
+#define CL_HPP_TARGET_OPENCL_VERSION 120
+#include <CL/cl2.hpp>
 
 #include <cstdio>
 #include <cstdlib>
@@ -81,7 +83,7 @@ main(void)
         b = poclu_bswap_cl_int (device(), b);
 
         // Create and program from source
-        cl::Program::Sources sources(1, std::make_pair(kernelSourceCode, 0));
+        cl::Program::Sources sources({kernelSourceCode});
         cl::Program program(context, sources);
 
         // Build program
diff --git a/tests/kernel/CMakeLists.txt b/tests/kernel/CMakeLists.txt
index 06230e9..d0b6158 100644
--- a/tests/kernel/CMakeLists.txt
+++ b/tests/kernel/CMakeLists.txt
@@ -38,7 +38,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 ${OPENCL_CFLAGS}")
 # -> POCLU_LINK_OPTIONS in toplevel cmake
 
 ######################################################################
-add_executable("kernel" "kernel.c") # test_as_type.cl test_bitselect.cl test_convert_sat_regression.cl test_convert_type_*.cl test_fabs.cl test_fmin_fmax_fma.cl test_hadd.cl test_min_max.cl test_rotate.cl test_short16.cl test_sizeof.cl test_block.cl test_printf.cl
+add_executable("kernel" "kernel.c") # test_as_type.cl test_bitselect.cl test_convert_sat_regression.cl test_convert_type_*.cl test_fabs.cl test_fmin_fmax_fma.cl test_hadd.cl test_min_max.cl test_length_distance.cl test_rotate.cl test_short16.cl test_sizeof.cl test_block.cl test_printf.cl
 target_link_libraries("kernel" ${POCLU_LINK_OPTIONS})
 
 add_test("kernel/test_as_type" "kernel" "test_as_type")
@@ -78,6 +78,8 @@ set_tests_properties("kernel/test_hadd_loopvec"
 
 add_test("kernel/test_min_max" "kernel" "test_min_max")
 
+add_test("kernel/test_length_distance" "kernel" "test_length_distance")
+
 add_test("kernel/test_fmin_fmax_fma" "kernel" "test_fmin_fmax_fma")
 
 add_test("kernel/test_convert_sat_regression" "kernel" "test_convert_sat_regression")
@@ -88,9 +90,14 @@ add_test("kernel/test_fabs" "kernel" "test_fabs")
 
 add_test("kernel/test_short16" "kernel" "test_short16")
 
-set_tests_properties("kernel/test_min_max" "kernel/test_fmin_fmax_fma"
+add_test("kernel/test_frexp_modf" "kernel" "test_frexp_modf")
+
+add_test("kernel/test_local_struct_array" "kernel" "test_local_struct_array")
+
+set_tests_properties("kernel/test_min_max" "kernel/test_length_distance"
+  "kernel/test_fmin_fmax_fma" "kernel/test_local_struct_array"
   "kernel/test_convert_sat_regression"   "kernel/test_fabs"
-  "kernel/test_rotate" "kernel/test_short16"
+  "kernel/test_rotate" "kernel/test_short16" "kernel/test_frexp_modf"
   PROPERTIES
     COST 4.0
     FAIL_REGULAR_EXPRESSION "FAIL"
@@ -108,6 +115,11 @@ if(LLVM_3_2 OR (LLVM_3_3 AND POWERPC))
     PROPERTIES WILL_FAIL 1)
 endif()
 
+if(LLVM_ASSERTS_BUILD)
+  set_tests_properties("kernel/test_local_struct_array"
+    PROPERTIES WILL_FAIL 1)
+endif()
+
 # 3-element vector cases fail when vectorizer is enabled,
 # at least with Intel Core i5 and AMD FX8. Assume it fails on all others too.
 if(X86_64 AND (LLVM_3_5 OR LLVM_3_6))
diff --git a/tests/kernel/Makefile.am b/tests/kernel/Makefile.am
index 1bccce1..c44f403 100644
--- a/tests/kernel/Makefile.am
+++ b/tests/kernel/Makefile.am
@@ -25,7 +25,7 @@
 noinst_PROGRAMS = kernel sampler_address_clamp image_query_funcs test_shuffle
 test_shuffle_SOURCES=test_shuffle.cc
 
-kernel_SOURCES = kernel.c test_as_type.cl test_bitselect.cl test_convert_sat_regression.cl $(srcdir)/test_convert_type_*.cl test_fabs.cl test_fmin_fmax_fma.cl test_hadd.cl test_min_max.cl test_rotate.cl test_short16.cl test_sizeof.cl test_block.cl test_printf.cl
+kernel_SOURCES = kernel.c test_as_type.cl test_bitselect.cl test_convert_sat_regression.cl $(srcdir)/test_convert_type_*.cl test_fabs.cl test_fmin_fmax_fma.cl test_hadd.cl test_min_max.cl test_length_distance.cl test_rotate.cl test_short16.cl test_sizeof.cl test_block.cl test_printf.cl test_local_struct_array.cl test_frexp_modf.cl
 kernel_LDADD = -lm @OPENCL_LIBS@ ../../lib/poclu/libpoclu.la
 kernel_CFLAGS = -std=c99 @OPENCL_CFLAGS@
 
diff --git a/tests/kernel/Makefile.in b/tests/kernel/Makefile.in
index 19fcae5..e2426dd 100644
--- a/tests/kernel/Makefile.in
+++ b/tests/kernel/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -106,8 +116,6 @@ target_triplet = @target@
 noinst_PROGRAMS = kernel$(EXEEXT) sampler_address_clamp$(EXEEXT) \
 	image_query_funcs$(EXEEXT) test_shuffle$(EXEEXT)
 subdir = tests/kernel
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -116,6 +124,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -225,6 +234,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -276,6 +286,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -312,6 +325,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -427,7 +441,7 @@ top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 test_shuffle_SOURCES = test_shuffle.cc
-kernel_SOURCES = kernel.c test_as_type.cl test_bitselect.cl test_convert_sat_regression.cl $(srcdir)/test_convert_type_*.cl test_fabs.cl test_fmin_fmax_fma.cl test_hadd.cl test_min_max.cl test_rotate.cl test_short16.cl test_sizeof.cl test_block.cl test_printf.cl
+kernel_SOURCES = kernel.c test_as_type.cl test_bitselect.cl test_convert_sat_regression.cl $(srcdir)/test_convert_type_*.cl test_fabs.cl test_fmin_fmax_fma.cl test_hadd.cl test_min_max.cl test_length_distance.cl test_rotate.cl test_short16.cl test_sizeof.cl test_block.cl test_printf.cl test_local_struct_array.cl test_frexp_modf.cl
 kernel_LDADD = -lm @OPENCL_LIBS@ ../../lib/poclu/libpoclu.la
 kernel_CFLAGS = -std=c99 @OPENCL_CFLAGS@
 sampler_address_clamp_SOURCES = sampler_address_clamp.c test_sampler_address_clamp.cl
@@ -455,7 +469,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/kernel/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign tests/kernel/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -789,6 +802,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/tests/kernel/image_query_funcs.c b/tests/kernel/image_query_funcs.c
index 1129680..f6e7d5b 100644
--- a/tests/kernel/image_query_funcs.c
+++ b/tests/kernel/image_query_funcs.c
@@ -31,16 +31,23 @@ int main(int argc, char **argv)
   /* image parameters */
   cl_uchar4 *imageData;
   cl_image_format image_format;
-  cl_image_desc image_desc;
+  cl_image_desc image2_desc, image3_desc;
 
   
 
   printf("Running test %s...\n", name);
-  memset(&image_desc, 0, sizeof(cl_image_desc));
-  image_desc.image_type = CL_MEM_OBJECT_IMAGE3D;
-  image_desc.image_width = 2;
-  image_desc.image_height = 4;
-  image_desc.image_depth = 8;
+
+  memset(&image2_desc, 0, sizeof(cl_image_desc));
+  image2_desc.image_type = CL_MEM_OBJECT_IMAGE2D;
+  image2_desc.image_width = 2;
+  image2_desc.image_height = 4;
+
+  memset(&image3_desc, 0, sizeof(cl_image_desc));
+  image3_desc.image_type = CL_MEM_OBJECT_IMAGE3D;
+  image3_desc.image_width = 2;
+  image3_desc.image_height = 4;
+  image3_desc.image_depth = 8;
+
   image_format.image_channel_order = CL_RGBA;
   image_format.image_channel_data_type = CL_UNSIGNED_INT8;
   imageData = (cl_uchar4*)malloc (4 * 4 * sizeof(cl_uchar4));
@@ -120,11 +127,19 @@ int main(int argc, char **argv)
 
   /* Create image */
 
-  cl_mem image = clCreateImage (context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR,
-                                &image_format, &image_desc, imageData, &result);
+  cl_mem image2 = clCreateImage (context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR,
+                                &image_format, &image2_desc, imageData, &result);
+  if (result != CL_SUCCESS)
+    {
+      puts("image2 creation failed\n");
+      goto error;
+    }
+
+  cl_mem image3 = clCreateImage (context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR,
+                                &image_format, &image3_desc, imageData, &result);
   if (result != CL_SUCCESS)
     {
-      puts("image creation failed\n");
+      puts("image3 creation failed\n");
       goto error;
     }
 
@@ -153,10 +168,17 @@ int main(int argc, char **argv)
       goto error;
     }
 
-   result = clSetKernelArg( kernel, 0, sizeof(cl_mem), &image);
+   result = clSetKernelArg( kernel, 0, sizeof(cl_mem), &image2);
    if (result)
      {
-       puts("clSetKernelArg failed\n");
+       puts("clSetKernelArg 0 failed\n");
+       goto error;
+     }
+
+   result = clSetKernelArg( kernel, 1, sizeof(cl_mem), &image3);
+   if (result)
+     {
+       puts("clSetKernelArg 1 failed\n");
        goto error;
      }
 
@@ -198,12 +220,15 @@ error:
     {
       free(source);
     }
-  if (filename) 
+  if (filename)
     {
       free(filename);
     }
+  if (imageData)
+    {
+      free(imageData);
+    }
 
-  
   if (retval) 
     {
       printf("FAIL\n");
diff --git a/tests/kernel/sampler_address_clamp.c b/tests/kernel/sampler_address_clamp.c
index 897a503..3f71b39 100644
--- a/tests/kernel/sampler_address_clamp.c
+++ b/tests/kernel/sampler_address_clamp.c
@@ -33,7 +33,7 @@ int main(int argc, char **argv)
   cl_image_format image_format;
   cl_image_desc image_desc;
 
-  
+
 
   printf("Running test %s...\n", name);
   memset(&image_desc, 0, sizeof(cl_image_desc));
@@ -197,12 +197,16 @@ error:
     {
       free(source);
     }
-  if (filename) 
+  if (filename)
     {
       free(filename);
     }
+  if (imageData)
+    {
+      free(imageData);
+    }
+
 
-  
   if (retval) 
     {
       printf("FAIL\n");
diff --git a/tests/kernel/test_frexp_modf.cl b/tests/kernel/test_frexp_modf.cl
new file mode 100644
index 0000000..664dac5
--- /dev/null
+++ b/tests/kernel/test_frexp_modf.cl
@@ -0,0 +1,10 @@
+kernel
+void test_frexp_modf() {
+    volatile float a = 8e2f, b = 1.5f, frac, frac2;
+    int exp;
+    frac = frexp(a, &exp);
+    float x;
+    frac2 = modf(b, &x);
+    printf("frexp(8e2f): %.1f %d\n", frac, exp);
+    printf("modf(1.5f): %.1f %1f\n", frac2, x);
+}
diff --git a/tests/kernel/test_image_query_funcs.cl b/tests/kernel/test_image_query_funcs.cl
index 8c8ee70..4cc5646 100644
--- a/tests/kernel/test_image_query_funcs.cl
+++ b/tests/kernel/test_image_query_funcs.cl
@@ -1,12 +1,13 @@
 
 
-kernel 
-void test_image_query_funcs(__read_only image3d_t image)
+kernel
+void test_image_query_funcs(__read_only image2d_t image2, __read_only image3d_t image3)
 {
-  int h = get_image_height (image);
-  int w = get_image_width (image);
-  int d = get_image_depth (image);
-  
+  int h = get_image_height (image3);
+  int w = get_image_width (image3);
+  int d = get_image_depth (image3);
+  int4 dim4 = get_image_dim (image3);
+
   if (h != 4)
     printf("get_image_height failed expected 4, got %d\n", h);
 
@@ -14,6 +15,24 @@ void test_image_query_funcs(__read_only image3d_t image)
     printf("get_image_width failed expected 2, got %d\n", w);
 
   if (d != 8)
-    printf("get_image_width failed expected 8, got %d\n", d);  
+    printf("get_image_width failed expected 8, got %d\n", d);
+
+  if (dim4.x != w || dim4.y != h || dim4.z != d || dim4.w != 0)
+    printf("get_image_dim failed expected (%d,%d,%d,0), got %v4d\n",
+      w, h, d, dim4);
+
+  h = get_image_height (image2);
+  w = get_image_width (image2);
+  int2 dim2 = get_image_dim (image2);
+
+  if (h != 4)
+    printf("get_image_height failed expected 4, got %d\n", h);
+
+  if (w != 2)
+    printf("get_image_width failed expected 2, got %d\n", w);
+
+  if (dim2.x != w || dim2.y != h)
+    printf("get_image_dim failed expected (%d,%d), got %v2d\n",
+      w, h, dim2);
 
 }
diff --git a/tests/kernel/test_length_distance.cl b/tests/kernel/test_length_distance.cl
new file mode 100644
index 0000000..b06627e
--- /dev/null
+++ b/tests/kernel/test_length_distance.cl
@@ -0,0 +1,68 @@
+kernel 
+void test_length_distance() {
+  volatile float a = 18446744073709551616.0f; /* 2^64 */
+  volatile float e = 1.0f;
+  volatile float l = length(a);
+  if (l != 18446744073709551616.0f) {
+    printf("length(float) failed.\n");
+  }
+  volatile float d = distance(a, e);
+  if (d != 18446744073709551616.0f) {
+    printf("distance(float,float) failed.\n");
+  }
+  volatile float n = normalize(a);
+  if (n != 1.0f) {
+    printf("normalize(float) failed.\n");
+  }
+
+  volatile float2 a2 = (float2)(18446744073709551616.0f,
+                                18446744073709551616.0f); /* 2^64 */
+  volatile float2 e2 = (float2)(1.0f, 1.0f);
+  volatile float l2 = length(a2);
+  if (l2 != 2.6087635e19f) {
+    printf("length(float2) failed.\n");
+  }
+  volatile float d2 = distance(a2, e2);
+  if (d2 != 2.6087635e19f) {
+    printf("distance(float2,float2) failed.\n");
+  }
+  volatile float2 n2 = normalize(a2);
+  if (any(n2 != (float2)(0.70710677f, 0.70710677f))) {
+    printf("normalize(float2) failed.\n");
+  }
+
+  volatile float3 a3 = (float3)(18446744073709551616.0f,
+                                18446744073709551616.0f,
+                                18446744073709551616.0f); /* 2^64 */
+  volatile float3 e3 = (float3)(1.0f, 1.0f, 1.0f);
+  float l3 = length(a3);
+  if (l3 != 3.1950697e19f) {
+    printf("length(float3) failed.\n");
+  }
+  float d3 = distance(a3, e3);
+  if (d3 != 3.1950697e19f) {
+    printf("distance(float3,float3) failed.\n");
+  }
+  float3 n3 = normalize(a3);
+  if (any(n3 != (float3)(0.57735026f, 0.57735026f, 0.57735026f))) {
+    printf("normalize(float3) failed.\n");
+  }
+
+  volatile float4 a4 = (float4)(18446744073709551616.0f,
+                                18446744073709551616.0f,
+                                18446744073709551616.0f,
+                                18446744073709551616.0f); /* 2^64 */
+  volatile float4 e4 = (float4)(1.0f, 1.0f, 1.0f, 1.0f);
+  float l4 = length(a4);
+  if (l4 != 3.689349e19f) {
+    printf("length(float4) failed.\n");
+  }
+  float d4 = distance(a4, e4);
+  if (d4 != 3.689349e19f) {
+    printf("distance(float4,float4) failed.\n");
+  }
+  float4 n4 = normalize(a4);
+  if (any(n4 != (float4)(0.5f, 0.5f, 0.5f, 0.5f))) {
+    printf("normalize(float4) failed.\n");
+  }
+}
diff --git a/tests/kernel/test_local_struct_array.cl b/tests/kernel/test_local_struct_array.cl
new file mode 100644
index 0000000..79287f1
--- /dev/null
+++ b/tests/kernel/test_local_struct_array.cl
@@ -0,0 +1,17 @@
+typedef struct {
+  int c00;
+  int c01;
+} scan_t;
+
+scan_t add(scan_t a, scan_t b)
+{
+  return b;
+}
+
+kernel
+void test_local_struct_array()
+{
+  local scan_t psc_ldata[2];
+
+  psc_ldata[0] = add(psc_ldata[0], psc_ldata[1]);
+}
diff --git a/tests/kernel/test_shuffle.cc b/tests/kernel/test_shuffle.cc
index c2defc4..db0b953 100644
--- a/tests/kernel/test_shuffle.cc
+++ b/tests/kernel/test_shuffle.cc
@@ -62,8 +62,8 @@ public:
     mask2=new M[nsize];
     
     for(unsigned i=0; i<m; i++) {
-      in1[i]=i;
-      in2[i]=i+m;
+      in1[i]=(D)i;
+      in2[i]=(D)(i+m);
     }
     for(unsigned i=0; i<n; i++) {
       mask1[i] = stimuli[i];
diff --git a/tests/package.m4 b/tests/package.m4
index 04a25f0..c7320e0 100644
--- a/tests/package.m4
+++ b/tests/package.m4
@@ -4,9 +4,9 @@ m4_define([AT_PACKAGE_NAME],
 m4_define([AT_PACKAGE_TARNAME],
   [pocl])
 m4_define([AT_PACKAGE_VERSION],
-  [0.11])
+  [0.12])
 m4_define([AT_PACKAGE_STRING],
-  [pocl 0.11])
+  [pocl 0.12])
 m4_define([AT_PACKAGE_BUGREPORT],
   [pocl-devel at lists.sourceforge.net])
 m4_define([AT_PACKAGE_URL],
diff --git a/tests/regression/CMakeLists.txt b/tests/regression/CMakeLists.txt
index 141ce1b..3ce631a 100644
--- a/tests/regression/CMakeLists.txt
+++ b/tests/regression/CMakeLists.txt
@@ -38,7 +38,7 @@ set(PROGRAMS_TO_BUILD test_barrier_between_for_loops test_early_return
 if (MSVC)
   add_compile_options(${OPENCL_CFLAGS})
 else ()
-  add_compile_options("-Wno-deprecated" "-Wno-deprecated-declarations" ${OPENCL_CFLAGS})
+  add_compile_options("-std=c++11" "-Wno-deprecated" "-Wno-deprecated-declarations" ${OPENCL_CFLAGS})
 endif ()
  
 
diff --git a/tests/regression/Makefile.am b/tests/regression/Makefile.am
index 6c5c3b3..81f24d2 100644
--- a/tests/regression/Makefile.am
+++ b/tests/regression/Makefile.am
@@ -31,7 +31,7 @@ noinst_PROGRAMS += test_barrier_between_for_loops test_early_return \
 	test_simple_for_with_a_barrier test_structs_as_args test_vectors_as_args \
 	test_barrier_before_return test_infinite_loop test_constant_array \
 	test_undominated_variable test_setargs test_null_arg \
-	test_fors_with_var_iteration_counts
+	test_fors_with_var_iteration_counts test_issue_231
 endif
 
 test_assign_loop_variable_to_privvar_makes_it_local_SOURCES = \
@@ -41,8 +41,10 @@ test_assign_loop_variable_to_privvar_makes_it_local_2_SOURCES = \
 
 AM_DEFAULT_SOURCE_EXT = .cpp
 
-AM_LDFLAGS = ../../lib/poclu/libpoclu.la @OPENCL_LIBS@
-AM_CXXFLAGS = @OPENCL_CFLAGS@ -Wno-deprecated -Wno-deprecated-declarations
+# Need to define -pthread because of an issue with std::call_once and gcc 4.8:
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60662
+AM_LDFLAGS = ../../lib/poclu/libpoclu.la @OPENCL_LIBS@ -pthread
+AM_CXXFLAGS = @OPENCL_CFLAGS@ -std=c++11 -Wno-deprecated -Wno-deprecated-declarations
 AM_CPPFLAGS = -I$(top_srcdir)/fix-include -I$(top_builddir)/include -I$(top_srcdir)/include -I$(top_srcdir)/lib/CL -DSRCDIR='"$(abs_srcdir)"'
 
 EXTRA_DIST = CMakeLists.txt
diff --git a/tests/regression/Makefile.in b/tests/regression/Makefile.in
index 4f3bd2b..fe5d465 100644
--- a/tests/regression/Makefile.in
+++ b/tests/regression/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -113,11 +123,9 @@ noinst_PROGRAMS =  \
 @HAVE_OPENCL_HPP_TRUE@	test_simple_for_with_a_barrier test_structs_as_args test_vectors_as_args \
 @HAVE_OPENCL_HPP_TRUE@	test_barrier_before_return test_infinite_loop test_constant_array \
 @HAVE_OPENCL_HPP_TRUE@	test_undominated_variable test_setargs test_null_arg \
- at HAVE_OPENCL_HPP_TRUE@	test_fors_with_var_iteration_counts
+ at HAVE_OPENCL_HPP_TRUE@	test_fors_with_var_iteration_counts test_issue_231
 
 subdir = tests/regression
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -126,6 +134,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -147,7 +156,8 @@ CONFIG_CLEAN_VPATH_FILES =
 @HAVE_OPENCL_HPP_TRUE@	test_undominated_variable$(EXEEXT) \
 @HAVE_OPENCL_HPP_TRUE@	test_setargs$(EXEEXT) \
 @HAVE_OPENCL_HPP_TRUE@	test_null_arg$(EXEEXT) \
- at HAVE_OPENCL_HPP_TRUE@	test_fors_with_var_iteration_counts$(EXEEXT)
+ at HAVE_OPENCL_HPP_TRUE@	test_fors_with_var_iteration_counts$(EXEEXT) \
+ at HAVE_OPENCL_HPP_TRUE@	test_issue_231$(EXEEXT)
 PROGRAMS = $(noinst_PROGRAMS)
 am_test_assign_loop_variable_to_privvar_makes_it_local_OBJECTS =  \
 	test_assign_loop_variable_to_privvar_makes_it_local.$(OBJEXT)
@@ -194,6 +204,9 @@ test_id_dependent_computation_LDADD = $(LDADD)
 test_infinite_loop_SOURCES = test_infinite_loop.cpp
 test_infinite_loop_OBJECTS = test_infinite_loop.$(OBJEXT)
 test_infinite_loop_LDADD = $(LDADD)
+test_issue_231_SOURCES = test_issue_231.cpp
+test_issue_231_OBJECTS = test_issue_231.$(OBJEXT)
+test_issue_231_LDADD = $(LDADD)
 test_locals_SOURCES = test_locals.cpp
 test_locals_OBJECTS = test_locals.$(OBJEXT)
 test_locals_LDADD = $(LDADD)
@@ -286,7 +299,8 @@ SOURCES = $(test_assign_loop_variable_to_privvar_makes_it_local_SOURCES) \
 	test_early_return.cpp test_for_with_var_iteration_count.cpp \
 	test_fors_with_var_iteration_counts.cpp \
 	test_id_dependent_computation.cpp test_infinite_loop.cpp \
-	test_locals.cpp test_loop_phi_replication.cpp \
+	test_issue_231.cpp test_locals.cpp \
+	test_loop_phi_replication.cpp \
 	test_multi_level_loops_with_barriers.cpp test_null_arg.cpp \
 	test_setargs.cpp test_simple_for_with_a_barrier.cpp \
 	test_structs_as_args.cpp test_undominated_variable.cpp \
@@ -298,7 +312,8 @@ DIST_SOURCES = $(test_assign_loop_variable_to_privvar_makes_it_local_SOURCES) \
 	test_early_return.cpp test_for_with_var_iteration_count.cpp \
 	test_fors_with_var_iteration_counts.cpp \
 	test_id_dependent_computation.cpp test_infinite_loop.cpp \
-	test_locals.cpp test_loop_phi_replication.cpp \
+	test_issue_231.cpp test_locals.cpp \
+	test_loop_phi_replication.cpp \
 	test_multi_level_loops_with_barriers.cpp test_null_arg.cpp \
 	test_setargs.cpp test_simple_for_with_a_barrier.cpp \
 	test_structs_as_args.cpp test_undominated_variable.cpp \
@@ -327,6 +342,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -378,6 +394,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -414,6 +433,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -535,8 +555,11 @@ test_assign_loop_variable_to_privvar_makes_it_local_2_SOURCES = \
 	test_assign_loop_variable_to_privvar_makes_it_local_2.c
 
 AM_DEFAULT_SOURCE_EXT = .cpp
-AM_LDFLAGS = ../../lib/poclu/libpoclu.la @OPENCL_LIBS@
-AM_CXXFLAGS = @OPENCL_CFLAGS@ -Wno-deprecated -Wno-deprecated-declarations
+
+# Need to define -pthread because of an issue with std::call_once and gcc 4.8:
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60662
+AM_LDFLAGS = ../../lib/poclu/libpoclu.la @OPENCL_LIBS@ -pthread
+AM_CXXFLAGS = @OPENCL_CFLAGS@ -std=c++11 -Wno-deprecated -Wno-deprecated-declarations
 AM_CPPFLAGS = -I$(top_srcdir)/fix-include -I$(top_builddir)/include -I$(top_srcdir)/include -I$(top_srcdir)/lib/CL -DSRCDIR='"$(abs_srcdir)"'
 EXTRA_DIST = CMakeLists.txt
 all: all-am
@@ -555,7 +578,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/regression/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign tests/regression/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -623,6 +645,10 @@ test_infinite_loop$(EXEEXT): $(test_infinite_loop_OBJECTS) $(test_infinite_loop_
 	@rm -f test_infinite_loop$(EXEEXT)
 	$(AM_V_CXXLD)$(CXXLINK) $(test_infinite_loop_OBJECTS) $(test_infinite_loop_LDADD) $(LIBS)
 
+test_issue_231$(EXEEXT): $(test_issue_231_OBJECTS) $(test_issue_231_DEPENDENCIES) $(EXTRA_test_issue_231_DEPENDENCIES) 
+	@rm -f test_issue_231$(EXEEXT)
+	$(AM_V_CXXLD)$(CXXLINK) $(test_issue_231_OBJECTS) $(test_issue_231_LDADD) $(LIBS)
+
 test_locals$(EXEEXT): $(test_locals_OBJECTS) $(test_locals_DEPENDENCIES) $(EXTRA_test_locals_DEPENDENCIES) 
 	@rm -f test_locals$(EXEEXT)
 	$(AM_V_CXXLD)$(CXXLINK) $(test_locals_OBJECTS) $(test_locals_LDADD) $(LIBS)
@@ -675,6 +701,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_fors_with_var_iteration_counts.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_id_dependent_computation.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_infinite_loop.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_issue_231.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_locals.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_loop_phi_replication.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_multi_level_loops_with_barriers.Po at am__quote@
@@ -936,6 +963,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/tests/regression/test_barrier_before_return.cpp b/tests/regression/test_barrier_before_return.cpp
index 5edaeef..f538a5d 100644
--- a/tests/regression/test_barrier_before_return.cpp
+++ b/tests/regression/test_barrier_before_return.cpp
@@ -22,8 +22,10 @@
 */
 
 // Enable OpenCL C++ exceptions
-#define __CL_ENABLE_EXCEPTIONS
-#include <CL/cl.hpp>
+#define CL_HPP_ENABLE_EXCEPTIONS
+#define CL_HPP_MINIMUM_OPENCL_VERSION 120
+#define CL_HPP_TARGET_OPENCL_VERSION 120
+#include <CL/cl2.hpp>
 
 #include <cstdio>
 #include <cstdlib>
@@ -78,7 +80,7 @@ main(void)
         std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
 
         // Create and program from source
-        cl::Program::Sources sources(1, std::make_pair(kernelSourceCode, 0));
+        cl::Program::Sources sources({kernelSourceCode});
         cl::Program program(context, sources);
 
         // Build program
@@ -134,20 +136,21 @@ main(void)
                 ok = false;
             }
         }
-        if (ok) 
-          return EXIT_SUCCESS;
-        else
-          return EXIT_FAILURE;
 
         // Finally release our hold on accessing the memory
         queue.enqueueUnmapMemObject(
             cBuffer,
             (void *) output);
- 
+
         // There is no need to perform a finish on the final unmap
         // or release any objects as this all happens implicitly with
         // the C++ Wrapper API.
-    } 
+
+        if (ok)
+          return EXIT_SUCCESS;
+        else
+          return EXIT_FAILURE;
+    }
     catch (cl::Error err) {
          std::cerr
              << "ERROR: "
diff --git a/tests/regression/test_barrier_between_for_loops.cpp b/tests/regression/test_barrier_between_for_loops.cpp
index 1483d26..6187101 100644
--- a/tests/regression/test_barrier_between_for_loops.cpp
+++ b/tests/regression/test_barrier_between_for_loops.cpp
@@ -22,8 +22,10 @@
 */
 
 // Enable OpenCL C++ exceptions
-#define __CL_ENABLE_EXCEPTIONS
-#include <CL/cl.hpp>
+#define CL_HPP_ENABLE_EXCEPTIONS
+#define CL_HPP_MINIMUM_OPENCL_VERSION 120
+#define CL_HPP_TARGET_OPENCL_VERSION 120
+#include <CL/cl2.hpp>
 
 #include <cstdio>
 #include <cstdlib>
@@ -94,7 +96,7 @@ main(void)
         std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
 
         // Create and program from source
-        cl::Program::Sources sources(1, std::make_pair(kernelSourceCode, 0));
+        cl::Program::Sources sources({kernelSourceCode});
         cl::Program program(context, sources);
 
         cl_device_id dev_id = devices.at(0)();
@@ -172,20 +174,22 @@ main(void)
                 ok = false;
             }
         }
-        if (ok) 
-            return EXIT_SUCCESS; 
-        else
-            return EXIT_FAILURE;
 
         // Finally release our hold on accessing the memory
         queue.enqueueUnmapMemObject(
             cBuffer,
             (void *) output);
- 
+
         // There is no need to perform a finish on the final unmap
         // or release any objects as this all happens implicitly with
         // the C++ Wrapper API.
-    } 
+	//
+
+        if (ok)
+            return EXIT_SUCCESS;
+        else
+            return EXIT_FAILURE;
+    }
     catch (cl::Error err) {
          std::cerr
              << "ERROR: "
diff --git a/tests/regression/test_constant_array.cpp b/tests/regression/test_constant_array.cpp
index 30f6eac..cf91c68 100644
--- a/tests/regression/test_constant_array.cpp
+++ b/tests/regression/test_constant_array.cpp
@@ -23,8 +23,10 @@
 */
 
 // Enable OpenCL C++ exceptions
-#define __CL_ENABLE_EXCEPTIONS
-#include <CL/cl.hpp>
+#define CL_HPP_ENABLE_EXCEPTIONS
+#define CL_HPP_MINIMUM_OPENCL_VERSION 120
+#define CL_HPP_TARGET_OPENCL_VERSION 120
+#include <CL/cl2.hpp>
 
 #include <cstdio>
 #include <cstdlib>
@@ -82,7 +84,7 @@ main(void)
         std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
 
         // Create and program from source
-        cl::Program::Sources sources(1, std::make_pair(kernelSourceCode, 0));
+        cl::Program::Sources sources({kernelSourceCode});
         cl::Program program(context, sources);
 
         // Build program
diff --git a/tests/regression/test_early_return.cpp b/tests/regression/test_early_return.cpp
index 0b8a9c9..669e971 100644
--- a/tests/regression/test_early_return.cpp
+++ b/tests/regression/test_early_return.cpp
@@ -22,8 +22,10 @@
 */
 
 // Enable OpenCL C++ exceptions
-#define __CL_ENABLE_EXCEPTIONS
-#include <CL/cl.hpp>
+#define CL_HPP_ENABLE_EXCEPTIONS
+#define CL_HPP_MINIMUM_OPENCL_VERSION 120
+#define CL_HPP_TARGET_OPENCL_VERSION 120
+#include <CL/cl2.hpp>
 
 #include <cstdio>
 #include <cstdlib>
@@ -51,7 +53,7 @@ main(void)
     int R[WORK_ITEMS];
 
     for (int i = 0; i < BUFFER_SIZE; i++) {
-        A[i] = i;
+        A[i] = (float)i;
     }
 
     for (int i = 0; i < WORK_ITEMS; i++) {
@@ -73,7 +75,7 @@ main(void)
         std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
 
         // Create and program from source
-        cl::Program::Sources sources(1, std::make_pair(kernelSourceCode, 0));
+        cl::Program::Sources sources({kernelSourceCode});
         cl::Program program(context, sources);
 
         // Build program
@@ -130,20 +132,21 @@ main(void)
                 ok = false;
             }
         }
-        if (ok) 
-            return EXIT_SUCCESS; 
-        else 
-            return EXIT_FAILURE;
 
         // Finally release our hold on accessing the memory
         queue.enqueueUnmapMemObject(
             cBuffer,
             (void *) output);
- 
+
         // There is no need to perform a finish on the final unmap
         // or release any objects as this all happens implicitly with
         // the C++ Wrapper API.
-    } 
+
+        if (ok)
+            return EXIT_SUCCESS;
+        else
+            return EXIT_FAILURE;
+    }
     catch (cl::Error err) {
          std::cerr
              << "ERROR: "
diff --git a/tests/regression/test_for_with_var_iteration_count.cpp b/tests/regression/test_for_with_var_iteration_count.cpp
index 4ef8ce4..803f38e 100644
--- a/tests/regression/test_for_with_var_iteration_count.cpp
+++ b/tests/regression/test_for_with_var_iteration_count.cpp
@@ -22,8 +22,10 @@
 */
 
 // Enable OpenCL C++ exceptions
-#define __CL_ENABLE_EXCEPTIONS
-#include <CL/cl.hpp>
+#define CL_HPP_ENABLE_EXCEPTIONS
+#define CL_HPP_MINIMUM_OPENCL_VERSION 120
+#define CL_HPP_TARGET_OPENCL_VERSION 120
+#include <CL/cl2.hpp>
 
 #include <cstdio>
 #include <cstdlib>
@@ -59,7 +61,7 @@ main(void)
     int a = 3;
 
     for (int i = 0; i < BUFFER_SIZE; i++) {
-        A[i] = i;
+        A[i] = (float)i;
     }
 
     for (int i = 0; i < WORK_ITEMS; i++) {
@@ -81,7 +83,7 @@ main(void)
         std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
 
         // Create and program from source
-        cl::Program::Sources sources(1, std::make_pair(kernelSourceCode, 0));
+        cl::Program::Sources sources({kernelSourceCode});
         cl::Program program(context, sources);
 
         // Build program
@@ -139,20 +141,21 @@ main(void)
                 ok = false;
             }
         }
-        if (ok) 
-          return EXIT_SUCCESS;
-        else
-          return EXIT_FAILURE;
 
         // Finally release our hold on accessing the memory
         queue.enqueueUnmapMemObject(
             cBuffer,
             (void *) output);
- 
+
         // There is no need to perform a finish on the final unmap
         // or release any objects as this all happens implicitly with
         // the C++ Wrapper API.
-    } 
+
+        if (ok)
+          return EXIT_SUCCESS;
+        else
+          return EXIT_FAILURE;
+    }
     catch (cl::Error err) {
          std::cerr
              << "ERROR: "
diff --git a/tests/regression/test_fors_with_var_iteration_counts.cpp b/tests/regression/test_fors_with_var_iteration_counts.cpp
index ed79cda..9b36f27 100644
--- a/tests/regression/test_fors_with_var_iteration_counts.cpp
+++ b/tests/regression/test_fors_with_var_iteration_counts.cpp
@@ -22,8 +22,10 @@
 */
 
 // Enable OpenCL C++ exceptions
-#define __CL_ENABLE_EXCEPTIONS
-#include <CL/cl.hpp>
+#define CL_HPP_ENABLE_EXCEPTIONS
+#define CL_HPP_MINIMUM_OPENCL_VERSION 120
+#define CL_HPP_TARGET_OPENCL_VERSION 120
+#include <CL/cl2.hpp>
 
 #include <cstdio>
 #include <cstdlib>
@@ -63,7 +65,7 @@ main(void)
     int a = 3;
 
     for (int i = 0; i < BUFFER_SIZE; i++) {
-        A[i] = i;
+        A[i] = (float)i;
     }
 
     for (int i = 0; i < WORK_ITEMS; i++) {
@@ -85,7 +87,7 @@ main(void)
         std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
 
         // Create and program from source
-        cl::Program::Sources sources(1, std::make_pair(kernelSourceCode, 0));
+        cl::Program::Sources sources({kernelSourceCode});
         cl::Program program(context, sources);
 
         // Build program
diff --git a/tests/regression/test_id_dependent_computation.cpp b/tests/regression/test_id_dependent_computation.cpp
index d724ab8..d501a86 100644
--- a/tests/regression/test_id_dependent_computation.cpp
+++ b/tests/regression/test_id_dependent_computation.cpp
@@ -22,8 +22,10 @@
 */
 
 // Enable OpenCL C++ exceptions
-#define __CL_ENABLE_EXCEPTIONS
-#include <CL/cl.hpp>
+#define CL_HPP_ENABLE_EXCEPTIONS
+#define CL_HPP_MINIMUM_OPENCL_VERSION 120
+#define CL_HPP_TARGET_OPENCL_VERSION 120
+#include <CL/cl2.hpp>
 
 #include <cstdio>
 #include <cstdlib>
@@ -71,7 +73,7 @@ main(void)
     int R[WORK_ITEMS];
 
     for (int i = 0; i < BUFFER_SIZE; i++) {
-        A[i] = i;
+        A[i] = (float)i;
     }
 
     for (int i = 0; i < WORK_ITEMS; i++) {
@@ -93,7 +95,7 @@ main(void)
         std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
 
         // Create and program from source
-        cl::Program::Sources sources(1, std::make_pair(kernelSourceCode, 0));
+        cl::Program::Sources sources({kernelSourceCode});
         cl::Program program(context, sources);
 
         // Build program
@@ -142,7 +144,7 @@ main(void)
 
         bool ok = true;
         for (int i = 0; i < WORK_ITEMS; i++) {
-            int correct = i;
+            int correct;
             if (i == 1)
                 correct = 43;
             else 
@@ -154,20 +156,21 @@ main(void)
                 ok = false;
             }
         }
-        if (ok) 
-            return EXIT_SUCCESS;
-        else
-            return EXIT_FAILURE;
 
         // Finally release our hold on accessing the memory
         queue.enqueueUnmapMemObject(
             cBuffer,
             (void *) output);
- 
+
         // There is no need to perform a finish on the final unmap
         // or release any objects as this all happens implicitly with
         // the C++ Wrapper API.
-    } 
+
+        if (ok)
+            return EXIT_SUCCESS;
+        else
+            return EXIT_FAILURE;
+    }
     catch (cl::Error err) {
          std::cerr
              << "ERROR: "
diff --git a/tests/regression/test_infinite_loop.cpp b/tests/regression/test_infinite_loop.cpp
index e8f436c..e3bc812 100644
--- a/tests/regression/test_infinite_loop.cpp
+++ b/tests/regression/test_infinite_loop.cpp
@@ -22,8 +22,10 @@
 */
 
 // Enable OpenCL C++ exceptions
-#define __CL_ENABLE_EXCEPTIONS
-#include <CL/cl.hpp>
+#define CL_HPP_ENABLE_EXCEPTIONS
+#define CL_HPP_MINIMUM_OPENCL_VERSION 120
+#define CL_HPP_TARGET_OPENCL_VERSION 120
+#include <CL/cl2.hpp>
 
 #include <cstdio>
 #include <cstdlib>
@@ -77,7 +79,7 @@ main(void)
         std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
 
         // Create and program from source
-        cl::Program::Sources sources(1, std::make_pair(kernelSourceCode, 0));
+        cl::Program::Sources sources({kernelSourceCode});
         cl::Program program(context, sources);
 
         // Build program
diff --git a/tests/regression/test_issue_231.cpp b/tests/regression/test_issue_231.cpp
new file mode 100644
index 0000000..65f15b7
--- /dev/null
+++ b/tests/regression/test_issue_231.cpp
@@ -0,0 +1,94 @@
+
+// Used to cause an LLVM crash with Haswell/Broadwell.
+// See https://github.com/pocl/pocl/issues/231
+
+#define CL_HPP_ENABLE_EXCEPTIONS
+#define CL_HPP_MINIMUM_OPENCL_VERSION 120
+#define CL_HPP_TARGET_OPENCL_VERSION 120
+#define CL_HPP_CL_1_2_DEFAULT_BUILD
+#include <CL/cl2.hpp>
+#include <iostream>
+
+using namespace std;
+
+const char *SOURCE = R"RAW(
+#define local_barrier() barrier(CLK_LOCAL_MEM_FENCE);
+#define WITHIN_KERNEL /* empty */
+#define KERNEL __kernel
+#define GLOBAL_MEM __global
+#define LOCAL_MEM __local
+#define LOCAL_MEM_ARG __local
+#define REQD_WG_SIZE(X,Y,psc_Z) __attribute__((reqd_work_group_size(X, Y, psc_Z)))
+#define psc_LID_0 get_local_id(0)
+#define psc_LID_1 get_local_id(1)
+#define psc_LID_2 get_local_id(2)
+#define psc_GID_0 get_group_id(0)
+#define psc_GID_1 get_group_id(1)
+#define psc_GID_2 get_group_id(2)
+#define psc_LDIM_0 get_local_size(0)
+#define psc_LDIM_1 get_local_size(1)
+#define psc_LDIM_2 get_local_size(2)
+#define psc_GDIM_0 get_num_groups(0)
+#define psc_GDIM_1 get_num_groups(1)
+#define psc_GDIM_2 get_num_groups(2)
+    #if __OPENCL_C_VERSION__ < 120
+    #pragma OPENCL EXTENSION cl_khr_fp64: enable
+    #endif
+//CL//
+#define psc_WG_SIZE 16
+#define psc_SCAN_EXPR(a, b, across_seg_boundary) a+b
+#define psc_INPUT_EXPR(i) (input_ary[i])
+typedef int psc_scan_type;
+typedef int psc_index_type;
+// NO_SEG_BOUNDARY is the largest representable integer in psc_index_type.
+// This assumption is used in code below.
+#define NO_SEG_BOUNDARY 2147483647
+//CL//
+#define psc_K 256
+KERNEL
+REQD_WG_SIZE(psc_WG_SIZE, 1, 1)
+void scan_scan_intervals_lev1(
+    __global int *input_ary, __global int *output_ary,
+    GLOBAL_MEM psc_scan_type *restrict psc_partial_scan_buffer,
+    const psc_index_type N,
+    const psc_index_type psc_interval_size
+        , GLOBAL_MEM psc_scan_type *restrict psc_interval_results
+    )
+{
+    // index psc_K in first dimension used for psc_carry storage
+    struct psc_wrapped_scan_type
+    {
+        psc_scan_type psc_value;
+    };
+    // padded in psc_WG_SIZE to avoid bank conflicts
+    LOCAL_MEM struct psc_wrapped_scan_type psc_ldata[psc_WG_SIZE];
+    for(int i = 0; i < 10; ++i)
+    {
+        local_barrier();
+        psc_scan_type psc_val = 0;
+        if (psc_LID_0 >= 2)
+        {
+            psc_scan_type psc_tmp = psc_ldata[psc_LID_0 - 2].psc_value;
+            psc_val = psc_tmp+ psc_val;
+        }
+        // {{{ writes to local allowed, reads from local not allowed
+        psc_ldata[psc_LID_0].psc_value = psc_val;
+    }
+}
+)RAW";
+
+int main(int argc, char *argv[])
+{
+  cl::Device device = cl::Device::getDefault();
+  cl::CommandQueue queue = cl::CommandQueue::getDefault();
+  cl::Program program(SOURCE, true);
+
+  auto kernel = cl::KernelFunctor<cl::Buffer, cl::Buffer, cl::Buffer, cl_int, cl_int, cl::Buffer>(program, "scan_scan_intervals_lev1");
+
+  cl_int i;
+  cl::Buffer buffer;
+  kernel(cl::EnqueueArgs(queue, cl::NDRange(16), cl::NDRange(16)),
+         buffer, buffer, buffer, i, i, buffer);
+
+  queue.finish();
+}
diff --git a/tests/regression/test_locals.cpp b/tests/regression/test_locals.cpp
index be41eb3..67167dd 100644
--- a/tests/regression/test_locals.cpp
+++ b/tests/regression/test_locals.cpp
@@ -22,8 +22,10 @@
 */
 
 // Enable OpenCL C++ exceptions
-#define __CL_ENABLE_EXCEPTIONS
-#include <CL/cl.hpp>
+#define CL_HPP_ENABLE_EXCEPTIONS
+#define CL_HPP_MINIMUM_OPENCL_VERSION 120
+#define CL_HPP_TARGET_OPENCL_VERSION 120
+#include <CL/cl2.hpp>
 
 #include <cstdio>
 #include <cstdlib>
@@ -75,7 +77,7 @@ main(void)
         std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
 
         // Create and program from source
-        cl::Program::Sources sources(1, std::make_pair(kernelSourceCode, 0));
+        cl::Program::Sources sources({kernelSourceCode});
         cl::Program program(context, sources);
 
         cl_device_id dev_id = devices.at(0)();
@@ -83,7 +85,7 @@ main(void)
         int scalar = poclu_bswap_cl_int (dev_id, 4);
 
         for (int i = 0; i < BUFFER_SIZE; ++i)
-            A[i] = poclu_bswap_cl_float(dev_id, i);
+            A[i] = poclu_bswap_cl_float(dev_id, (cl_float)i);
 
         // Build program
         program.build(devices);
diff --git a/tests/regression/test_loop_phi_replication.cpp b/tests/regression/test_loop_phi_replication.cpp
index 748f3f9..a730cf4 100644
--- a/tests/regression/test_loop_phi_replication.cpp
+++ b/tests/regression/test_loop_phi_replication.cpp
@@ -22,8 +22,10 @@
 */
 
 // Enable OpenCL C++ exceptions
-#define __CL_ENABLE_EXCEPTIONS
-#include <CL/cl.hpp>
+#define CL_HPP_ENABLE_EXCEPTIONS
+#define CL_HPP_MINIMUM_OPENCL_VERSION 120
+#define CL_HPP_TARGET_OPENCL_VERSION 120
+#include <CL/cl2.hpp>
 
 #include <cstdio>
 #include <cstdlib>
@@ -57,7 +59,7 @@ int
 main(void)
 {
     for (int i = 0; i < BUFFER_SIZE; i++) {
-        A[i] = i;
+        A[i] = (float)i;
     }
 
     for (int i = 0; i < WORK_ITEMS; i++) {
@@ -79,7 +81,7 @@ main(void)
         std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
 
         // Create and program from source
-        cl::Program::Sources sources(1, std::make_pair(kernelSourceCode, 0));
+        cl::Program::Sources sources({kernelSourceCode});
         cl::Program program(context, sources);
 
         // Build program
@@ -138,20 +140,21 @@ main(void)
                 ok = false;
             }
         }
-        if (ok) 
-            return EXIT_SUCCESS;
-        else
-            return EXIT_FAILURE;
 
         // Finally release our hold on accessing the memory
         queue.enqueueUnmapMemObject(
             cBuffer,
             (void *) output);
- 
+
         // There is no need to perform a finish on the final unmap
         // or release any objects as this all happens implicitly with
         // the C++ Wrapper API.
-    } 
+
+        if (ok)
+            return EXIT_SUCCESS;
+        else
+            return EXIT_FAILURE;
+    }
     catch (cl::Error err) {
          std::cerr
              << "ERROR: "
diff --git a/tests/regression/test_multi_level_loops_with_barriers.cpp b/tests/regression/test_multi_level_loops_with_barriers.cpp
index 898bc61..add66ed 100644
--- a/tests/regression/test_multi_level_loops_with_barriers.cpp
+++ b/tests/regression/test_multi_level_loops_with_barriers.cpp
@@ -22,8 +22,10 @@
 */
 
 // Enable OpenCL C++ exceptions
-#define __CL_ENABLE_EXCEPTIONS
-#include <CL/cl.hpp>
+#define CL_HPP_ENABLE_EXCEPTIONS
+#define CL_HPP_MINIMUM_OPENCL_VERSION 120
+#define CL_HPP_TARGET_OPENCL_VERSION 120
+#include <CL/cl2.hpp>
 
 #include <cstdio>
 #include <cstdlib>
@@ -59,7 +61,7 @@ main(void)
     int a = 2;
 
     for (int i = 0; i < BUFFER_SIZE; i++) {
-        A[i] = i;
+        A[i] = (float)i;
     }
 
     for (int i = 0; i < WORK_ITEMS; i++) {
@@ -81,7 +83,7 @@ main(void)
         std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
 
         // Create and program from source
-        cl::Program::Sources sources(1, std::make_pair(kernelSourceCode, 0));
+        cl::Program::Sources sources({kernelSourceCode});
         cl::Program program(context, sources);
 
         // Build program
@@ -148,20 +150,21 @@ main(void)
                 ok = false;
             }
         }
-        if (ok) 
-          return EXIT_SUCCESS; 
-        else
-          return EXIT_FAILURE;
 
         // Finally release our hold on accessing the memory
         queue.enqueueUnmapMemObject(
             cBuffer,
             (void *) output);
- 
+
         // There is no need to perform a finish on the final unmap
         // or release any objects as this all happens implicitly with
         // the C++ Wrapper API.
-    } 
+
+        if (ok)
+          return EXIT_SUCCESS;
+        else
+          return EXIT_FAILURE;
+    }
     catch (cl::Error err) {
          std::cerr
              << "ERROR: "
diff --git a/tests/regression/test_null_arg.cpp b/tests/regression/test_null_arg.cpp
index 3b9fa32..bda7a1a 100644
--- a/tests/regression/test_null_arg.cpp
+++ b/tests/regression/test_null_arg.cpp
@@ -22,8 +22,10 @@
 */
 
 // Enable OpenCL C++ exceptions
-#define __CL_ENABLE_EXCEPTIONS
-#include <CL/cl.hpp>
+#define CL_HPP_ENABLE_EXCEPTIONS
+#define CL_HPP_MINIMUM_OPENCL_VERSION 120
+#define CL_HPP_TARGET_OPENCL_VERSION 120
+#include <CL/cl2.hpp>
 
 #include <cstdio>
 #include <cstdlib>
@@ -70,7 +72,7 @@ main(void)
         std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
 
         // Create and program from source
-        cl::Program::Sources sources(1, std::make_pair(kernelSourceCode, 0));
+        cl::Program::Sources sources({kernelSourceCode});
         cl::Program program(context, sources);
 
         // Build program
@@ -124,20 +126,21 @@ main(void)
               ok = false;
         }
 
-        if (ok) 
-          return EXIT_SUCCESS;
-        else
-          return EXIT_FAILURE;
-
         // Finally release our hold on accessing the memory
         queue.enqueueUnmapMemObject(
             outBuffer,
             (void *) output);
- 
+
         // There is no need to perform a finish on the final unmap
         // or release any objects as this all happens implicitly with
         // the C++ Wrapper API.
-    } 
+
+        if (ok)
+          return EXIT_SUCCESS;
+        else
+          return EXIT_FAILURE;
+
+    }
     catch (cl::Error err) {
          std::cerr
              << "ERROR: "
diff --git a/tests/regression/test_setargs.cpp b/tests/regression/test_setargs.cpp
index 67d7f47..512c184 100644
--- a/tests/regression/test_setargs.cpp
+++ b/tests/regression/test_setargs.cpp
@@ -23,8 +23,10 @@
 */
 
 // Enable OpenCL C++ exceptions
-#define __CL_ENABLE_EXCEPTIONS
-#include <CL/cl.hpp>
+#define CL_HPP_ENABLE_EXCEPTIONS
+#define CL_HPP_MINIMUM_OPENCL_VERSION 120
+#define CL_HPP_TARGET_OPENCL_VERSION 120
+#include <CL/cl2.hpp>
 
 #include <cstdio>
 #include <cstdlib>
@@ -61,7 +63,7 @@ main(void)
         std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
 
         // Create and program from source
-        cl::Program::Sources sources(1, std::make_pair(kernelSourceCode, 0));
+        cl::Program::Sources sources({kernelSourceCode});
         cl::Program program(context, sources);
 
         // Build program
diff --git a/tests/regression/test_simple_for_with_a_barrier.cpp b/tests/regression/test_simple_for_with_a_barrier.cpp
index b15dc71..efe7086 100644
--- a/tests/regression/test_simple_for_with_a_barrier.cpp
+++ b/tests/regression/test_simple_for_with_a_barrier.cpp
@@ -23,8 +23,10 @@
 */
 
 // Enable OpenCL C++ exceptions
-#define __CL_ENABLE_EXCEPTIONS
-#include <CL/cl.hpp>
+#define CL_HPP_ENABLE_EXCEPTIONS
+#define CL_HPP_MINIMUM_OPENCL_VERSION 120
+#define CL_HPP_TARGET_OPENCL_VERSION 120
+#include <CL/cl2.hpp>
 
 #include <cstdio>
 #include <cstdlib>
@@ -58,7 +60,7 @@ main(void)
     int R[WORK_ITEMS];
 
     for (int i = 0; i < BUFFER_SIZE; i++) {
-        A[i] = i;
+        A[i] = (float)i;
     }
 
     for (int i = 0; i < WORK_ITEMS; i++) {
@@ -80,7 +82,7 @@ main(void)
         std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
 
         // Create and program from source
-        cl::Program::Sources sources(1, std::make_pair(kernelSourceCode, 0));
+        cl::Program::Sources sources({kernelSourceCode});
         cl::Program program(context, sources);
 
         // Build program
diff --git a/tests/regression/test_structs_as_args.cpp b/tests/regression/test_structs_as_args.cpp
index 49415cb..917af90 100644
--- a/tests/regression/test_structs_as_args.cpp
+++ b/tests/regression/test_structs_as_args.cpp
@@ -22,8 +22,10 @@
 */
 
 // Enable OpenCL C++ exceptions
-#define __CL_ENABLE_EXCEPTIONS
-#include <CL/cl.hpp>
+#define CL_HPP_ENABLE_EXCEPTIONS
+#define CL_HPP_MINIMUM_OPENCL_VERSION 120
+#define CL_HPP_TARGET_OPENCL_VERSION 120
+#include <CL/cl2.hpp>
 
 #include <cstdio>
 #include <cstdlib>
@@ -134,7 +136,7 @@ main(void)
         std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
 
         // Create and program from source
-        cl::Program::Sources sources(1, std::make_pair(kernelSourceCode, 0));
+        cl::Program::Sources sources({kernelSourceCode});
         cl::Program program(context, sources);
 
         // Build program
diff --git a/tests/regression/test_undominated_variable.cpp b/tests/regression/test_undominated_variable.cpp
index fd7a898..91f09f6 100644
--- a/tests/regression/test_undominated_variable.cpp
+++ b/tests/regression/test_undominated_variable.cpp
@@ -23,8 +23,10 @@
 */
 
 // Enable OpenCL C++ exceptions
-#define __CL_ENABLE_EXCEPTIONS
-#include <CL/cl.hpp>
+#define CL_HPP_ENABLE_EXCEPTIONS
+#define CL_HPP_MINIMUM_OPENCL_VERSION 120
+#define CL_HPP_TARGET_OPENCL_VERSION 120
+#include <CL/cl2.hpp>
 
 #include <cstdio>
 #include <cstdlib>
@@ -61,7 +63,7 @@ main(void)
     int a = 3;
 
     for (int i = 0; i < BUFFER_SIZE; i++) {
-        A[i] = i;
+        A[i] = (float)i;
     }
 
     for (int i = 0; i < WORK_ITEMS; i++) {
@@ -83,7 +85,7 @@ main(void)
         std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
 
         // Create and program from source
-        cl::Program::Sources sources(1, std::make_pair(kernelSourceCode, 0));
+        cl::Program::Sources sources({kernelSourceCode});
         cl::Program program(context, sources);
 
         // Build program
@@ -141,20 +143,21 @@ main(void)
                 ok = false;
             }
         }
-        if (ok) 
-          return EXIT_SUCCESS;
-        else
-          return EXIT_FAILURE;
 
         // Finally release our hold on accessing the memory
         queue.enqueueUnmapMemObject(
             cBuffer,
             (void *) output);
- 
+
         // There is no need to perform a finish on the final unmap
         // or release any objects as this all happens implicitly with
         // the C++ Wrapper API.
-    } 
+
+        if (ok)
+          return EXIT_SUCCESS;
+        else
+          return EXIT_FAILURE;
+    }
     catch (cl::Error err) {
          std::cerr
              << "ERROR: "
diff --git a/tests/regression/test_vectors_as_args.cpp b/tests/regression/test_vectors_as_args.cpp
index 8649751..6397e08 100644
--- a/tests/regression/test_vectors_as_args.cpp
+++ b/tests/regression/test_vectors_as_args.cpp
@@ -22,8 +22,10 @@
 */
 
 // Enable OpenCL C++ exceptions
-#define __CL_ENABLE_EXCEPTIONS
-#include <CL/cl.hpp>
+#define CL_HPP_ENABLE_EXCEPTIONS
+#define CL_HPP_MINIMUM_OPENCL_VERSION 120
+#define CL_HPP_TARGET_OPENCL_VERSION 120
+#include <CL/cl2.hpp>
 
 #include <cstdio>
 #include <cstdlib>
@@ -106,7 +108,7 @@ int main() {
         std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
 
         // Create and program from source
-        cl::Program::Sources sources(1, std::make_pair(kernelSourceCode, 0));
+        cl::Program::Sources sources({kernelSourceCode});
         cl::Program program(context, sources);
 
         // Build program
diff --git a/tests/runtime/CMakeLists.txt b/tests/runtime/CMakeLists.txt
index 401bf48..8739edd 100644
--- a/tests/runtime/CMakeLists.txt
+++ b/tests/runtime/CMakeLists.txt
@@ -28,7 +28,8 @@ set(PROGRAMS_TO_BUILD test_clFinish test_clGetDeviceInfo test_clGetEventInfo
   test_clCreateProgramWithBinary test_clGetSupportedImageFormats
   test_clSetEventCallback test_clEnqueueNativeKernel test_clBuildProgram
   test_clCreateKernelsInProgram test_clCreateKernel test_clGetKernelArgInfo
-  test_version)
+  test_version test_kernel_cache_includes test_event_cycle test_link_error
+  test_read-copy-write-buffer test_clCreateSubDevices test_event_free)
 
 #EXTRA_DIST= \
 # test_kernel_src_in_pwd.h \
@@ -64,8 +65,19 @@ add_test(NAME "runtime/clBuildProgram"
          WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
          COMMAND "${CMAKE_CURRENT_BINARY_DIR}/test_clBuildProgram")
 
+add_test(NAME "runtime/test_kernel_cache_includes"
+         WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
+         COMMAND "${CMAKE_CURRENT_BINARY_DIR}/test_kernel_cache_includes")
+
 add_test("runtime/clFinish" "test_clFinish")
 
+add_test("runtime/test_event_cycle" "test_event_cycle")
+
+# currently fails, see commit 13e5bc89a6b7675efbc
+#add_test("runtime/test_link_error" "test_link_error")
+
+add_test("runtime/test_read-copy-write-buffer" "test_read-copy-write-buffer")
+
 add_test("runtime/clCreateKernel" "test_clCreateKernel")
 
 add_test("runtime/clGetKernelArgInfo" "test_clGetKernelArgInfo")
@@ -82,11 +94,15 @@ set_tests_properties( "runtime/clGetDeviceInfo" "runtime/clEnqueueNativeKernel"
   "runtime/clBuildProgram" "runtime/clFinish" "runtime/clSetEventCallback"
   "runtime/clGetSupportedImageFormats" "runtime/clCreateKernelsInProgram"
   "runtime/clCreateKernel" "runtime/clGetKernelArgInfo"
+  "runtime/test_kernel_cache_includes" "runtime/test_event_cycle"
+  "runtime/test_read-copy-write-buffer" #"runtime/test_link_error"
   PROPERTIES
     COST 2.0
     PROCESSORS 1
     DEPENDS "pocl_version_check")
 
+
+
 set_tests_properties("runtime/clGetSupportedImageFormats"
   PROPERTIES
     ENVIRONMENT "POCL_DEVICES=pthread\ pthread")
@@ -106,3 +122,7 @@ set_tests_properties("runtime/clFinish"
   PROPERTIES
     PASS_REGULAR_EXPRESSION "ABABC")
 
+set_tests_properties("runtime/test_kernel_cache_includes"
+  PROPERTIES PASS_REGULAR_EXPRESSION
+  "function 1.*first include.*function 2.*second include")
+
diff --git a/tests/runtime/Makefile.am b/tests/runtime/Makefile.am
index 6986faf..cd2dbd7 100644
--- a/tests/runtime/Makefile.am
+++ b/tests/runtime/Makefile.am
@@ -23,8 +23,11 @@
 # THE SOFTWARE.
 
 noinst_PROGRAMS= test_clFinish test_clGetDeviceInfo test_clGetEventInfo \
+	test_read-copy-write-buffer test_event_cycle test_event_free \
 	test_clCreateProgramWithBinary test_clGetSupportedImageFormats \
 	test_clSetEventCallback test_clEnqueueNativeKernel test_clBuildProgram \
+	test_link_error test_kernel_cache_includes \
+	test_clCreateSubDevices \
 	test_clCreateKernelsInProgram test_clCreateKernel test_version \
 	test_clGetKernelArgInfo
 
@@ -32,6 +35,7 @@ EXTRA_DIST= \
 	test_kernel_src_in_pwd.h test_clSetEventCallback_expout.txt \
 	test_clCreateKernelsInProgram.cl CMakeLists.txt \
 	test_data/test_kernel_src_in_another_dir.h \
+        test_kernel_cache_includes.cl test_kernel_cache_includes_expout.txt \
 	clGetKernelArgInfo.spir32_meta clGetKernelArgInfo.spir32_nometa \
 	clGetKernelArgInfo.spir64_meta clGetKernelArgInfo.spir64_nometa
 
diff --git a/tests/runtime/Makefile.in b/tests/runtime/Makefile.in
index c07dd82..6eb8d16 100644
--- a/tests/runtime/Makefile.in
+++ b/tests/runtime/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -105,17 +115,19 @@ host_triplet = @host@
 target_triplet = @target@
 noinst_PROGRAMS = test_clFinish$(EXEEXT) test_clGetDeviceInfo$(EXEEXT) \
 	test_clGetEventInfo$(EXEEXT) \
+	test_read-copy-write-buffer$(EXEEXT) test_event_cycle$(EXEEXT) \
+	test_event_free$(EXEEXT) \
 	test_clCreateProgramWithBinary$(EXEEXT) \
 	test_clGetSupportedImageFormats$(EXEEXT) \
 	test_clSetEventCallback$(EXEEXT) \
 	test_clEnqueueNativeKernel$(EXEEXT) \
-	test_clBuildProgram$(EXEEXT) \
+	test_clBuildProgram$(EXEEXT) test_link_error$(EXEEXT) \
+	test_kernel_cache_includes$(EXEEXT) \
+	test_clCreateSubDevices$(EXEEXT) \
 	test_clCreateKernelsInProgram$(EXEEXT) \
 	test_clCreateKernel$(EXEEXT) test_version$(EXEEXT) \
 	test_clGetKernelArgInfo$(EXEEXT)
 subdir = tests/runtime
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -124,6 +136,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -149,6 +162,9 @@ test_clCreateProgramWithBinary_SOURCES =  \
 test_clCreateProgramWithBinary_OBJECTS =  \
 	test_clCreateProgramWithBinary.$(OBJEXT)
 test_clCreateProgramWithBinary_LDADD = $(LDADD)
+test_clCreateSubDevices_SOURCES = test_clCreateSubDevices.c
+test_clCreateSubDevices_OBJECTS = test_clCreateSubDevices.$(OBJEXT)
+test_clCreateSubDevices_LDADD = $(LDADD)
 test_clEnqueueNativeKernel_SOURCES = test_clEnqueueNativeKernel.c
 test_clEnqueueNativeKernel_OBJECTS =  \
 	test_clEnqueueNativeKernel.$(OBJEXT)
@@ -173,6 +189,23 @@ test_clGetSupportedImageFormats_LDADD = $(LDADD)
 test_clSetEventCallback_SOURCES = test_clSetEventCallback.c
 test_clSetEventCallback_OBJECTS = test_clSetEventCallback.$(OBJEXT)
 test_clSetEventCallback_LDADD = $(LDADD)
+test_event_cycle_SOURCES = test_event_cycle.c
+test_event_cycle_OBJECTS = test_event_cycle.$(OBJEXT)
+test_event_cycle_LDADD = $(LDADD)
+test_event_free_SOURCES = test_event_free.c
+test_event_free_OBJECTS = test_event_free.$(OBJEXT)
+test_event_free_LDADD = $(LDADD)
+test_kernel_cache_includes_SOURCES = test_kernel_cache_includes.c
+test_kernel_cache_includes_OBJECTS =  \
+	test_kernel_cache_includes.$(OBJEXT)
+test_kernel_cache_includes_LDADD = $(LDADD)
+test_link_error_SOURCES = test_link_error.c
+test_link_error_OBJECTS = test_link_error.$(OBJEXT)
+test_link_error_LDADD = $(LDADD)
+test_read_copy_write_buffer_SOURCES = test_read-copy-write-buffer.c
+test_read_copy_write_buffer_OBJECTS =  \
+	test_read-copy-write-buffer.$(OBJEXT)
+test_read_copy_write_buffer_LDADD = $(LDADD)
 test_version_SOURCES = test_version.c
 test_version_OBJECTS = test_version.$(OBJEXT)
 test_version_LDADD = $(LDADD)
@@ -212,16 +245,22 @@ am__v_CCLD_0 = @echo "  CCLD    " $@;
 am__v_CCLD_1 = 
 SOURCES = test_clBuildProgram.c test_clCreateKernel.c \
 	test_clCreateKernelsInProgram.c \
-	test_clCreateProgramWithBinary.c test_clEnqueueNativeKernel.c \
-	test_clFinish.c test_clGetDeviceInfo.c test_clGetEventInfo.c \
+	test_clCreateProgramWithBinary.c test_clCreateSubDevices.c \
+	test_clEnqueueNativeKernel.c test_clFinish.c \
+	test_clGetDeviceInfo.c test_clGetEventInfo.c \
 	test_clGetKernelArgInfo.c test_clGetSupportedImageFormats.c \
-	test_clSetEventCallback.c test_version.c
+	test_clSetEventCallback.c test_event_cycle.c test_event_free.c \
+	test_kernel_cache_includes.c test_link_error.c \
+	test_read-copy-write-buffer.c test_version.c
 DIST_SOURCES = test_clBuildProgram.c test_clCreateKernel.c \
 	test_clCreateKernelsInProgram.c \
-	test_clCreateProgramWithBinary.c test_clEnqueueNativeKernel.c \
-	test_clFinish.c test_clGetDeviceInfo.c test_clGetEventInfo.c \
+	test_clCreateProgramWithBinary.c test_clCreateSubDevices.c \
+	test_clEnqueueNativeKernel.c test_clFinish.c \
+	test_clGetDeviceInfo.c test_clGetEventInfo.c \
 	test_clGetKernelArgInfo.c test_clGetSupportedImageFormats.c \
-	test_clSetEventCallback.c test_version.c
+	test_clSetEventCallback.c test_event_cycle.c test_event_free.c \
+	test_kernel_cache_includes.c test_link_error.c \
+	test_read-copy-write-buffer.c test_version.c
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
     n|no|NO) false;; \
@@ -246,6 +285,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -297,6 +337,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -333,6 +376,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -451,6 +495,7 @@ EXTRA_DIST = \
 	test_kernel_src_in_pwd.h test_clSetEventCallback_expout.txt \
 	test_clCreateKernelsInProgram.cl CMakeLists.txt \
 	test_data/test_kernel_src_in_another_dir.h \
+        test_kernel_cache_includes.cl test_kernel_cache_includes_expout.txt \
 	clGetKernelArgInfo.spir32_meta clGetKernelArgInfo.spir32_nometa \
 	clGetKernelArgInfo.spir64_meta clGetKernelArgInfo.spir64_nometa
 
@@ -472,7 +517,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/runtime/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign tests/runtime/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -516,6 +560,10 @@ test_clCreateProgramWithBinary$(EXEEXT): $(test_clCreateProgramWithBinary_OBJECT
 	@rm -f test_clCreateProgramWithBinary$(EXEEXT)
 	$(AM_V_CCLD)$(LINK) $(test_clCreateProgramWithBinary_OBJECTS) $(test_clCreateProgramWithBinary_LDADD) $(LIBS)
 
+test_clCreateSubDevices$(EXEEXT): $(test_clCreateSubDevices_OBJECTS) $(test_clCreateSubDevices_DEPENDENCIES) $(EXTRA_test_clCreateSubDevices_DEPENDENCIES) 
+	@rm -f test_clCreateSubDevices$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(test_clCreateSubDevices_OBJECTS) $(test_clCreateSubDevices_LDADD) $(LIBS)
+
 test_clEnqueueNativeKernel$(EXEEXT): $(test_clEnqueueNativeKernel_OBJECTS) $(test_clEnqueueNativeKernel_DEPENDENCIES) $(EXTRA_test_clEnqueueNativeKernel_DEPENDENCIES) 
 	@rm -f test_clEnqueueNativeKernel$(EXEEXT)
 	$(AM_V_CCLD)$(LINK) $(test_clEnqueueNativeKernel_OBJECTS) $(test_clEnqueueNativeKernel_LDADD) $(LIBS)
@@ -544,6 +592,26 @@ test_clSetEventCallback$(EXEEXT): $(test_clSetEventCallback_OBJECTS) $(test_clSe
 	@rm -f test_clSetEventCallback$(EXEEXT)
 	$(AM_V_CCLD)$(LINK) $(test_clSetEventCallback_OBJECTS) $(test_clSetEventCallback_LDADD) $(LIBS)
 
+test_event_cycle$(EXEEXT): $(test_event_cycle_OBJECTS) $(test_event_cycle_DEPENDENCIES) $(EXTRA_test_event_cycle_DEPENDENCIES) 
+	@rm -f test_event_cycle$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(test_event_cycle_OBJECTS) $(test_event_cycle_LDADD) $(LIBS)
+
+test_event_free$(EXEEXT): $(test_event_free_OBJECTS) $(test_event_free_DEPENDENCIES) $(EXTRA_test_event_free_DEPENDENCIES) 
+	@rm -f test_event_free$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(test_event_free_OBJECTS) $(test_event_free_LDADD) $(LIBS)
+
+test_kernel_cache_includes$(EXEEXT): $(test_kernel_cache_includes_OBJECTS) $(test_kernel_cache_includes_DEPENDENCIES) $(EXTRA_test_kernel_cache_includes_DEPENDENCIES) 
+	@rm -f test_kernel_cache_includes$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(test_kernel_cache_includes_OBJECTS) $(test_kernel_cache_includes_LDADD) $(LIBS)
+
+test_link_error$(EXEEXT): $(test_link_error_OBJECTS) $(test_link_error_DEPENDENCIES) $(EXTRA_test_link_error_DEPENDENCIES) 
+	@rm -f test_link_error$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(test_link_error_OBJECTS) $(test_link_error_LDADD) $(LIBS)
+
+test_read-copy-write-buffer$(EXEEXT): $(test_read_copy_write_buffer_OBJECTS) $(test_read_copy_write_buffer_DEPENDENCIES) $(EXTRA_test_read_copy_write_buffer_DEPENDENCIES) 
+	@rm -f test_read-copy-write-buffer$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(test_read_copy_write_buffer_OBJECTS) $(test_read_copy_write_buffer_LDADD) $(LIBS)
+
 test_version$(EXEEXT): $(test_version_OBJECTS) $(test_version_DEPENDENCIES) $(EXTRA_test_version_DEPENDENCIES) 
 	@rm -f test_version$(EXEEXT)
 	$(AM_V_CCLD)$(LINK) $(test_version_OBJECTS) $(test_version_LDADD) $(LIBS)
@@ -558,6 +626,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_clCreateKernel.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_clCreateKernelsInProgram.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_clCreateProgramWithBinary.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_clCreateSubDevices.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_clEnqueueNativeKernel.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_clFinish.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_clGetDeviceInfo.Po at am__quote@
@@ -565,6 +634,11 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_clGetKernelArgInfo.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_clGetSupportedImageFormats.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_clSetEventCallback.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_event_cycle.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_event_free.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_kernel_cache_includes.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_link_error.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_read-copy-write-buffer.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_version.Po at am__quote@
 
 .c.o:
@@ -797,6 +871,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/tests/runtime/test_clBuildProgram.c b/tests/runtime/test_clBuildProgram.c
index 100a237..61ba372 100644
--- a/tests/runtime/test_clBuildProgram.c
+++ b/tests/runtime/test_clBuildProgram.c
@@ -35,13 +35,27 @@
 
 /* A dummy kernel that just includes another kernel. To test the #include and
    -I */
-char kernel[] = 
+static const char kernel[] =
   "#include \"test_kernel_src_in_another_dir.h\"\n"
   "#include \"test_kernel_src_in_pwd.h\"\n";
 
-char invalid_kernel[] =
+/* A program that fails at preprocess time due to missing endquote
+ * in an #include directive
+ */
+static const char preprocess_fail[] =
+  "#include \"missing_endquote.h\n";
+
+static const char invalid_kernel[] =
   "kernel void test_kernel(constant int a, j) { return 3; }\n";
 
+
+/* kernel can have any name, except main() starting from OpenCL 2.0 */
+static const char valid_kernel[] =
+  "kernel void init(global int *arg) { return; }\n";
+
+static const char invalid_build_option[] =
+  "-fnothing-to-see-here";
+
 int
 main(void){
   cl_int err;
@@ -51,7 +65,6 @@ main(void){
   cl_uint num_devices;
   cl_uint i;
   cl_program program = NULL;
-  cl_program program_with_binary = NULL;
   err = clGetPlatformIDs(MAX_PLATFORMS, platforms, &nplatforms);
   CHECK_OPENCL_ERROR_IN("clGetPlatformIDs");
   if (!nplatforms)
@@ -65,7 +78,7 @@ main(void){
   CHECK_OPENCL_ERROR_IN("clCreateContext");
 
   size_t kernel_size = strlen(kernel);
-  char* kernel_buffer = kernel;
+  const char* kernel_buffer = kernel;
 
   program = clCreateProgramWithSource(context, 1, (const char**)&kernel_buffer, 
                                      &kernel_size, &err);
@@ -90,5 +103,87 @@ main(void){
   err = clBuildProgram(program, num_devices, devices, NULL, NULL, NULL);
   TEST_ASSERT(err == CL_BUILD_PROGRAM_FAILURE);
 
+  err = clReleaseProgram(program);
+  CHECK_OPENCL_ERROR_IN("clReleaseProgram");
+
+  kernel_size = strlen(preprocess_fail);
+  kernel_buffer = preprocess_fail;
+
+  program = clCreateProgramWithSource(context, 1, (const char**)&kernel_buffer,
+				      &kernel_size, &err);
+  //clCreateProgramWithSource for invalid kernel failed
+  CHECK_OPENCL_ERROR_IN("clCreateProgramWithSource");
+
+  err = clBuildProgram(program, num_devices, devices, invalid_build_option, NULL, NULL);
+  TEST_ASSERT(err == CL_INVALID_BUILD_OPTIONS);
+
+  for (i = 0; i < num_devices; ++i) {
+          size_t log_size = 0;
+          err = clGetProgramBuildInfo(program, devices[i], CL_PROGRAM_BUILD_LOG,
+                  0, NULL, &log_size);
+          CHECK_OPENCL_ERROR_IN("get build log size");
+          char *log = malloc(log_size);
+          err = clGetProgramBuildInfo(program, devices[i], CL_PROGRAM_BUILD_LOG,
+                  log_size, log, NULL);
+          CHECK_OPENCL_ERROR_IN("get build log");
+          log[log_size] = '\0';
+          fprintf(stderr, "preprocess failure log[%u]: %s\n", i, log);
+  }
+
+  err = clBuildProgram(program, num_devices, devices, NULL, NULL, NULL);
+  TEST_ASSERT(err == CL_BUILD_PROGRAM_FAILURE);
+
+  for (i = 0; i < num_devices; ++i) {
+	  size_t log_size = 0;
+	  err = clGetProgramBuildInfo(program, devices[i], CL_PROGRAM_BUILD_LOG,
+		  0, NULL, &log_size);
+	  CHECK_OPENCL_ERROR_IN("get build log size");
+	  char *log = malloc(log_size);
+	  err = clGetProgramBuildInfo(program, devices[i], CL_PROGRAM_BUILD_LOG,
+		  log_size, log, NULL);
+	  CHECK_OPENCL_ERROR_IN("get build log");
+	  log[log_size] = '\0';
+	  fprintf(stderr, "preprocess failure log[%u]: %s\n", i, log);
+  }
+
+  err = clReleaseProgram(program);
+  CHECK_OPENCL_ERROR_IN("clReleaseProgram");
+
+  /* Test the possibility to call a kernel 'init'.
+   * Due to the delayed linking in current pocl, this will succeed even if it
+   * would fail at link time. Force linking by issuing the kernel once.
+   */
+
+  kernel_size = strlen(valid_kernel);
+  kernel_buffer = valid_kernel;
+
+  program = clCreateProgramWithSource(context, 1, (const char**)&kernel_buffer,
+				      &kernel_size, &err);
+  CHECK_OPENCL_ERROR_IN("clCreateProgramWithSource");
+
+  err = clBuildProgram(program, num_devices, devices, NULL, NULL, NULL);
+  TEST_ASSERT(err == CL_SUCCESS);
+
+  /* TODO FIXME: from here to the clFinish() should be removed once
+   * delayed linking is disabled/removed in pocl, probably
+   */
+  cl_command_queue q = clCreateCommandQueue(context, devices[0], 0, &err);
+  CHECK_OPENCL_ERROR_IN("clCreateCommandQueue");
+  cl_kernel k = clCreateKernel(program, "init", &err);
+  CHECK_OPENCL_ERROR_IN("clCreateKernel");
+
+  err = clSetKernelArg(k, 0, sizeof(cl_mem), NULL);
+  CHECK_OPENCL_ERROR_IN("clSetKernelArg");
+  size_t gws[] = {1};
+  err = clEnqueueNDRangeKernel(q, k, 1, NULL, gws, NULL, 0, NULL, NULL);
+  CHECK_OPENCL_ERROR_IN("clEnqueueNDRangeKernel");
+  err = clFinish(q);
+  TEST_ASSERT(err == CL_SUCCESS);
+
+  err  = clReleaseCommandQueue(q);
+  err |= clReleaseKernel(k);
+  err |= clReleaseProgram(program);
+  CHECK_OPENCL_ERROR_IN("'init' kernel name test clean-up");
+
   return EXIT_SUCCESS;
 }
diff --git a/tests/runtime/test_clCreateKernel.c b/tests/runtime/test_clCreateKernel.c
index b51b304..49f4d0e 100644
--- a/tests/runtime/test_clCreateKernel.c
+++ b/tests/runtime/test_clCreateKernel.c
@@ -15,7 +15,6 @@ int main(int argc, char **argv)
   cl_context ctx;
   cl_command_queue queue;
   cl_device_id did;
-  cl_uint num_krn;
   cl_kernel kernel;
 
   poclu_get_any_device(&ctx, &did, &queue);
@@ -34,9 +33,11 @@ int main(int argc, char **argv)
 
   kernel = clCreateKernel(program, NULL, &err);
   TEST_ASSERT(err == CL_INVALID_VALUE);
+  TEST_ASSERT(kernel == NULL);
 
   kernel = clCreateKernel(program, "nonexistent_kernel", &err);
   TEST_ASSERT(err == CL_INVALID_KERNEL_NAME);
+  TEST_ASSERT(kernel == NULL);
 
   printf("OK\n");
 
diff --git a/tests/runtime/test_clCreateKernelsInProgram.c b/tests/runtime/test_clCreateKernelsInProgram.c
index c67cf1c..1a9741c 100644
--- a/tests/runtime/test_clCreateKernelsInProgram.c
+++ b/tests/runtime/test_clCreateKernelsInProgram.c
@@ -6,12 +6,13 @@
 #include "config.h"
 #include "pocl_tests.h"
 
+static const char *empty_src = "\n";
 
 int main(int argc, char **argv)
 {
   cl_int err;
   const char *krn_src;
-  cl_program program;
+  cl_program empty, program;
   cl_context ctx;
   cl_device_id did;
   cl_command_queue queue;
@@ -23,6 +24,16 @@ int main(int argc, char **argv)
   TEST_ASSERT( did );
   TEST_ASSERT( queue );
 
+  /* Test creating a program from an empty source */
+  empty = clCreateProgramWithSource(ctx, 1, &empty_src, NULL, &err);
+  CHECK_OPENCL_ERROR_IN("clCreateProgramWithSource");
+  err = clBuildProgram(empty, 0, NULL, NULL, NULL, NULL);
+  CHECK_OPENCL_ERROR_IN("clBuildProgram");
+
+  err = clCreateKernelsInProgram(empty, 0, NULL, &num_krn);
+  CHECK_OPENCL_ERROR_IN("clCreateKernelsInProgram");
+  TEST_ASSERT(num_krn == 0);
+
   krn_src = poclu_read_file(SRCDIR "/tests/runtime/test_clCreateKernelsInProgram.cl");
   TEST_ASSERT(krn_src);
 
@@ -30,7 +41,7 @@ int main(int argc, char **argv)
   CHECK_OPENCL_ERROR_IN("clCreateProgramWithSource");
   err = clBuildProgram(program, 0, NULL, NULL, NULL, NULL);
   CHECK_OPENCL_ERROR_IN("clBuildProgram");
-  
+
   err = clCreateKernelsInProgram(program, 0, NULL, &num_krn);
   CHECK_OPENCL_ERROR_IN("clCreateKernelsInProgram");
   // test_clCreateKernelsInProgram.cl has two kernel functions.
@@ -38,7 +49,7 @@ int main(int argc, char **argv)
 
   err = clCreateKernelsInProgram(program, 2, kernels, NULL);
   CHECK_OPENCL_ERROR_IN("clCreateKernelsInProgram");
-  
+
   // make sure the kernels were actually created 
   // Note: nothing in the specification says which kernel function
   // is kernels[0], which is kernels[1]. For now assume pocl/LLVM
@@ -46,6 +57,9 @@ int main(int argc, char **argv)
   err = clEnqueueTask(queue, kernels[0], 0, NULL, NULL); 
   CHECK_OPENCL_ERROR_IN("clEnqueueTask");
 
+  err = clFinish(queue);
+  CHECK_OPENCL_ERROR_IN("clFinish");
+
   err = clEnqueueTask(queue, kernels[1], 0, NULL, NULL);
   CHECK_OPENCL_ERROR_IN("clEnqueueTask");
 
diff --git a/tests/runtime/test_clCreateProgramWithBinary.c b/tests/runtime/test_clCreateProgramWithBinary.c
index 3c2e6e7..1100e7b 100644
--- a/tests/runtime/test_clCreateProgramWithBinary.c
+++ b/tests/runtime/test_clCreateProgramWithBinary.c
@@ -16,7 +16,7 @@ main(void){
   cl_device_id devices[MAX_DEVICES + 1]; // + 1 for duplicate test
   cl_device_id device_id0;
   cl_uint num_devices;
-  cl_uint i;
+  size_t i;
   size_t num_binaries;
   const unsigned char **binaries = NULL;
   size_t *binary_sizes = NULL;
@@ -55,7 +55,7 @@ main(void){
       goto FREE_AND_EXIT;
 
   num_binaries = num_binaries/sizeof(size_t);
-  binary_sizes = (size_t*)malloc(num_binaries * sizeof(size_t)); 
+  binary_sizes = (size_t*)malloc(num_binaries * sizeof(size_t));
   binaries = (const unsigned char**)calloc(num_binaries, sizeof(unsigned char*));
 
   err = clGetProgramInfo(program, CL_PROGRAM_BINARY_SIZES, 
@@ -65,7 +65,7 @@ main(void){
       goto FREE_AND_EXIT;
   
   for (i = 0; i < num_binaries; ++i) 
-    binaries[i] = (const unsigned char*) malloc(binary_sizes[i] * 
+    binaries[i] = (const unsigned char*) malloc(binary_sizes[i] *
 						sizeof(const unsigned char));
 
   err = clGetProgramInfo(program, CL_PROGRAM_BINARIES, 
@@ -73,7 +73,7 @@ main(void){
   if (err != CL_SUCCESS)
       goto FREE_AND_EXIT;
   
-  cl_int num = num_binaries < num_devices ? num_binaries : num_devices;
+  cl_uint num = num_binaries < num_devices ? num_binaries : num_devices;
   if (num == 0)
     {
       err = !CL_SUCCESS;
@@ -117,7 +117,7 @@ main(void){
   num_binaries = 2;
   devices[1] = devices[0]; // duplicate
   
-  binary_sizes = (size_t*)malloc(num_binaries * sizeof(size_t)); 
+  binary_sizes = (size_t*)malloc(num_binaries * sizeof(size_t));
   binaries = (const unsigned char**)calloc(num_binaries, sizeof(unsigned char*));
   
   err = clGetProgramInfo(program, CL_PROGRAM_BINARY_SIZES, 1*sizeof(size_t), 
@@ -127,9 +127,9 @@ main(void){
   
   binary_sizes[1] = binary_sizes[0];
   
-  binaries[0] = (const unsigned char*) malloc(binary_sizes[0] * 
+  binaries[0] = (const unsigned char*) malloc(binary_sizes[0] *
 					      sizeof(const unsigned char));
-  binaries[1] = (const unsigned char*) malloc(binary_sizes[1] * 
+  binaries[1] = (const unsigned char*) malloc(binary_sizes[1] *
 					      sizeof(const unsigned char));
   
   err = clGetProgramInfo(program, CL_PROGRAM_BINARIES, 1 * sizeof(char*), 
diff --git a/tests/runtime/test_clCreateSubDevices.c b/tests/runtime/test_clCreateSubDevices.c
new file mode 100644
index 0000000..87369c1
--- /dev/null
+++ b/tests/runtime/test_clCreateSubDevices.c
@@ -0,0 +1,381 @@
+/* Test clCreateSubDevices
+
+   Copyright (C) 2015 Giuseppe Bilotta <giuseppe.bilotta at gmail.com>
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <CL/opencl.h>
+#include "poclu.h"
+#include "config.h"
+#include "pocl_tests.h"
+
+/* Two different kernel sources, to ensure that the test for all devices
+ * and the test with only sub-devices do not interphere with each other
+ * (cache-wise)
+ */
+static const char *prog_src_all = "kernel void\n"
+"setidx(global int *buf, int idx) {\n"
+"buf[idx] = idx;\n"
+"}\n";
+
+static const char *prog_src_two = "kernel void\n"
+"setidx(global int *buf, int idx) {\n"
+"buf[idx] = -idx;\n"
+"}\n";
+
+
+int test_context(cl_context ctx, const char *prog_src, int mul,
+  int ndevs, cl_device_id *devs) {
+  cl_int err;
+  cl_command_queue queue[ndevs];
+  cl_program prog;
+  cl_kernel krn;
+  cl_mem buf;
+  cl_event evt[ndevs];
+  cl_int i;
+
+  prog = clCreateProgramWithSource(ctx, 1, &prog_src, NULL, &err);
+  CHECK_OPENCL_ERROR_IN("create program");
+
+  err = clBuildProgram(prog, 0, NULL, NULL, NULL, NULL);
+  CHECK_OPENCL_ERROR_IN("build program");
+
+  krn = clCreateKernel(prog, "setidx", &err);
+  CHECK_OPENCL_ERROR_IN("create kernel");
+
+  buf = clCreateBuffer(ctx, CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE |
+    CL_MEM_HOST_READ_ONLY, ndevs*sizeof(cl_int), NULL, &err);
+  CHECK_OPENCL_ERROR_IN("create buffer");
+
+  err = clSetKernelArg(krn, 0, sizeof(cl_mem), &buf);
+  CHECK_OPENCL_ERROR_IN("set kernel arg 0");
+
+  /* create one queue per device, and submit task, waiting for all
+   * previous */
+  for (i = 0; i < ndevs; ++i) {
+    queue[i] = clCreateCommandQueue(ctx, devs[i], 0, &err);
+    CHECK_OPENCL_ERROR_IN("create queue");
+    err = clSetKernelArg(krn, 1, sizeof(i), &i);
+    CHECK_OPENCL_ERROR_IN("set kernel arg 1");
+    // no wait list for first (root) device
+    err = clEnqueueTask(queue[i], krn, i, i ? evt : NULL, evt + i);
+    CHECK_OPENCL_ERROR_IN("submit task");
+  }
+
+  /* enqueue map on last */
+  cl_int *buf_host = clEnqueueMapBuffer(queue[ndevs - 1], buf, CL_TRUE,
+    CL_MAP_READ, 0, ndevs*sizeof(cl_int), ndevs, evt, NULL, &err);
+  CHECK_OPENCL_ERROR_IN("map buffer");
+
+  int mismatch = 0;
+  for (i = 0; i < ndevs; ++i) {
+    mismatch += !!(buf_host[i] != i*mul);
+  }
+  TEST_ASSERT(mismatch == 0);
+
+  /* enqueue unmap on first */
+  err = clEnqueueUnmapMemObject(queue[0], buf, buf_host, 0, NULL, NULL);
+  CHECK_OPENCL_ERROR_IN("unmap buffer");
+
+  for (i = 0 ; i < ndevs; ++i) {
+    err = clFinish(queue[i]);
+    err |= clReleaseCommandQueue(queue[i]);
+    err |= clReleaseEvent(evt[i]);
+  }
+
+  err |= clReleaseKernel(krn);
+  err |= clReleaseMemObject(buf);
+  err |= clReleaseProgram(prog);
+  err |= clReleaseContext(ctx);
+
+  CHECK_OPENCL_ERROR_IN("cleanup");
+
+  return CL_SUCCESS;
+
+}
+
+int main(int argc, char **argv)
+{
+  cl_context ctx;
+  cl_command_queue q;
+  // root device, all devices
+#define NUMDEVS 5
+  cl_device_id rootdev, alldevs[NUMDEVS];
+  // pointers to the sub devices of the partitions EQUALLY and BY_COUNTS
+  // respectively
+  cl_device_id
+    *eqdev = alldevs + 1,
+    *countdev = alldevs + 3;
+  cl_uint max_cus, max_subs;
+  cl_uint i;
+
+  cl_int err = poclu_get_any_device(&ctx, &rootdev, &q);
+  CHECK_OPENCL_ERROR_IN("poclu_get_any_device");
+  TEST_ASSERT( ctx );
+  TEST_ASSERT( rootdev );
+  TEST_ASSERT( q );
+
+  alldevs[0] = rootdev;
+
+  err = clGetDeviceInfo(rootdev, CL_DEVICE_MAX_COMPUTE_UNITS,
+    sizeof(max_cus), &max_cus, NULL);
+  CHECK_OPENCL_ERROR_IN("CL_DEVICE_MAX_COMPUTE_UNITS");
+  if (max_cus < 2)
+    {
+      printf("This test requires a cl device with at least 2 compute units "
+             " (a dual-core or better CPU)\n");
+      return 1;
+    }
+
+  err = clGetDeviceInfo(rootdev, CL_DEVICE_PARTITION_MAX_SUB_DEVICES,
+    sizeof(max_subs), &max_subs, NULL);
+  CHECK_OPENCL_ERROR_IN("CL_DEVICE_PARTITION_MAX_SUB_DEVICES");
+
+  // test fails without possible sub-devices, e.g. with basic pocl device
+  TEST_ASSERT(max_subs > 1);
+
+  cl_device_partition_property *dev_pt;
+  size_t dev_pt_size;
+
+  err = clGetDeviceInfo(rootdev, CL_DEVICE_PARTITION_PROPERTIES,
+    0, NULL, &dev_pt_size);
+  CHECK_OPENCL_ERROR_IN("CL_DEVICE_PARTITION_PROPERTIES size");
+
+  dev_pt = malloc(dev_pt_size);
+  TEST_ASSERT(dev_pt);
+  err = clGetDeviceInfo(rootdev, CL_DEVICE_PARTITION_PROPERTIES,
+    dev_pt_size, dev_pt, NULL);
+  CHECK_OPENCL_ERROR_IN("CL_DEVICE_PARTITION_PROPERTIES");
+
+  dev_pt_size /= sizeof(*dev_pt); // number of partition types
+
+  // check that partition types EQUALLY and BY_COUNTS are supported
+  int found = 0;
+  for (i = 0; i < dev_pt_size; ++i) {
+    if (dev_pt[i] == CL_DEVICE_PARTITION_EQUALLY ||
+        dev_pt[i] == CL_DEVICE_PARTITION_BY_COUNTS)
+      ++found;
+  }
+
+  TEST_ASSERT(found == 2);
+
+  // here we will store the partition types returned by the subdevices
+  cl_device_partition_property *ptype = NULL;
+  size_t ptype_size;
+  cl_uint numdevs = 0;
+
+  cl_device_id parent;
+  cl_uint sub_cus;
+
+
+  /* CL_DEVICE_PARTITION_EQUALLY */
+
+  const cl_device_partition_property equal_splitter[] = {
+    CL_DEVICE_PARTITION_EQUALLY, max_cus/2, 0 };
+
+  err = clCreateSubDevices(rootdev, equal_splitter, 0, NULL, &numdevs);
+  CHECK_OPENCL_ERROR_IN("count sub devices");
+  TEST_ASSERT(numdevs == 2);
+
+  err = clCreateSubDevices(rootdev, equal_splitter, 2, eqdev, NULL);
+  CHECK_OPENCL_ERROR_IN("partition equally");
+
+  /* First, check that the root device is untouched */
+
+  err = clGetDeviceInfo(rootdev, CL_DEVICE_MAX_COMPUTE_UNITS,
+    sizeof(sub_cus), &sub_cus, NULL);
+  CHECK_OPENCL_ERROR_IN("parenty CU");
+  TEST_ASSERT(sub_cus == max_cus);
+
+  err = clGetDeviceInfo(rootdev, CL_DEVICE_PARENT_DEVICE,
+    sizeof(parent), &parent, NULL);
+  CHECK_OPENCL_ERROR_IN("root parent device");
+  TEST_ASSERT(parent == NULL);
+
+  /* partition type may either be NULL or contain a 0 entry */
+  err = clGetDeviceInfo(rootdev, CL_DEVICE_PARTITION_TYPE,
+    0, NULL, &ptype_size);
+  CHECK_OPENCL_ERROR_IN("root partition type");
+
+  if (ptype_size != 0) {
+    /* abuse dev_pt which should be large enough */
+    TEST_ASSERT(ptype_size == sizeof(cl_device_partition_property));
+    TEST_ASSERT(ptype_size <= dev_pt_size);
+    err = clGetDeviceInfo(rootdev, CL_DEVICE_PARTITION_TYPE,
+      ptype_size, dev_pt, NULL);
+    CHECK_OPENCL_ERROR_IN("root partition type #2");
+    TEST_ASSERT(dev_pt[0] == 0);
+  }
+
+  /* now test the subdevices */
+  for (i = 0; i < 2; ++i) {
+    err = clGetDeviceInfo(eqdev[i], CL_DEVICE_MAX_COMPUTE_UNITS,
+      sizeof(sub_cus), &sub_cus, NULL);
+    CHECK_OPENCL_ERROR_IN("sub CU");
+    TEST_ASSERT(sub_cus == max_cus/2);
+
+    err = clGetDeviceInfo(eqdev[i], CL_DEVICE_PARENT_DEVICE,
+      sizeof(parent), &parent, NULL);
+    CHECK_OPENCL_ERROR_IN("sub parent device");
+    TEST_ASSERT(parent == rootdev);
+
+    err = clGetDeviceInfo(eqdev[i], CL_DEVICE_PARTITION_TYPE,
+      0, NULL, &ptype_size);
+    CHECK_OPENCL_ERROR_IN("sub partition type");
+    TEST_ASSERT(ptype_size == sizeof(equal_splitter));
+
+    ptype = malloc(ptype_size);
+    TEST_ASSERT(ptype);
+    err = clGetDeviceInfo(eqdev[i], CL_DEVICE_PARTITION_TYPE,
+      ptype_size, ptype, NULL);
+    CHECK_OPENCL_ERROR_IN("sub partition type #2");
+
+    TEST_ASSERT(memcmp(ptype, equal_splitter, ptype_size) == 0);
+
+    /* free the partition type */
+    free(ptype) ; ptype = NULL;
+  }
+
+  /* CL_DEVICE_PARTITION_BY_COUNTS */
+
+  /* Note that the platform will only read this to the first 0,
+   * which is actually CL_DEVICE_PARTITION_BY_COUNTS_LIST_END;
+   * the test is structured with an additional final 0 intentionally,
+   * to follow the Khoronos doc example
+   */
+  const cl_device_partition_property count_splitter[] = {
+    CL_DEVICE_PARTITION_BY_COUNTS, 1, max_cus - 1,
+    CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, 0 };
+
+  err = clCreateSubDevices(rootdev, count_splitter, 0, NULL, &numdevs);
+  CHECK_OPENCL_ERROR_IN("count sub devices");
+  TEST_ASSERT(numdevs == 2);
+
+  err = clCreateSubDevices(rootdev, count_splitter, 2, countdev, NULL);
+  CHECK_OPENCL_ERROR_IN("partition by counts");
+
+  /* First, check that the root device is untouched */
+
+  err = clGetDeviceInfo(rootdev, CL_DEVICE_MAX_COMPUTE_UNITS,
+    sizeof(sub_cus), &sub_cus, NULL);
+  CHECK_OPENCL_ERROR_IN("parenty CU");
+  TEST_ASSERT(sub_cus == max_cus);
+
+  err = clGetDeviceInfo(rootdev, CL_DEVICE_PARENT_DEVICE,
+    sizeof(parent), &parent, NULL);
+  CHECK_OPENCL_ERROR_IN("root parent device");
+  TEST_ASSERT(parent == NULL);
+
+  /* partition type may either be NULL or contain a 0 entry */
+  err = clGetDeviceInfo(rootdev, CL_DEVICE_PARTITION_TYPE,
+    0, NULL, &ptype_size);
+  CHECK_OPENCL_ERROR_IN("root partition type");
+
+  if (ptype_size != 0) {
+    /* abuse dev_pt which should be large enough */
+    TEST_ASSERT(ptype_size == sizeof(cl_device_partition_property));
+    TEST_ASSERT(ptype_size <= dev_pt_size);
+    err = clGetDeviceInfo(rootdev, CL_DEVICE_PARTITION_TYPE,
+      ptype_size, dev_pt, NULL);
+    CHECK_OPENCL_ERROR_IN("root partition type #2");
+    TEST_ASSERT(dev_pt[0] == 0);
+  }
+
+  // devices might be returned in different order than the counts
+  // in the count_splitter
+
+  int found_cus[2] = {0, 0};
+
+  /* now test the subdevices */
+  for (i = 0; i < 2; ++i) {
+    err = clGetDeviceInfo(countdev[i], CL_DEVICE_MAX_COMPUTE_UNITS,
+      sizeof(sub_cus), &sub_cus, NULL);
+    CHECK_OPENCL_ERROR_IN("sub CU");
+    if (sub_cus == count_splitter[1])
+        found_cus[0] += 1;
+    else if (sub_cus == count_splitter[2])
+        found_cus[1] += 1;
+
+    err = clGetDeviceInfo(countdev[i], CL_DEVICE_PARENT_DEVICE,
+      sizeof(parent), &parent, NULL);
+    CHECK_OPENCL_ERROR_IN("sub parent device");
+    TEST_ASSERT(parent == rootdev);
+
+    /* The partition type returned is up to the first 0,
+     * which happens to be the CL_DEVICE_PARTITION_BY_COUNTS_LIST_END,
+     * not the final terminating 0 in count_splitter, so it has one less
+     * element. It should be otherwise equal */
+    err = clGetDeviceInfo(countdev[i], CL_DEVICE_PARTITION_TYPE,
+      0, NULL, &ptype_size);
+    CHECK_OPENCL_ERROR_IN("sub partition type");
+    TEST_ASSERT(ptype_size == sizeof(count_splitter) - sizeof(*count_splitter));
+
+    ptype = malloc(ptype_size);
+    TEST_ASSERT(ptype);
+    err = clGetDeviceInfo(countdev[i], CL_DEVICE_PARTITION_TYPE,
+      ptype_size, ptype, NULL);
+    CHECK_OPENCL_ERROR_IN("sub partition type #2");
+
+    TEST_ASSERT(memcmp(ptype, count_splitter, ptype_size) == 0);
+
+    /* free the partition type */
+    free(ptype) ; ptype = NULL;
+  }
+
+  /* the previous loop finds 1+1 subdevices only on >dual core systems;
+   * on dual cores, the count_splitter is [1, 1] and the above
+   * "(sub_cus == count_splitter[x])" results in 2+0 subdevices found */
+  if (max_cus > 2)
+    TEST_ASSERT(found_cus[0] == 1 && found_cus[1] == 1);
+  else
+    TEST_ASSERT((found_cus[0] + found_cus[1]) == 2);
+
+  /* So far, so good. Let's now try and use these devices,
+   * by building a program for all of them and launching kernels on them.
+   *
+   * Note that there's a discrepancy in behavior between implementations:
+   * some assume you can treat sub-devices as their parent device, and thus
+   * e.g. using them through any context which includes their parent devices,
+   * other fail miserably if you try this.
+   *
+   * For the time being we will test the stricter behavior, where
+   * sub-devices should be added manually to a context.
+   */
+
+  err = clReleaseCommandQueue(q);
+  CHECK_OPENCL_ERROR_IN("clReleaseCommandQueue");
+  err = clReleaseContext(ctx);
+  CHECK_OPENCL_ERROR_IN("clReleaseContext");
+
+  ctx = clCreateContext(NULL, NUMDEVS, alldevs, NULL, NULL, &err);
+  CHECK_OPENCL_ERROR_IN("clCreateContext");
+  TEST_ASSERT( test_context(ctx, prog_src_all, 1, NUMDEVS, alldevs) == CL_SUCCESS );
+
+  ctx = clCreateContext(NULL, NUMDEVS - 1, alldevs + 1, NULL, NULL, &err);
+  CHECK_OPENCL_ERROR_IN("clCreateContext");
+  TEST_ASSERT( test_context(ctx, prog_src_two, -1, NUMDEVS - 1, alldevs + 1)
+    == CL_SUCCESS );
+
+  return 0;
+}
+
diff --git a/tests/runtime/test_clEnqueueNativeKernel.c b/tests/runtime/test_clEnqueueNativeKernel.c
index 58651f9..12e7abc 100644
--- a/tests/runtime/test_clEnqueueNativeKernel.c
+++ b/tests/runtime/test_clEnqueueNativeKernel.c
@@ -75,11 +75,11 @@ int main(int argc, char **argv) {
   h_b = (double *) malloc(bytes);
   h_c = (double *) malloc(bytes);
  
-  int i;
+  size_t i;
   for( i = 0; i < n; i++ )
   {
-    h_a[i] = i;
-    h_b[i] = i;
+    h_a[i] = (double)i;
+    h_b[i] = (double)i;
   }
 
   cl_int err;
diff --git a/tests/runtime/test_clGetEventInfo.c b/tests/runtime/test_clGetEventInfo.c
index 4dc3699..b38fe92 100644
--- a/tests/runtime/test_clGetEventInfo.c
+++ b/tests/runtime/test_clGetEventInfo.c
@@ -24,59 +24,50 @@ main(void)
       err = clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, MAX_DEVICES,
 			   devices, &ndevices);
       if (err != CL_SUCCESS)
-	return EXIT_FAILURE;
+        return EXIT_FAILURE;
       
       for (j = 0; j < ndevices; j++)
-	{
-	  cl_context context = clCreateContext(NULL, 1, &devices[j], NULL, NULL, &err);
-	  if (err != CL_SUCCESS)
-	    return EXIT_FAILURE;
-	  cl_command_queue queue = clCreateCommandQueue(context, devices[j], 0, &err);
-	  if (err != CL_SUCCESS)
-	    return EXIT_FAILURE;
-
-	  const int buf_size = 1024;
-	  cl_int host_buf[buf_size];
-
-	  cl_mem buf = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(cl_int) * buf_size, NULL, &err);
-	  if (err != CL_SUCCESS)
-	    return EXIT_FAILURE;
-	  cl_event buf_event;
-	  if (clEnqueueReadBuffer(queue, buf, CL_TRUE, 0, sizeof(cl_int) * buf_size, &host_buf, 0, NULL, &buf_event) != CL_SUCCESS)
-	    return EXIT_FAILURE;
-	  clFinish(queue);
-	  cl_command_queue event_command_queue;
-	  size_t param_val_size_ret;
-	  if (clGetEventInfo(buf_event, CL_EVENT_COMMAND_QUEUE, sizeof(cl_command_queue), &event_command_queue, &param_val_size_ret) != CL_SUCCESS)
-	    return EXIT_FAILURE;
-	  if (param_val_size_ret != sizeof(cl_command_queue) || event_command_queue != queue)
-	    return EXIT_FAILURE;
-
-	  cl_command_type command_type;
-	  if (clGetEventInfo(buf_event, CL_EVENT_COMMAND_TYPE, sizeof(cl_command_type), &command_type, &param_val_size_ret) != CL_SUCCESS)
-	    return EXIT_FAILURE;
-	  if (param_val_size_ret != sizeof(cl_command_type) || command_type != CL_COMMAND_READ_BUFFER)
-	    return EXIT_FAILURE;
-
-	  cl_int execution_status;
-	  if (clGetEventInfo(buf_event, CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof(cl_int), &execution_status, &param_val_size_ret) != CL_SUCCESS)
-	    return EXIT_FAILURE;
-	  if (param_val_size_ret != sizeof(cl_int) || execution_status != CL_COMPLETE)
-	    return EXIT_FAILURE;
-
-	  cl_uint ref_count;
-	  if (clGetEventInfo(buf_event, CL_EVENT_REFERENCE_COUNT, sizeof(cl_uint), &ref_count, &param_val_size_ret) != CL_SUCCESS)
-	    return EXIT_FAILURE;
-	  if (param_val_size_ret != sizeof(cl_uint) || ref_count != 1)
         {
-          printf("FAIL: expected refcount 1, got %d\n", ref_count);
-          return EXIT_FAILURE;
+          cl_context context = clCreateContext(NULL, 1, &devices[j], NULL, NULL, &err);
+          if (err != CL_SUCCESS)
+            return EXIT_FAILURE;
+          cl_command_queue queue = clCreateCommandQueue(context, devices[j], 0, &err);
+          if (err != CL_SUCCESS)
+            return EXIT_FAILURE;
+          
+          const int buf_size = 1024;
+          cl_int host_buf[buf_size];
+          
+          cl_mem buf = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(cl_int) * buf_size, NULL, &err);
+          if (err != CL_SUCCESS)
+            return EXIT_FAILURE;
+          cl_event buf_event;
+          if (clEnqueueReadBuffer(queue, buf, CL_TRUE, 0, sizeof(cl_int) * buf_size, &host_buf, 0, NULL, &buf_event) != CL_SUCCESS)
+            return EXIT_FAILURE;
+          clFinish(queue);
+          cl_command_queue event_command_queue;
+          size_t param_val_size_ret;
+          if (clGetEventInfo(buf_event, CL_EVENT_COMMAND_QUEUE, sizeof(cl_command_queue), &event_command_queue, &param_val_size_ret) != CL_SUCCESS)
+            return EXIT_FAILURE;
+          if (param_val_size_ret != sizeof(cl_command_queue) || event_command_queue != queue)
+            return EXIT_FAILURE;
+          
+          cl_command_type command_type;
+          if (clGetEventInfo(buf_event, CL_EVENT_COMMAND_TYPE, sizeof(cl_command_type), &command_type, &param_val_size_ret) != CL_SUCCESS)
+            return EXIT_FAILURE;
+          if (param_val_size_ret != sizeof(cl_command_type) || command_type != CL_COMMAND_READ_BUFFER)
+            return EXIT_FAILURE;
+          
+          cl_int execution_status;
+          if (clGetEventInfo(buf_event, CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof(cl_int), &execution_status, &param_val_size_ret) != CL_SUCCESS)
+            return EXIT_FAILURE;
+          if (param_val_size_ret != sizeof(cl_int) || execution_status != CL_COMPLETE)
+            return EXIT_FAILURE;
+          
+          clReleaseEvent(buf_event);
+          clReleaseMemObject(buf);
+          clReleaseCommandQueue(queue);
         }
-
-	  clReleaseEvent(buf_event);
-	  clReleaseMemObject(buf);
-	  clReleaseCommandQueue(queue);
-	}
     }
   return EXIT_SUCCESS;
 }
diff --git a/tests/runtime/test_event_cycle.c b/tests/runtime/test_event_cycle.c
new file mode 100644
index 0000000..3713f87
--- /dev/null
+++ b/tests/runtime/test_event_cycle.c
@@ -0,0 +1,147 @@
+/* Test that recycling wait lists doesn't lead to lockups
+
+   Copyright (C) 2015 Giuseppe Bilotta <giuseppe.bilotta at gmail.com>
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <signal.h>
+#include <CL/cl.h>
+
+#include "pocl_tests.h"
+#include "poclu.h"
+
+#define MAX_PLATFORMS 32
+#define MAX_DEVICES   32
+
+void timeout(int signum)
+{
+  exit(EXIT_FAILURE);
+}
+
+int
+main(void)
+{
+  cl_int err;
+  cl_platform_id platforms[MAX_PLATFORMS];
+  cl_uint nplatforms;
+  cl_device_id devices[MAX_DEVICES];
+  cl_uint ndevices;
+  cl_uint i, j;
+
+  /* set up a signal handler for ALRM that will kill
+   * the program with EXIT_FAILURE on timeout
+   */
+  struct sigaction sa;
+  memset(&sa, 0, sizeof(sa));
+  sa.sa_handler = timeout;
+  sigaction(SIGALRM, &sa, NULL);
+
+  err = clGetPlatformIDs(MAX_PLATFORMS, platforms, &nplatforms);
+  CHECK_OPENCL_ERROR_IN("clGetPlatformIDs");
+
+  for (i = 0; i < nplatforms; i++)
+  {
+    err = clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, MAX_DEVICES,
+      devices, &ndevices);
+    CHECK_OPENCL_ERROR_IN("clGetDeviceIDs");
+
+    for (j = 0; j < ndevices; j++)
+    {
+      cl_context context = clCreateContext(NULL, 1, &devices[j], NULL, NULL, &err);
+      CHECK_OPENCL_ERROR_IN("clCreateContext");
+      cl_command_queue queue = clCreateCommandQueue(context, devices[j], 0, &err);
+      CHECK_OPENCL_ERROR_IN("clCreateCommandQueue");
+
+      cl_ulong alloc;
+#define MAXALLOC (128*1024U*1024U)
+
+      if (clGetDeviceInfo(devices[j], CL_DEVICE_MAX_MEM_ALLOC_SIZE,
+          sizeof(alloc), &alloc, NULL) != CL_SUCCESS)
+      CHECK_OPENCL_ERROR_IN("get max alloc");
+
+      while (alloc > MAXALLOC)
+        alloc /= 2;
+
+      const size_t buf_size = alloc;
+
+      cl_int *host_buf1 = malloc(buf_size);
+      if (host_buf1 == NULL)
+        return EXIT_FAILURE;
+      cl_int *host_buf2 = malloc(buf_size);
+      if (host_buf2 == NULL)
+        return EXIT_FAILURE;
+
+      memset(host_buf1, 1, buf_size);
+      memset(host_buf2, 2, buf_size);
+
+      cl_mem buf1 = clCreateBuffer(context, CL_MEM_READ_WRITE, buf_size, NULL, &err);
+      CHECK_OPENCL_ERROR_IN("create buf1");
+      cl_mem buf2 = clCreateBuffer(context, CL_MEM_READ_WRITE, buf_size, NULL, &err);
+      CHECK_OPENCL_ERROR_IN("create buf2");
+
+      cl_event buf1_event, bufcp_event, buf2_event;
+
+      /* we test if recycling the wait list leads to neverending loops */
+      cl_event wait_list[1];
+
+      /* Note that this must be CL_TRUE because to trigger the bug the next
+       * command must have a completed event in the waiting lists */
+      err = clEnqueueWriteBuffer(queue, buf1, CL_TRUE, 0, buf_size, host_buf1,
+	0, NULL, &buf1_event);
+      CHECK_OPENCL_ERROR_IN("write buf1");
+
+      *wait_list = buf1_event;
+
+      err = clEnqueueCopyBuffer(queue, buf1, buf2, 0, 0, buf_size,
+	1, wait_list, &bufcp_event);
+      CHECK_OPENCL_ERROR_IN("copy buffers");
+
+      *wait_list = bufcp_event;
+
+      err = clEnqueueReadBuffer(queue, buf2, CL_FALSE, 0, buf_size, host_buf2,
+	1, wait_list, &buf2_event);
+      CHECK_OPENCL_ERROR_IN("read buf");
+
+      /* timeout after 30 seconds: if we're not done by then, timeout() will be
+       * invoked and terminate the program with an EXIT_FAILURE */
+      alarm(30);
+
+      err = clFinish(queue);
+      CHECK_OPENCL_ERROR_IN("clFinish");
+
+      if (memcmp(host_buf2, host_buf1, buf_size) != 0)
+        return EXIT_FAILURE;
+
+      free(host_buf2);
+      free(host_buf1);
+      clReleaseEvent(buf2_event);
+      clReleaseEvent(bufcp_event);
+      clReleaseEvent(buf1_event);
+      clReleaseMemObject(buf2);
+      clReleaseMemObject(buf1);
+      clReleaseCommandQueue(queue);
+    }
+  }
+  return EXIT_SUCCESS;
+}
diff --git a/tests/runtime/test_event_free.c b/tests/runtime/test_event_free.c
new file mode 100644
index 0000000..bdaea89
--- /dev/null
+++ b/tests/runtime/test_event_free.c
@@ -0,0 +1,216 @@
+/* Test that the associated event to a failing command isn't unduly freed
+
+   Copyright (C) 2015 Giuseppe Bilotta <giuseppe.bilotta at gmail.com>
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <CL/cl.h>
+#include "poclu.h"
+#include "pocl_tests.h"
+
+int main(int argc, char **argv)
+{
+  cl_int err;
+  cl_context ctx;
+  cl_command_queue queue;
+  cl_device_id did;
+
+  poclu_get_any_device(&ctx, &did, &queue);
+  TEST_ASSERT(ctx);
+  TEST_ASSERT(did);
+  TEST_ASSERT(queue);
+
+  const size_t buf_size = sizeof(cl_int);
+  cl_mem buf = clCreateBuffer(ctx, CL_MEM_READ_WRITE, buf_size, NULL, &err);
+  CHECK_OPENCL_ERROR_IN("clCreateBuffer");
+
+  cl_image_format img_fmt = {
+    .image_channel_order = CL_R,
+    .image_channel_data_type = CL_UNSIGNED_INT32 };
+  cl_image_desc img_dsc = {
+    .image_type = CL_MEM_OBJECT_IMAGE2D,
+    .image_width = 1,
+    .image_height = 1,
+    .image_depth = 1,
+    .image_array_size = 1,
+    .image_row_pitch = 0,
+    .image_slice_pitch = 0,
+    .num_mip_levels = 0,
+    .num_samples = 0,
+    .buffer = NULL,
+  };
+
+  cl_mem img = clCreateImage(ctx, CL_MEM_READ_WRITE,
+    &img_fmt, &img_dsc, NULL, &err);
+  CHECK_OPENCL_ERROR_IN("clCreateImage");
+
+  /* An invalid waiting list (e.g. a null event in it) should make
+   * associated commands fail without segfaults and without touching any associated
+   * event. Test that this is indeed the case.
+   */
+
+  cl_int *host_ptr = NULL;
+  cl_event no_event = NULL;
+
+  /* We will test both NULL and invalid initial value for map_event */
+  cl_event initial_values[] = { NULL, (cl_event)1 };
+  cl_uint i = 0;
+
+  /***
+   * Test buffer mapping/unmapping
+   */
+
+  /* Test without associated event */
+  host_ptr = clEnqueueMapBuffer(queue, buf, CL_TRUE, CL_MAP_READ, 0, buf_size,
+    1, &no_event, NULL, &err);
+  TEST_ASSERT(err == CL_INVALID_EVENT_WAIT_LIST);
+  TEST_ASSERT(host_ptr == NULL);
+
+  /* Test with map_event = NULL */
+  cl_event map_event = NULL;
+  host_ptr = clEnqueueMapBuffer(queue, buf, CL_TRUE, CL_MAP_READ, 0, buf_size,
+    1, &no_event, &map_event, &err);
+  TEST_ASSERT(err == CL_INVALID_EVENT_WAIT_LIST);
+  TEST_ASSERT(host_ptr == NULL);
+  TEST_ASSERT(map_event == NULL); /* should not have been touched */
+
+  /* Now do an actual mapping to test the unmapping */
+  host_ptr = clEnqueueMapBuffer(queue, buf, CL_TRUE, CL_MAP_READ, 0, buf_size,
+    0, NULL, NULL, &err);
+  CHECK_OPENCL_ERROR_IN("map buffer");
+
+  err = clEnqueueUnmapMemObject(queue, buf, host_ptr, 1, &no_event, NULL);
+  TEST_ASSERT(err == CL_INVALID_EVENT_WAIT_LIST);
+  err = clEnqueueUnmapMemObject(queue, buf, host_ptr, 1, &no_event, &map_event);
+  TEST_ASSERT(err == CL_INVALID_EVENT_WAIT_LIST);
+  TEST_ASSERT(map_event == NULL); /* should not have been touched */
+
+  /* Actually unmap */
+  err = clEnqueueUnmapMemObject(queue, buf, host_ptr, 0, NULL, NULL);
+  CHECK_OPENCL_ERROR_IN("unmap buffer");
+  host_ptr = NULL;
+
+  /* Test with map_event != NULL but invalid */
+  map_event = (cl_event)1;
+  host_ptr = clEnqueueMapBuffer(queue, buf, CL_TRUE, CL_MAP_READ, 0, buf_size,
+    1, &no_event, &map_event, &err);
+  TEST_ASSERT(err == CL_INVALID_EVENT_WAIT_LIST);
+  TEST_ASSERT(host_ptr == NULL);
+  TEST_ASSERT(map_event == (cl_event)1); /* should not have been touched */
+
+  host_ptr = clEnqueueMapBuffer(queue, buf, CL_TRUE, CL_MAP_READ, 0, buf_size,
+    0, NULL, NULL, &err);
+  CHECK_OPENCL_ERROR_IN("map buffer");
+
+  err = clEnqueueUnmapMemObject(queue, buf, host_ptr, 1, &no_event, &map_event);
+  TEST_ASSERT(err == CL_INVALID_EVENT_WAIT_LIST);
+  TEST_ASSERT(map_event == (cl_event)1); /* should not have been touched */
+
+  err = clEnqueueUnmapMemObject(queue, buf, host_ptr, 0, NULL, NULL);
+  CHECK_OPENCL_ERROR_IN("unmap buffer");
+  host_ptr = NULL;
+
+  /***
+   * Test image commands
+   */
+
+  cl_int color = 0;
+  const size_t origin[] = {0, 0, 0};
+  const size_t region[] = {1, 1, 1};
+
+  /* First, no associated event */
+  err = clEnqueueFillImage(queue, img, &color, origin, region,
+	  1, &no_event, NULL);
+  TEST_ASSERT(err == CL_INVALID_EVENT_WAIT_LIST);
+  err = clEnqueueWriteImage(queue, img, CL_TRUE, origin, region,
+	  0, 0, &color,
+	  1, &no_event, NULL);
+  TEST_ASSERT(err == CL_INVALID_EVENT_WAIT_LIST);
+  err = clEnqueueWriteImage(queue, img, CL_TRUE, origin, region,
+	  0, 0, &color,
+	  1, &no_event, NULL);
+  TEST_ASSERT(err == CL_INVALID_EVENT_WAIT_LIST);
+  err = clEnqueueReadImage(queue, img, CL_TRUE, origin, region,
+	  0, 0, &color,
+	  1, &no_event, NULL);
+  TEST_ASSERT(err == CL_INVALID_EVENT_WAIT_LIST);
+
+  size_t img_pitch = 0;
+  host_ptr = clEnqueueMapImage(queue, img, CL_TRUE, CL_MAP_READ,
+    origin, region, &img_pitch, NULL,
+    1, &no_event, NULL, &err);
+  TEST_ASSERT(err == CL_INVALID_EVENT_WAIT_LIST);
+  TEST_ASSERT(host_ptr == NULL);
+
+  /* No need to test Unmap, it's the same API call as for buffers */
+
+  /* Next, associated event with initial NULL value and with initial
+   * invalid value */
+
+  for (i = 0; i < 2; ++i) {
+    cl_event initial_value = initial_values[i];
+    map_event = initial_value;
+
+    err = clEnqueueFillImage(queue, img, &color, origin, region,
+      1, &no_event, &map_event);
+    TEST_ASSERT(err == CL_INVALID_EVENT_WAIT_LIST);
+    TEST_ASSERT(map_event == initial_value);
+    err = clEnqueueWriteImage(queue, img, CL_TRUE, origin, region,
+      0, 0, &color,
+      1, &no_event, &map_event);
+    TEST_ASSERT(err == CL_INVALID_EVENT_WAIT_LIST);
+    TEST_ASSERT(map_event == initial_value);
+    err = clEnqueueWriteImage(queue, img, CL_TRUE, origin, region,
+      0, 0, &color,
+      1, &no_event, &map_event);
+    TEST_ASSERT(err == CL_INVALID_EVENT_WAIT_LIST);
+    TEST_ASSERT(map_event == initial_value);
+    err = clEnqueueReadImage(queue, img, CL_TRUE, origin, region,
+      0, 0, &color,
+      1, &no_event, &map_event);
+    TEST_ASSERT(err == CL_INVALID_EVENT_WAIT_LIST);
+    TEST_ASSERT(map_event == initial_value);
+    host_ptr = clEnqueueMapImage(queue, img, CL_TRUE, CL_MAP_READ,
+      origin, region, &img_pitch, NULL,
+      1, &no_event, &map_event, &err);
+    TEST_ASSERT(err == CL_INVALID_EVENT_WAIT_LIST);
+    TEST_ASSERT(host_ptr == NULL);
+    TEST_ASSERT(map_event == initial_value);
+
+  }
+
+  err = clEnqueueMarkerWithWaitList(queue, 1, &no_event, NULL);
+  TEST_ASSERT(err == CL_INVALID_EVENT_WAIT_LIST);
+  for (i = 0; i < 2; ++i) {
+    cl_event initial_value = initial_values[i];
+    map_event = initial_value;
+    err = clEnqueueMarkerWithWaitList(queue, 1, &no_event, &map_event);
+    TEST_ASSERT(err == CL_INVALID_EVENT_WAIT_LIST);
+    TEST_ASSERT(map_event == initial_value);
+  }
+
+  return EXIT_SUCCESS;
+
+}
+
+
diff --git a/tests/runtime/test_kernel_cache_includes.c b/tests/runtime/test_kernel_cache_includes.c
new file mode 100644
index 0000000..76b0b27
--- /dev/null
+++ b/tests/runtime/test_kernel_cache_includes.c
@@ -0,0 +1,80 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <CL/opencl.h>
+#include "poclu.h"
+#include "config.h"
+#include "pocl_tests.h"
+
+char first_include[] =
+    "#define PRINT_DEFINE \"This is printf from the first include\\n\"\n"
+    "void test_include() { printf(\"A printf from inside a function 1\\n\"); }\n";
+
+char second_include[] =
+    "#define PRINT_DEFINE \"This is printf from the second include\\n\"\n"
+    "void test_include() { printf(\"A printf from inside a function 2\\n\"); }\n";
+
+
+int main(int argc, char **argv)
+{
+  cl_int err;
+  const char *krn_src;
+  cl_program program, program2;
+  cl_context ctx;
+  cl_command_queue queue;
+  cl_device_id did;
+  cl_kernel kernel, kernel2;
+
+  poclu_get_any_device(&ctx, &did, &queue);
+  TEST_ASSERT(ctx);
+  TEST_ASSERT(did);
+  TEST_ASSERT(queue);
+
+  krn_src = poclu_read_file(SRCDIR "/tests/runtime/test_kernel_cache_includes.cl");
+  TEST_ASSERT(krn_src);
+
+  err = poclu_write_file(BUILDDIR "/tests/runtime/test_include.h", first_include,
+                         sizeof(first_include)-1);
+  TEST_ASSERT(err == 0);
+
+  program = clCreateProgramWithSource(ctx, 1, &krn_src, NULL, &err);
+  CHECK_OPENCL_ERROR_IN("clCreateProgramWithSource");
+
+  err = clBuildProgram(program, 0, NULL, NULL, NULL, NULL);
+  CHECK_OPENCL_ERROR_IN("clBuildProgram 1");
+
+  kernel = clCreateKernel(program, "testk", &err);
+  CHECK_OPENCL_ERROR_IN("clCreateKernel 1");
+
+  size_t off[3] = {0,0,0};
+  size_t ws[3] = {1,1,1};
+
+  err = clEnqueueNDRangeKernel(queue, kernel, 3, off, ws, ws, 0, NULL, 0);
+  CHECK_OPENCL_ERROR_IN("clEnqueueNDRangeKernel 1");
+
+  err = clFinish(queue);
+  CHECK_OPENCL_ERROR_IN("clFinish 1");
+
+  /***************************************/
+
+  program2 = clCreateProgramWithSource(ctx, 1, &krn_src, NULL, &err);
+  CHECK_OPENCL_ERROR_IN("clCreateProgramWithSource 2");
+
+  err = poclu_write_file(BUILDDIR "/tests/runtime/test_include.h", second_include,
+                         sizeof(second_include)-1);
+  TEST_ASSERT(err == 0);
+
+  err = clBuildProgram(program2, 0, NULL, NULL, NULL, NULL);
+  CHECK_OPENCL_ERROR_IN("clBuildProgram 2");
+
+  kernel2 = clCreateKernel(program2, "testk", &err);
+  CHECK_OPENCL_ERROR_IN("clCreateKernel 2");
+
+  err = clEnqueueNDRangeKernel(queue, kernel2, 3, off, ws, ws, 0, NULL, 0);
+  CHECK_OPENCL_ERROR_IN("clEnqueueNDRangeKernel 2");
+
+  err = clFinish(queue);
+  CHECK_OPENCL_ERROR_IN("clFinish 2");
+
+  return 0;
+}
diff --git a/tests/runtime/test_kernel_cache_includes.cl b/tests/runtime/test_kernel_cache_includes.cl
new file mode 100644
index 0000000..e9eca3d
--- /dev/null
+++ b/tests/runtime/test_kernel_cache_includes.cl
@@ -0,0 +1,7 @@
+#include "test_include.h"
+
+__kernel void testk()
+{
+  test_include();
+  printf(PRINT_DEFINE);
+}
diff --git a/tests/runtime/test_kernel_cache_includes_expout.txt b/tests/runtime/test_kernel_cache_includes_expout.txt
new file mode 100644
index 0000000..4c78eeb
--- /dev/null
+++ b/tests/runtime/test_kernel_cache_includes_expout.txt
@@ -0,0 +1,4 @@
+A printf from inside a function 1
+This is printf from the first include
+A printf from inside a function 2
+This is printf from the second include
diff --git a/tests/runtime/test_clBuildProgram.c b/tests/runtime/test_link_error.c
similarity index 63%
copy from tests/runtime/test_clBuildProgram.c
copy to tests/runtime/test_link_error.c
index 100a237..782a1e0 100644
--- a/tests/runtime/test_clBuildProgram.c
+++ b/tests/runtime/test_link_error.c
@@ -1,6 +1,6 @@
-/* Tests clBuildProgram, passing the user options etc.
+/* Test that link errors are caught at clBuildProgram time
 
-   Copyright (c) 2013 Pekka Jääskeläinen and
+   Copyright (c) 2015 Giuseppe Bilotta
                       Kalray
 
    Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -33,14 +33,10 @@
 #define MAX_DEVICES   32
 #define MAX_BINARIES  32
 
-/* A dummy kernel that just includes another kernel. To test the #include and
-   -I */
-char kernel[] = 
-  "#include \"test_kernel_src_in_another_dir.h\"\n"
-  "#include \"test_kernel_src_in_pwd.h\"\n";
-
-char invalid_kernel[] =
-  "kernel void test_kernel(constant int a, j) { return 3; }\n";
+/* A program that fails to link */
+char program_src[] =
+  "void test_func();\n" /* declared but not defined */
+  "kernel void test_kernel(global int *a) { test_func(); }\n";
 
 int
 main(void){
@@ -49,42 +45,25 @@ main(void){
   cl_uint nplatforms;
   cl_device_id devices[MAX_DEVICES + 1]; // + 1 for duplicate test
   cl_uint num_devices;
-  cl_uint i;
   cl_program program = NULL;
-  cl_program program_with_binary = NULL;
   err = clGetPlatformIDs(MAX_PLATFORMS, platforms, &nplatforms);
   CHECK_OPENCL_ERROR_IN("clGetPlatformIDs");
   if (!nplatforms)
     return EXIT_FAILURE;
 
   err = clGetDeviceIDs(platforms[0], CL_DEVICE_TYPE_ALL, MAX_DEVICES,
-		       devices, &num_devices);  
+		       devices, &num_devices);
   CHECK_OPENCL_ERROR_IN("clGetDeviceIDs");
 
   cl_context context = clCreateContext(NULL, num_devices, devices, NULL, NULL, &err);
   CHECK_OPENCL_ERROR_IN("clCreateContext");
 
-  size_t kernel_size = strlen(kernel);
-  char* kernel_buffer = kernel;
-
-  program = clCreateProgramWithSource(context, 1, (const char**)&kernel_buffer, 
-                                     &kernel_size, &err);
-  //clCreateProgramWithSource for the kernel with #include failed
-  CHECK_OPENCL_ERROR_IN("clCreateProgramWithSource");
-
-  err = clBuildProgram(program, num_devices, devices, 
-     "-D__FUNC__=helper_func -I./test_data", NULL, NULL);
-  CHECK_OPENCL_ERROR_IN("clBuildProgram");
-
-  err = clReleaseProgram(program);
-  CHECK_OPENCL_ERROR_IN("clReleaseProgram");
-
-  kernel_size = strlen(invalid_kernel);
-  kernel_buffer = invalid_kernel;
+  size_t program_size = strlen(program_src);
+  char* program_buffer = program_src;
 
-  program = clCreateProgramWithSource(context, 1, (const char**)&kernel_buffer,
-				      &kernel_size, &err);
-  //clCreateProgramWithSource for invalid kernel failed
+  program = clCreateProgramWithSource(context, 1, (const char**)&program_buffer,
+                                     &program_size, &err);
+  //clCreateProgramWithSource for the program with #include failed
   CHECK_OPENCL_ERROR_IN("clCreateProgramWithSource");
 
   err = clBuildProgram(program, num_devices, devices, NULL, NULL, NULL);
diff --git a/tests/runtime/test_read-copy-write-buffer.c b/tests/runtime/test_read-copy-write-buffer.c
new file mode 100644
index 0000000..21b5a6f
--- /dev/null
+++ b/tests/runtime/test_read-copy-write-buffer.c
@@ -0,0 +1,121 @@
+/* Test clEnqueue{Write,Copy,Read}Buffer
+
+   Copyright (C) 2015 Giuseppe Bilotta <giuseppe.bilotta at gmail.com>
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <CL/cl.h>
+
+#define MAX_PLATFORMS 32
+#define MAX_DEVICES   32
+
+int
+main(void)
+{
+  cl_int err;
+  cl_platform_id platforms[MAX_PLATFORMS];
+  cl_uint nplatforms;
+  cl_device_id devices[MAX_DEVICES];
+  cl_uint ndevices;
+  cl_uint i, j;
+
+  err = clGetPlatformIDs(MAX_PLATFORMS, platforms, &nplatforms);
+  if (err != CL_SUCCESS)
+    return EXIT_FAILURE;
+
+  for (i = 0; i < nplatforms; i++)
+  {
+    err = clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, MAX_DEVICES,
+      devices, &ndevices);
+    if (err != CL_SUCCESS)
+      return EXIT_FAILURE;
+
+    /* Only test the devices we actually have room for */
+    if (ndevices > MAX_DEVICES)
+      ndevices = MAX_DEVICES;
+
+    for (j = 0; j < ndevices; j++)
+    {
+      cl_context context = clCreateContext(NULL, 1, &devices[j], NULL, NULL, &err);
+      if (err != CL_SUCCESS)
+        return EXIT_FAILURE;
+      cl_command_queue queue = clCreateCommandQueue(context, devices[j], 0, &err);
+      if (err != CL_SUCCESS)
+        return EXIT_FAILURE;
+
+      cl_ulong alloc;
+#define MAXALLOC (1024U*1024U)
+
+      if (clGetDeviceInfo(devices[j], CL_DEVICE_MAX_MEM_ALLOC_SIZE,
+          sizeof(alloc), &alloc, NULL) != CL_SUCCESS)
+        return EXIT_FAILURE;
+
+      while (alloc > MAXALLOC)
+        alloc /= 2;
+
+      const size_t buf_size = (alloc/sizeof(cl_int))*sizeof(cl_int);
+
+      cl_int *host_buf1 = malloc(buf_size);
+      if (host_buf1 == NULL)
+        return EXIT_FAILURE;
+      cl_int *host_buf2 = malloc(buf_size);
+      if (host_buf2 == NULL)
+        return EXIT_FAILURE;
+
+      memset(host_buf1, 1, buf_size);
+      memset(host_buf2, 2, buf_size);
+
+      cl_mem buf1 = clCreateBuffer(context, CL_MEM_READ_WRITE, buf_size, NULL, &err);
+      if (err != CL_SUCCESS)
+        return EXIT_FAILURE;
+      cl_mem buf2 = clCreateBuffer(context, CL_MEM_READ_WRITE, buf_size, NULL, &err);
+      if (err != CL_SUCCESS)
+        return EXIT_FAILURE;
+
+      if (clEnqueueWriteBuffer(queue, buf1, CL_TRUE, 0, buf_size, host_buf1,
+	  0, NULL, NULL) != CL_SUCCESS)
+        return EXIT_FAILURE;
+
+      if (clEnqueueCopyBuffer(queue, buf1, buf2, 0, 0, buf_size,
+	  0, NULL, NULL) != CL_SUCCESS)
+        return EXIT_FAILURE;
+
+      if (clEnqueueReadBuffer(queue, buf2, CL_TRUE, 0, buf_size, host_buf2,
+	  0, NULL, NULL) != CL_SUCCESS)
+        return EXIT_FAILURE;
+
+      if (clFinish(queue) != CL_SUCCESS)
+        return EXIT_FAILURE;
+
+      if (memcmp(host_buf2, host_buf1, buf_size) != 0)
+        return EXIT_FAILURE;
+
+      free(host_buf2);
+      free(host_buf1);
+      clReleaseMemObject(buf2);
+      clReleaseMemObject(buf1);
+      clReleaseCommandQueue(queue);
+    }
+  }
+  return EXIT_SUCCESS;
+}
diff --git a/tests/tce/Makefile.in b/tests/tce/Makefile.in
index 31bffb3..90efc7c 100644
--- a/tests/tce/Makefile.in
+++ b/tests/tce/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -38,7 +38,17 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -104,7 +114,6 @@ host_triplet = @host@
 target_triplet = @target@
 @TCEMC_AVAILABLE_TRUE at am__append_1 = tcemc
 subdir = tests/tce
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -113,6 +122,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -172,6 +182,7 @@ am__define_uniq_tagged_files = \
 ETAGS = etags
 CTAGS = ctags
 DIST_SUBDIRS = ttasim fp16 tcemc
+am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 am__relativize = \
   dir0=`pwd`; \
@@ -248,6 +259,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -284,6 +298,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -414,7 +429,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/tce/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign tests/tce/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -709,6 +723,8 @@ uninstall-am:
 	mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
 	ps ps-am tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/tests/tce/fp16/Makefile.am b/tests/tce/fp16/Makefile.am
index b7eb2e0..13b7732 100644
--- a/tests/tce/fp16/Makefile.am
+++ b/tests/tce/fp16/Makefile.am
@@ -25,7 +25,7 @@ noinst_PROGRAMS = host
 
 host_SOURCES = host.cpp 
 host_LDADD = ../../../lib/CL/libpocl.la ../../../lib/poclu/libpoclu.la @LD_FLAGS_BIN@
-host_CXXFLAGS = @PTHREAD_CFLAGS@ -Wno-deprecated -Wno-deprecated-declarations
+host_CXXFLAGS = @PTHREAD_CFLAGS@ -std=c++11 -Wno-deprecated -Wno-deprecated-declarations
 
 AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include -I$(top_srcdir)/lib/CL \
 	-DSRCDIR='"$(abs_srcdir)"'
diff --git a/tests/tce/fp16/Makefile.in b/tests/tce/fp16/Makefile.in
index 849e184..1155616 100644
--- a/tests/tce/fp16/Makefile.in
+++ b/tests/tce/fp16/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -38,7 +38,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -104,8 +114,6 @@ host_triplet = @host@
 target_triplet = @target@
 noinst_PROGRAMS = host$(EXEEXT)
 subdir = tests/tce/fp16
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -114,6 +122,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -190,6 +199,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -241,6 +251,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -277,6 +290,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -393,7 +407,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 host_SOURCES = host.cpp 
 host_LDADD = ../../../lib/CL/libpocl.la ../../../lib/poclu/libpoclu.la @LD_FLAGS_BIN@
-host_CXXFLAGS = @PTHREAD_CFLAGS@ -Wno-deprecated -Wno-deprecated-declarations
+host_CXXFLAGS = @PTHREAD_CFLAGS@ -std=c++11 -Wno-deprecated -Wno-deprecated-declarations
 AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include -I$(top_srcdir)/lib/CL \
 	-DSRCDIR='"$(abs_srcdir)"'
 
@@ -413,7 +427,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/tce/fp16/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign tests/tce/fp16/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -697,6 +710,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 all-local: host
 
diff --git a/tests/tce/fp16/host.cpp b/tests/tce/fp16/host.cpp
index fd8196e..76befd9 100644
--- a/tests/tce/fp16/host.cpp
+++ b/tests/tce/fp16/host.cpp
@@ -22,8 +22,10 @@
 */
 
 // Enable OpenCL C++ exceptions
-#define __CL_ENABLE_EXCEPTIONS
-#include <CL/cl.hpp>
+#define CL_HPP_ENABLE_EXCEPTIONS
+#define CL_HPP_MINIMUM_OPENCL_VERSION 120
+#define CL_HPP_TARGET_OPENCL_VERSION 120
+#include <CL/cl2.hpp>
 
 #include <cstdio>
 #include <cstdlib>
@@ -87,7 +89,7 @@ main(void)
         a = poclu_bswap_cl_float (device(), a);
 
         // Create and program from source
-        cl::Program::Sources sources(1, std::make_pair(kernelSourceCode, 0));
+        cl::Program::Sources sources({kernelSourceCode});
         cl::Program program(context, sources);
 
         // Build program
diff --git a/tests/tce/tcemc/Makefile.am b/tests/tce/tcemc/Makefile.am
index 2c4abc9..2a1c957 100644
--- a/tests/tce/tcemc/Makefile.am
+++ b/tests/tce/tcemc/Makefile.am
@@ -25,7 +25,7 @@ noinst_PROGRAMS = host
 
 host_SOURCES = host.cpp 
 host_LDADD = ../../../lib/CL/libpocl.la ../../../lib/poclu/libpoclu.la @LD_FLAGS_BIN@
-host_CXXFLAGS = @PTHREAD_CFLAGS@ -Wno-deprecated -Wno-deprecated-declarations
+host_CXXFLAGS = @PTHREAD_CFLAGS@ -std=c++11 -Wno-deprecated -Wno-deprecated-declarations
 
 AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/lib/CL \
 	-DSRCDIR='"$(abs_srcdir)"'
diff --git a/tests/tce/tcemc/Makefile.in b/tests/tce/tcemc/Makefile.in
index d552fe5..797a4d6 100644
--- a/tests/tce/tcemc/Makefile.in
+++ b/tests/tce/tcemc/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -38,7 +38,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -104,8 +114,6 @@ host_triplet = @host@
 target_triplet = @target@
 noinst_PROGRAMS = host$(EXEEXT)
 subdir = tests/tce/tcemc
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -114,6 +122,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -190,6 +199,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -241,6 +251,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -277,6 +290,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -393,7 +407,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 host_SOURCES = host.cpp 
 host_LDADD = ../../../lib/CL/libpocl.la ../../../lib/poclu/libpoclu.la @LD_FLAGS_BIN@
-host_CXXFLAGS = @PTHREAD_CFLAGS@ -Wno-deprecated -Wno-deprecated-declarations
+host_CXXFLAGS = @PTHREAD_CFLAGS@ -std=c++11 -Wno-deprecated -Wno-deprecated-declarations
 AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/lib/CL \
 	-DSRCDIR='"$(abs_srcdir)"'
 
@@ -413,7 +427,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/tce/tcemc/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign tests/tce/tcemc/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -697,6 +710,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 all-local: host
 
diff --git a/tests/tce/tcemc/host.cpp b/tests/tce/tcemc/host.cpp
index 10eb279..e5c5122 100644
--- a/tests/tce/tcemc/host.cpp
+++ b/tests/tce/tcemc/host.cpp
@@ -22,8 +22,10 @@
 */
 
 // Enable OpenCL C++ exceptions
-#define __CL_ENABLE_EXCEPTIONS
-#include <CL/cl.hpp>
+#define CL_HPP_ENABLE_EXCEPTIONS
+#define CL_HPP_MINIMUM_OPENCL_VERSION 120
+#define CL_HPP_TARGET_OPENCL_VERSION 120
+#include <CL/cl2.hpp>
 
 #include <cstdio>
 #include <cstdlib>
@@ -91,7 +93,7 @@ main(void)
         b = poclu_bswap_cl_int (device(), b);
 
         // Create and program from source
-        cl::Program::Sources sources(1, std::make_pair(kernelSourceCode, 0));
+        cl::Program::Sources sources({kernelSourceCode});
         cl::Program program(context, sources);
 
         // Build program
diff --git a/tests/tce/ttasim/Makefile.am b/tests/tce/ttasim/Makefile.am
index 30d13fe..240ec71 100644
--- a/tests/tce/ttasim/Makefile.am
+++ b/tests/tce/ttasim/Makefile.am
@@ -25,7 +25,7 @@ noinst_PROGRAMS = host
 
 host_SOURCES = host.cpp 
 host_LDADD = @OPENCL_LIBS@ ../../../lib/poclu/libpoclu.la @LD_FLAGS_BIN@
-host_CXXFLAGS = @PTHREAD_CFLAGS@ -Wno-deprecated -Wno-deprecated-declarations
+host_CXXFLAGS = @PTHREAD_CFLAGS@ -std=c++11 -Wno-deprecated -Wno-deprecated-declarations
 
 AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include  -I$(top_srcdir)/lib/CL \
 	-DSRCDIR='"$(abs_srcdir)"'
diff --git a/tests/tce/ttasim/Makefile.in b/tests/tce/ttasim/Makefile.in
index d56d384..ec13ce2 100644
--- a/tests/tce/ttasim/Makefile.in
+++ b/tests/tce/ttasim/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -38,7 +38,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -104,8 +114,6 @@ host_triplet = @host@
 target_triplet = @target@
 noinst_PROGRAMS = host$(EXEEXT)
 subdir = tests/tce/ttasim
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -114,6 +122,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -189,6 +198,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -240,6 +250,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -276,6 +289,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -392,7 +406,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 host_SOURCES = host.cpp 
 host_LDADD = @OPENCL_LIBS@ ../../../lib/poclu/libpoclu.la @LD_FLAGS_BIN@
-host_CXXFLAGS = @PTHREAD_CFLAGS@ -Wno-deprecated -Wno-deprecated-declarations
+host_CXXFLAGS = @PTHREAD_CFLAGS@ -std=c++11 -Wno-deprecated -Wno-deprecated-declarations
 AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include  -I$(top_srcdir)/lib/CL \
 	-DSRCDIR='"$(abs_srcdir)"'
 
@@ -412,7 +426,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/tce/ttasim/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign tests/tce/ttasim/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -696,6 +709,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 all-local: host
 
diff --git a/tests/tce/ttasim/host.cpp b/tests/tce/ttasim/host.cpp
index 916f825..53114bb 100644
--- a/tests/tce/ttasim/host.cpp
+++ b/tests/tce/ttasim/host.cpp
@@ -22,8 +22,10 @@
 */
 
 // Enable OpenCL C++ exceptions
-#define __CL_ENABLE_EXCEPTIONS
-#include <CL/cl.hpp>
+#define CL_HPP_ENABLE_EXCEPTIONS
+#define CL_HPP_MINIMUM_OPENCL_VERSION 120
+#define CL_HPP_TARGET_OPENCL_VERSION 120
+#include <CL/cl2.hpp>
 
 #include <cstdio>
 #include <cstdlib>
@@ -91,7 +93,7 @@ main(void)
         b = poclu_bswap_cl_int (device(), b);
 
         // Create and program from source
-        cl::Program::Sources sources(1, std::make_pair(kernelSourceCode, 0));
+        cl::Program::Sources sources({kernelSourceCode});
         cl::Program program(context, sources);
 
         // Build program
diff --git a/tests/testsuite b/tests/testsuite
index 947928e..78d61f1 100755
--- a/tests/testsuite
+++ b/tests/testsuite
@@ -590,292 +590,363 @@ at_tested=''
 # numerical order.
 at_format='???'
 # Description of all the test groups.
-at_help_all="1;testsuite.at:28;check for pocl version;;
-2;testsuite.at:36;example1: dot product;tce;
-3;testsuite.at:43;example1: dot product (SPIR64);spir;
-4;testsuite.at:53;example1: dot product (SPIR32);spir;
-5;testsuite.at:63;example2: matrix transpose;tce;
-6;testsuite.at:69;example2a: matrix transpose (automatic locals);tce;
-7;testsuite.at:77;Kernel functions convert_char*;short16;
-8;testsuite.at:88;Kernel functions printf;printf;
-9;testsuite.at:98;Kernel functions as_type;conversion;
-10;testsuite.at:108;Kernel functions convert_type - scalars;conversion;
-11;testsuite.at:117;Kernel functions convert_type - vector of 2;conversion;
-12;testsuite.at:126;Kernel functions convert_type - vector of 4;conversion;
-13;testsuite.at:135;Kernel functions convert_type - vector of 8;conversion;
-14;testsuite.at:144;Kernel functions convert_type - vector of 16;conversion;
-15;testsuite.at:155;Kernel functions min and max when the operands are of different sign;min_max;
-16;testsuite.at:166;Kernel functions fmin, fmax, fma;fmin_fmax_fma;
-17;testsuite.at:177;A saturating conversion from long to uint;convert_sat_regression;
-18;testsuite.at:187;Kernel functions abs bitselect clz max min popcount;;
-19;testsuite.at:198;Kernel functions fabs signbit isfinite isinf isnan isnormal copysign ilogb ldexp;;
-20;testsuite.at:211;Kernel functions abs abs_diff add_sat hadd mad_hi mad_sat mul_hi rhadd sub_sat (loopvec);;
-21;testsuite.at:225;Kernel functions abs abs_diff add_sat hadd mad_hi mad_sat mul_hi rhadd sub_sat (loops);;
-22;testsuite.at:234;Kernel functions << >> rotate;rotate;
-23;testsuite.at:252;Trigonometric functions;;
-24;testsuite.at:259;Sampler address clamp;;
-25;testsuite.at:267;Image query functions;;
-26;testsuite.at:275;Kernel functions: shuffle charN;shuffle long;
-27;testsuite.at:283;Kernel functions: shuffle shortN;shuffle long;
-28;testsuite.at:291;Kernel functions: shuffle ushortN;shuffle long;
-29;testsuite.at:299;Kernel functions: shuffle halfN;shuffle long;
-30;testsuite.at:310;Kernel functions: shuffle intN;shuffle long;
-31;testsuite.at:318;Kernel functions: shuffle uintN;shuffle long;
-32;testsuite.at:326;Kernel functions: shuffle floatN;shuffle long;
-33;testsuite.at:334;Kernel functions: shuffle longN;shuffle long;
-34;testsuite.at:342;Kernel functions: shuffle ulongN;shuffle long;
-35;testsuite.at:350;Kernel functions: shuffle doubleN;shuffle long;
-36;testsuite.at:360;Scalar wave equation;scalarwave;
-37;testsuite-workgroup.at:28;unconditional barriers (full replication);workgroup;
-38;testsuite-workgroup.at:35;unconditional barriers (loops);workgroup;
-39;testsuite-workgroup.at:42;unbarriered for loops (full replication);workgroup;
-40;testsuite-workgroup.at:49;unbarriered for loops (loops);workgroup;
-41;testsuite-workgroup.at:56;barriered for loops (full replication);workgroup;
-42;testsuite-workgroup.at:63;barriered for loops (loops);workgroup;
-43;testsuite-workgroup.at:70;conditional barrier (full replication);condbar workgroup;
-44;testsuite-workgroup.at:77;conditional barrier (loops);condbar workgroup;
-45;testsuite-workgroup.at:84;b-loop with none of the WIs reaching the barrier (full replication);b-loop workgroup;
-46;testsuite-workgroup.at:91;b-loop with none of the WIs reaching the barrier (loops);b-loop workgroup;
-47;testsuite-workgroup.at:98;forcing horizontal parallelization to some outer loops (repl);workgroup outerlooppar;
-48;testsuite-workgroup.at:105;forcing horizontal parallelization to some outer loops (loops);workgroup outerlooppar;
-49;testsuite-workgroup.at:112;different implicit barrier injection scenarios (loops);workgroup implicit;
-50;testsuite-workgroup.at:119;loop with two paths to the latch (full replication);twolatchpaths workgroup;
-51;testsuite-workgroup.at:126;loop with two paths to the latch (loops);twolatchpaths workgroup;
-52;testsuite-workgroup.at:133;b-loop with two latches (full replication);twolatches workgroup;
-53;testsuite-workgroup.at:140;b-loop with two latches (loops);twolatches workgroup;
-54;testsuite-workgroup.at:147;workgroup_sizes: work-items get wrong ids (full replication);id workgroup;
-55;testsuite-workgroup.at:155;workgroup_sizes: work-items get wrong ids (loop);id workgroup;
-56;testsuite-regression.at:4;phi nodes not replicated (repl) - lp:927573;regression;
-57;testsuite-regression.at:10;phi nodes not replicated (loops) - lp:927573;regression;
-58;testsuite-regression.at:16;issues with local pointers (repl) - lp:918801;regression locals tce;
-59;testsuite-regression.at:22;issues with local pointers (loops) - lp:918801;regression locals tce;
-60;testsuite-regression.at:28;barrier between two for loops (repl);regression tce;
-61;testsuite-regression.at:34;barrier between two for loops (loops);regression tce;
-62;testsuite-regression.at:40;simple for-loop with a barrier inside (repl);regression;
-63;testsuite-regression.at:46;simple for-loop with a barrier inside (loops);regression;
-64;testsuite-regression.at:52;for-loop with computation after the brexit (repl) - lp:938123;regression tce;
-65;testsuite-regression.at:58;for-loop with computation after the brexit (loops) - lp:938123;regression tce;
-66;testsuite-regression.at:64;for-loop with a variable iteration count (repl) - lp:938883;regression;
-67;testsuite-regression.at:70;for-loop with a variable iteration count (loops) - lp:938883;regression;
-68;testsuite-regression.at:79;early return before a barrier region (repl) - lp:940248;regression early-return tce;
-69;testsuite-regression.at:85;early return before a barrier region (loops) - lp:940248;regression early-return tce;
-70;testsuite-regression.at:92;id-dependent computation before kernel exit (repl) - lp:940549;regression;
-71;testsuite-regression.at:98;id-dependent computation before kernel exit (loops) - lp:940549;regression;
-72;testsuite-regression.at:104;struct kernel arguments - lp:987905;regression struct;
-73;testsuite-regression.at:113;vector kernel arguments - lp:987905;regression vectorarg;
-74;testsuite-regression.at:127;barrier just before return (repl) - lp:1012030;regression struct;
-75;testsuite-regression.at:133;barrier just before return (loops) - lp:1012030;regression struct;
-76;testsuite-regression.at:139;infinite loop (repl) - lp:941558;regression infinite-loop tce;
-77;testsuite-regression.at:146;infinite loop (loops) - lp:941558;regression infinite-loop tce;
-78;testsuite-regression.at:153;passing a constant array as an arg - lp:1032203;regression const-array tce;
-79;testsuite-regression.at:159;undominated variable from conditional barrier handling (repl) - lp:1045835;regression undominated;
-80;testsuite-regression.at:165;undominated variable from conditional barrier handling (loops) - lp:1045835;regression undominated;
-81;testsuite-regression.at:174;clSetKernelArg overwriting the previous kernel's args - lp:1075134;regression setkernelarg;
-82;testsuite-regression.at:180;setting a buffer argument to NULL causes a segfault - lp:1109030;regression nullarg;
-83;testsuite-regression.at:186;sizeof(uint);sizeof;
-84;testsuite-regression.at:193;block;block;
-85;testsuite-regression.at:203;case with multiple variable length loops and a barrier in one;regression varlengthloops;
-86;testsuite-regression.at:209;assigning a loop iterator variable to a private makes it local - issue 94 (repl);regression looppriv;
-87;testsuite-regression.at:218;assigning a loop iterator variable to a private makes it local - issue 94 (loops);regression looppriv;
-88;testsuite-regression.at:227;assigning a loop iterator variable to a private makes it local 2 - issue 102 (repl);regression looppriv;
-89;testsuite-regression.at:236;assigning a loop iterator variable to a private makes it local 2 - issue 102 (loops);regression looppriv;
-90;testsuite-runtime.at:4;clGetDeviceInfo;runtime;
-91;testsuite-runtime.at:9;clEnqueueNativeKernel;runtime;
-92;testsuite-runtime.at:14;clGetEventInfo;runtime;
-93;testsuite-runtime.at:19;clCreateProgramWithBinary;runtime;
-94;testsuite-runtime.at:25;clBuildProgram;runtime;
-95;testsuite-runtime.at:30;clFinish;runtime;
-96;testsuite-runtime.at:36;clSetEventCallback;runtime;
-97;testsuite-runtime.at:43;clGetSupportedImageFormats;runtime;
-98;testsuite-runtime.at:48;clCreateKernelsInProgram;runtime;
-99;testsuite-runtime.at:56;clCreateKernel;runtime;
-100;testsuite-runtime.at:62;clGetKernelArgInfo;runtime;
-101;testsuite-tce.at:4;A basic ttasim driver test;tce tta ttasim;
-102;testsuite-tce.at:12;Half-precision floats on ttasim (repl);tce tta ttasim half;
-103;testsuite-tce.at:37;Half-precision floats on ttasim (loopvec);tce tta ttasim half;
-104;testsuite-tce.at:61;A basic TCEMC test;tce tta ttasim tcemc;
-105;testsuite-samples.at:8;Building the sources against pocl;booksamples buildsamples;
-106;testsuite-samples.at:28;Run Chapter 2: Hello World;booksamples helloworld;
-107;testsuite-samples.at:38;Run Chapter 3: OpenCLConvolution;booksamples;
-108;testsuite-samples.at:52;Run Chapter 6: HelloBinaryWorld;booksamples hellobinaryworld;
-109;testsuite-samples.at:66;Run Chapter 7: SimpleBufferSubBuffer;booksamples simplebuffersubbuffer;
-110;testsuite-samples.at:79;Run Chapter 8: ImageFilter2D;booksamples imagefilter2d;
-111;testsuite-samples.at:102;Run Chapter 12: VectorAdd (C++ bindings);booksamples;
-112;testsuite-viennacl.at:17;fft;viennacl fft;
-113;testsuite-viennacl.at:21;custom-context;viennacl custom-context;
-114;testsuite-viennacl.at:25;custom-kernels;viennacl custom-kernels;
-115;testsuite-viennacl.at:29;scheduler;viennacl scheduler;
-116;testsuite-viennacl.at:39;bandwidth-reduction;viennacl bandwidth-reduction long;
-117;testsuite-viennacl.at:55;blas3_solve_double-test-opencl;viennacl blas3_solve_double-test-opencl long;
-118;testsuite-viennacl.at:71;external_linkage-opencl;viennacl external_linkage-opencl;
-119;testsuite-viennacl.at:92;global_variables-test-opencl;viennacl global_variables-test-opencl;
-120;testsuite-viennacl.at:98;iterators-test-opencl;viennacl iterators-test-opencl;
-121;testsuite-viennacl.at:106;matrix_col_double-test-opencl long;viennacl matrix_col_double-test-opencl long;
-122;testsuite-viennacl.at:112;matrix_col_float-test-opencl long;viennacl matrix_col_float-test-opencl long;
-123;testsuite-viennacl.at:118;matrix_col_int-test-opencl;viennacl matrix_col_int-test-opencl;
-124;testsuite-viennacl.at:126;matrix_row_double-test-opencl long;viennacl matrix_row_double-test-opencl long;
-125;testsuite-viennacl.at:132;matrix_row_float-test-opencl long;viennacl matrix_row_float-test-opencl long;
-126;testsuite-viennacl.at:138;matrix_row_int-test-opencl;viennacl matrix_row_int-test-opencl;
-127;testsuite-viennacl.at:146;matrix_vector_int-test-opencl;viennacl matrix_vector_int-test-opencl;
-128;testsuite-viennacl.at:154;matrix_vector-test-opencl long;viennacl matrix_vector-test-opencl long;
-129;testsuite-viennacl.at:158;nmf-test-opencl;viennacl nmf-test-opencl;
-130;testsuite-viennacl.at:166;scalar-test-opencl;viennacl scalar-test-opencl;
-131;testsuite-viennacl.at:170;structured-matrices-test-opencl;viennacl structured-matrices-test-opencl;
-132;testsuite-viennacl.at:178;vector_double-test-opencl;viennacl vector_double-test-opencl;
-133;testsuite-rodinia.at:19;backprop;rodinia backprop long;
-134;testsuite-rodinia.at:31;bfs;rodinia bfs;
-135;testsuite-rodinia.at:42;cfd;rodinia cfd long;
-136;testsuite-rodinia.at:54;lud;rodinia lud;
-137;testsuite-rodinia.at:61;hotspot;rodinia hotspot long;
-138;testsuite-rodinia.at:69;kmeans;rodinia kmeans;
-139;testsuite-rodinia.at:78;lavaMD;rodinia lavamd;
-140;testsuite-rodinia.at:91;pathfinder;rodinia pathfinder;
-141;testsuite-rodinia.at:102;srad;rodinia srad;
-142;testsuite-parboil.at:17;spmv;parboil spmv;
-143;testsuite-parboil.at:26;stencil;parboil stencil;
-144;testsuite-parboil.at:33;tpacf;parboil tpacf;
-145;testsuite-parboil.at:44;cutcp;parboil cutcp;
-146;testsuite-parboil.at:51;mri-gridding;parboil mri-gridding long;
-147;testsuite-parboil.at:63;sad;parboil sad;
-148;testsuite-parboil.at:72;bfs;parboil bfs bfs-parboil long;
-149;testsuite-parboil.at:84;histo;parboil histo;
-150;testsuite-parboil.at:93;sgemm;parboil sgemm;
-151;testsuite-parboil.at:100;mri-q;parboil mri-q;
-152;testsuite-parboil.at:107;lbm;parboil lbm long;
-153;testsuite-amd.at:11;aesencryptdecrypt-repl;amdsdk aesencryptdecrypt-repl long;
-154;testsuite-amd.at:19;aesencryptdecrypt-loops;amdsdk aesencryptdecrypt-loops;
-155;testsuite-amd.at:25;atomiccounters;amdsdk atomiccounters;
-156;testsuite-amd.at:33;bitonicsort;amdsdk bitonicsort;
-157;testsuite-amd.at:39;binarysearch;amdsdk binarysearch;
-158;testsuite-amd.at:45;binomialoption-repl;amdsdk binomialoption-repl long;
-159;testsuite-amd.at:53;binomialoption-loops;amdsdk binomialoption-loops;
-160;testsuite-amd.at:59;blackscholes;amdsdk blackscholes;
-161;testsuite-amd.at:65;blackscholesdp;amdsdk blackscholesdp cl_amd_fp64;
-162;testsuite-amd.at:78;boxfilter;amdsdk boxfilter;
-163;testsuite-amd.at:85;dct;amdsdk dct;
-164;testsuite-amd.at:93;devicefission;amdsdk devicefission;
-165;testsuite-amd.at:99;dwthaar1d;amdsdk dwthaar1d;
-166;testsuite-amd.at:108;fastwalshtransform;amdsdk fastwalshtransform;
-167;testsuite-amd.at:114;floydwarshall;amdsdk floydwarshall;
-168;testsuite-amd.at:120;fluidsimulation2d;amdsdk fluidsimulation2d cl_amd_fp64;
-169;testsuite-amd.at:131;helloworld;amdsdk helloworld;
-170;testsuite-amd.at:138;histogram-repl;amdsdk histogram-repl long;
-171;testsuite-amd.at:144;histogram-loops;amdsdk histogram-loops;
-172;testsuite-amd.at:150;imageoverlap;amdsdk imageoverlap;
-173;testsuite-amd.at:158;ludecomposition;amdsdk ludecomposition cl_amd_fp64;
-174;testsuite-amd.at:170;mandelbrot;amdsdk mandelbrot;
-175;testsuite-amd.at:178;matrixmul;amdsdk matrixmul;
-176;testsuite-amd.at:186;matrixmulimage;amdsdk matrixmulimage;
-177;testsuite-amd.at:192;matrixtranspose;amdsdk matrixtranspose;
-178;testsuite-amd.at:198;memorymodel-repl;amdsdk memorymodel-repl long;
-179;testsuite-amd.at:204;memorymodel-loops;amdsdk memorymodel-loops;
-180;testsuite-amd.at:210;montecarloasian;amdsdk montecarloasian;
-181;testsuite-amd.at:222;montecarloasiandp;amdsdk montecarloasiandp cl_amd_fp64;
-182;testsuite-amd.at:232;nbody;amdsdk nbody;
-183;testsuite-amd.at:239;prefixsum;amdsdk prefixsum;
-184;testsuite-amd.at:245;quasirandomsequence;amdsdk quasirandomsequence;
-185;testsuite-amd.at:251;radixsort;amdsdk radixsort;
-186;testsuite-amd.at:257;recursivegaussian;amdsdk recursivegaussian;
-187;testsuite-amd.at:263;reduction;amdsdk reduction;
-188;testsuite-amd.at:269;scanlargearrays;amdsdk scanlargearrays;
-189;testsuite-amd.at:276;simpleconvolution;amdsdk simpleconvolution;
-190;testsuite-amd.at:282;simpleimage;amdsdk simpleimage;
-191;testsuite-amd.at:289;sobelfilter;amdsdk sobelfilter;
-192;testsuite-amd.at:295;template;amdsdk template;
-193;testsuite-amd.at:301;templatec;amdsdk templatec;
-194;testsuite-amd.at:307;transferoverlap;amdsdk transferoverlap;
-195;testsuite-amd.at:315;urng;amdsdk urng;
-196;testsuite-amdsdk2_9.at:11;asyncdatatransfer;amdsdk2.9 amdsdk long asyncdatatransfer;
-197;testsuite-amdsdk2_9.at:20;atomiccounters;amdsdk2.9 amdsdk long atomiccounters;
-198;testsuite-amdsdk2_9.at:28;basicdebug;amdsdk2.9 amdsdk long basicdebug;
-199;testsuite-amdsdk2_9.at:40;binarysearch;amdsdk2.9 amdsdk long binarysearch;
-200;testsuite-amdsdk2_9.at:46;binomialoption-repl;amdsdk2.9 amdsdk long binomialoption-repl;
-201;testsuite-amdsdk2_9.at:54;binomialoption-loops;amdsdk2.9 amdsdk long binomialoption-loops;
-202;testsuite-amdsdk2_9.at:60;binomialoptionmultigpu;amdsdk2.9 amdsdk long binomialoptionmultigpu;
-203;testsuite-amdsdk2_9.at:67;bitonicsort;amdsdk2.9 amdsdk long bitonicsort;
-204;testsuite-amdsdk2_9.at:73;blackscholes;amdsdk2.9 amdsdk long blackscholes;
-205;testsuite-amdsdk2_9.at:79;blackscholesdp;amdsdk2.9 amdsdk long blackscholesdp cl_amd_fp64;
-206;testsuite-amdsdk2_9.at:90;boxfilter;amdsdk2.9 amdsdk long boxfilter;
-207;testsuite-amdsdk2_9.at:97;boxfilterGL;amdsdk2.9 amdsdk long boxfiltergl;
-208;testsuite-amdsdk2_9.at:106;bufferbandwidth;amdsdk2.9 amdsdk long bufferbandwidth;
-209;testsuite-amdsdk2_9.at:116;bufferImageInterop;amdsdk2.9 amdsdk long bufferimageinterop;
-210;testsuite-amdsdk2_9.at:125;concurrentkernel;amdsdk2.9 amdsdk long concurrentkernel;
-211;testsuite-amdsdk2_9.at:132;constantbandwidth;amdsdk2.9 amdsdk long constantbandwidth;
-212;testsuite-amdsdk2_9.at:141;cpluspluswrapper;amdsdk2.9 amdsdk long cpluspluswrapper;
-213;testsuite-amdsdk2_9.at:147;dct;amdsdk2.9 amdsdk long dct;
-214;testsuite-amdsdk2_9.at:153;devicefission;amdsdk2.9 amdsdk long devicefission;
-215;testsuite-amdsdk2_9.at:159;devicefission11ext;amdsdk2.9 amdsdk long devicefission11ext;
-216;testsuite-amdsdk2_9.at:167;dwthaar1d;amdsdk2.9 amdsdk long dwthaar1d;
-217;testsuite-amdsdk2_9.at:176;dwthaar1dcppkernel;amdsdk2.9 amdsdk long dwthaar1dcppkernel;
-218;testsuite-amdsdk2_9.at:184;eigenvalue;amdsdk2.9 amdsdk long eigenvalue;
-219;testsuite-amdsdk2_9.at:192;fastwalshtransform;amdsdk2.9 amdsdk long fastwalshtransform;
-220;testsuite-amdsdk2_9.at:198;floydwarshall;amdsdk2.9 amdsdk long floydwarshall;
-221;testsuite-amdsdk2_9.at:204;fft;amdsdk2.9 amdsdk long fft;
-222;testsuite-amdsdk2_9.at:212;fluidsimulation2d;amdsdk2.9 amdsdk long fluidsimulation2d cl_amd_fp64;
-223;testsuite-amdsdk2_9.at:223;gaussiannoise;amdsdk2.9 amdsdk long gaussiannoise;
-224;testsuite-amdsdk2_9.at:229;gaussiannoisegl;amdsdk2.9 amdsdk long gaussiannoisegl;
-225;testsuite-amdsdk2_9.at:244;hdrtonemapping;amdsdk2.9 amdsdk long hdrtonemapping;
-226;testsuite-amdsdk2_9.at:250;helloworld;amdsdk2.9 amdsdk long helloworld;
-227;testsuite-amdsdk2_9.at:257;histogram-repl;amdsdk2.9 amdsdk long histogram-repl;
-228;testsuite-amdsdk2_9.at:263;histogram-loops;amdsdk2.9 amdsdk long histogram-loops;
-229;testsuite-amdsdk2_9.at:269;histogramatomic;amdsdk2.9 amdsdk long histogramatomic;
-230;testsuite-amdsdk2_9.at:275;imagebandwidth;amdsdk2.9 amdsdk long imagebandwidth;
-231;testsuite-amdsdk2_9.at:283;imageoverlap;amdsdk2.9 amdsdk long imageoverlap;
-232;testsuite-amdsdk2_9.at:289;introstatickcppkernel;amdsdk2.9 amdsdk long introstatickcppkernel;
-233;testsuite-amdsdk2_9.at:297;kernellauch;amdsdk2.9 amdsdk long kernellauch;
-234;testsuite-amdsdk2_9.at:305;kmeansautoclustering;amdsdk2.9 amdsdk long kmeansautoclustering;
-235;testsuite-amdsdk2_9.at:314;ldsbandwidth;amdsdk2.9 amdsdk long ldsbandwidth;
-236;testsuite-amdsdk2_9.at:322;ludecomposition;amdsdk2.9 amdsdk long ludecomposition cl_amd_fp64;
-237;testsuite-amdsdk2_9.at:332;mandelbrot;amdsdk2.9 amdsdk long mandelbrot;
-238;testsuite-amdsdk2_9.at:341;matrixmuldouble;amdsdk2.9 amdsdk long matrixmuldouble;
-239;testsuite-amdsdk2_9.at:347;matrixmulimage;amdsdk2.9 amdsdk long matrixmulimage;
-240;testsuite-amdsdk2_9.at:353;matrixmultiplication;amdsdk2.9 amdsdk long matrixmultiplication;
-241;testsuite-amdsdk2_9.at:361;matrixtranspose;amdsdk2.9 amdsdk long matrixtranspose;
-242;testsuite-amdsdk2_9.at:367;memorymodel-repl;amdsdk2.9 amdsdk long memorymodel-repl;
-243;testsuite-amdsdk2_9.at:373;memorymodel-loops;amdsdk2.9 amdsdk long memorymodel-loops;
-244;testsuite-amdsdk2_9.at:379;memoryoptimizations;amdsdk2.9 amdsdk long memoryoptimizations;
-245;testsuite-amdsdk2_9.at:409;merzennetwister;amdsdk2.9 amdsdk long merzennetwister;
-246;testsuite-amdsdk2_9.at:417;montecarloasian;amdsdk2.9 amdsdk long montecarloasian;
-247;testsuite-amdsdk2_9.at:427;montecarloasiandp;amdsdk2.9 amdsdk long montecarloasiandp cl_amd_fp64;
-248;testsuite-amdsdk2_9.at:437;montecarloasianmultigpu;amdsdk2.9 amdsdk long montecarloasianmultigpu;
-249;testsuite-amdsdk2_9.at:447;nbody;amdsdk2.9 amdsdk long nbody;
-250;testsuite-amdsdk2_9.at:455;prefixsum;amdsdk2.9 amdsdk long prefixsum;
-251;testsuite-amdsdk2_9.at:461;quasirandomsequence;amdsdk2.9 amdsdk long quasirandomsequence;
-252;testsuite-amdsdk2_9.at:467;radixsort;amdsdk2.9 amdsdk long radixsort;
-253;testsuite-amdsdk2_9.at:473;recursivegaussian;amdsdk2.9 amdsdk long recursivegaussian;
-254;testsuite-amdsdk2_9.at:479;reduction;amdsdk2.9 amdsdk long reduction;
-255;testsuite-amdsdk2_9.at:485;scanlargearrays;amdsdk2.9 amdsdk long scanlargearrays;
-256;testsuite-amdsdk2_9.at:492;simpleconvolution;amdsdk2.9 amdsdk long simpleconvolution;
-257;testsuite-amdsdk2_9.at:498;simplegl;amdsdk2.9 amdsdk long simplegl;
-258;testsuite-amdsdk2_9.at:506;simpleimage;amdsdk2.9 amdsdk long simpleimage;
-259;testsuite-amdsdk2_9.at:513;soaversusaos;amdsdk2.9 amdsdk long soaversusaos;
-260;testsuite-amdsdk2_9.at:522;sobelfilter;amdsdk2.9 amdsdk long sobelfilter;
-261;testsuite-amdsdk2_9.at:528;sobelfilterimage;amdsdk2.9 amdsdk long sobelfilterimage;
-262;testsuite-amdsdk2_9.at:536;stringsearch;amdsdk2.9 amdsdk long stringsearch;
-263;testsuite-amdsdk2_9.at:543;template;amdsdk2.9 amdsdk long template;
-264;testsuite-amdsdk2_9.at:549;transferoverlap;amdsdk2.9 amdsdk long transferoverlap;
-265;testsuite-amdsdk2_9.at:555;transferoverlapcpp;amdsdk2.9 amdsdk long transferoverlapcpp;
-266;testsuite-amdsdk2_9.at:563;unsharpmask;amdsdk2.9 amdsdk long unsharpmask;
-267;testsuite-amdsdk2_9.at:571;urng;amdsdk2.9 amdsdk long urng;
-268;testsuite-amdsdk2_9.at:577;urngnoisegl;amdsdk2.9 amdsdk long urngnoisegl;
-269;testsuite-vexcl.at:10;fft;vexcl fft;
-270;testsuite-vexcl.at:19;generator;vexcl generator;
-271;testsuite-vexcl.at:25;multiple_objects;vexcl multiple_objects;
-272;testsuite-vexcl.at:31;multivector_arithmetics;vexcl multivector_arithmetics;
-273;testsuite-vexcl.at:37;multivector_create;vexcl multivector_create;
-274;testsuite-vexcl.at:43;random;vexcl random;
-275;testsuite-vexcl.at:49;spmv;vexcl spmv;
-276;testsuite-vexcl.at:55;stencil;vexcl stencil;
-277;testsuite-vexcl.at:63;vector_arithmetics;vexcl vector_arithmetics;
-278;testsuite-vexcl.at:69;vector_copy;vexcl vector_copy;
-279;testsuite-vexcl.at:75;vector_create;vexcl vector_create;
-280;testsuite-halide.at:11;tutorial12;halide tutorial12;
-281;testsuite-halide.at:21;bilateral_grid;halide bilateral_grid;
-282;testsuite-halide.at:26;interpolate;halide interpolate;
-283;testsuite-halide.at:31;local_laplacian;halide local_laplacian;
-284;testsuite-cloverleaf.at:11;cloverleaf;cloverleaf;
-285;testsuite-piglit.at:3;Piglit testsuite with LLVM 3.4;piglit long;
-286;testsuite-piglit.at:12;Piglit testsuite with LLVM 3.5;piglit long;
+at_help_all="1;testsuite.at:29;check for pocl version;;
+2;testsuite.at:37;example1: dot product;tce hsa;
+3;testsuite.at:44;example1: dot product (SPIR64);spir;
+4;testsuite.at:54;example1: dot product (SPIR32);spir;
+5;testsuite.at:64;example2: matrix transpose;tce hsa;
+6;testsuite.at:70;example2a: matrix transpose (automatic locals);tce hsa;
+7;testsuite.at:78;Kernel functions convert_char*;short16;
+8;testsuite.at:89;Kernel functions printf;printf;
+9;testsuite.at:99;Kernel functions as_type;conversion;
+10;testsuite.at:109;Kernel functions convert_type - scalars;conversion;
+11;testsuite.at:118;Kernel functions convert_type - vector of 2;conversion;
+12;testsuite.at:127;Kernel functions convert_type - vector of 4;conversion;
+13;testsuite.at:136;Kernel functions convert_type - vector of 8;conversion;
+14;testsuite.at:145;Kernel functions convert_type - vector of 16;conversion;
+15;testsuite.at:156;Kernel functions min and max when the operands are of different sign;min_max;
+16;testsuite.at:167;Kernel functions length, distance, and normalize;length_distance;
+17;testsuite.at:177;Kernel functions fmin, fmax, fma;fmin_fmax_fma;
+18;testsuite.at:187;Kernel functions frexp modf;frexp_modf;
+19;testsuite.at:200;A saturating conversion from long to uint;convert_sat_regression;
+20;testsuite.at:210;Kernel functions abs bitselect clz max min popcount;;
+21;testsuite.at:221;Kernel functions fabs signbit isfinite isinf isnan isnormal copysign ilogb ldexp;;
+22;testsuite.at:234;Kernel functions abs abs_diff add_sat hadd mad_hi mad_sat mul_hi rhadd sub_sat (loopvec);;
+23;testsuite.at:248;Kernel functions abs abs_diff add_sat hadd mad_hi mad_sat mul_hi rhadd sub_sat (loops);;
+24;testsuite.at:257;Kernel functions << >> rotate;rotate;
+25;testsuite.at:275;Trigonometric functions;;
+26;testsuite.at:282;Sampler address clamp;;
+27;testsuite.at:290;Image query functions;;
+28;testsuite.at:298;Kernel functions: shuffle charN;shuffle long;
+29;testsuite.at:306;Kernel functions: shuffle shortN;shuffle long;
+30;testsuite.at:314;Kernel functions: shuffle ushortN;shuffle long;
+31;testsuite.at:322;Kernel functions: shuffle halfN;shuffle long;
+32;testsuite.at:333;Kernel functions: shuffle intN;shuffle long;
+33;testsuite.at:341;Kernel functions: shuffle uintN;shuffle long;
+34;testsuite.at:349;Kernel functions: shuffle floatN;shuffle long;
+35;testsuite.at:357;Kernel functions: shuffle longN;shuffle long;
+36;testsuite.at:365;Kernel functions: shuffle ulongN;shuffle long;
+37;testsuite.at:373;Kernel functions: shuffle doubleN;shuffle long;
+38;testsuite.at:383;Scalar wave equation;scalarwave;
+39;testsuite-workgroup.at:28;unconditional barriers (full replication);workgroup;
+40;testsuite-workgroup.at:35;unconditional barriers (loops);workgroup;
+41;testsuite-workgroup.at:42;unbarriered for loops (full replication);workgroup;
+42;testsuite-workgroup.at:49;unbarriered for loops (loops);workgroup;
+43;testsuite-workgroup.at:56;barriered for loops (full replication);workgroup;
+44;testsuite-workgroup.at:63;barriered for loops (loops);workgroup;
+45;testsuite-workgroup.at:70;conditional barrier (full replication);condbar workgroup;
+46;testsuite-workgroup.at:77;conditional barrier (loops);condbar workgroup;
+47;testsuite-workgroup.at:84;b-loop with none of the WIs reaching the barrier (full replication);b-loop workgroup;
+48;testsuite-workgroup.at:91;b-loop with none of the WIs reaching the barrier (loops);b-loop workgroup;
+49;testsuite-workgroup.at:98;forcing horizontal parallelization to some outer loops (repl);workgroup outerlooppar;
+50;testsuite-workgroup.at:105;forcing horizontal parallelization to some outer loops (loops);workgroup outerlooppar;
+51;testsuite-workgroup.at:112;different implicit barrier injection scenarios (loops);workgroup implicit;
+52;testsuite-workgroup.at:119;loop with two paths to the latch (full replication);twolatchpaths workgroup;
+53;testsuite-workgroup.at:126;loop with two paths to the latch (loops);twolatchpaths workgroup;
+54;testsuite-workgroup.at:133;b-loop with two latches (full replication);twolatches workgroup;
+55;testsuite-workgroup.at:140;b-loop with two latches (loops);twolatches workgroup;
+56;testsuite-workgroup.at:147;workgroup_sizes: work-items get wrong ids (full replication);id workgroup;
+57;testsuite-workgroup.at:155;workgroup_sizes: work-items get wrong ids (loop);id workgroup;
+58;testsuite-regression.at:4;phi nodes not replicated (repl) - lp:927573;regression;
+59;testsuite-regression.at:10;phi nodes not replicated (loops) - lp:927573;regression;
+60;testsuite-regression.at:16;issues with local pointers (repl) - lp:918801;regression locals tce;
+61;testsuite-regression.at:22;issues with local pointers (loops) - lp:918801;regression locals tce;
+62;testsuite-regression.at:28;barrier between two for loops (repl);regression tce;
+63;testsuite-regression.at:34;barrier between two for loops (loops);regression tce;
+64;testsuite-regression.at:40;simple for-loop with a barrier inside (repl);regression;
+65;testsuite-regression.at:46;simple for-loop with a barrier inside (loops);regression;
+66;testsuite-regression.at:52;for-loop with computation after the brexit (repl) - lp:938123;regression tce;
+67;testsuite-regression.at:58;for-loop with computation after the brexit (loops) - lp:938123;regression tce;
+68;testsuite-regression.at:64;for-loop with a variable iteration count (repl) - lp:938883;regression;
+69;testsuite-regression.at:70;for-loop with a variable iteration count (loops) - lp:938883;regression;
+70;testsuite-regression.at:79;early return before a barrier region (repl) - lp:940248;regression early-return tce;
+71;testsuite-regression.at:85;early return before a barrier region (loops) - lp:940248;regression early-return tce;
+72;testsuite-regression.at:92;id-dependent computation before kernel exit (repl) - lp:940549;regression;
+73;testsuite-regression.at:98;id-dependent computation before kernel exit (loops) - lp:940549;regression;
+74;testsuite-regression.at:104;struct kernel arguments - lp:987905;regression struct;
+75;testsuite-regression.at:113;vector kernel arguments - lp:987905;regression vectorarg;
+76;testsuite-regression.at:127;barrier just before return (repl) - lp:1012030;regression struct;
+77;testsuite-regression.at:133;barrier just before return (loops) - lp:1012030;regression struct;
+78;testsuite-regression.at:139;infinite loop (repl) - lp:941558;regression infinite-loop tce;
+79;testsuite-regression.at:146;infinite loop (loops) - lp:941558;regression infinite-loop tce;
+80;testsuite-regression.at:153;passing a constant array as an arg - lp:1032203;regression const-array tce;
+81;testsuite-regression.at:159;undominated variable from conditional barrier handling (repl) - lp:1045835;regression undominated;
+82;testsuite-regression.at:165;undominated variable from conditional barrier handling (loops) - lp:1045835;regression undominated;
+83;testsuite-regression.at:174;clSetKernelArg overwriting the previous kernel's args - lp:1075134;regression setkernelarg;
+84;testsuite-regression.at:180;setting a buffer argument to NULL causes a segfault - lp:1109030;regression nullarg;
+85;testsuite-regression.at:186;sizeof(uint);sizeof;
+86;testsuite-regression.at:193;block;block;
+87;testsuite-regression.at:203;case with multiple variable length loops and a barrier in one;regression varlengthloops;
+88;testsuite-regression.at:209;assigning a loop iterator variable to a private makes it local - issue 94 (repl);regression looppriv;
+89;testsuite-regression.at:218;assigning a loop iterator variable to a private makes it local - issue 94 (loops);regression looppriv;
+90;testsuite-regression.at:227;assigning a loop iterator variable to a private makes it local 2 - issue 102 (repl);regression looppriv;
+91;testsuite-regression.at:236;assigning a loop iterator variable to a private makes it local 2 - issue 102 (loops);regression looppriv;
+92;testsuite-regression.at:247;local struct arrays produce illegal AS casts;regression local_struct_array;
+93;testsuite-regression.at:263;LoopVectorizer crash with Haswell and Broadwell - issue 231;regression issue_231;
+94;testsuite-runtime.at:4;clGetDeviceInfo;runtime;
+95;testsuite-runtime.at:9;clEnqueueNativeKernel;runtime;
+96;testsuite-runtime.at:14;clGetEventInfo;runtime;
+97;testsuite-runtime.at:19;read/copy/write buffer;runtime;
+98;testsuite-runtime.at:24;event cycle;runtime;
+99;testsuite-runtime.at:29;event freeing;runtime;
+100;testsuite-runtime.at:34;clCreateProgramWithBinary;runtime;
+101;testsuite-runtime.at:40;clBuildProgram;runtime;
+102;testsuite-runtime.at:46;test_kernel_cache_includes;runtime;
+103;testsuite-runtime.at:53;clBuildProgram link error;runtime;
+104;testsuite-runtime.at:60;clFinish;runtime;
+105;testsuite-runtime.at:66;clSetEventCallback;runtime;
+106;testsuite-runtime.at:73;clGetSupportedImageFormats;runtime;
+107;testsuite-runtime.at:78;clCreateKernelsInProgram;runtime;
+108;testsuite-runtime.at:86;clCreateKernel;runtime;
+109;testsuite-runtime.at:92;clGetKernelArgInfo;runtime;
+110;testsuite-runtime.at:98;clCreateSubDevices;runtime;
+111;testsuite-tce.at:4;A basic ttasim driver test;tce tta ttasim;
+112;testsuite-tce.at:12;Half-precision floats on ttasim (repl);tce tta ttasim half;
+113;testsuite-tce.at:37;Half-precision floats on ttasim (loopvec);tce tta ttasim half;
+114;testsuite-tce.at:61;A basic TCEMC test;tce tta ttasim tcemc;
+115;testsuite-samples.at:8;Building the sources against pocl;booksamples buildsamples;
+116;testsuite-samples.at:28;Run Chapter 2: Hello World;booksamples helloworld;
+117;testsuite-samples.at:38;Run Chapter 3: OpenCLConvolution;booksamples;
+118;testsuite-samples.at:52;Run Chapter 6: HelloBinaryWorld;booksamples hellobinaryworld;
+119;testsuite-samples.at:66;Run Chapter 7: SimpleBufferSubBuffer;booksamples simplebuffersubbuffer;
+120;testsuite-samples.at:79;Run Chapter 8: ImageFilter2D;booksamples imagefilter2d;
+121;testsuite-samples.at:102;Run Chapter 12: VectorAdd (C++ bindings);booksamples;
+122;testsuite-viennacl.at:17;fft;viennacl fft;
+123;testsuite-viennacl.at:21;custom-context;viennacl custom-context;
+124;testsuite-viennacl.at:25;custom-kernels;viennacl custom-kernels;
+125;testsuite-viennacl.at:29;scheduler;viennacl scheduler;
+126;testsuite-viennacl.at:39;bandwidth-reduction;viennacl bandwidth-reduction long;
+127;testsuite-viennacl.at:55;blas3_solve_double-test-opencl;viennacl blas3_solve_double-test-opencl long;
+128;testsuite-viennacl.at:71;external_linkage-opencl;viennacl external_linkage-opencl;
+129;testsuite-viennacl.at:92;global_variables-test-opencl;viennacl global_variables-test-opencl;
+130;testsuite-viennacl.at:96;iterators-test-opencl;viennacl iterators-test-opencl;
+131;testsuite-viennacl.at:104;matrix_col_double-test-opencl long;viennacl matrix_col_double-test-opencl long;
+132;testsuite-viennacl.at:110;matrix_col_float-test-opencl long;viennacl matrix_col_float-test-opencl long;
+133;testsuite-viennacl.at:116;matrix_col_int-test-opencl;viennacl matrix_col_int-test-opencl;
+134;testsuite-viennacl.at:124;matrix_row_double-test-opencl long;viennacl matrix_row_double-test-opencl long;
+135;testsuite-viennacl.at:130;matrix_row_float-test-opencl long;viennacl matrix_row_float-test-opencl long;
+136;testsuite-viennacl.at:136;matrix_row_int-test-opencl;viennacl matrix_row_int-test-opencl;
+137;testsuite-viennacl.at:144;matrix_vector_int-test-opencl;viennacl matrix_vector_int-test-opencl;
+138;testsuite-viennacl.at:152;matrix_vector-test-opencl long;viennacl matrix_vector-test-opencl long;
+139;testsuite-viennacl.at:156;nmf-test-opencl;viennacl nmf-test-opencl;
+140;testsuite-viennacl.at:164;scalar-test-opencl;viennacl scalar-test-opencl;
+141;testsuite-viennacl.at:168;structured-matrices-test-opencl;viennacl structured-matrices-test-opencl;
+142;testsuite-viennacl.at:176;vector_double-test-opencl;viennacl vector_double-test-opencl;
+143;testsuite-rodinia.at:19;backprop;rodinia backprop long;
+144;testsuite-rodinia.at:31;bfs;rodinia bfs;
+145;testsuite-rodinia.at:42;cfd;rodinia cfd long;
+146;testsuite-rodinia.at:54;lud;rodinia lud;
+147;testsuite-rodinia.at:61;hotspot;rodinia hotspot long;
+148;testsuite-rodinia.at:69;kmeans;rodinia kmeans;
+149;testsuite-rodinia.at:78;lavaMD;rodinia lavamd;
+150;testsuite-rodinia.at:91;pathfinder;rodinia pathfinder;
+151;testsuite-rodinia.at:102;srad;rodinia srad;
+152;testsuite-parboil.at:17;spmv;parboil spmv;
+153;testsuite-parboil.at:26;stencil;parboil stencil;
+154;testsuite-parboil.at:33;tpacf;parboil tpacf;
+155;testsuite-parboil.at:44;cutcp;parboil cutcp;
+156;testsuite-parboil.at:51;mri-gridding;parboil mri-gridding long;
+157;testsuite-parboil.at:63;sad;parboil sad;
+158;testsuite-parboil.at:72;bfs;parboil bfs bfs-parboil long;
+159;testsuite-parboil.at:84;histo;parboil histo;
+160;testsuite-parboil.at:93;sgemm;parboil sgemm;
+161;testsuite-parboil.at:100;mri-q;parboil mri-q;
+162;testsuite-parboil.at:107;lbm;parboil lbm long;
+163;testsuite-amd.at:11;aesencryptdecrypt-repl;amdsdk aesencryptdecrypt-repl long;
+164;testsuite-amd.at:19;aesencryptdecrypt-loops;amdsdk aesencryptdecrypt-loops;
+165;testsuite-amd.at:25;atomiccounters;amdsdk atomiccounters;
+166;testsuite-amd.at:33;bitonicsort;amdsdk bitonicsort;
+167;testsuite-amd.at:39;binarysearch;amdsdk binarysearch;
+168;testsuite-amd.at:45;binomialoption-repl;amdsdk binomialoption-repl long;
+169;testsuite-amd.at:53;binomialoption-loops;amdsdk binomialoption-loops;
+170;testsuite-amd.at:59;blackscholes;amdsdk blackscholes;
+171;testsuite-amd.at:65;blackscholesdp;amdsdk blackscholesdp cl_amd_fp64;
+172;testsuite-amd.at:78;boxfilter;amdsdk boxfilter;
+173;testsuite-amd.at:85;dct;amdsdk dct;
+174;testsuite-amd.at:93;devicefission;amdsdk devicefission;
+175;testsuite-amd.at:99;dwthaar1d;amdsdk dwthaar1d;
+176;testsuite-amd.at:108;fastwalshtransform;amdsdk fastwalshtransform;
+177;testsuite-amd.at:114;floydwarshall;amdsdk floydwarshall;
+178;testsuite-amd.at:120;fluidsimulation2d;amdsdk fluidsimulation2d cl_amd_fp64;
+179;testsuite-amd.at:131;helloworld;amdsdk helloworld;
+180;testsuite-amd.at:138;histogram-repl;amdsdk histogram-repl long;
+181;testsuite-amd.at:144;histogram-loops;amdsdk histogram-loops;
+182;testsuite-amd.at:150;imageoverlap;amdsdk imageoverlap;
+183;testsuite-amd.at:158;ludecomposition;amdsdk ludecomposition cl_amd_fp64;
+184;testsuite-amd.at:170;mandelbrot;amdsdk mandelbrot;
+185;testsuite-amd.at:178;matrixmul;amdsdk matrixmul;
+186;testsuite-amd.at:186;matrixmulimage;amdsdk matrixmulimage;
+187;testsuite-amd.at:192;matrixtranspose;amdsdk matrixtranspose;
+188;testsuite-amd.at:198;memorymodel-repl;amdsdk memorymodel-repl long;
+189;testsuite-amd.at:204;memorymodel-loops;amdsdk memorymodel-loops;
+190;testsuite-amd.at:210;montecarloasian;amdsdk montecarloasian;
+191;testsuite-amd.at:216;montecarloasiandp;amdsdk montecarloasiandp cl_amd_fp64;
+192;testsuite-amd.at:226;nbody;amdsdk nbody;
+193;testsuite-amd.at:233;prefixsum;amdsdk prefixsum;
+194;testsuite-amd.at:239;quasirandomsequence;amdsdk quasirandomsequence;
+195;testsuite-amd.at:245;radixsort;amdsdk radixsort;
+196;testsuite-amd.at:251;recursivegaussian;amdsdk recursivegaussian;
+197;testsuite-amd.at:257;reduction;amdsdk reduction;
+198;testsuite-amd.at:263;scanlargearrays;amdsdk scanlargearrays;
+199;testsuite-amd.at:270;simpleconvolution;amdsdk simpleconvolution;
+200;testsuite-amd.at:276;simpleimage;amdsdk simpleimage;
+201;testsuite-amd.at:283;sobelfilter;amdsdk sobelfilter;
+202;testsuite-amd.at:289;template;amdsdk template;
+203;testsuite-amd.at:295;templatec;amdsdk templatec;
+204;testsuite-amd.at:301;transferoverlap;amdsdk transferoverlap;
+205;testsuite-amd.at:307;urng;amdsdk urng;
+206;testsuite-amdsdk2_9.at:20;asyncdatatransfer;amdsdk2.9 amdsdk long asyncdatatransfer;
+207;testsuite-amdsdk2_9.at:29;atomiccounters;amdsdk2.9 amdsdk long atomiccounters;
+208;testsuite-amdsdk2_9.at:37;basicdebug;amdsdk2.9 amdsdk long basicdebug;
+209;testsuite-amdsdk2_9.at:49;binarysearch;hsa amdsdk2.9 amdsdk long binarysearch;
+210;testsuite-amdsdk2_9.at:55;binomialoption-repl;amdsdk2.9 amdsdk long binomialoption-repl;
+211;testsuite-amdsdk2_9.at:63;binomialoption-loops;hsa amdsdk2.9 amdsdk long binomialoption-loops;
+212;testsuite-amdsdk2_9.at:69;binomialoptionmultigpu;amdsdk2.9 amdsdk long binomialoptionmultigpu;
+213;testsuite-amdsdk2_9.at:76;bitonicsort;hsa amdsdk2.9 amdsdk long bitonicsort;
+214;testsuite-amdsdk2_9.at:82;blackscholes;hsa amdsdk2.9 amdsdk long blackscholes;
+215;testsuite-amdsdk2_9.at:88;blackscholesdp;amdsdk2.9 amdsdk long blackscholesdp cl_amd_fp64;
+216;testsuite-amdsdk2_9.at:99;boxfilter;amdsdk2.9 amdsdk long boxfilter;
+217;testsuite-amdsdk2_9.at:106;boxfilterGL;amdsdk2.9 amdsdk long boxfiltergl;
+218;testsuite-amdsdk2_9.at:115;bufferbandwidth;amdsdk2.9 amdsdk long bufferbandwidth;
+219;testsuite-amdsdk2_9.at:125;bufferImageInterop;amdsdk2.9 amdsdk long bufferimageinterop;
+220;testsuite-amdsdk2_9.at:134;concurrentkernel;amdsdk2.9 amdsdk long concurrentkernel;
+221;testsuite-amdsdk2_9.at:141;constantbandwidth;amdsdk2.9 amdsdk long constantbandwidth;
+222;testsuite-amdsdk2_9.at:150;cpluspluswrapper;amdsdk2.9 amdsdk long cpluspluswrapper;
+223;testsuite-amdsdk2_9.at:156;dct;hsa amdsdk2.9 amdsdk long dct;
+224;testsuite-amdsdk2_9.at:162;devicefission;amdsdk2.9 amdsdk long devicefission;
+225;testsuite-amdsdk2_9.at:168;devicefission11ext;amdsdk2.9 amdsdk long devicefission11ext;
+226;testsuite-amdsdk2_9.at:176;dwthaar1d;amdsdk2.9 amdsdk long dwthaar1d;
+227;testsuite-amdsdk2_9.at:185;dwthaar1dcppkernel;amdsdk2.9 amdsdk long dwthaar1dcppkernel;
+228;testsuite-amdsdk2_9.at:193;eigenvalue;amdsdk2.9 amdsdk long eigenvalue;
+229;testsuite-amdsdk2_9.at:201;fastwalshtransform;hsa amdsdk2.9 amdsdk long fastwalshtransform;
+230;testsuite-amdsdk2_9.at:207;floydwarshall;hsa amdsdk2.9 amdsdk long floydwarshall;
+231;testsuite-amdsdk2_9.at:213;fft;amdsdk2.9 amdsdk long fft;
+232;testsuite-amdsdk2_9.at:221;fluidsimulation2d;amdsdk2.9 amdsdk long fluidsimulation2d cl_amd_fp64;
+233;testsuite-amdsdk2_9.at:232;gaussiannoise;amdsdk2.9 amdsdk long gaussiannoise;
+234;testsuite-amdsdk2_9.at:238;gaussiannoisegl;amdsdk2.9 amdsdk long gaussiannoisegl;
+235;testsuite-amdsdk2_9.at:253;hdrtonemapping;amdsdk2.9 amdsdk long hdrtonemapping;
+236;testsuite-amdsdk2_9.at:259;helloworld;hsa amdsdk2.9 amdsdk long helloworld;
+237;testsuite-amdsdk2_9.at:266;histogram-repl;amdsdk2.9 amdsdk long histogram-repl;
+238;testsuite-amdsdk2_9.at:272;histogram-loops;hsa amdsdk2.9 amdsdk long histogram-loops;
+239;testsuite-amdsdk2_9.at:278;histogramatomic;amdsdk2.9 amdsdk long histogramatomic;
+240;testsuite-amdsdk2_9.at:284;imagebandwidth;amdsdk2.9 amdsdk long imagebandwidth;
+241;testsuite-amdsdk2_9.at:292;imageoverlap;amdsdk2.9 amdsdk long imageoverlap;
+242;testsuite-amdsdk2_9.at:298;introstatickcppkernel;amdsdk2.9 amdsdk long introstatickcppkernel;
+243;testsuite-amdsdk2_9.at:306;kernellauch;amdsdk2.9 amdsdk long kernellauch;
+244;testsuite-amdsdk2_9.at:314;kmeansautoclustering;amdsdk2.9 amdsdk long kmeansautoclustering;
+245;testsuite-amdsdk2_9.at:323;ldsbandwidth;amdsdk2.9 amdsdk long ldsbandwidth;
+246;testsuite-amdsdk2_9.at:331;ludecomposition;amdsdk2.9 amdsdk long ludecomposition cl_amd_fp64;
+247;testsuite-amdsdk2_9.at:341;mandelbrot;amdsdk2.9 amdsdk long mandelbrot;
+248;testsuite-amdsdk2_9.at:350;matrixmuldouble;amdsdk2.9 amdsdk long matrixmuldouble;
+249;testsuite-amdsdk2_9.at:356;matrixmulimage;amdsdk2.9 amdsdk long matrixmulimage;
+250;testsuite-amdsdk2_9.at:362;matrixmultiplication;hsa amdsdk2.9 amdsdk long matrixmultiplication;
+251;testsuite-amdsdk2_9.at:370;matrixtranspose;hsa amdsdk2.9 amdsdk long matrixtranspose;
+252;testsuite-amdsdk2_9.at:376;memorymodel-repl;amdsdk2.9 amdsdk long memorymodel-repl;
+253;testsuite-amdsdk2_9.at:382;memorymodel-loops;amdsdk2.9 amdsdk long memorymodel-loops;
+254;testsuite-amdsdk2_9.at:388;memoryoptimizations;amdsdk2.9 amdsdk long memoryoptimizations;
+255;testsuite-amdsdk2_9.at:418;merzennetwister;amdsdk2.9 amdsdk long merzennetwister;
+256;testsuite-amdsdk2_9.at:426;montecarloasian;amdsdk2.9 amdsdk long montecarloasian;
+257;testsuite-amdsdk2_9.at:436;montecarloasiandp;amdsdk2.9 amdsdk long montecarloasiandp cl_amd_fp64;
+258;testsuite-amdsdk2_9.at:446;montecarloasianmultigpu;amdsdk2.9 amdsdk long montecarloasianmultigpu;
+259;testsuite-amdsdk2_9.at:452;nbody;amdsdk2.9 amdsdk long nbody;
+260;testsuite-amdsdk2_9.at:460;prefixsum;hsa amdsdk2.9 amdsdk long prefixsum;
+261;testsuite-amdsdk2_9.at:466;quasirandomsequence;hsa amdsdk2.9 amdsdk long quasirandomsequence;
+262;testsuite-amdsdk2_9.at:472;radixsort;amdsdk2.9 amdsdk long radixsort;
+263;testsuite-amdsdk2_9.at:478;recursivegaussian;amdsdk2.9 amdsdk long recursivegaussian;
+264;testsuite-amdsdk2_9.at:484;reduction;amdsdk2.9 amdsdk long reduction;
+265;testsuite-amdsdk2_9.at:490;scanlargearrays;hsa amdsdk2.9 amdsdk long scanlargearrays;
+266;testsuite-amdsdk2_9.at:497;simpleconvolution;hsa amdsdk2.9 amdsdk long simpleconvolution;
+267;testsuite-amdsdk2_9.at:503;simplegl;amdsdk2.9 amdsdk long simplegl;
+268;testsuite-amdsdk2_9.at:511;simpleimage;amdsdk2.9 amdsdk long simpleimage;
+269;testsuite-amdsdk2_9.at:518;soaversusaos;amdsdk2.9 amdsdk long soaversusaos;
+270;testsuite-amdsdk2_9.at:527;sobelfilter;hsa amdsdk2.9 amdsdk long sobelfilter;
+271;testsuite-amdsdk2_9.at:533;sobelfilterimage;amdsdk2.9 amdsdk long sobelfilterimage;
+272;testsuite-amdsdk2_9.at:541;stringsearch;amdsdk2.9 amdsdk long stringsearch;
+273;testsuite-amdsdk2_9.at:548;template;amdsdk2.9 amdsdk long template;
+274;testsuite-amdsdk2_9.at:554;transferoverlap;amdsdk2.9 amdsdk long transferoverlap;
+275;testsuite-amdsdk2_9.at:560;transferoverlapcpp;amdsdk2.9 amdsdk long transferoverlapcpp;
+276;testsuite-amdsdk2_9.at:568;unsharpmask;amdsdk2.9 amdsdk long unsharpmask;
+277;testsuite-amdsdk2_9.at:576;urng;hsa amdsdk2.9 amdsdk long urng;
+278;testsuite-amdsdk2_9.at:582;urngnoisegl;amdsdk2.9 amdsdk long urngnoisegl;
+279;testsuite-vexcl.at:10;fft;vexcl fft;
+280;testsuite-vexcl.at:19;generator;vexcl generator;
+281;testsuite-vexcl.at:25;multiple_objects;vexcl multiple_objects;
+282;testsuite-vexcl.at:31;multivector_arithmetics;vexcl multivector_arithmetics;
+283;testsuite-vexcl.at:37;multivector_create;vexcl multivector_create;
+284;testsuite-vexcl.at:43;random;vexcl random;
+285;testsuite-vexcl.at:49;spmv;vexcl spmv;
+286;testsuite-vexcl.at:55;stencil;vexcl stencil;
+287;testsuite-vexcl.at:63;vector_arithmetics;vexcl vector_arithmetics;
+288;testsuite-vexcl.at:69;vector_copy;vexcl vector_copy;
+289;testsuite-vexcl.at:75;vector_create;vexcl vector_create;
+290;testsuite-halide.at:11;tutorial12;halide tutorial12;
+291;testsuite-halide.at:21;bilateral_grid;halide bilateral_grid;
+292;testsuite-halide.at:26;interpolate;halide interpolate;
+293;testsuite-halide.at:31;local_laplacian;halide local_laplacian;
+294;testsuite-cloverleaf.at:11;cloverleaf;cloverleaf;
+295;testsuite-piglit.at:3;Piglit testsuite with LLVM 3.5;piglit long;
+296;testsuite-opencv.at:9;UMat;opencv umat;
+297;testsuite-opencv.at:14;Core_UMat;opencv core_umat;
+298;testsuite-opencv.at:19;Image2D;opencv image2d;
+299;testsuite-opencv.at:24;UMatBasicTests;opencv umatbasictests;
+300;testsuite-opencv.at:29;UMatTestReshape;opencv umattestreshape;
+301;testsuite-opencv.at:34;UMatTestRoi;opencv umattestroi;
+302;testsuite-opencv.at:39;UMatTestSizeOperations;opencv umattestsizeoperations;
+303;testsuite-opencv.at:44;UMatTestUMatOperations;opencv umattestumatoperations;
+304;testsuite-opencv.at:51;OCL_Channels/Merge;opencv ocl_channels/merge;
+305;testsuite-opencv.at:56;OCL_Channels/Split;opencv ocl_channels/split;
+306;testsuite-opencv.at:61;OCL_Channels/MixChannels;opencv ocl_channels/mixchannels;
+307;testsuite-opencv.at:66;OCL_Channels/InsertChannel;opencv ocl_channels/insertchannel;
+308;testsuite-opencv.at:71;OCL_Channels/ExtractChannel;opencv ocl_channels/extractchannel;
+309;testsuite-opencv.at:78;Lut;opencv lut;
+310;testsuite-opencv.at:83;Add;opencv add;
+311;testsuite-opencv.at:88;Subtract;opencv subtract;
+312;testsuite-opencv.at:93;Mul;opencv mul;
+313;testsuite-opencv.at:98;Div;opencv div;
+314;testsuite-opencv.at:103;Min;opencv min;
+315;testsuite-opencv.at:108;Max;opencv max;
+316;testsuite-opencv.at:113;AddWeighted;opencv addweighted;
+317;testsuite-opencv.at:118;Absdiff;opencv absdiff;
+318;testsuite-opencv.at:123;CartToPolar;opencv carttopolar;
+319;testsuite-opencv.at:128;PolarToCart;opencv polartocart;
+320;testsuite-opencv.at:133;Transpose;opencv transpose;
+321;testsuite-opencv.at:138;Bitwise_and;opencv bitwise_and;
+322;testsuite-opencv.at:143;Bitwise_or;opencv bitwise_or;
+323;testsuite-opencv.at:148;Bitwise_xor;opencv bitwise_xor;
+324;testsuite-opencv.at:153;Bitwise_not;opencv bitwise_not;
+325;testsuite-opencv.at:158;Compare;opencv compare;
+326;testsuite-opencv.at:163;Pow;opencv pow;
+327;testsuite-opencv.at:168;SetIdentity;opencv setidentity;
+328;testsuite-opencv.at:173;Repeat;opencv repeat;
+329;testsuite-opencv.at:178;CountNonZero;opencv countnonzero;
+330;testsuite-opencv.at:183;Sum;opencv sum;
+331;testsuite-opencv.at:188;MeanStdDev;opencv meanstddev;
+332;testsuite-opencv.at:193;Log;opencv log;
+333;testsuite-opencv.at:198;Exp;opencv exp;
+334;testsuite-opencv.at:203;Phase;opencv phase;
+335;testsuite-opencv.at:208;Magnitude;opencv magnitude;
+336;testsuite-opencv.at:213;Flip;opencv flip;
+337;testsuite-opencv.at:218;MinMaxIdx;opencv minmaxidx;
+338;testsuite-opencv.at:223;MinMaxIdx_Mask;opencv minmaxidx_mask;
+339;testsuite-opencv.at:228;Norm;opencv norm;
+340;testsuite-opencv.at:233;UMatDot;opencv umatdot;
+341;testsuite-opencv.at:238;Sqrt;opencv sqrt;
+342;testsuite-opencv.at:243;Normalize;opencv normalize;
+343;testsuite-opencv.at:248;InRange;opencv inrange;
+344;testsuite-opencv.at:253;ConvertScaleAbs;opencv convertscaleabs;
+345;testsuite-opencv.at:258;ScaleAdd;opencv scaleadd;
+346;testsuite-opencv.at:263;PatchNaNs;opencv patchnans;
+347;testsuite-opencv.at:268;Psnr;opencv psnr;
+348;testsuite-opencv.at:273;ReduceSum;opencv reducesum;
+349;testsuite-opencv.at:278;ReduceMax;opencv reducemax;
+350;testsuite-opencv.at:283;ReduceAvg;opencv reduceavg;
+351;testsuite-opencv.at:290;Gemm;opencv gemm;
+352;testsuite-opencv.at:295;Dft;opencv dft;
+353;testsuite-opencv.at:302;MultiSpectrums;opencv multispectrums;
+354;testsuite-opencv.at:309;ConvertTo;opencv convertto;
+355;testsuite-opencv.at:314;CopyTo;opencv copyto;
+356;testsuite-opencv.at:319;SetTo;opencv setto;
+357;testsuite-opencv.at:324;UMatExpr;opencv umatexpr;
 "
 # List of the all the test groups.
 at_groups_all=`$as_echo "$at_help_all" | sed 's/;.*//'`
@@ -889,7 +960,7 @@ at_fn_validate_ranges ()
   for at_grp
   do
     eval at_value=\$$at_grp
-    if test $at_value -lt 1 || test $at_value -gt 286; then
+    if test $at_value -lt 1 || test $at_value -gt 357; then
       $as_echo "invalid test group: $at_value" >&2
       exit 1
     fi
@@ -1187,7 +1258,7 @@ fi
 # List of tests.
 if $at_list_p; then
   cat <<_ATEOF || at_write_fail=1
-pocl 0.11 test suite test groups:
+pocl 0.12 test suite test groups:
 
  NUM: FILE-NAME:LINE     TEST-GROUP-NAME
       KEYWORDS
@@ -1228,7 +1299,7 @@ _ATEOF
   exit $at_write_fail
 fi
 if $at_version_p; then
-  $as_echo "$as_me (pocl 0.11)" &&
+  $as_echo "$as_me (pocl 0.12)" &&
   cat <<\_ATEOF || at_write_fail=1
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1245,57 +1316,72 @@ case $at_groups in #(
   * ) at_print_banners=false ;;
 esac
 # Text for banner N, set to a single space once printed.
-# Banner 1. testsuite.at:34
+# Banner 1. testsuite.at:35
 # Category starts at test group 2.
 at_banner_text_1="OpenCL specification tests"
-# Banner 2. testsuite.at:75
+# Banner 2. testsuite.at:76
 # Category starts at test group 7.
 at_banner_text_2="Kernel runtime library"
-# Banner 3. testsuite.at:358
-# Category starts at test group 36.
+# Banner 3. testsuite.at:381
+# Category starts at test group 38.
 at_banner_text_3="Full applications"
 # Banner 4. testsuite-workgroup.at:26
-# Category starts at test group 37.
+# Category starts at test group 39.
 at_banner_text_4="Workgroup creation tests"
 # Banner 5. testsuite-regression.at:2
-# Category starts at test group 56.
+# Category starts at test group 58.
 at_banner_text_5="Regression tests"
 # Banner 6. testsuite-runtime.at:2
-# Category starts at test group 90.
+# Category starts at test group 94.
 at_banner_text_6="Runtime library tests"
 # Banner 7. testsuite-tce.at:2
-# Category starts at test group 101.
+# Category starts at test group 111.
 at_banner_text_7="TCE tests"
 # Banner 8. testsuite-samples.at:6
-# Category starts at test group 105.
+# Category starts at test group 115.
 at_banner_text_8="OpenCL Programming Guide Samples"
 # Banner 9. testsuite-viennacl.at:15
-# Category starts at test group 112.
+# Category starts at test group 122.
 at_banner_text_9="ViennaCL 1.5.1 tests"
 # Banner 10. testsuite-rodinia.at:17
-# Category starts at test group 133.
+# Category starts at test group 143.
 at_banner_text_10="Rodinia 2.0.1 tests"
 # Banner 11. testsuite-parboil.at:15
-# Category starts at test group 142.
+# Category starts at test group 152.
 at_banner_text_11="Parboil tests"
 # Banner 12. testsuite-amd.at:9
-# Category starts at test group 153.
+# Category starts at test group 163.
 at_banner_text_12="AMD APP SDK tests"
-# Banner 13. testsuite-amdsdk2_9.at:9
-# Category starts at test group 196.
+# Banner 13. testsuite-amdsdk2_9.at:18
+# Category starts at test group 206.
 at_banner_text_13="AMD APP SDK 2.9 tests"
 # Banner 14. testsuite-vexcl.at:8
-# Category starts at test group 269.
+# Category starts at test group 279.
 at_banner_text_14="VexCL tests"
 # Banner 15. testsuite-halide.at:9
-# Category starts at test group 280.
+# Category starts at test group 290.
 at_banner_text_15="Halide OpenCL examples"
 # Banner 16. testsuite-cloverleaf.at:9
-# Category starts at test group 284.
+# Category starts at test group 294.
 at_banner_text_16="CloverLeaf"
 # Banner 17. testsuite-piglit.at:1
-# Category starts at test group 285.
+# Category starts at test group 295.
 at_banner_text_17="Piglit OpenCL tests"
+# Banner 18. testsuite-opencv.at:7
+# Category starts at test group 296.
+at_banner_text_18="OpenCV UMat tests"
+# Banner 19. testsuite-opencv.at:49
+# Category starts at test group 304.
+at_banner_text_19="OpenCV Channels test"
+# Banner 20. testsuite-opencv.at:76
+# Category starts at test group 309.
+at_banner_text_20="OpenCV Arithm tests"
+# Banner 21. testsuite-opencv.at:300
+# Category starts at test group 353.
+at_banner_text_21="OpenCV ImgProc test"
+# Banner 22. testsuite-opencv.at:307
+# Category starts at test group 354.
+at_banner_text_22="OpenCV MatrixOperation tests"
 
 # Take any -C into account.
 if $at_change_dir ; then
@@ -1456,11 +1542,11 @@ exec 5>>"$at_suite_log"
 
 # Banners and logs.
 $as_echo "## --------------------- ##
-## pocl 0.11 test suite. ##
+## pocl 0.12 test suite. ##
 ## --------------------- ##"
 {
   $as_echo "## --------------------- ##
-## pocl 0.11 test suite. ##
+## pocl 0.12 test suite. ##
 ## --------------------- ##"
   echo
 
@@ -1705,7 +1791,7 @@ IFS=$as_save_IFS
   esac
   if test -f "$at_program_"; then
     {
-      $as_echo "$at_srcdir/testsuite.at:25: $at_program_ --version"
+      $as_echo "$at_srcdir/testsuite.at:26: $at_program_ --version"
       "$at_program_" --version </dev/null
       echo
     } >&5 2>&1
@@ -2304,7 +2390,7 @@ _ASBOX
   $as_echo "Please send $at_msg and all information you think might help:
 
    To: <pocl-devel at lists.sourceforge.net>
-   Subject: [pocl 0.11] $as_me: $at_fail_list${at_fail_list:+ failed${at_xpass_list:+, }}$at_xpass_list${at_xpass_list:+ passed unexpectedly}
+   Subject: [pocl 0.12] $as_me: $at_fail_list${at_fail_list:+ failed${at_xpass_list:+, }}$at_xpass_list${at_xpass_list:+ passed unexpectedly}
 
 You may investigate any problem if you feel able to do so, in which
 case the test suite provides a good starting point.  Its output may
@@ -2319,7 +2405,7 @@ exit 0
 ## Actual tests. ##
 ## ------------- ##
 #AT_START_1
-at_fn_group_banner 1 'testsuite.at:28' \
+at_fn_group_banner 1 'testsuite.at:29' \
   "check for pocl version" "                         "
 at_xfail=no
 (
@@ -2327,8 +2413,8 @@ at_xfail=no
   $at_traceon
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:29: POCL_DEVICES=basic \$abs_top_builddir/tests/runtime/test_version"
-at_fn_check_prepare_dynamic "POCL_DEVICES=basic $abs_top_builddir/tests/runtime/test_version" "testsuite.at:29"
+$as_echo "$at_srcdir/testsuite.at:30: POCL_DEVICES=basic \$abs_top_builddir/tests/runtime/test_version"
+at_fn_check_prepare_dynamic "POCL_DEVICES=basic $abs_top_builddir/tests/runtime/test_version" "testsuite.at:30"
 ( $at_check_trace; POCL_DEVICES=basic $abs_top_builddir/tests/runtime/test_version
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -2337,7 +2423,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "basic
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:29"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:30"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -2347,7 +2433,7 @@ $at_traceon; }
 read at_status <"$at_status_file"
 #AT_STOP_1
 #AT_START_2
-at_fn_group_banner 2 'testsuite.at:36' \
+at_fn_group_banner 2 'testsuite.at:37' \
   "example1: dot product" "                          " 1
 at_xfail=no
 (
@@ -2356,8 +2442,8 @@ at_xfail=no
 
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:38: \$abs_top_builddir/examples/example1/example1"
-at_fn_check_prepare_dynamic "$abs_top_builddir/examples/example1/example1" "testsuite.at:38"
+$as_echo "$at_srcdir/testsuite.at:39: \$abs_top_builddir/examples/example1/example1"
+at_fn_check_prepare_dynamic "$abs_top_builddir/examples/example1/example1" "testsuite.at:39"
 ( $at_check_trace; $abs_top_builddir/examples/example1/example1
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -2366,7 +2452,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "$(cat $abs_top_srcdir/tests/example_expout.txt)
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:38"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:39"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -2376,7 +2462,7 @@ $at_traceon; }
 read at_status <"$at_status_file"
 #AT_STOP_2
 #AT_START_3
-at_fn_group_banner 3 'testsuite.at:43' \
+at_fn_group_banner 3 'testsuite.at:44' \
   "example1: dot product (SPIR64)" "                 " 1
 at_xfail=no
 (
@@ -2385,13 +2471,13 @@ at_xfail=no
 
 # This SPIR example works because it does not use local memory nor
 # call builtins that are mangled with address spaces.
-$as_echo "testsuite.at:46" >"$at_check_line_file"
+$as_echo "testsuite.at:47" >"$at_check_line_file"
 (! grep "#define POCL_DEVICE_ADDRESS_BITS 64" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite.at:46"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite.at:47"
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:48: \$abs_top_builddir/examples/example1-spir64/example1-spir"
-at_fn_check_prepare_dynamic "$abs_top_builddir/examples/example1-spir64/example1-spir" "testsuite.at:48"
+$as_echo "$at_srcdir/testsuite.at:49: \$abs_top_builddir/examples/example1-spir64/example1-spir"
+at_fn_check_prepare_dynamic "$abs_top_builddir/examples/example1-spir64/example1-spir" "testsuite.at:49"
 ( $at_check_trace; $abs_top_builddir/examples/example1-spir64/example1-spir
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -2400,7 +2486,7 @@ echo stderr:; cat "$at_stderr"
 echo >>"$at_stdout"; $as_echo "$(cat $abs_top_srcdir/tests/example_expout.txt)
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:48"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:49"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -2410,7 +2496,7 @@ $at_traceon; }
 read at_status <"$at_status_file"
 #AT_STOP_3
 #AT_START_4
-at_fn_group_banner 4 'testsuite.at:53' \
+at_fn_group_banner 4 'testsuite.at:54' \
   "example1: dot product (SPIR32)" "                 " 1
 at_xfail=no
 (
@@ -2419,13 +2505,13 @@ at_xfail=no
 
 # This SPIR example works because it does not use local memory nor
 # call builtins that are mangled with address spaces.
-$as_echo "testsuite.at:56" >"$at_check_line_file"
+$as_echo "testsuite.at:57" >"$at_check_line_file"
 (! grep "#define POCL_DEVICE_ADDRESS_BITS 32" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite.at:56"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite.at:57"
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:58: \$abs_top_builddir/examples/example1-spir32/example1-spir32"
-at_fn_check_prepare_dynamic "$abs_top_builddir/examples/example1-spir32/example1-spir32" "testsuite.at:58"
+$as_echo "$at_srcdir/testsuite.at:59: \$abs_top_builddir/examples/example1-spir32/example1-spir32"
+at_fn_check_prepare_dynamic "$abs_top_builddir/examples/example1-spir32/example1-spir32" "testsuite.at:59"
 ( $at_check_trace; $abs_top_builddir/examples/example1-spir32/example1-spir32
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -2434,7 +2520,7 @@ echo stderr:; cat "$at_stderr"
 echo >>"$at_stdout"; $as_echo "$(cat $abs_top_srcdir/tests/example_expout.txt)
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:58"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:59"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -2444,7 +2530,7 @@ $at_traceon; }
 read at_status <"$at_status_file"
 #AT_STOP_4
 #AT_START_5
-at_fn_group_banner 5 'testsuite.at:63' \
+at_fn_group_banner 5 'testsuite.at:64' \
   "example2: matrix transpose" "                     " 1
 at_xfail=no
 (
@@ -2453,8 +2539,8 @@ at_xfail=no
 
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:65: \$abs_top_builddir/examples/example2/example2"
-at_fn_check_prepare_dynamic "$abs_top_builddir/examples/example2/example2" "testsuite.at:65"
+$as_echo "$at_srcdir/testsuite.at:66: \$abs_top_builddir/examples/example2/example2"
+at_fn_check_prepare_dynamic "$abs_top_builddir/examples/example2/example2" "testsuite.at:66"
 ( $at_check_trace; $abs_top_builddir/examples/example2/example2
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -2463,7 +2549,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "OK
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:65"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:66"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -2473,7 +2559,7 @@ $at_traceon; }
 read at_status <"$at_status_file"
 #AT_STOP_5
 #AT_START_6
-at_fn_group_banner 6 'testsuite.at:69' \
+at_fn_group_banner 6 'testsuite.at:70' \
   "example2a: matrix transpose (automatic locals)" " " 1
 at_xfail=no
 (
@@ -2482,8 +2568,8 @@ at_xfail=no
 
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:71: \$abs_top_builddir/examples/example2a/example2a"
-at_fn_check_prepare_dynamic "$abs_top_builddir/examples/example2a/example2a" "testsuite.at:71"
+$as_echo "$at_srcdir/testsuite.at:72: \$abs_top_builddir/examples/example2a/example2a"
+at_fn_check_prepare_dynamic "$abs_top_builddir/examples/example2a/example2a" "testsuite.at:72"
 ( $at_check_trace; $abs_top_builddir/examples/example2a/example2a
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -2492,7 +2578,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "OK
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:71"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:72"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -2502,7 +2588,7 @@ $at_traceon; }
 read at_status <"$at_status_file"
 #AT_STOP_6
 #AT_START_7
-at_fn_group_banner 7 'testsuite.at:77' \
+at_fn_group_banner 7 'testsuite.at:78' \
   "Kernel functions convert_char*" "                 " 2
 at_xfail=no
       grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc &&
@@ -2519,15 +2605,15 @@ OK
 _ATEOF
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:85: \$abs_top_builddir/tests/kernel/kernel test_short16"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_short16" "testsuite.at:85"
+$as_echo "$at_srcdir/testsuite.at:86: \$abs_top_builddir/tests/kernel/kernel test_short16"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_short16" "testsuite.at:86"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/kernel test_short16
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:85"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:86"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -2537,7 +2623,7 @@ $at_traceon; }
 read at_status <"$at_status_file"
 #AT_STOP_7
 #AT_START_8
-at_fn_group_banner 8 'testsuite.at:88' \
+at_fn_group_banner 8 'testsuite.at:89' \
   "Kernel functions printf" "                        " 2
 at_xfail=no
       grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q i686 && at_xfail=yes
@@ -2551,8 +2637,8 @@ at_xfail=no
 
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:93: \$abs_top_builddir/tests/kernel/kernel test_printf"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_printf" "testsuite.at:93"
+$as_echo "$at_srcdir/testsuite.at:94: \$abs_top_builddir/tests/kernel/kernel test_printf"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_printf" "testsuite.at:94"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/kernel test_printf
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -2561,7 +2647,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "$(cat $abs_top_srcdir/tests/test_printf_expout.txt)
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:93"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:94"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -2571,16 +2657,16 @@ $at_traceon; }
 read at_status <"$at_status_file"
 #AT_STOP_8
 #AT_START_9
-at_fn_group_banner 9 'testsuite.at:98' \
+at_fn_group_banner 9 'testsuite.at:99' \
   "Kernel functions as_type" "                       " 2
 at_xfail=no
 (
   $as_echo "9. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
-$as_echo "testsuite.at:99" >"$at_check_line_file"
+$as_echo "testsuite.at:100" >"$at_check_line_file"
 (grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite.at:99"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite.at:100"
 
 cat >expout <<'_ATEOF'
 Running test test_as_type...
@@ -2588,15 +2674,15 @@ OK
 _ATEOF
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:105: \$abs_top_builddir/tests/kernel/kernel test_as_type"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_as_type" "testsuite.at:105"
+$as_echo "$at_srcdir/testsuite.at:106: \$abs_top_builddir/tests/kernel/kernel test_as_type"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_as_type" "testsuite.at:106"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/kernel test_as_type
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:105"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:106"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -2606,7 +2692,7 @@ $at_traceon; }
 read at_status <"$at_status_file"
 #AT_STOP_9
 #AT_START_10
-at_fn_group_banner 10 'testsuite.at:108' \
+at_fn_group_banner 10 'testsuite.at:109' \
   "Kernel functions convert_type - scalars" "        " 2
 at_xfail=no
       grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc64 && at_xfail=yes
@@ -2618,8 +2704,8 @@ at_xfail=no
 
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:112: \$abs_top_builddir/tests/kernel/kernel test_convert_type_1"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_convert_type_1" "testsuite.at:112"
+$as_echo "$at_srcdir/testsuite.at:113: \$abs_top_builddir/tests/kernel/kernel test_convert_type_1"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_convert_type_1" "testsuite.at:113"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/kernel test_convert_type_1
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -2629,7 +2715,7 @@ echo >>"$at_stdout"; $as_echo "Running test test_convert_type_1...
 OK
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:112"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:113"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -2639,7 +2725,7 @@ $at_traceon; }
 read at_status <"$at_status_file"
 #AT_STOP_10
 #AT_START_11
-at_fn_group_banner 11 'testsuite.at:117' \
+at_fn_group_banner 11 'testsuite.at:118' \
   "Kernel functions convert_type - vector of 2" "    " 2
 at_xfail=no
       grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc64 && at_xfail=yes
@@ -2651,8 +2737,8 @@ at_xfail=no
 
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:121: \$abs_top_builddir/tests/kernel/kernel test_convert_type_2"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_convert_type_2" "testsuite.at:121"
+$as_echo "$at_srcdir/testsuite.at:122: \$abs_top_builddir/tests/kernel/kernel test_convert_type_2"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_convert_type_2" "testsuite.at:122"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/kernel test_convert_type_2
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -2662,7 +2748,7 @@ echo >>"$at_stdout"; $as_echo "Running test test_convert_type_2...
 OK
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:121"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:122"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -2672,7 +2758,7 @@ $at_traceon; }
 read at_status <"$at_status_file"
 #AT_STOP_11
 #AT_START_12
-at_fn_group_banner 12 'testsuite.at:126' \
+at_fn_group_banner 12 'testsuite.at:127' \
   "Kernel functions convert_type - vector of 4" "    " 2
 at_xfail=no
       grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc64 && at_xfail=yes
@@ -2684,8 +2770,8 @@ at_xfail=no
 
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:130: \$abs_top_builddir/tests/kernel/kernel test_convert_type_4"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_convert_type_4" "testsuite.at:130"
+$as_echo "$at_srcdir/testsuite.at:131: \$abs_top_builddir/tests/kernel/kernel test_convert_type_4"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_convert_type_4" "testsuite.at:131"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/kernel test_convert_type_4
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -2695,7 +2781,7 @@ echo >>"$at_stdout"; $as_echo "Running test test_convert_type_4...
 OK
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:130"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:131"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -2705,7 +2791,7 @@ $at_traceon; }
 read at_status <"$at_status_file"
 #AT_STOP_12
 #AT_START_13
-at_fn_group_banner 13 'testsuite.at:135' \
+at_fn_group_banner 13 'testsuite.at:136' \
   "Kernel functions convert_type - vector of 8" "    " 2
 at_xfail=no
       grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc64 && at_xfail=yes
@@ -2717,8 +2803,8 @@ at_xfail=no
 
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:139: \$abs_top_builddir/tests/kernel/kernel test_convert_type_8"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_convert_type_8" "testsuite.at:139"
+$as_echo "$at_srcdir/testsuite.at:140: \$abs_top_builddir/tests/kernel/kernel test_convert_type_8"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_convert_type_8" "testsuite.at:140"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/kernel test_convert_type_8
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -2728,7 +2814,7 @@ echo >>"$at_stdout"; $as_echo "Running test test_convert_type_8...
 OK
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:139"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:140"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -2738,7 +2824,7 @@ $at_traceon; }
 read at_status <"$at_status_file"
 #AT_STOP_13
 #AT_START_14
-at_fn_group_banner 14 'testsuite.at:144' \
+at_fn_group_banner 14 'testsuite.at:145' \
   "Kernel functions convert_type - vector of 16" "   " 2
 at_xfail=no
       grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc64 && at_xfail=yes
@@ -2750,8 +2836,8 @@ at_xfail=no
 
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:148: \$abs_top_builddir/tests/kernel/kernel test_convert_type_16"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_convert_type_16" "testsuite.at:148"
+$as_echo "$at_srcdir/testsuite.at:149: \$abs_top_builddir/tests/kernel/kernel test_convert_type_16"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_convert_type_16" "testsuite.at:149"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/kernel test_convert_type_16
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -2761,7 +2847,7 @@ echo >>"$at_stdout"; $as_echo "Running test test_convert_type_16...
 OK
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:148"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:149"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -2771,7 +2857,7 @@ $at_traceon; }
 read at_status <"$at_status_file"
 #AT_STOP_14
 #AT_START_15
-at_fn_group_banner 15 'testsuite.at:155' \
+at_fn_group_banner 15 'testsuite.at:156' \
   "Kernel functions min and max when the operands are of different sign" "" 2
 at_xfail=no
 (
@@ -2787,15 +2873,15 @@ OK
 _ATEOF
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:163: \$abs_top_builddir/tests/kernel/kernel test_min_max"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_min_max" "testsuite.at:163"
+$as_echo "$at_srcdir/testsuite.at:164: \$abs_top_builddir/tests/kernel/kernel test_min_max"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_min_max" "testsuite.at:164"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/kernel test_min_max
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:163"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:164"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -2805,31 +2891,30 @@ $at_traceon; }
 read at_status <"$at_status_file"
 #AT_STOP_15
 #AT_START_16
-at_fn_group_banner 16 'testsuite.at:166' \
-  "Kernel functions fmin, fmax, fma" "               " 2
+at_fn_group_banner 16 'testsuite.at:167' \
+  "Kernel functions length, distance, and normalize" "" 2
 at_xfail=no
-      grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc  && at_xfail=yes
 (
   $as_echo "16. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
-
+# This tests in particular for unintended overflow
 
 cat >expout <<'_ATEOF'
-Running test test_fmin_fmax_fma...
+Running test test_length_distance...
 OK
 _ATEOF
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:173: \$abs_top_builddir/tests/kernel/kernel test_fmin_fmax_fma"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_fmin_fmax_fma" "testsuite.at:173"
-( $at_check_trace; $abs_top_builddir/tests/kernel/kernel test_fmin_fmax_fma
+$as_echo "$at_srcdir/testsuite.at:174: \$abs_top_builddir/tests/kernel/kernel test_length_distance"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_length_distance" "testsuite.at:174"
+( $at_check_trace; $abs_top_builddir/tests/kernel/kernel test_length_distance
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:173"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:174"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -2840,28 +2925,30 @@ read at_status <"$at_status_file"
 #AT_STOP_16
 #AT_START_17
 at_fn_group_banner 17 'testsuite.at:177' \
-  "A saturating conversion from long to uint" "      " 2
+  "Kernel functions fmin, fmax, fma" "               " 2
 at_xfail=no
+      grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc  && at_xfail=yes
 (
   $as_echo "17. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
+
 cat >expout <<'_ATEOF'
-Running test test_convert_sat_regression...
+Running test test_fmin_fmax_fma...
 OK
 _ATEOF
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:183: \$abs_top_builddir/tests/kernel/kernel test_convert_sat_regression"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_convert_sat_regression" "testsuite.at:183"
-( $at_check_trace; $abs_top_builddir/tests/kernel/kernel test_convert_sat_regression
+$as_echo "$at_srcdir/testsuite.at:184: \$abs_top_builddir/tests/kernel/kernel test_fmin_fmax_fma"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_fmin_fmax_fma" "testsuite.at:184"
+( $at_check_trace; $abs_top_builddir/tests/kernel/kernel test_fmin_fmax_fma
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:183"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:184"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -2872,11 +2959,79 @@ read at_status <"$at_status_file"
 #AT_STOP_17
 #AT_START_18
 at_fn_group_banner 18 'testsuite.at:187' \
+  "Kernel functions frexp modf" "                    " 2
+at_xfail=no
+      grep -q "#undef USE_VECMATHLIB" $abs_top_builddir/config.h && at_xfail=yes
+(
+  $as_echo "18. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+cat >expout <<'_ATEOF'
+Running test test_frexp_modf...
+frexp(8e2f): 0.8 10
+modf(1.5f): 0.5 1.000000
+OK
+_ATEOF
+
+{ set +x
+$as_echo "$at_srcdir/testsuite.at:195: \$abs_top_builddir/tests/kernel/kernel test_frexp_modf"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_frexp_modf" "testsuite.at:195"
+( $at_check_trace; $abs_top_builddir/tests/kernel/kernel test_frexp_modf
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+$at_diff expout "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:195"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_18
+#AT_START_19
+at_fn_group_banner 19 'testsuite.at:200' \
+  "A saturating conversion from long to uint" "      " 2
+at_xfail=no
+(
+  $as_echo "19. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+cat >expout <<'_ATEOF'
+Running test test_convert_sat_regression...
+OK
+_ATEOF
+
+{ set +x
+$as_echo "$at_srcdir/testsuite.at:206: \$abs_top_builddir/tests/kernel/kernel test_convert_sat_regression"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_convert_sat_regression" "testsuite.at:206"
+( $at_check_trace; $abs_top_builddir/tests/kernel/kernel test_convert_sat_regression
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+$at_diff expout "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:206"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_19
+#AT_START_20
+at_fn_group_banner 20 'testsuite.at:210' \
   "Kernel functions abs bitselect clz max min popcount" "" 2
 at_xfail=no
       grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc && at_xfail=yes
 (
-  $as_echo "18. $at_setup_line: testing $at_desc ..."
+  $as_echo "20. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 #Fails on tce due to bug #1160383
@@ -2888,15 +3043,15 @@ OK
 _ATEOF
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:195: \$abs_top_builddir/tests/kernel/kernel test_bitselect"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_bitselect" "testsuite.at:195"
+$as_echo "$at_srcdir/testsuite.at:218: \$abs_top_builddir/tests/kernel/kernel test_bitselect"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_bitselect" "testsuite.at:218"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/kernel test_bitselect
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:195"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:218"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -2904,16 +3059,16 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_18
-#AT_START_19
-at_fn_group_banner 19 'testsuite.at:198' \
+#AT_STOP_20
+#AT_START_21
+at_fn_group_banner 21 'testsuite.at:221' \
   "Kernel functions fabs signbit isfinite isinf isnan isnormal copysign ilogb ldexp" "" 2
 at_xfail=no
       grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc64 && at_xfail=yes
       grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc &&
              grep -q "#define LLVM_3_2" $abs_top_builddir/config.h && at_xfail=yes
 (
-  $as_echo "19. $at_setup_line: testing $at_desc ..."
+  $as_echo "21. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 #Fails with what looks like rounding with vecmathlib on ppc32. ppc64 uninvestigated
@@ -2926,15 +3081,15 @@ OK
 _ATEOF
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:208: \$abs_top_builddir/tests/kernel/kernel test_fabs"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_fabs" "testsuite.at:208"
+$as_echo "$at_srcdir/testsuite.at:231: \$abs_top_builddir/tests/kernel/kernel test_fabs"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_fabs" "testsuite.at:231"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/kernel test_fabs
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:208"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:231"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -2942,9 +3097,9 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_19
-#AT_START_20
-at_fn_group_banner 20 'testsuite.at:211' \
+#AT_STOP_21
+#AT_START_22
+at_fn_group_banner 22 'testsuite.at:234' \
   "Kernel functions abs abs_diff add_sat hadd mad_hi mad_sat mul_hi rhadd sub_sat (loopvec)" "" 2
 at_xfail=no
       grep OCL_KERNEL_TARGET $abs_top_builddir/config.h | cut -d\" -f2 | grep -q x86_64 &&
@@ -2952,7 +3107,7 @@ at_xfail=no
       grep OCL_KERNEL_TARGET $abs_top_builddir/config.h | cut -d\" -f2 | grep -q x86_64 &&
              grep -q "#define LLVM_3_6" $abs_top_builddir/config.h && at_xfail=yes
 (
-  $as_echo "20. $at_setup_line: testing $at_desc ..."
+  $as_echo "22. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 # 3-element vector cases fail when vectorizer is enabled,
@@ -2965,15 +3120,15 @@ OK
 _ATEOF
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:222: POCL_WORK_GROUP_METHOD=loopvec \$abs_top_builddir/tests/kernel/kernel test_hadd 2>&1"
-at_fn_check_prepare_dynamic "POCL_WORK_GROUP_METHOD=loopvec $abs_top_builddir/tests/kernel/kernel test_hadd 2>&1" "testsuite.at:222"
+$as_echo "$at_srcdir/testsuite.at:245: POCL_WORK_GROUP_METHOD=loopvec \$abs_top_builddir/tests/kernel/kernel test_hadd 2>&1"
+at_fn_check_prepare_dynamic "POCL_WORK_GROUP_METHOD=loopvec $abs_top_builddir/tests/kernel/kernel test_hadd 2>&1" "testsuite.at:245"
 ( $at_check_trace; POCL_WORK_GROUP_METHOD=loopvec $abs_top_builddir/tests/kernel/kernel test_hadd 2>&1
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:222"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:245"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -2981,14 +3136,14 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_20
-#AT_START_21
-at_fn_group_banner 21 'testsuite.at:225' \
+#AT_STOP_22
+#AT_START_23
+at_fn_group_banner 23 'testsuite.at:248' \
   "Kernel functions abs abs_diff add_sat hadd mad_hi mad_sat mul_hi rhadd sub_sat (loops)" "" 2
 at_xfail=no
       grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc && at_xfail=yes
 (
-  $as_echo "21. $at_setup_line: testing $at_desc ..."
+  $as_echo "23. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -2998,15 +3153,15 @@ OK
 _ATEOF
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:231: POCL_WORK_GROUP_METHOD=loops \$abs_top_builddir/tests/kernel/kernel test_hadd 2>&1"
-at_fn_check_prepare_dynamic "POCL_WORK_GROUP_METHOD=loops $abs_top_builddir/tests/kernel/kernel test_hadd 2>&1" "testsuite.at:231"
+$as_echo "$at_srcdir/testsuite.at:254: POCL_WORK_GROUP_METHOD=loops \$abs_top_builddir/tests/kernel/kernel test_hadd 2>&1"
+at_fn_check_prepare_dynamic "POCL_WORK_GROUP_METHOD=loops $abs_top_builddir/tests/kernel/kernel test_hadd 2>&1" "testsuite.at:254"
 ( $at_check_trace; POCL_WORK_GROUP_METHOD=loops $abs_top_builddir/tests/kernel/kernel test_hadd 2>&1
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:231"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:254"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -3014,16 +3169,16 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_21
-#AT_START_22
-at_fn_group_banner 22 'testsuite.at:234' \
+#AT_STOP_23
+#AT_START_24
+at_fn_group_banner 24 'testsuite.at:257' \
   "Kernel functions << >> rotate" "                  " 2
 at_xfail=no
       grep -q "#define LLVM_3_2" $abs_top_builddir/config.h && at_xfail=yes
       grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc &&
              grep -q "#define LLVM_3_3" $abs_top_builddir/config.h && at_xfail=yes
 (
-  $as_echo "22. $at_setup_line: testing $at_desc ..."
+  $as_echo "24. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 # Fails because of bugs in rotate.
@@ -3041,15 +3196,15 @@ OK
 _ATEOF
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:249: \$abs_top_builddir/tests/kernel/kernel test_rotate"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_rotate" "testsuite.at:249"
+$as_echo "$at_srcdir/testsuite.at:272: \$abs_top_builddir/tests/kernel/kernel test_rotate"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_rotate" "testsuite.at:272"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/kernel test_rotate
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:249"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:272"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -3057,13 +3212,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_22
-#AT_START_23
-at_fn_group_banner 23 'testsuite.at:252' \
+#AT_STOP_24
+#AT_START_25
+at_fn_group_banner 25 'testsuite.at:275' \
   "Trigonometric functions" "                        " 2
 at_xfail=no
 (
-  $as_echo "23. $at_setup_line: testing $at_desc ..."
+  $as_echo "25. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 cat >expout <<'_ATEOF'
@@ -3071,15 +3226,15 @@ OK
 _ATEOF
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:256: \$abs_top_builddir/examples/trig/trig"
-at_fn_check_prepare_dynamic "$abs_top_builddir/examples/trig/trig" "testsuite.at:256"
+$as_echo "$at_srcdir/testsuite.at:279: \$abs_top_builddir/examples/trig/trig"
+at_fn_check_prepare_dynamic "$abs_top_builddir/examples/trig/trig" "testsuite.at:279"
 ( $at_check_trace; $abs_top_builddir/examples/trig/trig
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:256"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:279"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -3087,13 +3242,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_23
-#AT_START_24
-at_fn_group_banner 24 'testsuite.at:259' \
+#AT_STOP_25
+#AT_START_26
+at_fn_group_banner 26 'testsuite.at:282' \
   "Sampler address clamp" "                          " 2
 at_xfail=no
 (
-  $as_echo "24. $at_setup_line: testing $at_desc ..."
+  $as_echo "26. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 cat >expout <<'_ATEOF'
@@ -3102,15 +3257,15 @@ OK
 _ATEOF
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:264: \$abs_top_builddir/tests/kernel/sampler_address_clamp"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/sampler_address_clamp" "testsuite.at:264"
+$as_echo "$at_srcdir/testsuite.at:287: \$abs_top_builddir/tests/kernel/sampler_address_clamp"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/sampler_address_clamp" "testsuite.at:287"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/sampler_address_clamp
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:264"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:287"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -3118,13 +3273,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_24
-#AT_START_25
-at_fn_group_banner 25 'testsuite.at:267' \
+#AT_STOP_26
+#AT_START_27
+at_fn_group_banner 27 'testsuite.at:290' \
   "Image query functions" "                          " 2
 at_xfail=no
 (
-  $as_echo "25. $at_setup_line: testing $at_desc ..."
+  $as_echo "27. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 cat >expout <<'_ATEOF'
@@ -3133,15 +3288,15 @@ OK
 _ATEOF
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:272: \$abs_top_builddir/tests/kernel/image_query_funcs"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/image_query_funcs" "testsuite.at:272"
+$as_echo "$at_srcdir/testsuite.at:295: \$abs_top_builddir/tests/kernel/image_query_funcs"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/image_query_funcs" "testsuite.at:295"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/image_query_funcs
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:272"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:295"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -3149,13 +3304,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_25
-#AT_START_26
-at_fn_group_banner 26 'testsuite.at:275' \
+#AT_STOP_27
+#AT_START_28
+at_fn_group_banner 28 'testsuite.at:298' \
   "Kernel functions: shuffle charN" "                " 2
 at_xfail=no
 (
-  $as_echo "26. $at_setup_line: testing $at_desc ..."
+  $as_echo "28. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3164,15 +3319,15 @@ OK
 _ATEOF
 ]
 { set +x
-$as_echo "$at_srcdir/testsuite.at:280: \$abs_top_builddir/tests/kernel/test_shuffle char"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/test_shuffle char" "testsuite.at:280"
+$as_echo "$at_srcdir/testsuite.at:303: \$abs_top_builddir/tests/kernel/test_shuffle char"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/test_shuffle char" "testsuite.at:303"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/test_shuffle char
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:280"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:303"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -3180,13 +3335,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_26
-#AT_START_27
-at_fn_group_banner 27 'testsuite.at:283' \
+#AT_STOP_28
+#AT_START_29
+at_fn_group_banner 29 'testsuite.at:306' \
   "Kernel functions: shuffle shortN" "               " 2
 at_xfail=no
 (
-  $as_echo "27. $at_setup_line: testing $at_desc ..."
+  $as_echo "29. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3195,15 +3350,15 @@ OK
 _ATEOF
 ]
 { set +x
-$as_echo "$at_srcdir/testsuite.at:288: \$abs_top_builddir/tests/kernel/test_shuffle short"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/test_shuffle short" "testsuite.at:288"
+$as_echo "$at_srcdir/testsuite.at:311: \$abs_top_builddir/tests/kernel/test_shuffle short"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/test_shuffle short" "testsuite.at:311"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/test_shuffle short
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:288"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:311"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -3211,13 +3366,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_27
-#AT_START_28
-at_fn_group_banner 28 'testsuite.at:291' \
+#AT_STOP_29
+#AT_START_30
+at_fn_group_banner 30 'testsuite.at:314' \
   "Kernel functions: shuffle ushortN" "              " 2
 at_xfail=no
 (
-  $as_echo "28. $at_setup_line: testing $at_desc ..."
+  $as_echo "30. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3226,15 +3381,15 @@ OK
 _ATEOF
 ]
 { set +x
-$as_echo "$at_srcdir/testsuite.at:296: \$abs_top_builddir/tests/kernel/test_shuffle ushort"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/test_shuffle ushort" "testsuite.at:296"
+$as_echo "$at_srcdir/testsuite.at:319: \$abs_top_builddir/tests/kernel/test_shuffle ushort"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/test_shuffle ushort" "testsuite.at:319"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/test_shuffle ushort
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:296"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:319"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -3242,15 +3397,15 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_28
-#AT_START_29
-at_fn_group_banner 29 'testsuite.at:299' \
+#AT_STOP_30
+#AT_START_31
+at_fn_group_banner 31 'testsuite.at:322' \
   "Kernel functions: shuffle halfN" "                " 2
 at_xfail=no
       grep -q "#define LLVM_3_3" $abs_top_builddir/config.h ||
              grep -q "#define LLVM_3_4" $abs_top_builddir/config.h  && at_xfail=yes
 (
-  $as_echo "29. $at_setup_line: testing $at_desc ..."
+  $as_echo "31. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3258,19 +3413,19 @@ cat >expout <<'_ATEOF'
 OK
 _ATEOF
 ]
-$as_echo "testsuite.at:304" >"$at_check_line_file"
-at_fn_check_skip 77 "$at_srcdir/testsuite.at:304"
+$as_echo "testsuite.at:327" >"$at_check_line_file"
+at_fn_check_skip 77 "$at_srcdir/testsuite.at:327"
 
 { set +x
-$as_echo "$at_srcdir/testsuite.at:307: \$abs_top_builddir/tests/kernel/test_shuffle half"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/test_shuffle half" "testsuite.at:307"
+$as_echo "$at_srcdir/testsuite.at:330: \$abs_top_builddir/tests/kernel/test_shuffle half"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/test_shuffle half" "testsuite.at:330"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/test_shuffle half
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:307"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:330"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -3278,13 +3433,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_29
-#AT_START_30
-at_fn_group_banner 30 'testsuite.at:310' \
+#AT_STOP_31
+#AT_START_32
+at_fn_group_banner 32 'testsuite.at:333' \
   "Kernel functions: shuffle intN" "                 " 2
 at_xfail=no
 (
-  $as_echo "30. $at_setup_line: testing $at_desc ..."
+  $as_echo "32. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3293,15 +3448,15 @@ OK
 _ATEOF
 ]
 { set +x
-$as_echo "$at_srcdir/testsuite.at:315: \$abs_top_builddir/tests/kernel/test_shuffle int"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/test_shuffle int" "testsuite.at:315"
+$as_echo "$at_srcdir/testsuite.at:338: \$abs_top_builddir/tests/kernel/test_shuffle int"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/test_shuffle int" "testsuite.at:338"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/test_shuffle int
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:315"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:338"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -3309,13 +3464,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_30
-#AT_START_31
-at_fn_group_banner 31 'testsuite.at:318' \
+#AT_STOP_32
+#AT_START_33
+at_fn_group_banner 33 'testsuite.at:341' \
   "Kernel functions: shuffle uintN" "                " 2
 at_xfail=no
 (
-  $as_echo "31. $at_setup_line: testing $at_desc ..."
+  $as_echo "33. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3324,15 +3479,15 @@ OK
 _ATEOF
 ]
 { set +x
-$as_echo "$at_srcdir/testsuite.at:323: \$abs_top_builddir/tests/kernel/test_shuffle uint"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/test_shuffle uint" "testsuite.at:323"
+$as_echo "$at_srcdir/testsuite.at:346: \$abs_top_builddir/tests/kernel/test_shuffle uint"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/test_shuffle uint" "testsuite.at:346"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/test_shuffle uint
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:323"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:346"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -3340,13 +3495,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_31
-#AT_START_32
-at_fn_group_banner 32 'testsuite.at:326' \
+#AT_STOP_33
+#AT_START_34
+at_fn_group_banner 34 'testsuite.at:349' \
   "Kernel functions: shuffle floatN" "               " 2
 at_xfail=no
 (
-  $as_echo "32. $at_setup_line: testing $at_desc ..."
+  $as_echo "34. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3355,15 +3510,15 @@ OK
 _ATEOF
 ]
 { set +x
-$as_echo "$at_srcdir/testsuite.at:331: \$abs_top_builddir/tests/kernel/test_shuffle float"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/test_shuffle float" "testsuite.at:331"
+$as_echo "$at_srcdir/testsuite.at:354: \$abs_top_builddir/tests/kernel/test_shuffle float"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/test_shuffle float" "testsuite.at:354"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/test_shuffle float
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:331"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:354"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -3371,13 +3526,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_32
-#AT_START_33
-at_fn_group_banner 33 'testsuite.at:334' \
+#AT_STOP_34
+#AT_START_35
+at_fn_group_banner 35 'testsuite.at:357' \
   "Kernel functions: shuffle longN" "                " 2
 at_xfail=no
 (
-  $as_echo "33. $at_setup_line: testing $at_desc ..."
+  $as_echo "35. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3386,15 +3541,15 @@ OK
 _ATEOF
 ]
 { set +x
-$as_echo "$at_srcdir/testsuite.at:339: \$abs_top_builddir/tests/kernel/test_shuffle long"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/test_shuffle long" "testsuite.at:339"
+$as_echo "$at_srcdir/testsuite.at:362: \$abs_top_builddir/tests/kernel/test_shuffle long"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/test_shuffle long" "testsuite.at:362"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/test_shuffle long
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:339"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:362"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -3402,13 +3557,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_33
-#AT_START_34
-at_fn_group_banner 34 'testsuite.at:342' \
+#AT_STOP_35
+#AT_START_36
+at_fn_group_banner 36 'testsuite.at:365' \
   "Kernel functions: shuffle ulongN" "               " 2
 at_xfail=no
 (
-  $as_echo "34. $at_setup_line: testing $at_desc ..."
+  $as_echo "36. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3417,15 +3572,15 @@ OK
 _ATEOF
 ]
 { set +x
-$as_echo "$at_srcdir/testsuite.at:347: \$abs_top_builddir/tests/kernel/test_shuffle ulong"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/test_shuffle ulong" "testsuite.at:347"
+$as_echo "$at_srcdir/testsuite.at:370: \$abs_top_builddir/tests/kernel/test_shuffle ulong"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/test_shuffle ulong" "testsuite.at:370"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/test_shuffle ulong
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:347"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:370"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -3433,13 +3588,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_34
-#AT_START_35
-at_fn_group_banner 35 'testsuite.at:350' \
+#AT_STOP_36
+#AT_START_37
+at_fn_group_banner 37 'testsuite.at:373' \
   "Kernel functions: shuffle doubleN" "              " 2
 at_xfail=no
 (
-  $as_echo "35. $at_setup_line: testing $at_desc ..."
+  $as_echo "37. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3448,15 +3603,15 @@ OK
 _ATEOF
 ]
 { set +x
-$as_echo "$at_srcdir/testsuite.at:355: \$abs_top_builddir/tests/kernel/test_shuffle double"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/test_shuffle double" "testsuite.at:355"
+$as_echo "$at_srcdir/testsuite.at:378: \$abs_top_builddir/tests/kernel/test_shuffle double"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/test_shuffle double" "testsuite.at:378"
 ( $at_check_trace; $abs_top_builddir/tests/kernel/test_shuffle double
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:355"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:378"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -3464,23 +3619,23 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_35
-#AT_START_36
-at_fn_group_banner 36 'testsuite.at:360' \
+#AT_STOP_37
+#AT_START_38
+at_fn_group_banner 38 'testsuite.at:383' \
   "Scalar wave equation" "                           " 3
 at_xfail=no
 (
-  $as_echo "36. $at_setup_line: testing $at_desc ..."
+  $as_echo "38. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
 #this is a check for if doubles are available
-$as_echo "testsuite.at:363" >"$at_check_line_file"
+$as_echo "testsuite.at:386" >"$at_check_line_file"
 (grep DISABLE_LONG $abs_top_builddir/Makefile) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite.at:363"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite.at:386"
 { set +x
-$as_echo "$at_srcdir/testsuite.at:364: \$abs_top_builddir/examples/scalarwave/scalarwave"
-at_fn_check_prepare_dynamic "$abs_top_builddir/examples/scalarwave/scalarwave" "testsuite.at:364"
+$as_echo "$at_srcdir/testsuite.at:387: \$abs_top_builddir/examples/scalarwave/scalarwave"
+at_fn_check_prepare_dynamic "$abs_top_builddir/examples/scalarwave/scalarwave" "testsuite.at:387"
 ( $at_check_trace; $abs_top_builddir/examples/scalarwave/scalarwave
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -3489,7 +3644,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "$(cat $abs_top_srcdir/tests/scalarwave_expout.txt)
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:364"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite.at:387"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -3497,13 +3652,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_36
-#AT_START_37
-at_fn_group_banner 37 'testsuite-workgroup.at:28' \
+#AT_STOP_38
+#AT_START_39
+at_fn_group_banner 39 'testsuite-workgroup.at:28' \
   "unconditional barriers (full replication)" "      " 4
 at_xfail=no
 (
-  $as_echo "37. $at_setup_line: testing $at_desc ..."
+  $as_echo "39. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3526,13 +3681,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_37
-#AT_START_38
-at_fn_group_banner 38 'testsuite-workgroup.at:35' \
+#AT_STOP_39
+#AT_START_40
+at_fn_group_banner 40 'testsuite-workgroup.at:35' \
   "unconditional barriers (loops)" "                 " 4
 at_xfail=no
 (
-  $as_echo "38. $at_setup_line: testing $at_desc ..."
+  $as_echo "40. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3555,13 +3710,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_38
-#AT_START_39
-at_fn_group_banner 39 'testsuite-workgroup.at:42' \
+#AT_STOP_40
+#AT_START_41
+at_fn_group_banner 41 'testsuite-workgroup.at:42' \
   "unbarriered for loops (full replication)" "       " 4
 at_xfail=no
 (
-  $as_echo "39. $at_setup_line: testing $at_desc ..."
+  $as_echo "41. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3584,13 +3739,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_39
-#AT_START_40
-at_fn_group_banner 40 'testsuite-workgroup.at:49' \
+#AT_STOP_41
+#AT_START_42
+at_fn_group_banner 42 'testsuite-workgroup.at:49' \
   "unbarriered for loops (loops)" "                  " 4
 at_xfail=no
 (
-  $as_echo "40. $at_setup_line: testing $at_desc ..."
+  $as_echo "42. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3613,13 +3768,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_40
-#AT_START_41
-at_fn_group_banner 41 'testsuite-workgroup.at:56' \
+#AT_STOP_42
+#AT_START_43
+at_fn_group_banner 43 'testsuite-workgroup.at:56' \
   "barriered for loops (full replication)" "         " 4
 at_xfail=no
 (
-  $as_echo "41. $at_setup_line: testing $at_desc ..."
+  $as_echo "43. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3642,13 +3797,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_41
-#AT_START_42
-at_fn_group_banner 42 'testsuite-workgroup.at:63' \
+#AT_STOP_43
+#AT_START_44
+at_fn_group_banner 44 'testsuite-workgroup.at:63' \
   "barriered for loops (loops)" "                    " 4
 at_xfail=no
 (
-  $as_echo "42. $at_setup_line: testing $at_desc ..."
+  $as_echo "44. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3671,13 +3826,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_42
-#AT_START_43
-at_fn_group_banner 43 'testsuite-workgroup.at:70' \
+#AT_STOP_44
+#AT_START_45
+at_fn_group_banner 45 'testsuite-workgroup.at:70' \
   "conditional barrier (full replication)" "         " 4
 at_xfail=no
 (
-  $as_echo "43. $at_setup_line: testing $at_desc ..."
+  $as_echo "45. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3700,13 +3855,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_43
-#AT_START_44
-at_fn_group_banner 44 'testsuite-workgroup.at:77' \
+#AT_STOP_45
+#AT_START_46
+at_fn_group_banner 46 'testsuite-workgroup.at:77' \
   "conditional barrier (loops)" "                    " 4
 at_xfail=no
 (
-  $as_echo "44. $at_setup_line: testing $at_desc ..."
+  $as_echo "46. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3729,13 +3884,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_44
-#AT_START_45
-at_fn_group_banner 45 'testsuite-workgroup.at:84' \
+#AT_STOP_46
+#AT_START_47
+at_fn_group_banner 47 'testsuite-workgroup.at:84' \
   "b-loop with none of the WIs reaching the barrier (full replication)" "" 4
 at_xfail=no
 (
-  $as_echo "45. $at_setup_line: testing $at_desc ..."
+  $as_echo "47. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3758,13 +3913,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_45
-#AT_START_46
-at_fn_group_banner 46 'testsuite-workgroup.at:91' \
+#AT_STOP_47
+#AT_START_48
+at_fn_group_banner 48 'testsuite-workgroup.at:91' \
   "b-loop with none of the WIs reaching the barrier (loops)" "" 4
 at_xfail=no
 (
-  $as_echo "46. $at_setup_line: testing $at_desc ..."
+  $as_echo "48. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3787,13 +3942,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_46
-#AT_START_47
-at_fn_group_banner 47 'testsuite-workgroup.at:98' \
+#AT_STOP_48
+#AT_START_49
+at_fn_group_banner 49 'testsuite-workgroup.at:98' \
   "forcing horizontal parallelization to some outer loops (repl)" "" 4
 at_xfail=no
 (
-  $as_echo "47. $at_setup_line: testing $at_desc ..."
+  $as_echo "49. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3816,13 +3971,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_47
-#AT_START_48
-at_fn_group_banner 48 'testsuite-workgroup.at:105' \
+#AT_STOP_49
+#AT_START_50
+at_fn_group_banner 50 'testsuite-workgroup.at:105' \
   "forcing horizontal parallelization to some outer loops (loops)" "" 4
 at_xfail=no
 (
-  $as_echo "48. $at_setup_line: testing $at_desc ..."
+  $as_echo "50. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3845,13 +4000,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_48
-#AT_START_49
-at_fn_group_banner 49 'testsuite-workgroup.at:112' \
+#AT_STOP_50
+#AT_START_51
+at_fn_group_banner 51 'testsuite-workgroup.at:112' \
   "different implicit barrier injection scenarios (loops)" "" 4
 at_xfail=no
 (
-  $as_echo "49. $at_setup_line: testing $at_desc ..."
+  $as_echo "51. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3874,13 +4029,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_49
-#AT_START_50
-at_fn_group_banner 50 'testsuite-workgroup.at:119' \
+#AT_STOP_51
+#AT_START_52
+at_fn_group_banner 52 'testsuite-workgroup.at:119' \
   "loop with two paths to the latch (full replication)" "" 4
 at_xfail=no
 (
-  $as_echo "50. $at_setup_line: testing $at_desc ..."
+  $as_echo "52. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3903,13 +4058,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_50
-#AT_START_51
-at_fn_group_banner 51 'testsuite-workgroup.at:126' \
+#AT_STOP_52
+#AT_START_53
+at_fn_group_banner 53 'testsuite-workgroup.at:126' \
   "loop with two paths to the latch (loops)" "       " 4
 at_xfail=no
 (
-  $as_echo "51. $at_setup_line: testing $at_desc ..."
+  $as_echo "53. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3932,13 +4087,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_51
-#AT_START_52
-at_fn_group_banner 52 'testsuite-workgroup.at:133' \
+#AT_STOP_53
+#AT_START_54
+at_fn_group_banner 54 'testsuite-workgroup.at:133' \
   "b-loop with two latches (full replication)" "     " 4
 at_xfail=no
 (
-  $as_echo "52. $at_setup_line: testing $at_desc ..."
+  $as_echo "54. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3961,13 +4116,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_52
-#AT_START_53
-at_fn_group_banner 53 'testsuite-workgroup.at:140' \
+#AT_STOP_54
+#AT_START_55
+at_fn_group_banner 55 'testsuite-workgroup.at:140' \
   "b-loop with two latches (loops)" "                " 4
 at_xfail=no
 (
-  $as_echo "53. $at_setup_line: testing $at_desc ..."
+  $as_echo "55. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -3990,13 +4145,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_53
-#AT_START_54
-at_fn_group_banner 54 'testsuite-workgroup.at:147' \
+#AT_STOP_55
+#AT_START_56
+at_fn_group_banner 56 'testsuite-workgroup.at:147' \
   "workgroup_sizes: work-items get wrong ids (full replication)" "" 4
 at_xfail=no
 (
-  $as_echo "54. $at_setup_line: testing $at_desc ..."
+  $as_echo "56. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4019,13 +4174,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_54
-#AT_START_55
-at_fn_group_banner 55 'testsuite-workgroup.at:155' \
+#AT_STOP_56
+#AT_START_57
+at_fn_group_banner 57 'testsuite-workgroup.at:155' \
   "workgroup_sizes: work-items get wrong ids (loop)" "" 4
 at_xfail=no
 (
-  $as_echo "55. $at_setup_line: testing $at_desc ..."
+  $as_echo "57. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4048,13 +4203,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_55
-#AT_START_56
-at_fn_group_banner 56 'testsuite-regression.at:4' \
+#AT_STOP_57
+#AT_START_58
+at_fn_group_banner 58 'testsuite-regression.at:4' \
   "phi nodes not replicated (repl) - lp:927573" "    " 5
 at_xfail=no
 (
-  $as_echo "56. $at_setup_line: testing $at_desc ..."
+  $as_echo "58. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4078,13 +4233,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_56
-#AT_START_57
-at_fn_group_banner 57 'testsuite-regression.at:10' \
+#AT_STOP_58
+#AT_START_59
+at_fn_group_banner 59 'testsuite-regression.at:10' \
   "phi nodes not replicated (loops) - lp:927573" "   " 5
 at_xfail=no
 (
-  $as_echo "57. $at_setup_line: testing $at_desc ..."
+  $as_echo "59. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4108,13 +4263,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_57
-#AT_START_58
-at_fn_group_banner 58 'testsuite-regression.at:16' \
+#AT_STOP_59
+#AT_START_60
+at_fn_group_banner 60 'testsuite-regression.at:16' \
   "issues with local pointers (repl) - lp:918801" "  " 5
 at_xfail=no
 (
-  $as_echo "58. $at_setup_line: testing $at_desc ..."
+  $as_echo "60. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4138,13 +4293,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_58
-#AT_START_59
-at_fn_group_banner 59 'testsuite-regression.at:22' \
+#AT_STOP_60
+#AT_START_61
+at_fn_group_banner 61 'testsuite-regression.at:22' \
   "issues with local pointers (loops) - lp:918801" " " 5
 at_xfail=no
 (
-  $as_echo "59. $at_setup_line: testing $at_desc ..."
+  $as_echo "61. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4168,13 +4323,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_59
-#AT_START_60
-at_fn_group_banner 60 'testsuite-regression.at:28' \
+#AT_STOP_61
+#AT_START_62
+at_fn_group_banner 62 'testsuite-regression.at:28' \
   "barrier between two for loops (repl)" "           " 5
 at_xfail=no
 (
-  $as_echo "60. $at_setup_line: testing $at_desc ..."
+  $as_echo "62. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4198,13 +4353,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_60
-#AT_START_61
-at_fn_group_banner 61 'testsuite-regression.at:34' \
+#AT_STOP_62
+#AT_START_63
+at_fn_group_banner 63 'testsuite-regression.at:34' \
   "barrier between two for loops (loops)" "          " 5
 at_xfail=no
 (
-  $as_echo "61. $at_setup_line: testing $at_desc ..."
+  $as_echo "63. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4228,13 +4383,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_61
-#AT_START_62
-at_fn_group_banner 62 'testsuite-regression.at:40' \
+#AT_STOP_63
+#AT_START_64
+at_fn_group_banner 64 'testsuite-regression.at:40' \
   "simple for-loop with a barrier inside (repl)" "   " 5
 at_xfail=no
 (
-  $as_echo "62. $at_setup_line: testing $at_desc ..."
+  $as_echo "64. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4258,13 +4413,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_62
-#AT_START_63
-at_fn_group_banner 63 'testsuite-regression.at:46' \
+#AT_STOP_64
+#AT_START_65
+at_fn_group_banner 65 'testsuite-regression.at:46' \
   "simple for-loop with a barrier inside (loops)" "  " 5
 at_xfail=no
 (
-  $as_echo "63. $at_setup_line: testing $at_desc ..."
+  $as_echo "65. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4288,13 +4443,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_63
-#AT_START_64
-at_fn_group_banner 64 'testsuite-regression.at:52' \
+#AT_STOP_65
+#AT_START_66
+at_fn_group_banner 66 'testsuite-regression.at:52' \
   "for-loop with computation after the brexit (repl) - lp:938123" "" 5
 at_xfail=no
 (
-  $as_echo "64. $at_setup_line: testing $at_desc ..."
+  $as_echo "66. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4318,13 +4473,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_64
-#AT_START_65
-at_fn_group_banner 65 'testsuite-regression.at:58' \
+#AT_STOP_66
+#AT_START_67
+at_fn_group_banner 67 'testsuite-regression.at:58' \
   "for-loop with computation after the brexit (loops) - lp:938123" "" 5
 at_xfail=no
 (
-  $as_echo "65. $at_setup_line: testing $at_desc ..."
+  $as_echo "67. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4348,13 +4503,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_65
-#AT_START_66
-at_fn_group_banner 66 'testsuite-regression.at:64' \
+#AT_STOP_67
+#AT_START_68
+at_fn_group_banner 68 'testsuite-regression.at:64' \
   "for-loop with a variable iteration count (repl) - lp:938883" "" 5
 at_xfail=no
 (
-  $as_echo "66. $at_setup_line: testing $at_desc ..."
+  $as_echo "68. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4378,15 +4533,15 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_66
-#AT_START_67
-at_fn_group_banner 67 'testsuite-regression.at:70' \
+#AT_STOP_68
+#AT_START_69
+at_fn_group_banner 69 'testsuite-regression.at:70' \
   "for-loop with a variable iteration count (loops) - lp:938883" "" 5
 at_xfail=no
       grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc &&\
   grep -q "define LLVM_3_1" $abs_top_builddir/config.h && at_xfail=yes
 (
-  $as_echo "67. $at_setup_line: testing $at_desc ..."
+  $as_echo "69. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4412,13 +4567,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_67
-#AT_START_68
-at_fn_group_banner 68 'testsuite-regression.at:79' \
+#AT_STOP_69
+#AT_START_70
+at_fn_group_banner 70 'testsuite-regression.at:79' \
   "early return before a barrier region (repl) - lp:940248" "" 5
 at_xfail=no
 (
-  $as_echo "68. $at_setup_line: testing $at_desc ..."
+  $as_echo "70. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4442,13 +4597,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_68
-#AT_START_69
-at_fn_group_banner 69 'testsuite-regression.at:85' \
+#AT_STOP_70
+#AT_START_71
+at_fn_group_banner 71 'testsuite-regression.at:85' \
   "early return before a barrier region (loops) - lp:940248" "" 5
 at_xfail=no
 (
-  $as_echo "69. $at_setup_line: testing $at_desc ..."
+  $as_echo "71. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4473,13 +4628,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_69
-#AT_START_70
-at_fn_group_banner 70 'testsuite-regression.at:92' \
+#AT_STOP_71
+#AT_START_72
+at_fn_group_banner 72 'testsuite-regression.at:92' \
   "id-dependent computation before kernel exit (repl) - lp:940549" "" 5
 at_xfail=no
 (
-  $as_echo "70. $at_setup_line: testing $at_desc ..."
+  $as_echo "72. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4503,13 +4658,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_70
-#AT_START_71
-at_fn_group_banner 71 'testsuite-regression.at:98' \
+#AT_STOP_72
+#AT_START_73
+at_fn_group_banner 73 'testsuite-regression.at:98' \
   "id-dependent computation before kernel exit (loops) - lp:940549" "" 5
 at_xfail=no
 (
-  $as_echo "71. $at_setup_line: testing $at_desc ..."
+  $as_echo "73. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4533,13 +4688,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_71
-#AT_START_72
-at_fn_group_banner 72 'testsuite-regression.at:104' \
+#AT_STOP_73
+#AT_START_74
+at_fn_group_banner 74 'testsuite-regression.at:104' \
   "struct kernel arguments - lp:987905" "            " 5
 at_xfail=yes
 (
-  $as_echo "72. $at_setup_line: testing $at_desc ..."
+  $as_echo "74. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4567,15 +4722,15 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_72
-#AT_START_73
-at_fn_group_banner 73 'testsuite-regression.at:113' \
+#AT_STOP_74
+#AT_START_75
+at_fn_group_banner 75 'testsuite-regression.at:113' \
   "vector kernel arguments - lp:987905" "            " 5
 at_xfail=no
       grep LLVM_CXX_FLAGS $abs_top_builddir/config.log | grep -q -v DNDEBUG && at_xfail=yes
       grep LLVM_CXX_FLAGS $abs_top_builddir/config.log | grep -q _DEBUG && at_xfail=yes
 (
-  $as_echo "73. $at_setup_line: testing $at_desc ..."
+  $as_echo "75. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 $as_echo "testsuite-regression.at:114" >"$at_check_line_file"
@@ -4608,13 +4763,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_73
-#AT_START_74
-at_fn_group_banner 74 'testsuite-regression.at:127' \
+#AT_STOP_75
+#AT_START_76
+at_fn_group_banner 76 'testsuite-regression.at:127' \
   "barrier just before return (repl) - lp:1012030" " " 5
 at_xfail=no
 (
-  $as_echo "74. $at_setup_line: testing $at_desc ..."
+  $as_echo "76. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4638,13 +4793,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_74
-#AT_START_75
-at_fn_group_banner 75 'testsuite-regression.at:133' \
+#AT_STOP_76
+#AT_START_77
+at_fn_group_banner 77 'testsuite-regression.at:133' \
   "barrier just before return (loops) - lp:1012030" "" 5
 at_xfail=no
 (
-  $as_echo "75. $at_setup_line: testing $at_desc ..."
+  $as_echo "77. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4668,13 +4823,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_75
-#AT_START_76
-at_fn_group_banner 76 'testsuite-regression.at:139' \
+#AT_STOP_77
+#AT_START_78
+at_fn_group_banner 78 'testsuite-regression.at:139' \
   "infinite loop (repl) - lp:941558" "               " 5
 at_xfail=no
 (
-  $as_echo "76. $at_setup_line: testing $at_desc ..."
+  $as_echo "78. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4701,13 +4856,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_76
-#AT_START_77
-at_fn_group_banner 77 'testsuite-regression.at:146' \
+#AT_STOP_78
+#AT_START_79
+at_fn_group_banner 79 'testsuite-regression.at:146' \
   "infinite loop (loops) - lp:941558" "              " 5
 at_xfail=no
 (
-  $as_echo "77. $at_setup_line: testing $at_desc ..."
+  $as_echo "79. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4734,13 +4889,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_77
-#AT_START_78
-at_fn_group_banner 78 'testsuite-regression.at:153' \
+#AT_STOP_79
+#AT_START_80
+at_fn_group_banner 80 'testsuite-regression.at:153' \
   "passing a constant array as an arg - lp:1032203" "" 5
 at_xfail=no
 (
-  $as_echo "78. $at_setup_line: testing $at_desc ..."
+  $as_echo "80. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4764,13 +4919,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_78
-#AT_START_79
-at_fn_group_banner 79 'testsuite-regression.at:159' \
+#AT_STOP_80
+#AT_START_81
+at_fn_group_banner 81 'testsuite-regression.at:159' \
   "undominated variable from conditional barrier handling (repl) - lp:1045835" "" 5
 at_xfail=no
 (
-  $as_echo "79. $at_setup_line: testing $at_desc ..."
+  $as_echo "81. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4794,15 +4949,15 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_79
-#AT_START_80
-at_fn_group_banner 80 'testsuite-regression.at:165' \
+#AT_STOP_81
+#AT_START_82
+at_fn_group_banner 82 'testsuite-regression.at:165' \
   "undominated variable from conditional barrier handling (loops) - lp:1045835" "" 5
 at_xfail=no
       grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc &&\
   grep -q "define LLVM_3_1" $abs_top_builddir/config.h && at_xfail=yes
 (
-  $as_echo "80. $at_setup_line: testing $at_desc ..."
+  $as_echo "82. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4828,13 +4983,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_80
-#AT_START_81
-at_fn_group_banner 81 'testsuite-regression.at:174' \
+#AT_STOP_82
+#AT_START_83
+at_fn_group_banner 83 'testsuite-regression.at:174' \
   "clSetKernelArg overwriting the previous kernel's args - lp:1075134" "" 5
 at_xfail=no
 (
-  $as_echo "81. $at_setup_line: testing $at_desc ..."
+  $as_echo "83. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4858,13 +5013,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_81
-#AT_START_82
-at_fn_group_banner 82 'testsuite-regression.at:180' \
+#AT_STOP_83
+#AT_START_84
+at_fn_group_banner 84 'testsuite-regression.at:180' \
   "setting a buffer argument to NULL causes a segfault - lp:1109030" "" 5
 at_xfail=no
 (
-  $as_echo "82. $at_setup_line: testing $at_desc ..."
+  $as_echo "84. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4888,13 +5043,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_82
-#AT_START_83
-at_fn_group_banner 83 'testsuite-regression.at:186' \
+#AT_STOP_84
+#AT_START_85
+at_fn_group_banner 85 'testsuite-regression.at:186' \
   "sizeof(uint)" "                                   " 5
 at_xfail=no
 (
-  $as_echo "83. $at_setup_line: testing $at_desc ..."
+  $as_echo "85. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4917,14 +5072,14 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_83
-#AT_START_84
-at_fn_group_banner 84 'testsuite-regression.at:193' \
+#AT_STOP_85
+#AT_START_86
+at_fn_group_banner 86 'testsuite-regression.at:193' \
   "block" "                                          " 5
 at_xfail=no
       grep -q "#define LLVM_3_4" $abs_top_builddir/config.h && at_xfail=yes
 (
-  $as_echo "84. $at_setup_line: testing $at_desc ..."
+  $as_echo "86. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4952,13 +5107,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_84
-#AT_START_85
-at_fn_group_banner 85 'testsuite-regression.at:203' \
+#AT_STOP_86
+#AT_START_87
+at_fn_group_banner 87 'testsuite-regression.at:203' \
   "case with multiple variable length loops and a barrier in one" "" 5
 at_xfail=no
 (
-  $as_echo "85. $at_setup_line: testing $at_desc ..."
+  $as_echo "87. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -4982,13 +5137,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_85
-#AT_START_86
-at_fn_group_banner 86 'testsuite-regression.at:209' \
+#AT_STOP_87
+#AT_START_88
+at_fn_group_banner 88 'testsuite-regression.at:209' \
   "assigning a loop iterator variable to a private makes it local - issue 94 (repl)" "" 5
 at_xfail=no
 (
-  $as_echo "86. $at_setup_line: testing $at_desc ..."
+  $as_echo "88. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -5014,13 +5169,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_86
-#AT_START_87
-at_fn_group_banner 87 'testsuite-regression.at:218' \
+#AT_STOP_88
+#AT_START_89
+at_fn_group_banner 89 'testsuite-regression.at:218' \
   "assigning a loop iterator variable to a private makes it local - issue 94 (loops)" "" 5
 at_xfail=no
 (
-  $as_echo "87. $at_setup_line: testing $at_desc ..."
+  $as_echo "89. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -5046,13 +5201,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_87
-#AT_START_88
-at_fn_group_banner 88 'testsuite-regression.at:227' \
+#AT_STOP_89
+#AT_START_90
+at_fn_group_banner 90 'testsuite-regression.at:227' \
   "assigning a loop iterator variable to a private makes it local 2 - issue 102 (repl)" "" 5
 at_xfail=no
 (
-  $as_echo "88. $at_setup_line: testing $at_desc ..."
+  $as_echo "90. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -5078,13 +5233,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_88
-#AT_START_89
-at_fn_group_banner 89 'testsuite-regression.at:236' \
+#AT_STOP_90
+#AT_START_91
+at_fn_group_banner 91 'testsuite-regression.at:236' \
   "assigning a loop iterator variable to a private makes it local 2 - issue 102 (loops)" "" 5
 at_xfail=no
 (
-  $as_echo "89. $at_setup_line: testing $at_desc ..."
+  $as_echo "91. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -5110,19 +5265,85 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_89
-#AT_START_90
-at_fn_group_banner 90 'testsuite-runtime.at:4' \
-  "clGetDeviceInfo" "                                " 6
+#AT_STOP_91
+#AT_START_92
+at_fn_group_banner 92 'testsuite-regression.at:247' \
+  "local struct arrays produce illegal AS casts" "   " 5
 at_xfail=no
+      grep -q "#define LLVM_BUILT_WITH_ASSERTS" $abs_top_builddir/config.h && \
+! grep -q "#define LLVM_3_2" $abs_top_builddir/config.h && \
+! grep -q "#define LLVM_3_3" $abs_top_builddir/config.h && at_xfail=yes
 (
-  $as_echo "90. $at_setup_line: testing $at_desc ..."
+  $as_echo "92. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
+# The HSA branch of LLVM 3.7 is probably outdated in comparison
+# to the upstream trunk and makes this case fail.
+$as_echo "testsuite-regression.at:251" >"$at_check_line_file"
+(grep -q "#define BUILD_HSA" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-regression.at:251"
 { set +x
-$as_echo "$at_srcdir/testsuite-runtime.at:6: \$abs_top_builddir/tests/runtime/test_clGetDeviceInfo"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/runtime/test_clGetDeviceInfo" "testsuite-runtime.at:6"
+$as_echo "$at_srcdir/testsuite-regression.at:252: \$abs_top_builddir/tests/kernel/kernel test_local_struct_array"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/kernel/kernel test_local_struct_array" "testsuite-regression.at:252"
+( $at_check_trace; $abs_top_builddir/tests/kernel/kernel test_local_struct_array
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Running test test_local_struct_array...
+OK
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-regression.at:252"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_92
+#AT_START_93
+at_fn_group_banner 93 'testsuite-regression.at:263' \
+  "LoopVectorizer crash with Haswell and Broadwell - issue 231" "" 5
+at_xfail=no
+(
+  $as_echo "93. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-regression.at:265: \$abs_top_builddir/tests/regression/test_issue_231"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/regression/test_issue_231" "testsuite-regression.at:265"
+( $at_check_trace; $abs_top_builddir/tests/regression/test_issue_231
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-regression.at:265"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_93
+#AT_START_94
+at_fn_group_banner 94 'testsuite-runtime.at:4' \
+  "clGetDeviceInfo" "                                " 6
+at_xfail=no
+(
+  $as_echo "94. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-runtime.at:6: \$abs_top_builddir/tests/runtime/test_clGetDeviceInfo"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/runtime/test_clGetDeviceInfo" "testsuite-runtime.at:6"
 ( $at_check_trace; $abs_top_builddir/tests/runtime/test_clGetDeviceInfo
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -5137,13 +5358,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_90
-#AT_START_91
-at_fn_group_banner 91 'testsuite-runtime.at:9' \
+#AT_STOP_94
+#AT_START_95
+at_fn_group_banner 95 'testsuite-runtime.at:9' \
   "clEnqueueNativeKernel" "                          " 6
 at_xfail=no
 (
-  $as_echo "91. $at_setup_line: testing $at_desc ..."
+  $as_echo "95. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -5164,13 +5385,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_91
-#AT_START_92
-at_fn_group_banner 92 'testsuite-runtime.at:14' \
+#AT_STOP_95
+#AT_START_96
+at_fn_group_banner 96 'testsuite-runtime.at:14' \
   "clGetEventInfo" "                                 " 6
 at_xfail=no
 (
-  $as_echo "92. $at_setup_line: testing $at_desc ..."
+  $as_echo "96. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -5191,26 +5412,107 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_92
-#AT_START_93
-at_fn_group_banner 93 'testsuite-runtime.at:19' \
+#AT_STOP_96
+#AT_START_97
+at_fn_group_banner 97 'testsuite-runtime.at:19' \
+  "read/copy/write buffer" "                         " 6
+at_xfail=no
+(
+  $as_echo "97. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-runtime.at:21: \$abs_top_builddir/tests/runtime/test_read-copy-write-buffer"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/runtime/test_read-copy-write-buffer" "testsuite-runtime.at:21"
+( $at_check_trace; $abs_top_builddir/tests/runtime/test_read-copy-write-buffer
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-runtime.at:21"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_97
+#AT_START_98
+at_fn_group_banner 98 'testsuite-runtime.at:24' \
+  "event cycle" "                                    " 6
+at_xfail=no
+(
+  $as_echo "98. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-runtime.at:26: \$abs_top_builddir/tests/runtime/test_event_cycle"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/runtime/test_event_cycle" "testsuite-runtime.at:26"
+( $at_check_trace; $abs_top_builddir/tests/runtime/test_event_cycle
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-runtime.at:26"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_98
+#AT_START_99
+at_fn_group_banner 99 'testsuite-runtime.at:29' \
+  "event freeing" "                                  " 6
+at_xfail=no
+(
+  $as_echo "99. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-runtime.at:31: \$abs_top_builddir/tests/runtime/test_event_free"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/runtime/test_event_free" "testsuite-runtime.at:31"
+( $at_check_trace; $abs_top_builddir/tests/runtime/test_event_free
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-runtime.at:31"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_99
+#AT_START_100
+at_fn_group_banner 100 'testsuite-runtime.at:34' \
   "clCreateProgramWithBinary" "                      " 6
 at_xfail=no
 (
-  $as_echo "93. $at_setup_line: testing $at_desc ..."
+  $as_echo "100. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
 { set +x
-$as_echo "$at_srcdir/testsuite-runtime.at:21: \$abs_top_builddir/tests/runtime/test_clCreateProgramWithBinary"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/runtime/test_clCreateProgramWithBinary" "testsuite-runtime.at:21"
+$as_echo "$at_srcdir/testsuite-runtime.at:36: \$abs_top_builddir/tests/runtime/test_clCreateProgramWithBinary"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/runtime/test_clCreateProgramWithBinary" "testsuite-runtime.at:36"
 ( $at_check_trace; $abs_top_builddir/tests/runtime/test_clCreateProgramWithBinary
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 at_fn_diff_devnull "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-runtime.at:21"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-runtime.at:36"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -5218,26 +5520,26 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_93
-#AT_START_94
-at_fn_group_banner 94 'testsuite-runtime.at:25' \
+#AT_STOP_100
+#AT_START_101
+at_fn_group_banner 101 'testsuite-runtime.at:40' \
   "clBuildProgram" "                                 " 6
 at_xfail=no
 (
-  $as_echo "94. $at_setup_line: testing $at_desc ..."
+  $as_echo "101. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
 { set +x
-$as_echo "$at_srcdir/testsuite-runtime.at:27: cd \$abs_top_srcdir/tests/runtime/; \$abs_top_builddir/tests/runtime/test_clBuildProgram"
-at_fn_check_prepare_dynamic "cd $abs_top_srcdir/tests/runtime/; $abs_top_builddir/tests/runtime/test_clBuildProgram" "testsuite-runtime.at:27"
+$as_echo "$at_srcdir/testsuite-runtime.at:42: cd \$abs_top_srcdir/tests/runtime/; \$abs_top_builddir/tests/runtime/test_clBuildProgram"
+at_fn_check_prepare_dynamic "cd $abs_top_srcdir/tests/runtime/; $abs_top_builddir/tests/runtime/test_clBuildProgram" "testsuite-runtime.at:42"
 ( $at_check_trace; cd $abs_top_srcdir/tests/runtime/; $abs_top_builddir/tests/runtime/test_clBuildProgram
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 echo stderr:; cat "$at_stderr"
 echo stdout:; cat "$at_stdout"
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-runtime.at:27"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-runtime.at:42"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -5245,19 +5547,76 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_94
-#AT_START_95
-at_fn_group_banner 95 'testsuite-runtime.at:30' \
+#AT_STOP_101
+#AT_START_102
+at_fn_group_banner 102 'testsuite-runtime.at:46' \
+  "test_kernel_cache_includes" "                     " 6
+at_xfail=no
+(
+  $as_echo "102. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-runtime.at:48: cd \$abs_top_builddir/tests/runtime/; \$abs_top_builddir/tests/runtime/test_kernel_cache_includes"
+at_fn_check_prepare_dynamic "cd $abs_top_builddir/tests/runtime/; $abs_top_builddir/tests/runtime/test_kernel_cache_includes" "testsuite-runtime.at:48"
+( $at_check_trace; cd $abs_top_builddir/tests/runtime/; $abs_top_builddir/tests/runtime/test_kernel_cache_includes
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "$(cat $abs_top_srcdir/tests/runtime/test_kernel_cache_includes_expout.txt)
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-runtime.at:48"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_102
+#AT_START_103
+at_fn_group_banner 103 'testsuite-runtime.at:53' \
+  "clBuildProgram link error" "                      " 6
+at_xfail=yes
+(
+  $as_echo "103. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-runtime.at:56: \$abs_top_builddir/tests/runtime/test_link_error"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/runtime/test_link_error" "testsuite-runtime.at:56"
+( $at_check_trace; $abs_top_builddir/tests/runtime/test_link_error
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-runtime.at:56"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_103
+#AT_START_104
+at_fn_group_banner 104 'testsuite-runtime.at:60' \
   "clFinish" "                                       " 6
 at_xfail=no
 (
-  $as_echo "95. $at_setup_line: testing $at_desc ..."
+  $as_echo "104. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
 { set +x
-$as_echo "$at_srcdir/testsuite-runtime.at:32: \$abs_top_builddir/tests/runtime/test_clFinish | grep \"ABABC\""
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-runtime.at:32"
+$as_echo "$at_srcdir/testsuite-runtime.at:62: \$abs_top_builddir/tests/runtime/test_clFinish | grep \"ABABC\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-runtime.at:62"
 ( $at_check_trace; $abs_top_builddir/tests/runtime/test_clFinish | grep "ABABC"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -5266,7 +5625,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "ABABC
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-runtime.at:32"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-runtime.at:62"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -5274,19 +5633,19 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_95
-#AT_START_96
-at_fn_group_banner 96 'testsuite-runtime.at:36' \
+#AT_STOP_104
+#AT_START_105
+at_fn_group_banner 105 'testsuite-runtime.at:66' \
   "clSetEventCallback" "                             " 6
 at_xfail=no
 (
-  $as_echo "96. $at_setup_line: testing $at_desc ..."
+  $as_echo "105. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
 { set +x
-$as_echo "$at_srcdir/testsuite-runtime.at:38: \$abs_top_builddir/tests/runtime/test_clSetEventCallback"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/runtime/test_clSetEventCallback" "testsuite-runtime.at:38"
+$as_echo "$at_srcdir/testsuite-runtime.at:68: \$abs_top_builddir/tests/runtime/test_clSetEventCallback"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/runtime/test_clSetEventCallback" "testsuite-runtime.at:68"
 ( $at_check_trace; $abs_top_builddir/tests/runtime/test_clSetEventCallback
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -5295,7 +5654,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "$(cat $abs_top_srcdir/tests/runtime/test_clSetEventCallback_expout.txt)
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-runtime.at:38"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-runtime.at:68"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -5303,26 +5662,26 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_96
-#AT_START_97
-at_fn_group_banner 97 'testsuite-runtime.at:43' \
+#AT_STOP_105
+#AT_START_106
+at_fn_group_banner 106 'testsuite-runtime.at:73' \
   "clGetSupportedImageFormats" "                     " 6
 at_xfail=no
 (
-  $as_echo "97. $at_setup_line: testing $at_desc ..."
+  $as_echo "106. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
 { set +x
-$as_echo "$at_srcdir/testsuite-runtime.at:45: POCL_DEVICES=\"pthread pthread\" \$abs_top_builddir/tests/runtime/test_clGetSupportedImageFormats"
-at_fn_check_prepare_dynamic "POCL_DEVICES=\"pthread pthread\" $abs_top_builddir/tests/runtime/test_clGetSupportedImageFormats" "testsuite-runtime.at:45"
+$as_echo "$at_srcdir/testsuite-runtime.at:75: POCL_DEVICES=\"pthread pthread\" \$abs_top_builddir/tests/runtime/test_clGetSupportedImageFormats"
+at_fn_check_prepare_dynamic "POCL_DEVICES=\"pthread pthread\" $abs_top_builddir/tests/runtime/test_clGetSupportedImageFormats" "testsuite-runtime.at:75"
 ( $at_check_trace; POCL_DEVICES="pthread pthread" $abs_top_builddir/tests/runtime/test_clGetSupportedImageFormats
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 at_fn_diff_devnull "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-runtime.at:45"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-runtime.at:75"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -5330,19 +5689,19 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_97
-#AT_START_98
-at_fn_group_banner 98 'testsuite-runtime.at:48' \
+#AT_STOP_106
+#AT_START_107
+at_fn_group_banner 107 'testsuite-runtime.at:78' \
   "clCreateKernelsInProgram" "                       " 6
 at_xfail=no
 (
-  $as_echo "98. $at_setup_line: testing $at_desc ..."
+  $as_echo "107. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
 { set +x
-$as_echo "$at_srcdir/testsuite-runtime.at:50: \$abs_top_builddir/tests/runtime/test_clCreateKernelsInProgram "
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/runtime/test_clCreateKernelsInProgram " "testsuite-runtime.at:50"
+$as_echo "$at_srcdir/testsuite-runtime.at:80: \$abs_top_builddir/tests/runtime/test_clCreateKernelsInProgram "
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/runtime/test_clCreateKernelsInProgram " "testsuite-runtime.at:80"
 ( $at_check_trace; $abs_top_builddir/tests/runtime/test_clCreateKernelsInProgram
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -5352,7 +5711,7 @@ echo >>"$at_stdout"; $as_echo "Hello
 World
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-runtime.at:50"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-runtime.at:80"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -5360,19 +5719,19 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_98
-#AT_START_99
-at_fn_group_banner 99 'testsuite-runtime.at:56' \
+#AT_STOP_107
+#AT_START_108
+at_fn_group_banner 108 'testsuite-runtime.at:86' \
   "clCreateKernel" "                                 " 6
 at_xfail=no
 (
-  $as_echo "99. $at_setup_line: testing $at_desc ..."
+  $as_echo "108. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
 { set +x
-$as_echo "$at_srcdir/testsuite-runtime.at:58: \$abs_top_builddir/tests/runtime/test_clCreateKernel "
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/runtime/test_clCreateKernel " "testsuite-runtime.at:58"
+$as_echo "$at_srcdir/testsuite-runtime.at:88: \$abs_top_builddir/tests/runtime/test_clCreateKernel "
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/runtime/test_clCreateKernel " "testsuite-runtime.at:88"
 ( $at_check_trace; $abs_top_builddir/tests/runtime/test_clCreateKernel
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -5381,7 +5740,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "OK
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-runtime.at:58"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-runtime.at:88"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -5389,28 +5748,28 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_99
-#AT_START_100
-at_fn_group_banner 100 'testsuite-runtime.at:62' \
+#AT_STOP_108
+#AT_START_109
+at_fn_group_banner 109 'testsuite-runtime.at:92' \
   "clGetKernelArgInfo" "                             " 6
 at_xfail=no
       grep -q "#define LLVM_3_2" $abs_top_builddir/config.h && at_xfail=yes
 (
-  $as_echo "100. $at_setup_line: testing $at_desc ..."
+  $as_echo "109. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
 
 { set +x
-$as_echo "$at_srcdir/testsuite-runtime.at:65: \$abs_top_builddir/tests/runtime/test_clGetKernelArgInfo"
-at_fn_check_prepare_dynamic "$abs_top_builddir/tests/runtime/test_clGetKernelArgInfo" "testsuite-runtime.at:65"
+$as_echo "$at_srcdir/testsuite-runtime.at:95: \$abs_top_builddir/tests/runtime/test_clGetKernelArgInfo"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/runtime/test_clGetKernelArgInfo" "testsuite-runtime.at:95"
 ( $at_check_trace; $abs_top_builddir/tests/runtime/test_clGetKernelArgInfo
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 echo stderr:; cat "$at_stderr"
 echo stdout:; cat "$at_stdout"
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-runtime.at:65"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-runtime.at:95"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -5418,13 +5777,40 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_100
-#AT_START_101
-at_fn_group_banner 101 'testsuite-tce.at:4' \
+#AT_STOP_109
+#AT_START_110
+at_fn_group_banner 110 'testsuite-runtime.at:98' \
+  "clCreateSubDevices" "                             " 6
+at_xfail=no
+(
+  $as_echo "110. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-runtime.at:100: \$abs_top_builddir/tests/runtime/test_clCreateSubDevices"
+at_fn_check_prepare_dynamic "$abs_top_builddir/tests/runtime/test_clCreateSubDevices" "testsuite-runtime.at:100"
+( $at_check_trace; $abs_top_builddir/tests/runtime/test_clCreateSubDevices
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-runtime.at:100"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_110
+#AT_START_111
+at_fn_group_banner 111 'testsuite-tce.at:4' \
   "A basic ttasim driver test" "                     " 7
 at_xfail=no
 (
-  $as_echo "101. $at_setup_line: testing $at_desc ..."
+  $as_echo "111. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -5450,14 +5836,14 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_101
-#AT_START_102
-at_fn_group_banner 102 'testsuite-tce.at:12' \
+#AT_STOP_111
+#AT_START_112
+at_fn_group_banner 112 'testsuite-tce.at:12' \
   "Half-precision floats on ttasim (repl)" "         " 7
 at_xfail=no
       grep -q "#define LLVM_3_2" $abs_top_builddir/config.h && at_xfail=yes
 (
-  $as_echo "102. $at_setup_line: testing $at_desc ..."
+  $as_echo "112. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -5500,18 +5886,18 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_102
-#AT_START_103
-at_fn_group_banner 103 'testsuite-tce.at:37' \
+#AT_STOP_112
+#AT_START_113
+at_fn_group_banner 113 'testsuite-tce.at:37' \
   "Half-precision floats on ttasim (loopvec)" "      " 7
 at_xfail=no
 (
-  $as_echo "103. $at_setup_line: testing $at_desc ..."
+  $as_echo "113. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
 $as_echo "testsuite-tce.at:39" >"$at_check_line_file"
-(! grep -c "define TCE_AVAILABLE" $abs_top_builddir/config.h) \
+(! grep -c "define TCEMC_AVAILABLE" $abs_top_builddir/config.h) \
   && at_fn_check_skip 77 "$at_srcdir/testsuite-tce.at:39"
 { set +x
 $as_echo "$at_srcdir/testsuite-tce.at:40: make -s -C \$abs_top_builddir/tests/tce/fp16 run | egrep -v \"^make\""
@@ -5548,13 +5934,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_103
-#AT_START_104
-at_fn_group_banner 104 'testsuite-tce.at:61' \
+#AT_STOP_113
+#AT_START_114
+at_fn_group_banner 114 'testsuite-tce.at:61' \
   "A basic TCEMC test" "                             " 7
 at_xfail=no
 (
-  $as_echo "104. $at_setup_line: testing $at_desc ..."
+  $as_echo "114. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -5580,13 +5966,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_104
-#AT_START_105
-at_fn_group_banner 105 'testsuite-samples.at:8' \
+#AT_STOP_114
+#AT_START_115
+at_fn_group_banner 115 'testsuite-samples.at:8' \
   "Building the sources against pocl" "              " 8
 at_xfail=no
 (
-  $as_echo "105. $at_setup_line: testing $at_desc ..."
+  $as_echo "115. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -5634,13 +6020,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_105
-#AT_START_106
-at_fn_group_banner 106 'testsuite-samples.at:28' \
+#AT_STOP_115
+#AT_START_116
+at_fn_group_banner 116 'testsuite-samples.at:28' \
   "Run Chapter 2: Hello World" "                     " 8
 at_xfail=no
 (
-  $as_echo "106. $at_setup_line: testing $at_desc ..."
+  $as_echo "116. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -5675,13 +6061,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_106
-#AT_START_107
-at_fn_group_banner 107 'testsuite-samples.at:38' \
+#AT_STOP_116
+#AT_START_117
+at_fn_group_banner 117 'testsuite-samples.at:38' \
   "Run Chapter 3: OpenCLConvolution" "               " 8
 at_xfail=no
 (
-  $as_echo "107. $at_setup_line: testing $at_desc ..."
+  $as_echo "117. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -5724,13 +6110,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_107
-#AT_START_108
-at_fn_group_banner 108 'testsuite-samples.at:52' \
+#AT_STOP_117
+#AT_START_118
+at_fn_group_banner 118 'testsuite-samples.at:52' \
   "Run Chapter 6: HelloBinaryWorld" "                " 8
 at_xfail=no
 (
-  $as_echo "108. $at_setup_line: testing $at_desc ..."
+  $as_echo "118. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -5774,13 +6160,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_108
-#AT_START_109
-at_fn_group_banner 109 'testsuite-samples.at:66' \
+#AT_STOP_118
+#AT_START_119
+at_fn_group_banner 119 'testsuite-samples.at:66' \
   "Run Chapter 7: SimpleBufferSubBuffer" "           " 8
 at_xfail=no
 (
-  $as_echo "109. $at_setup_line: testing $at_desc ..."
+  $as_echo "119. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -5821,13 +6207,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_109
-#AT_START_110
-at_fn_group_banner 110 'testsuite-samples.at:79' \
+#AT_STOP_119
+#AT_START_120
+at_fn_group_banner 120 'testsuite-samples.at:79' \
   "Run Chapter 8: ImageFilter2D" "                   " 8
 at_xfail=no
 (
-  $as_echo "110. $at_setup_line: testing $at_desc ..."
+  $as_echo "120. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -5897,13 +6283,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_110
-#AT_START_111
-at_fn_group_banner 111 'testsuite-samples.at:102' \
+#AT_STOP_120
+#AT_START_121
+at_fn_group_banner 121 'testsuite-samples.at:102' \
   "Run Chapter 12: VectorAdd (C++ bindings)" "       " 8
 at_xfail=no
 (
-  $as_echo "111. $at_setup_line: testing $at_desc ..."
+  $as_echo "121. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -5944,13 +6330,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_111
-#AT_START_112
-at_fn_group_banner 112 'testsuite-viennacl.at:17' \
+#AT_STOP_121
+#AT_START_122
+at_fn_group_banner 122 'testsuite-viennacl.at:17' \
   "fft" "                                            " 9
 at_xfail=no
 (
-  $as_echo "112. $at_setup_line: testing $at_desc ..."
+  $as_echo "122. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -5983,13 +6369,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_112
-#AT_START_113
-at_fn_group_banner 113 'testsuite-viennacl.at:21' \
+#AT_STOP_122
+#AT_START_123
+at_fn_group_banner 123 'testsuite-viennacl.at:21' \
   "custom-context" "                                 " 9
 at_xfail=no
 (
-  $as_echo "113. $at_setup_line: testing $at_desc ..."
+  $as_echo "123. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -6022,13 +6408,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_113
-#AT_START_114
-at_fn_group_banner 114 'testsuite-viennacl.at:25' \
+#AT_STOP_123
+#AT_START_124
+at_fn_group_banner 124 'testsuite-viennacl.at:25' \
   "custom-kernels" "                                 " 9
 at_xfail=no
 (
-  $as_echo "114. $at_setup_line: testing $at_desc ..."
+  $as_echo "124. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -6061,13 +6447,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_114
-#AT_START_115
-at_fn_group_banner 115 'testsuite-viennacl.at:29' \
+#AT_STOP_124
+#AT_START_125
+at_fn_group_banner 125 'testsuite-viennacl.at:29' \
   "scheduler" "                                      " 9
 at_xfail=no
 (
-  $as_echo "115. $at_setup_line: testing $at_desc ..."
+  $as_echo "125. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -6100,13 +6486,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_115
-#AT_START_116
-at_fn_group_banner 116 'testsuite-viennacl.at:39' \
+#AT_STOP_125
+#AT_START_126
+at_fn_group_banner 126 'testsuite-viennacl.at:39' \
   "bandwidth-reduction" "                            " 9
 at_xfail=no
 (
-  $as_echo "116. $at_setup_line: testing $at_desc ..."
+  $as_echo "126. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -6139,13 +6525,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_116
-#AT_START_117
-at_fn_group_banner 117 'testsuite-viennacl.at:55' \
+#AT_STOP_126
+#AT_START_127
+at_fn_group_banner 127 'testsuite-viennacl.at:55' \
   "blas3_solve_double-test-opencl" "                 " 9
 at_xfail=yes
 (
-  $as_echo "117. $at_setup_line: testing $at_desc ..."
+  $as_echo "127. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -6182,13 +6568,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_117
-#AT_START_118
-at_fn_group_banner 118 'testsuite-viennacl.at:71' \
+#AT_STOP_127
+#AT_START_128
+at_fn_group_banner 128 'testsuite-viennacl.at:71' \
   "external_linkage-opencl" "                        " 9
 at_xfail=no
 (
-  $as_echo "118. $at_setup_line: testing $at_desc ..."
+  $as_echo "128. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -6226,13 +6612,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_118
-#AT_START_119
-at_fn_group_banner 119 'testsuite-viennacl.at:92' \
+#AT_STOP_128
+#AT_START_129
+at_fn_group_banner 129 'testsuite-viennacl.at:92' \
   "global_variables-test-opencl" "                   " 9
 at_xfail=no
 (
-  $as_echo "119. $at_setup_line: testing $at_desc ..."
+  $as_echo "129. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -6245,22 +6631,18 @@ at_xfail=no
 esac) \
   && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:92"
 
-#This spinns on LLVM 3.6
-$as_echo "testsuite-viennacl.at:94" >"$at_check_line_file"
-(egrep -q "#define LLVM_3_6" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:94"
 
   cat $abs_top_srcdir/examples/ViennaCL/$(basename tests/global_variables-test-opencl).stdout > expout
   { set +x
-$as_echo "$at_srcdir/testsuite-viennacl.at:95: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/global_variables-test-opencl 2>&1 | sed -e ''"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:95"
+$as_echo "$at_srcdir/testsuite-viennacl.at:93: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/global_variables-test-opencl 2>&1 | sed -e ''"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:93"
 ( $at_check_trace; $abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/global_variables-test-opencl 2>&1 | sed -e ''
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:95"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:93"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -6269,37 +6651,37 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_119
-#AT_START_120
-at_fn_group_banner 120 'testsuite-viennacl.at:98' \
+#AT_STOP_129
+#AT_START_130
+at_fn_group_banner 130 'testsuite-viennacl.at:96' \
   "iterators-test-opencl" "                          " 9
 at_xfail=no
 (
-  $as_echo "120. $at_setup_line: testing $at_desc ..."
+  $as_echo "130. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-viennacl.at:98" >"$at_check_line_file"
+  $as_echo "testsuite-viennacl.at:96" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" viennacl "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:98"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:96"
 
 
   cat $abs_top_srcdir/examples/ViennaCL/$(basename tests/iterators-test-opencl).stdout > expout
   { set +x
-$as_echo "$at_srcdir/testsuite-viennacl.at:99: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/iterators-test-opencl 2>&1 | sed -e ''"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:99"
+$as_echo "$at_srcdir/testsuite-viennacl.at:97: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/iterators-test-opencl 2>&1 | sed -e ''"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:97"
 ( $at_check_trace; $abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/iterators-test-opencl 2>&1 | sed -e ''
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:99"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:97"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -6308,37 +6690,37 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_120
-#AT_START_121
-at_fn_group_banner 121 'testsuite-viennacl.at:106' \
+#AT_STOP_130
+#AT_START_131
+at_fn_group_banner 131 'testsuite-viennacl.at:104' \
   "matrix_col_double-test-opencl long" "             " 9
 at_xfail=no
 (
-  $as_echo "121. $at_setup_line: testing $at_desc ..."
+  $as_echo "131. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-viennacl.at:106" >"$at_check_line_file"
+  $as_echo "testsuite-viennacl.at:104" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" viennacl "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:106"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:104"
 
 
   cat $abs_top_srcdir/examples/ViennaCL/$(basename tests/matrix_col_double-test-opencl).stdout > expout
   { set +x
-$as_echo "$at_srcdir/testsuite-viennacl.at:107: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_col_double-test-opencl 2>&1 | sed -e ''"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:107"
+$as_echo "$at_srcdir/testsuite-viennacl.at:105: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_col_double-test-opencl 2>&1 | sed -e ''"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:105"
 ( $at_check_trace; $abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_col_double-test-opencl 2>&1 | sed -e ''
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:107"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:105"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -6347,37 +6729,37 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_121
-#AT_START_122
-at_fn_group_banner 122 'testsuite-viennacl.at:112' \
+#AT_STOP_131
+#AT_START_132
+at_fn_group_banner 132 'testsuite-viennacl.at:110' \
   "matrix_col_float-test-opencl long" "              " 9
 at_xfail=no
 (
-  $as_echo "122. $at_setup_line: testing $at_desc ..."
+  $as_echo "132. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-viennacl.at:112" >"$at_check_line_file"
+  $as_echo "testsuite-viennacl.at:110" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" viennacl "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:112"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:110"
 
 
   cat $abs_top_srcdir/examples/ViennaCL/$(basename tests/matrix_col_float-test-opencl).stdout > expout
   { set +x
-$as_echo "$at_srcdir/testsuite-viennacl.at:113: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_col_float-test-opencl 2>&1 | sed -e ''"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:113"
+$as_echo "$at_srcdir/testsuite-viennacl.at:111: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_col_float-test-opencl 2>&1 | sed -e ''"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:111"
 ( $at_check_trace; $abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_col_float-test-opencl 2>&1 | sed -e ''
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:113"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:111"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -6386,40 +6768,40 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_122
-#AT_START_123
-at_fn_group_banner 123 'testsuite-viennacl.at:118' \
+#AT_STOP_132
+#AT_START_133
+at_fn_group_banner 133 'testsuite-viennacl.at:116' \
   "matrix_col_int-test-opencl" "                     " 9
 at_xfail=no
       grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q armv && at_xfail=yes
 (
-  $as_echo "123. $at_setup_line: testing $at_desc ..."
+  $as_echo "133. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-viennacl.at:118" >"$at_check_line_file"
+  $as_echo "testsuite-viennacl.at:116" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" viennacl "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:118"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:116"
 
 #uninvestigated
 
 
   cat $abs_top_srcdir/examples/ViennaCL/$(basename tests/matrix_col_int-test-opencl).stdout > expout
   { set +x
-$as_echo "$at_srcdir/testsuite-viennacl.at:121: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_col_int-test-opencl 2>&1 | sed -e ''"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:121"
+$as_echo "$at_srcdir/testsuite-viennacl.at:119: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_col_int-test-opencl 2>&1 | sed -e ''"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:119"
 ( $at_check_trace; $abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_col_int-test-opencl 2>&1 | sed -e ''
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:121"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:119"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -6428,37 +6810,37 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_123
-#AT_START_124
-at_fn_group_banner 124 'testsuite-viennacl.at:126' \
+#AT_STOP_133
+#AT_START_134
+at_fn_group_banner 134 'testsuite-viennacl.at:124' \
   "matrix_row_double-test-opencl long" "             " 9
 at_xfail=no
 (
-  $as_echo "124. $at_setup_line: testing $at_desc ..."
+  $as_echo "134. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-viennacl.at:126" >"$at_check_line_file"
+  $as_echo "testsuite-viennacl.at:124" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" viennacl "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:126"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:124"
 
 
   cat $abs_top_srcdir/examples/ViennaCL/$(basename tests/matrix_row_double-test-opencl).stdout > expout
   { set +x
-$as_echo "$at_srcdir/testsuite-viennacl.at:127: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_row_double-test-opencl 2>&1 | sed -e ''"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:127"
+$as_echo "$at_srcdir/testsuite-viennacl.at:125: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_row_double-test-opencl 2>&1 | sed -e ''"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:125"
 ( $at_check_trace; $abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_row_double-test-opencl 2>&1 | sed -e ''
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:127"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:125"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -6467,37 +6849,37 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_124
-#AT_START_125
-at_fn_group_banner 125 'testsuite-viennacl.at:132' \
+#AT_STOP_134
+#AT_START_135
+at_fn_group_banner 135 'testsuite-viennacl.at:130' \
   "matrix_row_float-test-opencl long" "              " 9
 at_xfail=no
 (
-  $as_echo "125. $at_setup_line: testing $at_desc ..."
+  $as_echo "135. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-viennacl.at:132" >"$at_check_line_file"
+  $as_echo "testsuite-viennacl.at:130" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" viennacl "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:132"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:130"
 
 
   cat $abs_top_srcdir/examples/ViennaCL/$(basename tests/matrix_row_float-test-opencl).stdout > expout
   { set +x
-$as_echo "$at_srcdir/testsuite-viennacl.at:133: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_row_float-test-opencl 2>&1 | sed -e ''"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:133"
+$as_echo "$at_srcdir/testsuite-viennacl.at:131: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_row_float-test-opencl 2>&1 | sed -e ''"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:131"
 ( $at_check_trace; $abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_row_float-test-opencl 2>&1 | sed -e ''
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:133"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:131"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -6506,40 +6888,40 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_125
-#AT_START_126
-at_fn_group_banner 126 'testsuite-viennacl.at:138' \
+#AT_STOP_135
+#AT_START_136
+at_fn_group_banner 136 'testsuite-viennacl.at:136' \
   "matrix_row_int-test-opencl" "                     " 9
 at_xfail=no
       grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q armv && at_xfail=yes
 (
-  $as_echo "126. $at_setup_line: testing $at_desc ..."
+  $as_echo "136. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-viennacl.at:138" >"$at_check_line_file"
+  $as_echo "testsuite-viennacl.at:136" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" viennacl "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:138"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:136"
 
 #uninvestigated
 
 
   cat $abs_top_srcdir/examples/ViennaCL/$(basename tests/matrix_row_int-test-opencl).stdout > expout
   { set +x
-$as_echo "$at_srcdir/testsuite-viennacl.at:141: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_row_int-test-opencl 2>&1 | sed -e ''"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:141"
+$as_echo "$at_srcdir/testsuite-viennacl.at:139: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_row_int-test-opencl 2>&1 | sed -e ''"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:139"
 ( $at_check_trace; $abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_row_int-test-opencl 2>&1 | sed -e ''
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:141"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:139"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -6548,40 +6930,40 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_126
-#AT_START_127
-at_fn_group_banner 127 'testsuite-viennacl.at:146' \
+#AT_STOP_136
+#AT_START_137
+at_fn_group_banner 137 'testsuite-viennacl.at:144' \
   "matrix_vector_int-test-opencl" "                  " 9
 at_xfail=no
       grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q armv && at_xfail=yes
 (
-  $as_echo "127. $at_setup_line: testing $at_desc ..."
+  $as_echo "137. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-viennacl.at:146" >"$at_check_line_file"
+  $as_echo "testsuite-viennacl.at:144" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" viennacl "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:146"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:144"
 
 #uninvestigated
 
 
   cat $abs_top_srcdir/examples/ViennaCL/$(basename tests/matrix_vector_int-test-opencl).stdout > expout
   { set +x
-$as_echo "$at_srcdir/testsuite-viennacl.at:149: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_vector_int-test-opencl 2>&1 | sed -e ''"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:149"
+$as_echo "$at_srcdir/testsuite-viennacl.at:147: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_vector_int-test-opencl 2>&1 | sed -e ''"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:147"
 ( $at_check_trace; $abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_vector_int-test-opencl 2>&1 | sed -e ''
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:149"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:147"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -6590,37 +6972,37 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_127
-#AT_START_128
-at_fn_group_banner 128 'testsuite-viennacl.at:154' \
+#AT_STOP_137
+#AT_START_138
+at_fn_group_banner 138 'testsuite-viennacl.at:152' \
   "matrix_vector-test-opencl long" "                 " 9
 at_xfail=no
 (
-  $as_echo "128. $at_setup_line: testing $at_desc ..."
+  $as_echo "138. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-viennacl.at:154" >"$at_check_line_file"
+  $as_echo "testsuite-viennacl.at:152" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" viennacl "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:154"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:152"
 
 
   cat $abs_top_srcdir/examples/ViennaCL/$(basename tests/matrix_vector-test-opencl).stdout > expout
   { set +x
-$as_echo "$at_srcdir/testsuite-viennacl.at:155: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_vector-test-opencl 2>&1 | sed -e ''"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:155"
+$as_echo "$at_srcdir/testsuite-viennacl.at:153: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_vector-test-opencl 2>&1 | sed -e ''"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:153"
 ( $at_check_trace; $abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/matrix_vector-test-opencl 2>&1 | sed -e ''
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:155"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:153"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -6629,24 +7011,24 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_128
-#AT_START_129
-at_fn_group_banner 129 'testsuite-viennacl.at:158' \
+#AT_STOP_138
+#AT_START_139
+at_fn_group_banner 139 'testsuite-viennacl.at:156' \
   "nmf-test-opencl" "                                " 9
 at_xfail=yes
 (
-  $as_echo "129. $at_setup_line: testing $at_desc ..."
+  $as_echo "139. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-viennacl.at:158" >"$at_check_line_file"
+  $as_echo "testsuite-viennacl.at:156" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" viennacl "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:158"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:156"
 
 # ViennaCL borks with "Generator: Key not found in map"
 #Note: uncomment a few other tests if fixing this
@@ -6654,15 +7036,15 @@ esac) \
 
   cat $abs_top_srcdir/examples/ViennaCL/$(basename tests/nmf-test-opencl).stdout > expout
   { set +x
-$as_echo "$at_srcdir/testsuite-viennacl.at:162: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/nmf-test-opencl 2>&1 | sed -e ''"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:162"
+$as_echo "$at_srcdir/testsuite-viennacl.at:160: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/nmf-test-opencl 2>&1 | sed -e ''"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:160"
 ( $at_check_trace; $abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/nmf-test-opencl 2>&1 | sed -e ''
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:162"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:160"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -6671,37 +7053,37 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_129
-#AT_START_130
-at_fn_group_banner 130 'testsuite-viennacl.at:166' \
+#AT_STOP_139
+#AT_START_140
+at_fn_group_banner 140 'testsuite-viennacl.at:164' \
   "scalar-test-opencl" "                             " 9
 at_xfail=no
 (
-  $as_echo "130. $at_setup_line: testing $at_desc ..."
+  $as_echo "140. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-viennacl.at:166" >"$at_check_line_file"
+  $as_echo "testsuite-viennacl.at:164" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" viennacl "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:166"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:164"
 
 
   cat $abs_top_srcdir/examples/ViennaCL/$(basename tests/scalar-test-opencl).stdout > expout
   { set +x
-$as_echo "$at_srcdir/testsuite-viennacl.at:167: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/scalar-test-opencl 2>&1 | sed -e ''"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:167"
+$as_echo "$at_srcdir/testsuite-viennacl.at:165: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/scalar-test-opencl 2>&1 | sed -e ''"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:165"
 ( $at_check_trace; $abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/scalar-test-opencl 2>&1 | sed -e ''
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:167"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:165"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -6710,42 +7092,42 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_130
-#AT_START_131
-at_fn_group_banner 131 'testsuite-viennacl.at:170' \
+#AT_STOP_140
+#AT_START_141
+at_fn_group_banner 141 'testsuite-viennacl.at:168' \
   "structured-matrices-test-opencl" "                " 9
 at_xfail=no
 (
-  $as_echo "131. $at_setup_line: testing $at_desc ..."
+  $as_echo "141. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-viennacl.at:170" >"$at_check_line_file"
+  $as_echo "testsuite-viennacl.at:168" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" viennacl "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:170"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:168"
 
 #float/double precision errors. Might not even be
 #errors, the test seems to pass.
 #TODO, investigate, skip result passing with sed
-$as_echo "testsuite-viennacl.at:174" >"$at_check_line_file"
-at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:174"
+$as_echo "testsuite-viennacl.at:172" >"$at_check_line_file"
+at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:172"
 
   cat $abs_top_srcdir/examples/ViennaCL/$(basename tests/structured-matrices-test-opencl).stdout > expout
   { set +x
-$as_echo "$at_srcdir/testsuite-viennacl.at:175: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/structured-matrices-test-opencl 2>&1 | sed -e ''"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:175"
+$as_echo "$at_srcdir/testsuite-viennacl.at:173: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/structured-matrices-test-opencl 2>&1 | sed -e ''"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:173"
 ( $at_check_trace; $abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/structured-matrices-test-opencl 2>&1 | sed -e ''
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:175"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:173"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -6754,25 +7136,25 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_131
-#AT_START_132
-at_fn_group_banner 132 'testsuite-viennacl.at:178' \
+#AT_STOP_141
+#AT_START_142
+at_fn_group_banner 142 'testsuite-viennacl.at:176' \
   "vector_double-test-opencl" "                      " 9
 at_xfail=no
       egrep -q "#define LLVM_3_4" $abs_top_builddir/config.h && at_xfail=yes
 (
-  $as_echo "132. $at_setup_line: testing $at_desc ..."
+  $as_echo "142. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-viennacl.at:178" >"$at_check_line_file"
+  $as_echo "testsuite-viennacl.at:176" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" viennacl "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:178"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-viennacl.at:176"
 
 #fails with "Could not find a dominating alternative variable"
 #Note: uncomment a few other tests if fixing this
@@ -6780,15 +7162,15 @@ esac) \
 
   cat $abs_top_srcdir/examples/ViennaCL/$(basename tests/vector_double-test-opencl).stdout > expout
   { set +x
-$as_echo "$at_srcdir/testsuite-viennacl.at:182: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/vector_double-test-opencl 2>&1 | sed -e ''"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:182"
+$as_echo "$at_srcdir/testsuite-viennacl.at:180: \$abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/vector_double-test-opencl 2>&1 | sed -e ''"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-viennacl.at:180"
 ( $at_check_trace; $abs_top_builddir/examples/ViennaCL/ViennaCL-1.5.1/build/tests/vector_double-test-opencl 2>&1 | sed -e ''
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 $at_diff expout "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:182"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-viennacl.at:180"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -6797,13 +7179,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_132
-#AT_START_133
-at_fn_group_banner 133 'testsuite-rodinia.at:19' \
+#AT_STOP_142
+#AT_START_143
+at_fn_group_banner 143 'testsuite-rodinia.at:19' \
   "backprop" "                                       " 10
 at_xfail=no
 (
-  $as_echo "133. $at_setup_line: testing $at_desc ..."
+  $as_echo "143. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -6861,13 +7243,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_133
-#AT_START_134
-at_fn_group_banner 134 'testsuite-rodinia.at:31' \
+#AT_STOP_143
+#AT_START_144
+at_fn_group_banner 144 'testsuite-rodinia.at:31' \
   "bfs" "                                            " 10
 at_xfail=no
 (
-  $as_echo "134. $at_setup_line: testing $at_desc ..."
+  $as_echo "144. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -6925,13 +7307,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_134
-#AT_START_135
-at_fn_group_banner 135 'testsuite-rodinia.at:42' \
+#AT_STOP_144
+#AT_START_145
+at_fn_group_banner 145 'testsuite-rodinia.at:42' \
   "cfd" "                                            " 10
 at_xfail=no
 (
-  $as_echo "135. $at_setup_line: testing $at_desc ..."
+  $as_echo "145. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -6989,13 +7371,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_135
-#AT_START_136
-at_fn_group_banner 136 'testsuite-rodinia.at:54' \
+#AT_STOP_145
+#AT_START_146
+at_fn_group_banner 146 'testsuite-rodinia.at:54' \
   "lud" "                                            " 10
 at_xfail=no
 (
-  $as_echo "136. $at_setup_line: testing $at_desc ..."
+  $as_echo "146. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -7048,13 +7430,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_136
-#AT_START_137
-at_fn_group_banner 137 'testsuite-rodinia.at:61' \
+#AT_STOP_146
+#AT_START_147
+at_fn_group_banner 147 'testsuite-rodinia.at:61' \
   "hotspot" "                                        " 10
 at_xfail=no
 (
-  $as_echo "137. $at_setup_line: testing $at_desc ..."
+  $as_echo "147. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -7108,13 +7490,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_137
-#AT_START_138
-at_fn_group_banner 138 'testsuite-rodinia.at:69' \
+#AT_STOP_147
+#AT_START_148
+at_fn_group_banner 148 'testsuite-rodinia.at:69' \
   "kmeans" "                                         " 10
 at_xfail=no
 (
-  $as_echo "138. $at_setup_line: testing $at_desc ..."
+  $as_echo "148. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -7169,13 +7551,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_138
-#AT_START_139
-at_fn_group_banner 139 'testsuite-rodinia.at:78' \
+#AT_STOP_148
+#AT_START_149
+at_fn_group_banner 149 'testsuite-rodinia.at:78' \
   "lavaMD" "                                         " 10
 at_xfail=no
 (
-  $as_echo "139. $at_setup_line: testing $at_desc ..."
+  $as_echo "149. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -7235,13 +7617,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_139
-#AT_START_140
-at_fn_group_banner 140 'testsuite-rodinia.at:91' \
+#AT_STOP_149
+#AT_START_150
+at_fn_group_banner 150 'testsuite-rodinia.at:91' \
   "pathfinder" "                                     " 10
 at_xfail=no
 (
-  $as_echo "140. $at_setup_line: testing $at_desc ..."
+  $as_echo "150. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -7301,13 +7683,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_140
-#AT_START_141
-at_fn_group_banner 141 'testsuite-rodinia.at:102' \
+#AT_STOP_150
+#AT_START_151
+at_fn_group_banner 151 'testsuite-rodinia.at:102' \
   "srad" "                                           " 10
 at_xfail=no
 (
-  $as_echo "141. $at_setup_line: testing $at_desc ..."
+  $as_echo "151. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -7362,14 +7744,14 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_141
-#AT_START_142
-at_fn_group_banner 142 'testsuite-parboil.at:17' \
+#AT_STOP_151
+#AT_START_152
+at_fn_group_banner 152 'testsuite-parboil.at:17' \
   "spmv" "                                           " 11
 at_xfail=no
       grep -q "#define HAVE_OCL_ICD 1" $abs_top_builddir/config.h && at_xfail=yes
 (
-  $as_echo "142. $at_setup_line: testing $at_desc ..."
+  $as_echo "152. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -7420,13 +7802,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_142
-#AT_START_143
-at_fn_group_banner 143 'testsuite-parboil.at:26' \
+#AT_STOP_152
+#AT_START_153
+at_fn_group_banner 153 'testsuite-parboil.at:26' \
   "stencil" "                                        " 11
 at_xfail=no
 (
-  $as_echo "143. $at_setup_line: testing $at_desc ..."
+  $as_echo "153. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -7475,13 +7857,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_143
-#AT_START_144
-at_fn_group_banner 144 'testsuite-parboil.at:33' \
+#AT_STOP_153
+#AT_START_154
+at_fn_group_banner 154 'testsuite-parboil.at:33' \
   "tpacf" "                                          " 11
 at_xfail=yes
 (
-  $as_echo "144. $at_setup_line: testing $at_desc ..."
+  $as_echo "154. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -7535,13 +7917,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_144
-#AT_START_145
-at_fn_group_banner 145 'testsuite-parboil.at:44' \
+#AT_STOP_154
+#AT_START_155
+at_fn_group_banner 155 'testsuite-parboil.at:44' \
   "cutcp" "                                          " 11
 at_xfail=no
 (
-  $as_echo "145. $at_setup_line: testing $at_desc ..."
+  $as_echo "155. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -7590,13 +7972,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_145
-#AT_START_146
-at_fn_group_banner 146 'testsuite-parboil.at:51' \
+#AT_STOP_155
+#AT_START_156
+at_fn_group_banner 156 'testsuite-parboil.at:51' \
   "mri-gridding" "                                   " 11
 at_xfail=no
 (
-  $as_echo "146. $at_setup_line: testing $at_desc ..."
+  $as_echo "156. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -7651,13 +8033,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_146
-#AT_START_147
-at_fn_group_banner 147 'testsuite-parboil.at:63' \
+#AT_STOP_156
+#AT_START_157
+at_fn_group_banner 157 'testsuite-parboil.at:63' \
   "sad" "                                            " 11
 at_xfail=yes
 (
-  $as_echo "147. $at_setup_line: testing $at_desc ..."
+  $as_echo "157. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -7708,13 +8090,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_147
-#AT_START_148
-at_fn_group_banner 148 'testsuite-parboil.at:72' \
+#AT_STOP_157
+#AT_START_158
+at_fn_group_banner 158 'testsuite-parboil.at:72' \
   "bfs" "                                            " 11
 at_xfail=no
 (
-  $as_echo "148. $at_setup_line: testing $at_desc ..."
+  $as_echo "158. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -7770,13 +8152,13 @@ $as_echo "testsuite-parboil.at:80" >"$at_check_line_file"
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_148
-#AT_START_149
-at_fn_group_banner 149 'testsuite-parboil.at:84' \
+#AT_STOP_158
+#AT_START_159
+at_fn_group_banner 159 'testsuite-parboil.at:84' \
   "histo" "                                          " 11
 at_xfail=yes
 (
-  $as_echo "149. $at_setup_line: testing $at_desc ..."
+  $as_echo "159. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -7827,13 +8209,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_149
-#AT_START_150
-at_fn_group_banner 150 'testsuite-parboil.at:93' \
+#AT_STOP_159
+#AT_START_160
+at_fn_group_banner 160 'testsuite-parboil.at:93' \
   "sgemm" "                                          " 11
 at_xfail=no
 (
-  $as_echo "150. $at_setup_line: testing $at_desc ..."
+  $as_echo "160. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -7882,13 +8264,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_150
-#AT_START_151
-at_fn_group_banner 151 'testsuite-parboil.at:100' \
+#AT_STOP_160
+#AT_START_161
+at_fn_group_banner 161 'testsuite-parboil.at:100' \
   "mri-q" "                                          " 11
 at_xfail=no
 (
-  $as_echo "151. $at_setup_line: testing $at_desc ..."
+  $as_echo "161. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -7937,13 +8319,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_151
-#AT_START_152
-at_fn_group_banner 152 'testsuite-parboil.at:107' \
+#AT_STOP_161
+#AT_START_162
+at_fn_group_banner 162 'testsuite-parboil.at:107' \
   "lbm" "                                            " 11
 at_xfail=no
 (
-  $as_echo "152. $at_setup_line: testing $at_desc ..."
+  $as_echo "162. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -7993,13 +8375,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_152
-#AT_START_153
-at_fn_group_banner 153 'testsuite-amd.at:11' \
+#AT_STOP_162
+#AT_START_163
+at_fn_group_banner 163 'testsuite-amd.at:11' \
   "aesencryptdecrypt-repl" "                         " 12
 at_xfail=no
 (
-  $as_echo "153. $at_setup_line: testing $at_desc ..."
+  $as_echo "163. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -8039,13 +8421,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_153
-#AT_START_154
-at_fn_group_banner 154 'testsuite-amd.at:19' \
+#AT_STOP_163
+#AT_START_164
+at_fn_group_banner 164 'testsuite-amd.at:19' \
   "aesencryptdecrypt-loops" "                        " 12
 at_xfail=no
 (
-  $as_echo "154. $at_setup_line: testing $at_desc ..."
+  $as_echo "164. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -8081,13 +8463,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_154
-#AT_START_155
-at_fn_group_banner 155 'testsuite-amd.at:25' \
+#AT_STOP_164
+#AT_START_165
+at_fn_group_banner 165 'testsuite-amd.at:25' \
   "atomiccounters" "                                 " 12
 at_xfail=yes
 (
-  $as_echo "155. $at_setup_line: testing $at_desc ..."
+  $as_echo "165. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -8125,13 +8507,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_155
-#AT_START_156
-at_fn_group_banner 156 'testsuite-amd.at:33' \
+#AT_STOP_165
+#AT_START_166
+at_fn_group_banner 166 'testsuite-amd.at:33' \
   "bitonicsort" "                                    " 12
 at_xfail=no
 (
-  $as_echo "156. $at_setup_line: testing $at_desc ..."
+  $as_echo "166. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -8167,13 +8549,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_156
-#AT_START_157
-at_fn_group_banner 157 'testsuite-amd.at:39' \
+#AT_STOP_166
+#AT_START_167
+at_fn_group_banner 167 'testsuite-amd.at:39' \
   "binarysearch" "                                   " 12
 at_xfail=no
 (
-  $as_echo "157. $at_setup_line: testing $at_desc ..."
+  $as_echo "167. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -8209,15 +8591,15 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_157
-#AT_START_158
-at_fn_group_banner 158 'testsuite-amd.at:45' \
+#AT_STOP_167
+#AT_START_168
+at_fn_group_banner 168 'testsuite-amd.at:45' \
   "binomialoption-repl" "                            " 12
 at_xfail=no
       grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc &&
              grep -q "define LLVM_3_2" $abs_top_builddir/config.h && at_xfail=yes
 (
-  $as_echo "158. $at_setup_line: testing $at_desc ..."
+  $as_echo "168. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -8254,13 +8636,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_158
-#AT_START_159
-at_fn_group_banner 159 'testsuite-amd.at:53' \
+#AT_STOP_168
+#AT_START_169
+at_fn_group_banner 169 'testsuite-amd.at:53' \
   "binomialoption-loops" "                           " 12
 at_xfail=no
 (
-  $as_echo "159. $at_setup_line: testing $at_desc ..."
+  $as_echo "169. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -8296,13 +8678,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_159
-#AT_START_160
-at_fn_group_banner 160 'testsuite-amd.at:59' \
+#AT_STOP_169
+#AT_START_170
+at_fn_group_banner 170 'testsuite-amd.at:59' \
   "blackscholes" "                                   " 12
 at_xfail=no
 (
-  $as_echo "160. $at_setup_line: testing $at_desc ..."
+  $as_echo "170. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -8338,9 +8720,9 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_160
-#AT_START_161
-at_fn_group_banner 161 'testsuite-amd.at:65' \
+#AT_STOP_170
+#AT_START_171
+at_fn_group_banner 171 'testsuite-amd.at:65' \
   "blackscholesdp" "                                 " 12
 at_xfail=no
       grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc && at_xfail=yes
@@ -8348,7 +8730,7 @@ at_xfail=no
              (grep -q "define LLVM_3_2" $abs_top_builddir/config.h ||
               grep -q "define LLVM_3_3" $abs_top_builddir/config.h ) && at_xfail=yes
 (
-  $as_echo "161. $at_setup_line: testing $at_desc ..."
+  $as_echo "171. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -8391,13 +8773,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_161
-#AT_START_162
-at_fn_group_banner 162 'testsuite-amd.at:78' \
+#AT_STOP_171
+#AT_START_172
+at_fn_group_banner 172 'testsuite-amd.at:78' \
   "boxfilter" "                                      " 12
 at_xfail=no
 (
-  $as_echo "162. $at_setup_line: testing $at_desc ..."
+  $as_echo "172. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -8434,13 +8816,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_162
-#AT_START_163
-at_fn_group_banner 163 'testsuite-amd.at:85' \
+#AT_STOP_172
+#AT_START_173
+at_fn_group_banner 173 'testsuite-amd.at:85' \
   "dct" "                                            " 12
 at_xfail=no
 (
-  $as_echo "163. $at_setup_line: testing $at_desc ..."
+  $as_echo "173. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -8480,13 +8862,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_163
-#AT_START_164
-at_fn_group_banner 164 'testsuite-amd.at:93' \
+#AT_STOP_173
+#AT_START_174
+at_fn_group_banner 174 'testsuite-amd.at:93' \
   "devicefission" "                                  " 12
 at_xfail=no
 (
-  $as_echo "164. $at_setup_line: testing $at_desc ..."
+  $as_echo "174. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -8522,14 +8904,14 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_164
-#AT_START_165
-at_fn_group_banner 165 'testsuite-amd.at:99' \
+#AT_STOP_174
+#AT_START_175
+at_fn_group_banner 175 'testsuite-amd.at:99' \
   "dwthaar1d" "                                      " 12
 at_xfail=no
       egrep -q "#define LLVM_3_4" $abs_top_builddir/config.h && at_xfail=yes
 (
-  $as_echo "165. $at_setup_line: testing $at_desc ..."
+  $as_echo "175. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -8568,13 +8950,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_165
-#AT_START_166
-at_fn_group_banner 166 'testsuite-amd.at:108' \
+#AT_STOP_175
+#AT_START_176
+at_fn_group_banner 176 'testsuite-amd.at:108' \
   "fastwalshtransform" "                             " 12
 at_xfail=no
 (
-  $as_echo "166. $at_setup_line: testing $at_desc ..."
+  $as_echo "176. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -8610,13 +8992,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_166
-#AT_START_167
-at_fn_group_banner 167 'testsuite-amd.at:114' \
+#AT_STOP_176
+#AT_START_177
+at_fn_group_banner 177 'testsuite-amd.at:114' \
   "floydwarshall" "                                  " 12
 at_xfail=no
 (
-  $as_echo "167. $at_setup_line: testing $at_desc ..."
+  $as_echo "177. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -8652,13 +9034,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_167
-#AT_START_168
-at_fn_group_banner 168 'testsuite-amd.at:120' \
+#AT_STOP_177
+#AT_START_178
+at_fn_group_banner 178 'testsuite-amd.at:120' \
   "fluidsimulation2d" "                              " 12
 at_xfail=yes
 (
-  $as_echo "168. $at_setup_line: testing $at_desc ..."
+  $as_echo "178. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -8699,13 +9081,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_168
-#AT_START_169
-at_fn_group_banner 169 'testsuite-amd.at:131' \
+#AT_STOP_178
+#AT_START_179
+at_fn_group_banner 179 'testsuite-amd.at:131' \
   "helloworld" "                                     " 12
 at_xfail=no
 (
-  $as_echo "169. $at_setup_line: testing $at_desc ..."
+  $as_echo "179. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -8742,13 +9124,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_169
-#AT_START_170
-at_fn_group_banner 170 'testsuite-amd.at:138' \
+#AT_STOP_179
+#AT_START_180
+at_fn_group_banner 180 'testsuite-amd.at:138' \
   "histogram-repl" "                                 " 12
 at_xfail=no
 (
-  $as_echo "170. $at_setup_line: testing $at_desc ..."
+  $as_echo "180. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -8784,13 +9166,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_170
-#AT_START_171
-at_fn_group_banner 171 'testsuite-amd.at:144' \
+#AT_STOP_180
+#AT_START_181
+at_fn_group_banner 181 'testsuite-amd.at:144' \
   "histogram-loops" "                                " 12
 at_xfail=no
 (
-  $as_echo "171. $at_setup_line: testing $at_desc ..."
+  $as_echo "181. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -8826,13 +9208,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_171
-#AT_START_172
-at_fn_group_banner 172 'testsuite-amd.at:150' \
+#AT_STOP_181
+#AT_START_182
+at_fn_group_banner 182 'testsuite-amd.at:150' \
   "imageoverlap" "                                   " 12
 at_xfail=no
 (
-  $as_echo "172. $at_setup_line: testing $at_desc ..."
+  $as_echo "182. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -8871,9 +9253,9 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_172
-#AT_START_173
-at_fn_group_banner 173 'testsuite-amd.at:158' \
+#AT_STOP_182
+#AT_START_183
+at_fn_group_banner 183 'testsuite-amd.at:158' \
   "ludecomposition" "                                " 12
 at_xfail=no
       grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc && at_xfail=yes
@@ -8881,7 +9263,7 @@ at_xfail=no
              (grep -q "define LLVM_3_2" $abs_top_builddir/config.h ||
               grep -q "define LLVM_3_3" $abs_top_builddir/config.h ) && at_xfail=yes
 (
-  $as_echo "173. $at_setup_line: testing $at_desc ..."
+  $as_echo "183. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -8921,13 +9303,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_173
-#AT_START_174
-at_fn_group_banner 174 'testsuite-amd.at:170' \
+#AT_STOP_183
+#AT_START_184
+at_fn_group_banner 184 'testsuite-amd.at:170' \
   "mandelbrot" "                                     " 12
 at_xfail=no
 (
-  $as_echo "174. $at_setup_line: testing $at_desc ..."
+  $as_echo "184. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -8967,13 +9349,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_174
-#AT_START_175
-at_fn_group_banner 175 'testsuite-amd.at:178' \
+#AT_STOP_184
+#AT_START_185
+at_fn_group_banner 185 'testsuite-amd.at:178' \
   "matrixmul" "                                      " 12
 at_xfail=no
 (
-  $as_echo "175. $at_setup_line: testing $at_desc ..."
+  $as_echo "185. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -9013,13 +9395,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_175
-#AT_START_176
-at_fn_group_banner 176 'testsuite-amd.at:186' \
+#AT_STOP_185
+#AT_START_186
+at_fn_group_banner 186 'testsuite-amd.at:186' \
   "matrixmulimage" "                                 " 12
 at_xfail=no
 (
-  $as_echo "176. $at_setup_line: testing $at_desc ..."
+  $as_echo "186. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -9055,13 +9437,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_176
-#AT_START_177
-at_fn_group_banner 177 'testsuite-amd.at:192' \
+#AT_STOP_186
+#AT_START_187
+at_fn_group_banner 187 'testsuite-amd.at:192' \
   "matrixtranspose" "                                " 12
 at_xfail=no
 (
-  $as_echo "177. $at_setup_line: testing $at_desc ..."
+  $as_echo "187. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -9097,13 +9479,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_177
-#AT_START_178
-at_fn_group_banner 178 'testsuite-amd.at:198' \
+#AT_STOP_187
+#AT_START_188
+at_fn_group_banner 188 'testsuite-amd.at:198' \
   "memorymodel-repl" "                               " 12
 at_xfail=no
 (
-  $as_echo "178. $at_setup_line: testing $at_desc ..."
+  $as_echo "188. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -9139,13 +9521,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_178
-#AT_START_179
-at_fn_group_banner 179 'testsuite-amd.at:204' \
+#AT_STOP_188
+#AT_START_189
+at_fn_group_banner 189 'testsuite-amd.at:204' \
   "memorymodel-loops" "                              " 12
 at_xfail=no
 (
-  $as_echo "179. $at_setup_line: testing $at_desc ..."
+  $as_echo "189. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -9181,15 +9563,13 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_179
-#AT_START_180
-at_fn_group_banner 180 'testsuite-amd.at:210' \
+#AT_STOP_189
+#AT_START_190
+at_fn_group_banner 190 'testsuite-amd.at:210' \
   "montecarloasian" "                                " 12
 at_xfail=no
-      grep -q "#define LLVM_3_5" $abs_top_builddir/config.h && at_xfail=yes
-      grep -q "#define LLVM_3_6" $abs_top_builddir/config.h && at_xfail=yes
 (
-  $as_echo "180. $at_setup_line: testing $at_desc ..."
+  $as_echo "190. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
@@ -9206,15 +9586,9 @@ esac) \
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
   && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:210"
 
-# kernel compilation fails due to
-# error: can't convert between vector values of different size ('float4' and 'int')
-# It should be a legal implicit conversion according to 6.3 Operators. Works also with Intel OCL
-# Seems this is a regression in LLVM 3.5
-
-
 { set +x
-$as_echo "$at_srcdir/testsuite-amd.at:217: make test_MonteCarloAsian -sC \$abs_top_builddir/examples/AMD | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:217"
+$as_echo "$at_srcdir/testsuite-amd.at:211: make test_MonteCarloAsian -sC \$abs_top_builddir/examples/AMD | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:211"
 ( $at_check_trace; make test_MonteCarloAsian -sC $abs_top_builddir/examples/AMD | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -9223,7 +9597,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:217"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:211"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -9231,36 +9605,36 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_180
-#AT_START_181
-at_fn_group_banner 181 'testsuite-amd.at:222' \
+#AT_STOP_190
+#AT_START_191
+at_fn_group_banner 191 'testsuite-amd.at:216' \
   "montecarloasiandp" "                              " 12
 at_xfail=yes
 (
-  $as_echo "181. $at_setup_line: testing $at_desc ..."
+  $as_echo "191. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amd.at:222" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:216" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amd "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:222"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:216"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amd.at:222" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:216" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:222"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:216"
 
 
 # error: can't convert between vector values of different size ('double4' and 'int')
 # It should be a legal implicit conversion according to 6.3 Operators. Works also with Intel OCL
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amd.at:227: make test_MonteCarloAsianDP -sC \$abs_top_builddir/examples/AMD | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:227"
+$as_echo "$at_srcdir/testsuite-amd.at:221: make test_MonteCarloAsianDP -sC \$abs_top_builddir/examples/AMD | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:221"
 ( $at_check_trace; make test_MonteCarloAsianDP -sC $abs_top_builddir/examples/AMD | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -9269,7 +9643,7 @@ echo stderr:; cat "$at_stderr"
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:227"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:221"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -9277,35 +9651,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_181
-#AT_START_182
-at_fn_group_banner 182 'testsuite-amd.at:232' \
+#AT_STOP_191
+#AT_START_192
+at_fn_group_banner 192 'testsuite-amd.at:226' \
   "nbody" "                                          " 12
 at_xfail=no
 (
-  $as_echo "182. $at_setup_line: testing $at_desc ..."
+  $as_echo "192. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amd.at:232" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:226" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amd "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:232"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:226"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amd.at:232" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:226" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:232"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:226"
 
-$as_echo "testsuite-amd.at:233" >"$at_check_line_file"
+$as_echo "testsuite-amd.at:227" >"$at_check_line_file"
 ( grep "undef HAVE_GLEW" $abs_top_builddir/config.h ) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:233"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:227"
 { set +x
-$as_echo "$at_srcdir/testsuite-amd.at:234: make test_NBody -sC \$abs_top_builddir/examples/AMD | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:234"
+$as_echo "$at_srcdir/testsuite-amd.at:228: make test_NBody -sC \$abs_top_builddir/examples/AMD | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:228"
 ( $at_check_trace; make test_NBody -sC $abs_top_builddir/examples/AMD | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -9314,7 +9688,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:234"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:228"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -9322,32 +9696,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_182
-#AT_START_183
-at_fn_group_banner 183 'testsuite-amd.at:239' \
+#AT_STOP_192
+#AT_START_193
+at_fn_group_banner 193 'testsuite-amd.at:233' \
   "prefixsum" "                                      " 12
 at_xfail=no
 (
-  $as_echo "183. $at_setup_line: testing $at_desc ..."
+  $as_echo "193. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amd.at:239" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:233" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amd "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:239"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:233"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amd.at:239" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:233" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:239"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:233"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amd.at:240: make test_PrefixSum -sC \$abs_top_builddir/examples/AMD | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:240"
+$as_echo "$at_srcdir/testsuite-amd.at:234: make test_PrefixSum -sC \$abs_top_builddir/examples/AMD | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:234"
 ( $at_check_trace; make test_PrefixSum -sC $abs_top_builddir/examples/AMD | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -9356,7 +9730,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:240"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:234"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -9364,32 +9738,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_183
-#AT_START_184
-at_fn_group_banner 184 'testsuite-amd.at:245' \
+#AT_STOP_193
+#AT_START_194
+at_fn_group_banner 194 'testsuite-amd.at:239' \
   "quasirandomsequence" "                            " 12
 at_xfail=no
 (
-  $as_echo "184. $at_setup_line: testing $at_desc ..."
+  $as_echo "194. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amd.at:245" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:239" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amd "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:245"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:239"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amd.at:245" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:239" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:245"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:239"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amd.at:246: make test_QuasiRandomSequence -sC \$abs_top_builddir/examples/AMD | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:246"
+$as_echo "$at_srcdir/testsuite-amd.at:240: make test_QuasiRandomSequence -sC \$abs_top_builddir/examples/AMD | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:240"
 ( $at_check_trace; make test_QuasiRandomSequence -sC $abs_top_builddir/examples/AMD | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -9398,7 +9772,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:246"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:240"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -9406,32 +9780,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_184
-#AT_START_185
-at_fn_group_banner 185 'testsuite-amd.at:251' \
+#AT_STOP_194
+#AT_START_195
+at_fn_group_banner 195 'testsuite-amd.at:245' \
   "radixsort" "                                      " 12
 at_xfail=no
 (
-  $as_echo "185. $at_setup_line: testing $at_desc ..."
+  $as_echo "195. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amd.at:251" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:245" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amd "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:251"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:245"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amd.at:251" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:245" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:251"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:245"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amd.at:252: make test_RadixSort -sC \$abs_top_builddir/examples/AMD | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:252"
+$as_echo "$at_srcdir/testsuite-amd.at:246: make test_RadixSort -sC \$abs_top_builddir/examples/AMD | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:246"
 ( $at_check_trace; make test_RadixSort -sC $abs_top_builddir/examples/AMD | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -9440,7 +9814,7 @@ echo stderr:; cat "$at_stderr"
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:252"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:246"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -9448,32 +9822,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_185
-#AT_START_186
-at_fn_group_banner 186 'testsuite-amd.at:257' \
+#AT_STOP_195
+#AT_START_196
+at_fn_group_banner 196 'testsuite-amd.at:251' \
   "recursivegaussian" "                              " 12
 at_xfail=no
 (
-  $as_echo "186. $at_setup_line: testing $at_desc ..."
+  $as_echo "196. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amd.at:257" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:251" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amd "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:257"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:251"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amd.at:257" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:251" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:257"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:251"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amd.at:258: make test_RecursiveGaussian -sC \$abs_top_builddir/examples/AMD | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:258"
+$as_echo "$at_srcdir/testsuite-amd.at:252: make test_RecursiveGaussian -sC \$abs_top_builddir/examples/AMD | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:252"
 ( $at_check_trace; make test_RecursiveGaussian -sC $abs_top_builddir/examples/AMD | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -9482,7 +9856,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:258"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:252"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -9490,32 +9864,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_186
-#AT_START_187
-at_fn_group_banner 187 'testsuite-amd.at:263' \
+#AT_STOP_196
+#AT_START_197
+at_fn_group_banner 197 'testsuite-amd.at:257' \
   "reduction" "                                      " 12
 at_xfail=no
 (
-  $as_echo "187. $at_setup_line: testing $at_desc ..."
+  $as_echo "197. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amd.at:263" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:257" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amd "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:263"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:257"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amd.at:263" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:257" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:263"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:257"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amd.at:264: make test_Reduction -sC \$abs_top_builddir/examples/AMD | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:264"
+$as_echo "$at_srcdir/testsuite-amd.at:258: make test_Reduction -sC \$abs_top_builddir/examples/AMD | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:258"
 ( $at_check_trace; make test_Reduction -sC $abs_top_builddir/examples/AMD | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -9524,7 +9898,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:264"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:258"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -9532,33 +9906,33 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_187
-#AT_START_188
-at_fn_group_banner 188 'testsuite-amd.at:269' \
+#AT_STOP_197
+#AT_START_198
+at_fn_group_banner 198 'testsuite-amd.at:263' \
   "scanlargearrays" "                                " 12
 at_xfail=no
 (
-  $as_echo "188. $at_setup_line: testing $at_desc ..."
+  $as_echo "198. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amd.at:269" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:263" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amd "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:269"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:263"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amd.at:269" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:263" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:269"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:263"
 
 # Fails with vectorization. With wiloops and no unrolling, the vectorization won't apply.
 { set +x
-$as_echo "$at_srcdir/testsuite-amd.at:271: make test_ScanLargeArrays -sC \$abs_top_builddir/examples/AMD | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:271"
+$as_echo "$at_srcdir/testsuite-amd.at:265: make test_ScanLargeArrays -sC \$abs_top_builddir/examples/AMD | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:265"
 ( $at_check_trace; make test_ScanLargeArrays -sC $abs_top_builddir/examples/AMD | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -9567,7 +9941,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:271"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:265"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -9575,32 +9949,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_188
-#AT_START_189
-at_fn_group_banner 189 'testsuite-amd.at:276' \
+#AT_STOP_198
+#AT_START_199
+at_fn_group_banner 199 'testsuite-amd.at:270' \
   "simpleconvolution" "                              " 12
 at_xfail=no
 (
-  $as_echo "189. $at_setup_line: testing $at_desc ..."
+  $as_echo "199. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amd.at:276" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:270" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amd "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:276"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:270"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amd.at:276" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:270" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:276"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:270"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amd.at:277: make test_SimpleConvolution -sC \$abs_top_builddir/examples/AMD | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:277"
+$as_echo "$at_srcdir/testsuite-amd.at:271: make test_SimpleConvolution -sC \$abs_top_builddir/examples/AMD | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:271"
 ( $at_check_trace; make test_SimpleConvolution -sC $abs_top_builddir/examples/AMD | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -9609,7 +9983,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:277"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:271"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -9617,32 +9991,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_189
-#AT_START_190
-at_fn_group_banner 190 'testsuite-amd.at:282' \
+#AT_STOP_199
+#AT_START_200
+at_fn_group_banner 200 'testsuite-amd.at:276' \
   "simpleimage" "                                    " 12
 at_xfail=no
 (
-  $as_echo "190. $at_setup_line: testing $at_desc ..."
+  $as_echo "200. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amd.at:282" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:276" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amd "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:282"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:276"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amd.at:282" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:276" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:282"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:276"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amd.at:283: make test_SimpleImage -sC \$abs_top_builddir/examples/AMD | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:283"
+$as_echo "$at_srcdir/testsuite-amd.at:277: make test_SimpleImage -sC \$abs_top_builddir/examples/AMD | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:277"
 ( $at_check_trace; make test_SimpleImage -sC $abs_top_builddir/examples/AMD | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -9652,7 +10026,7 @@ echo >>"$at_stdout"; $as_echo "Verifying 2D copy result - Passed!
 Verifying 3D copy result - Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:283"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:277"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -9660,32 +10034,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_190
-#AT_START_191
-at_fn_group_banner 191 'testsuite-amd.at:289' \
+#AT_STOP_200
+#AT_START_201
+at_fn_group_banner 201 'testsuite-amd.at:283' \
   "sobelfilter" "                                    " 12
 at_xfail=no
 (
-  $as_echo "191. $at_setup_line: testing $at_desc ..."
+  $as_echo "201. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amd.at:289" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:283" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amd "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:289"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:283"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amd.at:289" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:283" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:289"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:283"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amd.at:290: make test_SobelFilter -sC \$abs_top_builddir/examples/AMD | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:290"
+$as_echo "$at_srcdir/testsuite-amd.at:284: make test_SobelFilter -sC \$abs_top_builddir/examples/AMD | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:284"
 ( $at_check_trace; make test_SobelFilter -sC $abs_top_builddir/examples/AMD | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -9694,7 +10068,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:290"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:284"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -9702,32 +10076,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_191
-#AT_START_192
-at_fn_group_banner 192 'testsuite-amd.at:295' \
+#AT_STOP_201
+#AT_START_202
+at_fn_group_banner 202 'testsuite-amd.at:289' \
   "template" "                                       " 12
 at_xfail=no
 (
-  $as_echo "192. $at_setup_line: testing $at_desc ..."
+  $as_echo "202. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amd.at:295" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:289" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amd "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:295"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:289"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amd.at:295" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:289" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:295"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:289"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amd.at:296: make test_Template -sC \$abs_top_builddir/examples/AMD | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:296"
+$as_echo "$at_srcdir/testsuite-amd.at:290: make test_Template -sC \$abs_top_builddir/examples/AMD | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:290"
 ( $at_check_trace; make test_Template -sC $abs_top_builddir/examples/AMD | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -9736,7 +10110,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:296"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:290"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -9744,32 +10118,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_192
-#AT_START_193
-at_fn_group_banner 193 'testsuite-amd.at:301' \
+#AT_STOP_202
+#AT_START_203
+at_fn_group_banner 203 'testsuite-amd.at:295' \
   "templatec" "                                      " 12
 at_xfail=no
 (
-  $as_echo "193. $at_setup_line: testing $at_desc ..."
+  $as_echo "203. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amd.at:301" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:295" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amd "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:301"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:295"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amd.at:301" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:295" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:301"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:295"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amd.at:302: make test_TemplateC -sC \$abs_top_builddir/examples/AMD | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:302"
+$as_echo "$at_srcdir/testsuite-amd.at:296: make test_TemplateC -sC \$abs_top_builddir/examples/AMD | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:296"
 ( $at_check_trace; make test_TemplateC -sC $abs_top_builddir/examples/AMD | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -9778,7 +10152,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:302"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:296"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -9786,34 +10160,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_193
-#AT_START_194
-at_fn_group_banner 194 'testsuite-amd.at:307' \
+#AT_STOP_203
+#AT_START_204
+at_fn_group_banner 204 'testsuite-amd.at:301' \
   "transferoverlap" "                                " 12
-at_xfail=yes
+at_xfail=no
 (
-  $as_echo "194. $at_setup_line: testing $at_desc ..."
+  $as_echo "204. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amd.at:307" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:301" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amd "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:307"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:301"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amd.at:307" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:301" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:307"
-
-# Expected Error: Device does not support cl_khr_local_int32_base_atomics extension!
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:301"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amd.at:310: make test_TransferOverlap -sC \$abs_top_builddir/examples/AMD | grep \"Passed\""
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:310"
+$as_echo "$at_srcdir/testsuite-amd.at:302: make test_TransferOverlap -sC \$abs_top_builddir/examples/AMD | grep \"Passed\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:302"
 ( $at_check_trace; make test_TransferOverlap -sC $abs_top_builddir/examples/AMD | grep "Passed"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -9822,7 +10194,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:310"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:302"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -9830,32 +10202,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_194
-#AT_START_195
-at_fn_group_banner 195 'testsuite-amd.at:315' \
+#AT_STOP_204
+#AT_START_205
+at_fn_group_banner 205 'testsuite-amd.at:307' \
   "urng" "                                           " 12
 at_xfail=no
 (
-  $as_echo "195. $at_setup_line: testing $at_desc ..."
+  $as_echo "205. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amd.at:315" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:307" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amd "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:315"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:307"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amd.at:315" >"$at_check_line_file"
+  $as_echo "testsuite-amd.at:307" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:315"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amd.at:307"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amd.at:316: make test_URNG -sC \$abs_top_builddir/examples/AMD | grep Passed | cut -c -7"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:316"
+$as_echo "$at_srcdir/testsuite-amd.at:308: make test_URNG -sC \$abs_top_builddir/examples/AMD | grep Passed | cut -c -7"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amd.at:308"
 ( $at_check_trace; make test_URNG -sC $abs_top_builddir/examples/AMD | grep Passed | cut -c -7
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -9864,7 +10236,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:316"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amd.at:308"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -9872,35 +10244,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_195
-#AT_START_196
-at_fn_group_banner 196 'testsuite-amdsdk2_9.at:11' \
+#AT_STOP_205
+#AT_START_206
+at_fn_group_banner 206 'testsuite-amdsdk2_9.at:20' \
   "asyncdatatransfer" "                              " 13
 at_xfail=no
 (
-  $as_echo "196. $at_setup_line: testing $at_desc ..."
+  $as_echo "206. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:11" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:20" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:11"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:20"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:11" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:20" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:11"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:20"
 
 # needs asynch properties implemented
-$as_echo "testsuite-amdsdk2_9.at:13" >"$at_check_line_file"
-at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:13"
+$as_echo "testsuite-amdsdk2_9.at:22" >"$at_check_line_file"
+at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:22"
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:14: make test_AsyncDataTransfer -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep \"Passed\" | sed -e 's/^ \\t*//'"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:14"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:23: make test_AsyncDataTransfer -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep \"Passed\" | sed -e 's/^ \\t*//'"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:23"
 ( $at_check_trace; make test_AsyncDataTransfer -sC $abs_top_builddir/examples/AMDSDK2.9 | grep "Passed" | sed -e 's/^ \t*//'
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -9910,7 +10282,7 @@ echo >>"$at_stdout"; $as_echo "SyncKernel verification  : Passed!
 AsyncKernel verification : Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:14"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:23"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -9918,34 +10290,34 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_196
-#AT_START_197
-at_fn_group_banner 197 'testsuite-amdsdk2_9.at:20' \
+#AT_STOP_206
+#AT_START_207
+at_fn_group_banner 207 'testsuite-amdsdk2_9.at:29' \
   "atomiccounters" "                                 " 13
 at_xfail=yes
 (
-  $as_echo "197. $at_setup_line: testing $at_desc ..."
+  $as_echo "207. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:20" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:29" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:20"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:29"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:20" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:29" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:20"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:29"
 
 # Expected Error: Device does not support cl_ext_atomic_counters_32 extension!
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:23: make test_AtomicCounters -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep \"Encryption Passed\""
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:23"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:32: make test_AtomicCounters -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep \"Encryption Passed\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:32"
 ( $at_check_trace; make test_AtomicCounters -sC $abs_top_builddir/examples/AMDSDK2.9 | grep "Encryption Passed"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -9954,7 +10326,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Encryption Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:23"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:32"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -9962,39 +10334,39 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_197
-#AT_START_198
-at_fn_group_banner 198 'testsuite-amdsdk2_9.at:28' \
+#AT_STOP_207
+#AT_START_208
+at_fn_group_banner 208 'testsuite-amdsdk2_9.at:37' \
   "basicdebug" "                                     " 13
 at_xfail=no
 (
-  $as_echo "198. $at_setup_line: testing $at_desc ..."
+  $as_echo "208. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:28" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:37" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:28"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:37"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:28" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:37" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:28"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:37"
 
 # This tests debugging features by executing a kernel that writes
 # out of bounds of a local array. No point testing it here as the
 # result should be undefined (basic device crashes, pthread device
 # silently passes). It passes if the kernel's local array size is
 # increased so there is no out of bounds error.
-$as_echo "testsuite-amdsdk2_9.at:34" >"$at_check_line_file"
-at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:34"
+$as_echo "testsuite-amdsdk2_9.at:43" >"$at_check_line_file"
+at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:43"
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:35: make test_BasicDebug -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:35"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:44: make test_BasicDebug -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:44"
 ( $at_check_trace; make test_BasicDebug -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -10003,7 +10375,7 @@ echo stderr:; cat "$at_stderr"
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:35"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:44"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -10011,32 +10383,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_198
-#AT_START_199
-at_fn_group_banner 199 'testsuite-amdsdk2_9.at:40' \
+#AT_STOP_208
+#AT_START_209
+at_fn_group_banner 209 'testsuite-amdsdk2_9.at:49' \
   "binarysearch" "                                   " 13
 at_xfail=no
 (
-  $as_echo "199. $at_setup_line: testing $at_desc ..."
+  $as_echo "209. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:40" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:49" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:40"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:49"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:40" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:49" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:40"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:49"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:41: make test_BinarySearch -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:41"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:50: make test_BinarySearch -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:50"
 ( $at_check_trace; make test_BinarySearch -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -10045,7 +10417,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:41"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:50"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -10053,35 +10425,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_199
-#AT_START_200
-at_fn_group_banner 200 'testsuite-amdsdk2_9.at:46' \
+#AT_STOP_209
+#AT_START_210
+at_fn_group_banner 210 'testsuite-amdsdk2_9.at:55' \
   "binomialoption-repl" "                            " 13
 at_xfail=no
       grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc &&
              grep -q "define LLVM_3_2" $abs_top_builddir/config.h && at_xfail=yes
 (
-  $as_echo "200. $at_setup_line: testing $at_desc ..."
+  $as_echo "210. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:46" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:55" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:46"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:55"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:46" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:55" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:46"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:55"
 
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:49: POCL_WORK_GROUP_METHOD=repl make test_BinomialOption -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:49"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:58: POCL_WORK_GROUP_METHOD=repl make test_BinomialOption -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:58"
 ( $at_check_trace; POCL_WORK_GROUP_METHOD=repl make test_BinomialOption -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -10090,7 +10462,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:49"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:58"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -10098,32 +10470,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_200
-#AT_START_201
-at_fn_group_banner 201 'testsuite-amdsdk2_9.at:54' \
+#AT_STOP_210
+#AT_START_211
+at_fn_group_banner 211 'testsuite-amdsdk2_9.at:63' \
   "binomialoption-loops" "                           " 13
 at_xfail=no
 (
-  $as_echo "201. $at_setup_line: testing $at_desc ..."
+  $as_echo "211. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:54" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:63" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:54"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:63"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:54" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:63" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:54"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:63"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:55: POCL_WORK_GROUP_METHOD=loops make test_BinomialOption -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:55"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:64: POCL_WORK_GROUP_METHOD=loops make test_BinomialOption -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:64"
 ( $at_check_trace; POCL_WORK_GROUP_METHOD=loops make test_BinomialOption -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -10132,7 +10504,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:55"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:64"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -10140,35 +10512,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_201
-#AT_START_202
-at_fn_group_banner 202 'testsuite-amdsdk2_9.at:60' \
+#AT_STOP_211
+#AT_START_212
+at_fn_group_banner 212 'testsuite-amdsdk2_9.at:69' \
   "binomialoptionmultigpu" "                         " 13
 at_xfail=no
 (
-  $as_echo "202. $at_setup_line: testing $at_desc ..."
+  $as_echo "212. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:60" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:69" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:60"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:69"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:60" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:69" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:60"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:69"
 
-$as_echo "testsuite-amdsdk2_9.at:61" >"$at_check_line_file"
+$as_echo "testsuite-amdsdk2_9.at:70" >"$at_check_line_file"
 ( ! test -e $abs_top_builddir/examples/AMDSDK2.9/AMD-APP-SDK-v2.9-RC-lnx64/samples/opencl/cl/BinomialOptionMultiGPU/bin/x86_64/Release/BinomialOptionMultiGPU) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:61"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:70"
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:62: make test_BinomialOptionMultiGPU -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:62"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:71: make test_BinomialOptionMultiGPU -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:71"
 ( $at_check_trace; make test_BinomialOptionMultiGPU -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -10177,7 +10549,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:62"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:71"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -10185,32 +10557,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_202
-#AT_START_203
-at_fn_group_banner 203 'testsuite-amdsdk2_9.at:67' \
+#AT_STOP_212
+#AT_START_213
+at_fn_group_banner 213 'testsuite-amdsdk2_9.at:76' \
   "bitonicsort" "                                    " 13
 at_xfail=no
 (
-  $as_echo "203. $at_setup_line: testing $at_desc ..."
+  $as_echo "213. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:67" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:76" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:67"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:76"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:67" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:76" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:67"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:76"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:68: make test_BitonicSort -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:68"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:77: make test_BitonicSort -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:77"
 ( $at_check_trace; make test_BitonicSort -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -10219,7 +10591,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:68"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:77"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -10227,32 +10599,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_203
-#AT_START_204
-at_fn_group_banner 204 'testsuite-amdsdk2_9.at:73' \
+#AT_STOP_213
+#AT_START_214
+at_fn_group_banner 214 'testsuite-amdsdk2_9.at:82' \
   "blackscholes" "                                   " 13
 at_xfail=no
 (
-  $as_echo "204. $at_setup_line: testing $at_desc ..."
+  $as_echo "214. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:73" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:82" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:73"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:82"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:73" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:82" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:73"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:82"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:74: make test_BlackScholes -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:74"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:83: make test_BlackScholes -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:83"
 ( $at_check_trace; make test_BlackScholes -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -10261,7 +10633,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:74"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:83"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -10269,41 +10641,41 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_204
-#AT_START_205
-at_fn_group_banner 205 'testsuite-amdsdk2_9.at:79' \
+#AT_STOP_214
+#AT_START_215
+at_fn_group_banner 215 'testsuite-amdsdk2_9.at:88' \
   "blackscholesdp" "                                 " 13
 at_xfail=no
       grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc && at_xfail=yes
       grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q armv && at_xfail=yes
 (
-  $as_echo "205. $at_setup_line: testing $at_desc ..."
+  $as_echo "215. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:79" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:88" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:79"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:88"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:79" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:88" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:79"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:88"
 
 
 #this causes assert on LLVM 3.1
-$as_echo "testsuite-amdsdk2_9.at:82" >"$at_check_line_file"
+$as_echo "testsuite-amdsdk2_9.at:91" >"$at_check_line_file"
 ( grep "#define LLVM_3_1" $abs_top_builddir/config.h ) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:82"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:91"
 
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:85: make test_BlackScholesDP -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:85"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:94: make test_BlackScholesDP -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:94"
 ( $at_check_trace; make test_BlackScholesDP -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -10312,7 +10684,7 @@ echo stderr:; cat "$at_stderr"
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:85"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:94"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -10320,32 +10692,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_205
-#AT_START_206
-at_fn_group_banner 206 'testsuite-amdsdk2_9.at:90' \
+#AT_STOP_215
+#AT_START_216
+at_fn_group_banner 216 'testsuite-amdsdk2_9.at:99' \
   "boxfilter" "                                      " 13
 at_xfail=no
 (
-  $as_echo "206. $at_setup_line: testing $at_desc ..."
+  $as_echo "216. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:90" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:99" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:90"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:99"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:90" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:99" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:90"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:99"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:91: make test_BoxFilter -sC \$abs_top_builddir/examples/AMDSDK2.9 | egrep \"Passed|failed\""
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:91"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:100: make test_BoxFilter -sC \$abs_top_builddir/examples/AMDSDK2.9 | egrep \"Passed|failed\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:100"
 ( $at_check_trace; make test_BoxFilter -sC $abs_top_builddir/examples/AMDSDK2.9 | egrep "Passed|failed"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -10355,7 +10727,7 @@ echo >>"$at_stdout"; $as_echo "Passed!
 Verifying results...Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:91"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:100"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -10363,34 +10735,34 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_206
-#AT_START_207
-at_fn_group_banner 207 'testsuite-amdsdk2_9.at:97' \
+#AT_STOP_216
+#AT_START_217
+at_fn_group_banner 217 'testsuite-amdsdk2_9.at:106' \
   "boxfilterGL" "                                    " 13
 at_xfail=yes
 (
-  $as_echo "207. $at_setup_line: testing $at_desc ..."
+  $as_echo "217. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:97" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:106" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:97"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:106"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:97" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:106" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:97"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:106"
 
 # doesnt work
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:100: make test_BoxFilterGL -sC \$abs_top_builddir/examples/AMDSDK2.9 | egrep \"Passed|failed\""
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:100"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:109: make test_BoxFilterGL -sC \$abs_top_builddir/examples/AMDSDK2.9 | egrep \"Passed|failed\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:109"
 ( $at_check_trace; make test_BoxFilterGL -sC $abs_top_builddir/examples/AMDSDK2.9 | egrep "Passed|failed"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -10400,7 +10772,7 @@ echo >>"$at_stdout"; $as_echo "Passed!
 Verifying results...Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:100"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:109"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -10408,34 +10780,34 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_207
-#AT_START_208
-at_fn_group_banner 208 'testsuite-amdsdk2_9.at:106' \
+#AT_STOP_217
+#AT_START_218
+at_fn_group_banner 218 'testsuite-amdsdk2_9.at:115' \
   "bufferbandwidth" "                                " 13
 at_xfail=no
 (
-  $as_echo "208. $at_setup_line: testing $at_desc ..."
+  $as_echo "218. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:106" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:115" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:106"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:115"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:106" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:115" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:106"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:115"
 
 # Device does not support cl_khr_local_int32_base_atomics extension!
 # AT_XFAIL_IF(true)
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:109: make test_BufferBandwidth -sC \$abs_top_builddir/examples/AMDSDK2.9 | egrep \"Passed|failed\""
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:109"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:118: make test_BufferBandwidth -sC \$abs_top_builddir/examples/AMDSDK2.9 | egrep \"Passed|failed\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:118"
 ( $at_check_trace; make test_BufferBandwidth -sC $abs_top_builddir/examples/AMDSDK2.9 | egrep "Passed|failed"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -10446,7 +10818,7 @@ echo >>"$at_stdout"; $as_echo " Verification Passed!
 Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:109"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:118"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -10454,34 +10826,34 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_208
-#AT_START_209
-at_fn_group_banner 209 'testsuite-amdsdk2_9.at:116' \
+#AT_STOP_218
+#AT_START_219
+at_fn_group_banner 219 'testsuite-amdsdk2_9.at:125' \
   "bufferImageInterop" "                             " 13
 at_xfail=yes
 (
-  $as_echo "209. $at_setup_line: testing $at_desc ..."
+  $as_echo "219. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:116" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:125" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:116"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:125"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:116" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:125" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:116"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:125"
 
 # Error: Selected device doesn't support Buffer-Image
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:119: make test_BufferImageInterop -sC \$abs_top_builddir/examples/AMDSDK2.9 | egrep \"Passed|failed\""
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:119"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:128: make test_BufferImageInterop -sC \$abs_top_builddir/examples/AMDSDK2.9 | egrep \"Passed|failed\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:128"
 ( $at_check_trace; make test_BufferImageInterop -sC $abs_top_builddir/examples/AMDSDK2.9 | egrep "Passed|failed"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -10491,7 +10863,7 @@ echo >>"$at_stdout"; $as_echo "Passed!
 Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:119"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:128"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -10499,32 +10871,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_209
-#AT_START_210
-at_fn_group_banner 210 'testsuite-amdsdk2_9.at:125' \
+#AT_STOP_219
+#AT_START_220
+at_fn_group_banner 220 'testsuite-amdsdk2_9.at:134' \
   "concurrentkernel" "                               " 13
 at_xfail=no
 (
-  $as_echo "210. $at_setup_line: testing $at_desc ..."
+  $as_echo "220. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:125" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:134" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:125"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:134"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:125" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:134" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:125"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:134"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:126: make test_ConcurrentKernel -sC \$abs_top_builddir/examples/AMDSDK2.9 | egrep \"Passed|failed\""
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:126"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:135: make test_ConcurrentKernel -sC \$abs_top_builddir/examples/AMDSDK2.9 | egrep \"Passed|failed\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:135"
 ( $at_check_trace; make test_ConcurrentKernel -sC $abs_top_builddir/examples/AMDSDK2.9 | egrep "Passed|failed"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -10534,7 +10906,7 @@ echo >>"$at_stdout"; $as_echo " Sequential Kernel verification : Passed!
  Concurrent Kernel verification : Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:126"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:135"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -10542,32 +10914,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_210
-#AT_START_211
-at_fn_group_banner 211 'testsuite-amdsdk2_9.at:132' \
+#AT_STOP_220
+#AT_START_221
+at_fn_group_banner 221 'testsuite-amdsdk2_9.at:141' \
   "constantbandwidth" "                              " 13
 at_xfail=no
 (
-  $as_echo "211. $at_setup_line: testing $at_desc ..."
+  $as_echo "221. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:132" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:141" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:132"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:141"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:132" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:141" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:132"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:141"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:133: make test_ConstantBandwidth -sC \$abs_top_builddir/examples/AMDSDK2.9 | egrep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:133"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:142: make test_ConstantBandwidth -sC \$abs_top_builddir/examples/AMDSDK2.9 | egrep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:142"
 ( $at_check_trace; make test_ConstantBandwidth -sC $abs_top_builddir/examples/AMDSDK2.9 | egrep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -10579,7 +10951,7 @@ Passed!
 Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:133"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:142"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -10587,32 +10959,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_211
-#AT_START_212
-at_fn_group_banner 212 'testsuite-amdsdk2_9.at:141' \
+#AT_STOP_221
+#AT_START_222
+at_fn_group_banner 222 'testsuite-amdsdk2_9.at:150' \
   "cpluspluswrapper" "                               " 13
 at_xfail=no
 (
-  $as_echo "212. $at_setup_line: testing $at_desc ..."
+  $as_echo "222. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:141" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:150" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:141"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:150"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:141" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:150" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:141"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:150"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:142: make test_CplusplusWrapper -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:142"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:151: make test_CplusplusWrapper -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:151"
 ( $at_check_trace; make test_CplusplusWrapper -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -10621,7 +10993,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:142"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:151"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -10629,32 +11001,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_212
-#AT_START_213
-at_fn_group_banner 213 'testsuite-amdsdk2_9.at:147' \
+#AT_STOP_222
+#AT_START_223
+at_fn_group_banner 223 'testsuite-amdsdk2_9.at:156' \
   "dct" "                                            " 13
 at_xfail=no
 (
-  $as_echo "213. $at_setup_line: testing $at_desc ..."
+  $as_echo "223. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:147" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:156" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:147"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:156"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:147" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:156" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:147"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:156"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:148: make test_DCT -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:148"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:157: make test_DCT -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:157"
 ( $at_check_trace; make test_DCT -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -10663,7 +11035,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:148"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:157"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -10671,32 +11043,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_213
-#AT_START_214
-at_fn_group_banner 214 'testsuite-amdsdk2_9.at:153' \
+#AT_STOP_223
+#AT_START_224
+at_fn_group_banner 224 'testsuite-amdsdk2_9.at:162' \
   "devicefission" "                                  " 13
 at_xfail=no
 (
-  $as_echo "214. $at_setup_line: testing $at_desc ..."
+  $as_echo "224. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:153" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:162" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:153"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:162"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:153" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:162" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:153"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:162"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:154: make test_DeviceFission -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:154"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:163: make test_DeviceFission -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:163"
 ( $at_check_trace; make test_DeviceFission -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -10705,7 +11077,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:154"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:163"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -10713,34 +11085,34 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_214
-#AT_START_215
-at_fn_group_banner 215 'testsuite-amdsdk2_9.at:159' \
+#AT_STOP_224
+#AT_START_225
+at_fn_group_banner 225 'testsuite-amdsdk2_9.at:168' \
   "devicefission11ext" "                             " 13
 at_xfail=yes
 (
-  $as_echo "215. $at_setup_line: testing $at_desc ..."
+  $as_echo "225. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:159" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:168" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:159"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:168"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:159" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:168" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:159"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:168"
 
 # Expected Error: Device does not support cl_ext_device_fission extension!
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:162: make test_DeviceFission11Ext -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:162"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:171: make test_DeviceFission11Ext -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:171"
 ( $at_check_trace; make test_DeviceFission11Ext -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -10749,7 +11121,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:162"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:171"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -10757,36 +11129,36 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_215
-#AT_START_216
-at_fn_group_banner 216 'testsuite-amdsdk2_9.at:167' \
+#AT_STOP_225
+#AT_START_226
+at_fn_group_banner 226 'testsuite-amdsdk2_9.at:176' \
   "dwthaar1d" "                                      " 13
 at_xfail=no
       egrep -q "#define LLVM_3_4" $abs_top_builddir/config.h && at_xfail=yes
 (
-  $as_echo "216. $at_setup_line: testing $at_desc ..."
+  $as_echo "226. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:167" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:176" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:167"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:176"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:167" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:176" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:167"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:176"
 
 # 3.5 introduced the noduplicate attribute which, when
 # used with barrier(), fixes this.
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:171: make test_DwtHaar1D -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:171"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:180: make test_DwtHaar1D -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:180"
 ( $at_check_trace; make test_DwtHaar1D -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -10795,7 +11167,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:171"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:180"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -10803,34 +11175,34 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_216
-#AT_START_217
-at_fn_group_banner 217 'testsuite-amdsdk2_9.at:176' \
+#AT_STOP_226
+#AT_START_227
+at_fn_group_banner 227 'testsuite-amdsdk2_9.at:185' \
   "dwthaar1dcppkernel" "                             " 13
 at_xfail=yes
 (
-  $as_echo "217. $at_setup_line: testing $at_desc ..."
+  $as_echo "227. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:176" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:185" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:176"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:185"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:176" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:185" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:176"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:185"
 
 # Error: clBuildProgram failed. Error code : CL_INVALID_BUILD_OPTIONS (-x clc++)
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:179: make test_DwtHaar1DCPPKernel -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:179"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:188: make test_DwtHaar1DCPPKernel -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:188"
 ( $at_check_trace; make test_DwtHaar1DCPPKernel -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -10839,7 +11211,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:179"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:188"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -10847,34 +11219,34 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_217
-#AT_START_218
-at_fn_group_banner 218 'testsuite-amdsdk2_9.at:184' \
+#AT_STOP_227
+#AT_START_228
+at_fn_group_banner 228 'testsuite-amdsdk2_9.at:193' \
   "eigenvalue" "                                     " 13
 at_xfail=yes
 (
-  $as_echo "218. $at_setup_line: testing $at_desc ..."
+  $as_echo "228. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:184" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:193" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:184"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:193"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:184" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:193" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:184"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:193"
 
 # Error: clBuildProgram failed. Error code : CL_INVALID_BUILD_OPTIONS (-x clc++)
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:187: make test_EigenValue -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:187"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:196: make test_EigenValue -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:196"
 ( $at_check_trace; make test_EigenValue -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -10883,7 +11255,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:187"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:196"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -10891,32 +11263,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_218
-#AT_START_219
-at_fn_group_banner 219 'testsuite-amdsdk2_9.at:192' \
+#AT_STOP_228
+#AT_START_229
+at_fn_group_banner 229 'testsuite-amdsdk2_9.at:201' \
   "fastwalshtransform" "                             " 13
 at_xfail=no
 (
-  $as_echo "219. $at_setup_line: testing $at_desc ..."
+  $as_echo "229. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:192" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:201" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:192"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:201"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:192" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:201" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:192"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:201"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:193: make test_FastWalshTransform -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:193"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:202: make test_FastWalshTransform -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:202"
 ( $at_check_trace; make test_FastWalshTransform -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -10925,7 +11297,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:193"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:202"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -10933,32 +11305,32 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_219
-#AT_START_220
-at_fn_group_banner 220 'testsuite-amdsdk2_9.at:198' \
+#AT_STOP_229
+#AT_START_230
+at_fn_group_banner 230 'testsuite-amdsdk2_9.at:207' \
   "floydwarshall" "                                  " 13
 at_xfail=no
 (
-  $as_echo "220. $at_setup_line: testing $at_desc ..."
+  $as_echo "230. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:198" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:207" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:198"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:207"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:198" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:207" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:198"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:207"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:199: make test_FloydWarshall -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:199"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:208: make test_FloydWarshall -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:208"
 ( $at_check_trace; make test_FloydWarshall -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -10967,7 +11339,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:199"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:208"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -10975,35 +11347,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_220
-#AT_START_221
-at_fn_group_banner 221 'testsuite-amdsdk2_9.at:204' \
+#AT_STOP_230
+#AT_START_231
+at_fn_group_banner 231 'testsuite-amdsdk2_9.at:213' \
   "fft" "                                            " 13
 at_xfail=no
 (
-  $as_echo "221. $at_setup_line: testing $at_desc ..."
+  $as_echo "231. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:204" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:213" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:204"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:213"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:204" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:213" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:204"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:213"
 
 # Build parameter clc++ not supported
-$as_echo "testsuite-amdsdk2_9.at:206" >"$at_check_line_file"
-at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:206"
+$as_echo "testsuite-amdsdk2_9.at:215" >"$at_check_line_file"
+at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:215"
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:207: make test_FFT -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:207"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:216: make test_FFT -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:216"
 ( $at_check_trace; make test_FFT -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -11012,7 +11384,7 @@ at_fn_diff_devnull "$at_stderr" || at_failed=:
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:207"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:216"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -11020,28 +11392,28 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_221
-#AT_START_222
-at_fn_group_banner 222 'testsuite-amdsdk2_9.at:212' \
+#AT_STOP_231
+#AT_START_232
+at_fn_group_banner 232 'testsuite-amdsdk2_9.at:221' \
   "fluidsimulation2d" "                              " 13
 at_xfail=yes
 (
-  $as_echo "222. $at_setup_line: testing $at_desc ..."
+  $as_echo "232. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:212" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:221" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
   *" amdsdk2_9 "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:212"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:221"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:212" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:221" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:212"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:221"
 
 # error: can't convert between vector values of different size ('uint' (aka 'unsigned int') and 'int8')
 # It should be a legal implicit conversion according to 6.3 Operators. Some other error makes it
@@ -11049,8 +11421,8 @@ esac) \
 
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:218: make test_FluidSimulation2D -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:218"
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:227: make test_FluidSimulation2D -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:227"
 ( $at_check_trace; make test_FluidSimulation2D -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
@@ -11059,7 +11431,7 @@ echo stderr:; cat "$at_stderr"
 echo >>"$at_stdout"; $as_echo "Passed!
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:218"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:227"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -11067,41 +11439,2659 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_222
-#AT_START_223
-at_fn_group_banner 223 'testsuite-amdsdk2_9.at:223' \
+#AT_STOP_232
+#AT_START_233
+at_fn_group_banner 233 'testsuite-amdsdk2_9.at:232' \
   "gaussiannoise" "                                  " 13
 at_xfail=no
 (
-  $as_echo "223. $at_setup_line: testing $at_desc ..."
+  $as_echo "233. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:232" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:232"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:232" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:232"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:233: make test_GaussianNoise -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed | sed 's/ //g'"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:233"
+( $at_check_trace; make test_GaussianNoise -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed | sed 's/ //g'
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:233"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_233
+#AT_START_234
+at_fn_group_banner 234 'testsuite-amdsdk2_9.at:238' \
+  "gaussiannoisegl" "                                " 13
+at_xfail=no
+(
+  $as_echo "234. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:238" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:238"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:238" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:238"
+
+#doesnt work
+$as_echo "testsuite-amdsdk2_9.at:240" >"$at_check_line_file"
+at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:240"
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:241: make test_GaussianNoiseGL -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:241"
+( $at_check_trace; make test_GaussianNoiseGL -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:241"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_234
+#AT_START_235
+at_fn_group_banner 235 'testsuite-amdsdk2_9.at:253' \
+  "hdrtonemapping" "                                 " 13
+at_xfail=no
+(
+  $as_echo "235. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:253" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:253"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:253" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:253"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:254: make test_HDRToneMapping -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:254"
+( $at_check_trace; make test_HDRToneMapping -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+echo stderr:; cat "$at_stderr"
+echo >>"$at_stdout"; $as_echo "Passed!!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:254"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_235
+#AT_START_236
+at_fn_group_banner 236 'testsuite-amdsdk2_9.at:259' \
+  "helloworld" "                                     " 13
+at_xfail=no
+(
+  $as_echo "236. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:223" >"$at_check_line_file"
+  $as_echo "testsuite-amdsdk2_9.at:259" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:259"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:259" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:259"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:260: make test_HelloWorld -sC \$abs_top_builddir/examples/AMDSDK2.9 | egrep \"GdkknVnqkc|HelloWorld\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:260"
+( $at_check_trace; make test_HelloWorld -sC $abs_top_builddir/examples/AMDSDK2.9 | egrep "GdkknVnqkc|HelloWorld"
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "GdkknVnqkc
+HelloWorld
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:260"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_236
+#AT_START_237
+at_fn_group_banner 237 'testsuite-amdsdk2_9.at:266' \
+  "histogram-repl" "                                 " 13
+at_xfail=no
+(
+  $as_echo "237. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:266" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:266"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:266" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:266"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:267: POCL_WORK_GROUP_METHOD=repl make test_Histogram -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:267"
+( $at_check_trace; POCL_WORK_GROUP_METHOD=repl make test_Histogram -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:267"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_237
+#AT_START_238
+at_fn_group_banner 238 'testsuite-amdsdk2_9.at:272' \
+  "histogram-loops" "                                " 13
+at_xfail=no
+(
+  $as_echo "238. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:272" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:272"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:272" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:272"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:273: POCL_WORK_GROUP_METHOD=loops make test_Histogram -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:273"
+( $at_check_trace; POCL_WORK_GROUP_METHOD=loops make test_Histogram -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:273"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_238
+#AT_START_239
+at_fn_group_banner 239 'testsuite-amdsdk2_9.at:278' \
+  "histogramatomic" "                                " 13
+at_xfail=no
+(
+  $as_echo "239. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:278" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:278"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:278" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:278"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:279: make test_HistogramAtomics -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:279"
+( $at_check_trace; make test_HistogramAtomics -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:279"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_239
+#AT_START_240
+at_fn_group_banner 240 'testsuite-amdsdk2_9.at:284' \
+  "imagebandwidth" "                                 " 13
+at_xfail=no
+(
+  $as_echo "240. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:284" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:284"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:284" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:284"
+
+# AT_SKIP_IF(true)
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:286: make test_ImageBandwidth -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:286"
+( $at_check_trace; make test_ImageBandwidth -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:286"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_240
+#AT_START_241
+at_fn_group_banner 241 'testsuite-amdsdk2_9.at:292' \
+  "imageoverlap" "                                   " 13
+at_xfail=no
+(
+  $as_echo "241. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:292" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:292"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:292" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:292"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:293: make test_ImageOverlap -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:293"
+( $at_check_trace; make test_ImageOverlap -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Verifying result - Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:293"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_241
+#AT_START_242
+at_fn_group_banner 242 'testsuite-amdsdk2_9.at:298' \
+  "introstatickcppkernel" "                          " 13
+at_xfail=yes
+(
+  $as_echo "242. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:298" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:298"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:298" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:298"
+
+# Error: clBuildProgram failed. Error code : CL_INVALID_BUILD_OPTIONS (-x clc++)
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:301: make test_IntroStaticCPPKernel -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:301"
+( $at_check_trace; make test_IntroStaticCPPKernel -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Verifying result - Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:301"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_242
+#AT_START_243
+at_fn_group_banner 243 'testsuite-amdsdk2_9.at:306' \
+  "kernellauch" "                                    " 13
+at_xfail=no
+(
+  $as_echo "243. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:306" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:306"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:306" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:306"
+
+# Device does not support cl_khr_local_int32_base_atomics extension!
+# works anyway
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:309: make test_KernelLaunch -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed!"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:309"
+( $at_check_trace; make test_KernelLaunch -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed!
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:309"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_243
+#AT_START_244
+at_fn_group_banner 244 'testsuite-amdsdk2_9.at:314' \
+  "kmeansautoclustering" "                           " 13
+at_xfail=yes
+(
+  $as_echo "244. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:314" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:314"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:314" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:314"
+
+# doesn't find opencl library for some reason
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:317: make test_KmeansAutoclustering -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:317"
+( $at_check_trace; make test_KmeansAutoclustering -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:317"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_244
+#AT_START_245
+at_fn_group_banner 245 'testsuite-amdsdk2_9.at:323' \
+  "ldsbandwidth" "                                   " 13
+at_xfail=no
+(
+  $as_echo "245. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:323" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:323"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:323" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:323"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:324: make test_LDSBandwidth -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:324"
+( $at_check_trace; make test_LDSBandwidth -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+Passed!
+Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:324"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_245
+#AT_START_246
+at_fn_group_banner 246 'testsuite-amdsdk2_9.at:331' \
+  "ludecomposition" "                                " 13
+at_xfail=no
+      grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc && at_xfail=yes
+      grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q armv && at_xfail=yes
+(
+  $as_echo "246. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:331" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:331"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:331" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:331"
+
+
+#test uses doubles
+
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:336: make test_LUDecomposition -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:336"
+( $at_check_trace; make test_LUDecomposition -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+echo stderr:; cat "$at_stderr"
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:336"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_246
+#AT_START_247
+at_fn_group_banner 247 'testsuite-amdsdk2_9.at:341' \
+  "mandelbrot" "                                     " 13
+at_xfail=no
+(
+  $as_echo "247. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:341" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:341"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:341" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:341"
+
+$as_echo "testsuite-amdsdk2_9.at:342" >"$at_check_line_file"
+( grep "undef HAVE_GLEW" $abs_top_builddir/config.h ) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:342"
+$as_echo "testsuite-amdsdk2_9.at:343" >"$at_check_line_file"
+( ! test -e $abs_top_builddir/examples/AMDSDK2.9/AMD-APP-SDK-v2.9-RC-lnx64/samples/opencl/cl/Mandelbrot/bin/x86_64/Release/Mandelbrot) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:343"
+# undefined symbol: _Z7std_fmaDv4_fS_S_ with VML
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:345: make test_Mandelbrot -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:345"
+( $at_check_trace; make test_Mandelbrot -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+echo stderr:; cat "$at_stderr"
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:345"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_247
+#AT_START_248
+at_fn_group_banner 248 'testsuite-amdsdk2_9.at:350' \
+  "matrixmuldouble" "                                " 13
+at_xfail=no
+(
+  $as_echo "248. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:350" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:350"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:350" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:350"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:351: make test_MatrixMulDouble -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:351"
+( $at_check_trace; make test_MatrixMulDouble -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:351"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_248
+#AT_START_249
+at_fn_group_banner 249 'testsuite-amdsdk2_9.at:356' \
+  "matrixmulimage" "                                 " 13
+at_xfail=no
+(
+  $as_echo "249. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:356" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:356"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:356" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:356"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:357: make test_MatrixMulImage -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:357"
+( $at_check_trace; make test_MatrixMulImage -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+echo stderr:; cat "$at_stderr"
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:357"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_249
+#AT_START_250
+at_fn_group_banner 250 'testsuite-amdsdk2_9.at:362' \
+  "matrixmultiplication" "                           " 13
+at_xfail=no
+(
+  $as_echo "250. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:362" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:362"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:362" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:362"
+
+# pocl error: encountered unimplemented part of the OpenCL specs in clCreateImage2D.c:119
+#AT_XFAIL_IF(true)
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:365: make test_MatrixMultiplication -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:365"
+( $at_check_trace; make test_MatrixMultiplication -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:365"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_250
+#AT_START_251
+at_fn_group_banner 251 'testsuite-amdsdk2_9.at:370' \
+  "matrixtranspose" "                                " 13
+at_xfail=no
+(
+  $as_echo "251. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:370" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:370"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:370" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:370"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:371: make test_MatrixTranspose -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:371"
+( $at_check_trace; make test_MatrixTranspose -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:371"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_251
+#AT_START_252
+at_fn_group_banner 252 'testsuite-amdsdk2_9.at:376' \
+  "memorymodel-repl" "                               " 13
+at_xfail=no
+(
+  $as_echo "252. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:376" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:376"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:376" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:376"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:377: POCL_WORK_GROUP_METHOD=repl make test_MemoryModel -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:377"
+( $at_check_trace; POCL_WORK_GROUP_METHOD=repl make test_MemoryModel -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:377"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_252
+#AT_START_253
+at_fn_group_banner 253 'testsuite-amdsdk2_9.at:382' \
+  "memorymodel-loops" "                              " 13
+at_xfail=no
+(
+  $as_echo "253. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:382" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:382"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:382" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:382"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:383: POCL_WORK_GROUP_METHOD=loops make test_MemoryModel -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:383"
+( $at_check_trace; POCL_WORK_GROUP_METHOD=loops make test_MemoryModel -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:383"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_253
+#AT_START_254
+at_fn_group_banner 254 'testsuite-amdsdk2_9.at:388' \
+  "memoryoptimizations" "                            " 13
+at_xfail=no
+(
+  $as_echo "254. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:388" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:388"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:388" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:388"
+
+#Device does not support global_int32_base_atomics
+#AT_SKIP_IF(true)
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:391: make test_MemoryOptimizations -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:391"
+( $at_check_trace; make test_MemoryOptimizations -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+echo stderr:; cat "$at_stderr"
+echo >>"$at_stdout"; $as_echo "Passed!
+Passed!
+Passed!
+Passed!
+Passed!
+Passed!
+Passed!
+Passed!
+Passed!
+Passed!
+Passed!
+Passed!
+Passed!
+Passed!
+Passed!
+Passed!
+Passed!
+Passed!
+Passed!
+Passed!
+Passed!
+Passed!
+Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:391"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_254
+#AT_START_255
+at_fn_group_banner 255 'testsuite-amdsdk2_9.at:418' \
+  "merzennetwister" "                                " 13
+at_xfail=no
+(
+  $as_echo "255. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:418" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:418"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:418" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:418"
+
+#Build parameter clc++ is not supported
+$as_echo "testsuite-amdsdk2_9.at:420" >"$at_check_line_file"
+at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:420"
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:421: make test_MersenneTwister -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:421"
+( $at_check_trace; make test_MersenneTwister -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+echo stderr:; cat "$at_stderr"
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:421"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_255
+#AT_START_256
+at_fn_group_banner 256 'testsuite-amdsdk2_9.at:426' \
+  "montecarloasian" "                                " 13
+at_xfail=yes
+(
+  $as_echo "256. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:426" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:426"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:426" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:426"
+
+# kernel compilation fails due to
+# error: can't convert between vector values of different size ('float4' and 'int')
+# It should be a legal implicit conversion according to 6.3 Operators. Works also with Intel OCL
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:431: make test_MonteCarloAsian -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:431"
+( $at_check_trace; make test_MonteCarloAsian -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:431"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_256
+#AT_START_257
+at_fn_group_banner 257 'testsuite-amdsdk2_9.at:436' \
+  "montecarloasiandp" "                              " 13
+at_xfail=yes
+(
+  $as_echo "257. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:436" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:436"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:436" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:436"
+
+
+# error: can't convert between vector values of different size ('double4' and 'int')
+# It should be a legal implicit conversion according to 6.3 Operators. Works also with Intel OCL
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:441: make test_MonteCarloAsianDP -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:441"
+( $at_check_trace; make test_MonteCarloAsianDP -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+echo stderr:; cat "$at_stderr"
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:441"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_257
+#AT_START_258
+at_fn_group_banner 258 'testsuite-amdsdk2_9.at:446' \
+  "montecarloasianmultigpu" "                        " 13
+at_xfail=no
+(
+  $as_echo "258. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:446" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:446"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:446" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:446"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:447: make test_MonteCarloAsianMultiGPU -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:447"
+( $at_check_trace; make test_MonteCarloAsianMultiGPU -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:447"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_258
+#AT_START_259
+at_fn_group_banner 259 'testsuite-amdsdk2_9.at:452' \
+  "nbody" "                                          " 13
+at_xfail=no
+(
+  $as_echo "259. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:452" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:452"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:452" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:452"
+
+$as_echo "testsuite-amdsdk2_9.at:453" >"$at_check_line_file"
+( grep "undef HAVE_GLEW" $abs_top_builddir/config.h ) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:453"
+$as_echo "testsuite-amdsdk2_9.at:454" >"$at_check_line_file"
+( ! test -e $abs_top_builddir/examples/AMDSDK2.9/AMD-APP-SDK-v2.9-RC-lnx64/samples/opencl/cl/NBody/bin/x86_64/Release/NBody) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:454"
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:455: make test_NBody -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:455"
+( $at_check_trace; make test_NBody -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:455"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_259
+#AT_START_260
+at_fn_group_banner 260 'testsuite-amdsdk2_9.at:460' \
+  "prefixsum" "                                      " 13
+at_xfail=no
+(
+  $as_echo "260. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:460" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:460"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:460" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:460"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:461: make test_PrefixSum -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:461"
+( $at_check_trace; make test_PrefixSum -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:461"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_260
+#AT_START_261
+at_fn_group_banner 261 'testsuite-amdsdk2_9.at:466' \
+  "quasirandomsequence" "                            " 13
+at_xfail=no
+(
+  $as_echo "261. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:466" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:466"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:466" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:466"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:467: make test_QuasiRandomSequence -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:467"
+( $at_check_trace; make test_QuasiRandomSequence -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:467"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_261
+#AT_START_262
+at_fn_group_banner 262 'testsuite-amdsdk2_9.at:472' \
+  "radixsort" "                                      " 13
+at_xfail=no
+(
+  $as_echo "262. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:472" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:472"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:472" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:472"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:473: make test_RadixSort -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:473"
+( $at_check_trace; make test_RadixSort -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+echo stderr:; cat "$at_stderr"
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:473"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_262
+#AT_START_263
+at_fn_group_banner 263 'testsuite-amdsdk2_9.at:478' \
+  "recursivegaussian" "                              " 13
+at_xfail=no
+(
+  $as_echo "263. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:478" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:478"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:478" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:478"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:479: make test_RecursiveGaussian -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:479"
+( $at_check_trace; make test_RecursiveGaussian -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:479"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_263
+#AT_START_264
+at_fn_group_banner 264 'testsuite-amdsdk2_9.at:484' \
+  "reduction" "                                      " 13
+at_xfail=no
+(
+  $as_echo "264. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:484" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:484"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:484" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:484"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:485: make test_Reduction -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:485"
+( $at_check_trace; make test_Reduction -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:485"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_264
+#AT_START_265
+at_fn_group_banner 265 'testsuite-amdsdk2_9.at:490' \
+  "scanlargearrays" "                                " 13
+at_xfail=no
+(
+  $as_echo "265. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:490" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:490"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:490" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:490"
+
+# Fails with vectorization. With wiloops and no unrolling, the vectorization won't apply.
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:492: make test_ScanLargeArrays -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:492"
+( $at_check_trace; make test_ScanLargeArrays -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:492"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_265
+#AT_START_266
+at_fn_group_banner 266 'testsuite-amdsdk2_9.at:497' \
+  "simpleconvolution" "                              " 13
+at_xfail=no
+(
+  $as_echo "266. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:497" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:497"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:497" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:497"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:498: make test_SimpleConvolution -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:498"
+( $at_check_trace; make test_SimpleConvolution -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:498"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_266
+#AT_START_267
+at_fn_group_banner 267 'testsuite-amdsdk2_9.at:503' \
+  "simplegl" "                                       " 13
+at_xfail=yes
+(
+  $as_echo "267. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:503" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:503"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:503" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:503"
+
+# doesn't find opecl library
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:506: make test_SimpleGL -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:506"
+( $at_check_trace; make test_SimpleGL -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:506"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_267
+#AT_START_268
+at_fn_group_banner 268 'testsuite-amdsdk2_9.at:511' \
+  "simpleimage" "                                    " 13
+at_xfail=no
+(
+  $as_echo "268. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:511" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:511"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:511" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:511"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:512: make test_SimpleImage -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:512"
+( $at_check_trace; make test_SimpleImage -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Verifying 2D copy result - Passed!
+Verifying 3D copy result - Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:512"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_268
+#AT_START_269
+at_fn_group_banner 269 'testsuite-amdsdk2_9.at:518' \
+  "soaversusaos" "                                   " 13
+at_xfail=no
+(
+  $as_echo "269. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:518" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:518"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:518" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:518"
+
+#Build Options are : -x clc++ -D num1=4096 -D num2=4096
+#Error: clBuildProgram failed. Error code : CL_INVALID_BUILD_OPTIONS
+$as_echo "testsuite-amdsdk2_9.at:521" >"$at_check_line_file"
+at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:521"
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:522: make test_SoAversusAoS -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:522"
+( $at_check_trace; make test_SoAversusAoS -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:522"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_269
+#AT_START_270
+at_fn_group_banner 270 'testsuite-amdsdk2_9.at:527' \
+  "sobelfilter" "                                    " 13
+at_xfail=no
+(
+  $as_echo "270. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:527" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:527"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:527" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:527"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:528: make test_SobelFilter -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:528"
+( $at_check_trace; make test_SobelFilter -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:528"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_270
+#AT_START_271
+at_fn_group_banner 271 'testsuite-amdsdk2_9.at:533' \
+  "sobelfilterimage" "                               " 13
+at_xfail=yes
+(
+  $as_echo "271. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:533" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:533"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:533" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:533"
+
+# segfault
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:536: make test_SobelFilterImage -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:536"
+( $at_check_trace; make test_SobelFilterImage -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:536"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_271
+#AT_START_272
+at_fn_group_banner 272 'testsuite-amdsdk2_9.at:541' \
+  "stringsearch" "                                   " 13
+at_xfail=no
+(
+  $as_echo "272. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:541" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:541"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:541" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:541"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:542: make test_StringSearch -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:542"
+( $at_check_trace; make test_StringSearch -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:542"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_272
+#AT_START_273
+at_fn_group_banner 273 'testsuite-amdsdk2_9.at:548' \
+  "template" "                                       " 13
+at_xfail=no
+(
+  $as_echo "273. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:548" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:548"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:548" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:548"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:549: make test_Template -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:549"
+( $at_check_trace; make test_Template -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:549"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_273
+#AT_START_274
+at_fn_group_banner 274 'testsuite-amdsdk2_9.at:554' \
+  "transferoverlap" "                                " 13
+at_xfail=no
+(
+  $as_echo "274. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:554" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:554"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:554" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:554"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:555: make test_TransferOverlap -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep \"Passed\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:555"
+( $at_check_trace; make test_TransferOverlap -sC $abs_top_builddir/examples/AMDSDK2.9 | grep "Passed"
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:555"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_274
+#AT_START_275
+at_fn_group_banner 275 'testsuite-amdsdk2_9.at:560' \
+  "transferoverlapcpp" "                             " 13
+at_xfail=yes
+(
+  $as_echo "275. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:560" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:560"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:560" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:560"
+
+# Expected Error: Device does not support cl_khr_local_int32_base_atomics extension! and segfault
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:563: make test_TransferOverlapCPP -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep \"Passed\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:563"
+( $at_check_trace; make test_TransferOverlapCPP -sC $abs_top_builddir/examples/AMDSDK2.9 | grep "Passed"
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:563"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_275
+#AT_START_276
+at_fn_group_banner 276 'testsuite-amdsdk2_9.at:568' \
+  "unsharpmask" "                                    " 13
+at_xfail=yes
+(
+  $as_echo "276. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:568" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:568"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:568" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:568"
+
+# doesn't find opencl library
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:571: make test_UnsharpMask -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:571"
+( $at_check_trace; make test_UnsharpMask -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:571"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_276
+#AT_START_277
+at_fn_group_banner 277 'testsuite-amdsdk2_9.at:576' \
+  "urng" "                                           " 13
+at_xfail=no
+(
+  $as_echo "277. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:576" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:576"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:576" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:576"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:577: make test_URNG -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed | cut -c -7"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:577"
+( $at_check_trace; make test_URNG -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed | cut -c -7
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:577"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_277
+#AT_START_278
+at_fn_group_banner 278 'testsuite-amdsdk2_9.at:582' \
+  "urngnoisegl" "                                    " 13
+at_xfail=yes
+(
+  $as_echo "278. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-amdsdk2_9.at:582" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" amdsdk2_9 "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:582"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-amdsdk2_9.at:582" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:582"
+
+# Error: clGetPlatformIDs failed. Error code : CL_PLATFORM_NOT_FOUND_KHR
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:585: make test_URNGNoiseGL -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed | cut -c -7"
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:585"
+( $at_check_trace; make test_URNGNoiseGL -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed | cut -c -7
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "Passed!
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:585"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_278
+#AT_START_279
+at_fn_group_banner 279 'testsuite-vexcl.at:10' \
+  "fft" "                                            " 14
+at_xfail=no
+(
+  $as_echo "279. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-vexcl.at:10" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" vexcl "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-vexcl.at:10"
+
+# Warnings ignored:
+# clang: warning: argument unused during compilation: '-cl-mad-enable'
+# clang: warning: argument unused during compilation: '-cl-fast-relaxed-math'
+{ set +x
+$as_echo "$at_srcdir/testsuite-vexcl.at:14: cd \$abs_top_builddir/examples/VexCL/vexcl/tests ; ./fft 2>&1 | grep \"No errors\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-vexcl.at:14"
+( $at_check_trace; cd $abs_top_builddir/examples/VexCL/vexcl/tests ; ./fft 2>&1 | grep "No errors"
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+echo stderr:; cat "$at_stderr"
+echo >>"$at_stdout"; $as_echo "*** No errors detected
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-vexcl.at:14"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_279
+#AT_START_280
+at_fn_group_banner 280 'testsuite-vexcl.at:19' \
+  "generator" "                                      " 14
+at_xfail=no
+(
+  $as_echo "280. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-vexcl.at:19" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" vexcl "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-vexcl.at:19"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-vexcl.at:20: cd \$abs_top_builddir/examples/VexCL/vexcl/tests ; ./generator 2>&1 | grep \"No errors\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-vexcl.at:20"
+( $at_check_trace; cd $abs_top_builddir/examples/VexCL/vexcl/tests ; ./generator 2>&1 | grep "No errors"
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+echo stderr:; cat "$at_stderr"
+echo >>"$at_stdout"; $as_echo "*** No errors detected
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-vexcl.at:20"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_280
+#AT_START_281
+at_fn_group_banner 281 'testsuite-vexcl.at:25' \
+  "multiple_objects" "                               " 14
+at_xfail=no
+(
+  $as_echo "281. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-vexcl.at:25" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" vexcl "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-vexcl.at:25"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-vexcl.at:26: cd \$abs_top_builddir/examples/VexCL/vexcl/tests ; ./multiple_objects 2>&1 | grep \"No errors\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-vexcl.at:26"
+( $at_check_trace; cd $abs_top_builddir/examples/VexCL/vexcl/tests ; ./multiple_objects 2>&1 | grep "No errors"
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+echo stderr:; cat "$at_stderr"
+echo >>"$at_stdout"; $as_echo "*** No errors detected
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-vexcl.at:26"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_281
+#AT_START_282
+at_fn_group_banner 282 'testsuite-vexcl.at:31' \
+  "multivector_arithmetics" "                        " 14
+at_xfail=no
+(
+  $as_echo "282. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-vexcl.at:31" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" vexcl "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-vexcl.at:31"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-vexcl.at:32: cd \$abs_top_builddir/examples/VexCL/vexcl/tests ; ./multivector_arithmetics 2>&1 | grep \"No errors\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-vexcl.at:32"
+( $at_check_trace; cd $abs_top_builddir/examples/VexCL/vexcl/tests ; ./multivector_arithmetics 2>&1 | grep "No errors"
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+echo stderr:; cat "$at_stderr"
+echo >>"$at_stdout"; $as_echo "*** No errors detected
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-vexcl.at:32"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_282
+#AT_START_283
+at_fn_group_banner 283 'testsuite-vexcl.at:37' \
+  "multivector_create" "                             " 14
+at_xfail=no
+(
+  $as_echo "283. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-vexcl.at:37" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" vexcl "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-vexcl.at:37"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-vexcl.at:38: cd \$abs_top_builddir/examples/VexCL/vexcl/tests ; ./multivector_create 2>&1 | grep \"No errors\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-vexcl.at:38"
+( $at_check_trace; cd $abs_top_builddir/examples/VexCL/vexcl/tests ; ./multivector_create 2>&1 | grep "No errors"
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+echo stderr:; cat "$at_stderr"
+echo >>"$at_stdout"; $as_echo "*** No errors detected
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-vexcl.at:38"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_283
+#AT_START_284
+at_fn_group_banner 284 'testsuite-vexcl.at:43' \
+  "random" "                                         " 14
+at_xfail=no
+(
+  $as_echo "284. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-vexcl.at:43" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" vexcl "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-vexcl.at:43"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-vexcl.at:44: cd \$abs_top_builddir/examples/VexCL/vexcl/tests ; ./random 2>&1 | grep \"No errors\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-vexcl.at:44"
+( $at_check_trace; cd $abs_top_builddir/examples/VexCL/vexcl/tests ; ./random 2>&1 | grep "No errors"
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+echo stderr:; cat "$at_stderr"
+echo >>"$at_stdout"; $as_echo "*** No errors detected
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-vexcl.at:44"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_284
+#AT_START_285
+at_fn_group_banner 285 'testsuite-vexcl.at:49' \
+  "spmv" "                                           " 14
+at_xfail=no
+(
+  $as_echo "285. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-vexcl.at:49" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" vexcl "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-vexcl.at:49"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-vexcl.at:50: cd \$abs_top_builddir/examples/VexCL/vexcl/tests ; ./spmv 2>&1 | grep \"No errors\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-vexcl.at:50"
+( $at_check_trace; cd $abs_top_builddir/examples/VexCL/vexcl/tests ; ./spmv 2>&1 | grep "No errors"
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+echo stderr:; cat "$at_stderr"
+echo >>"$at_stdout"; $as_echo "*** No errors detected
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-vexcl.at:50"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_285
+#AT_START_286
+at_fn_group_banner 286 'testsuite-vexcl.at:55' \
+  "stencil" "                                        " 14
+at_xfail=yes
+(
+  $as_echo "286. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-vexcl.at:55" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" vexcl "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-vexcl.at:55"
+
+# Crash.
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-vexcl.at:58: cd \$abs_top_builddir/examples/VexCL/vexcl/tests ; ./stencil 2>&1 | grep \"No errors\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-vexcl.at:58"
+( $at_check_trace; cd $abs_top_builddir/examples/VexCL/vexcl/tests ; ./stencil 2>&1 | grep "No errors"
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+echo stderr:; cat "$at_stderr"
+echo >>"$at_stdout"; $as_echo "*** No errors detected
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-vexcl.at:58"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_286
+#AT_START_287
+at_fn_group_banner 287 'testsuite-vexcl.at:63' \
+  "vector_arithmetics" "                             " 14
+at_xfail=no
+(
+  $as_echo "287. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-vexcl.at:63" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" vexcl "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-vexcl.at:63"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-vexcl.at:64: cd \$abs_top_builddir/examples/VexCL/vexcl/tests ; ./vector_arithmetics 2>&1 | grep \"No errors\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-vexcl.at:64"
+( $at_check_trace; cd $abs_top_builddir/examples/VexCL/vexcl/tests ; ./vector_arithmetics 2>&1 | grep "No errors"
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+echo stderr:; cat "$at_stderr"
+echo >>"$at_stdout"; $as_echo "*** No errors detected
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-vexcl.at:64"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_287
+#AT_START_288
+at_fn_group_banner 288 'testsuite-vexcl.at:69' \
+  "vector_copy" "                                    " 14
+at_xfail=no
+(
+  $as_echo "288. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-vexcl.at:69" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" vexcl "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-vexcl.at:69"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-vexcl.at:70: cd \$abs_top_builddir/examples/VexCL/vexcl/tests ; ./vector_copy 2>&1 | grep \"No errors\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-vexcl.at:70"
+( $at_check_trace; cd $abs_top_builddir/examples/VexCL/vexcl/tests ; ./vector_copy 2>&1 | grep "No errors"
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+echo stderr:; cat "$at_stderr"
+echo >>"$at_stdout"; $as_echo "*** No errors detected
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-vexcl.at:70"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_288
+#AT_START_289
+at_fn_group_banner 289 'testsuite-vexcl.at:75' \
+  "vector_create" "                                  " 14
+at_xfail=no
+(
+  $as_echo "289. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-vexcl.at:75" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" vexcl "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-vexcl.at:75"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-vexcl.at:76: cd \$abs_top_builddir/examples/VexCL/vexcl/tests ; ./vector_create 2>&1 | grep \"No errors\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-vexcl.at:76"
+( $at_check_trace; cd $abs_top_builddir/examples/VexCL/vexcl/tests ; ./vector_create 2>&1 | grep "No errors"
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+echo stderr:; cat "$at_stderr"
+echo >>"$at_stdout"; $as_echo "*** No errors detected
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-vexcl.at:76"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_289
+#AT_START_290
+at_fn_group_banner 290 'testsuite-halide.at:11' \
+  "tutorial12" "                                     " 15
+at_xfail=no
+(
+  $as_echo "290. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-halide.at:11" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" Halide "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-halide.at:11"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-halide.at:11" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-halide.at:11"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-halide.at:12: cd \$abs_top_builddir/examples/Halide/Halide/tutorial ;
+LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:../bin HL_TARGET=opencl ../bin/tutorial_lesson_12_using_the_gpu | cut -d ' ' -f 2"
+at_fn_check_prepare_notrace 'a ${...} parameter expansion' "testsuite-halide.at:12"
+( $at_check_trace; cd $abs_top_builddir/examples/Halide/Halide/tutorial ;
+LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../bin HL_TARGET=opencl ../bin/tutorial_lesson_12_using_the_gpu | cut -d ' ' -f 2
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo >>"$at_stdout"; $as_echo "performance
+milliseconds
+performance
+milliseconds
+" | \
+  $at_diff - "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-halide.at:12"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_290
+#AT_START_291
+at_fn_group_banner 291 'testsuite-halide.at:21' \
+  "bilateral_grid" "                                 " 15
+at_xfail=no
+(
+  $as_echo "291. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-halide.at:21" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" Halide "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-halide.at:21"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-halide.at:21" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-halide.at:21"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-halide.at:22: cd \$abs_top_builddir/examples/Halide/Halide/apps/bilateral_grid ;
+LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:../bin HL_TARGET=opencl ./filter ../images/gray.png out.png 0.1"
+at_fn_check_prepare_notrace 'a ${...} parameter expansion' "testsuite-halide.at:22"
+( $at_check_trace; cd $abs_top_builddir/examples/Halide/Halide/apps/bilateral_grid ;
+LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../bin HL_TARGET=opencl ./filter ../images/gray.png out.png 0.1
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo stdout:; cat "$at_stdout"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-halide.at:22"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_291
+#AT_START_292
+at_fn_group_banner 292 'testsuite-halide.at:26' \
+  "interpolate" "                                    " 15
+at_xfail=no
+(
+  $as_echo "292. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-halide.at:26" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" Halide "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-halide.at:26"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-halide.at:26" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-halide.at:26"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-halide.at:27: cd \$abs_top_builddir/examples/Halide/Halide/apps/interpolate ;
+LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:../bin HL_TARGET=opencl ./interpolate ../images/rgba.png out.png"
+at_fn_check_prepare_notrace 'a ${...} parameter expansion' "testsuite-halide.at:27"
+( $at_check_trace; cd $abs_top_builddir/examples/Halide/Halide/apps/interpolate ;
+LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../bin HL_TARGET=opencl ./interpolate ../images/rgba.png out.png
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo stdout:; cat "$at_stdout"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-halide.at:27"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_292
+#AT_START_293
+at_fn_group_banner 293 'testsuite-halide.at:31' \
+  "local_laplacian" "                                " 15
+at_xfail=no
+(
+  $as_echo "293. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-halide.at:31" >"$at_check_line_file"
+(case " $POAT_TESTSUITES " in #(
+  *" Halide "*) :
+    false ;; #(
+  *) :
+    : ;;
+esac) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-halide.at:31"
+  # AMD APP SDK tests require ICD loader with
+  $as_echo "testsuite-halide.at:31" >"$at_check_line_file"
+(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-halide.at:31"
+
+{ set +x
+$as_echo "$at_srcdir/testsuite-halide.at:32: cd \$abs_top_builddir/examples/Halide/Halide/apps/local_laplacian ;
+LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:../bin HL_TARGET=opencl ./process ../images/rgb.png 8 1 1 out.png"
+at_fn_check_prepare_notrace 'a ${...} parameter expansion' "testsuite-halide.at:32"
+( $at_check_trace; cd $abs_top_builddir/examples/Halide/Halide/apps/local_laplacian ;
+LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../bin HL_TARGET=opencl ./process ../images/rgb.png 8 1 1 out.png
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+echo stdout:; cat "$at_stdout"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-halide.at:32"
+$at_failed && at_fn_log_failure
+$at_traceon; }
+
+  set +x
+  $at_times_p && times >"$at_times_file"
+) 5>&1 2>&1 7>&- | eval $at_tee_pipe
+read at_status <"$at_status_file"
+#AT_STOP_293
+#AT_START_294
+at_fn_group_banner 294 'testsuite-cloverleaf.at:11' \
+  "cloverleaf" "                                     " 16
+at_xfail=no
+(
+  $as_echo "294. $at_setup_line: testing $at_desc ..."
+  $at_traceon
+
+
+  $as_echo "testsuite-cloverleaf.at:11" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" CloverLeaf "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:223"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-cloverleaf.at:11"
   # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:223" >"$at_check_line_file"
+  $as_echo "testsuite-cloverleaf.at:11" >"$at_check_line_file"
 (! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:223"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-cloverleaf.at:11"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:224: make test_GaussianNoise -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed | sed 's/ //g'"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:224"
-( $at_check_trace; make test_GaussianNoise -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed | sed 's/ //g'
+$as_echo "$at_srcdir/testsuite-cloverleaf.at:12: cd \$abs_top_builddir/examples/CloverLeaf/CloverLeaf_OpenCL ;
+./clover_leaf 2>&1 |grep First | cut -c-6
+"
+at_fn_check_prepare_notrace 'an embedded newline' "testsuite-cloverleaf.at:12"
+( $at_check_trace; cd $abs_top_builddir/examples/CloverLeaf/CloverLeaf_OpenCL ;
+./clover_leaf 2>&1 |grep First | cut -c-6
+
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
+echo >>"$at_stdout"; $as_echo " First
 " | \
   $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:224"
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-cloverleaf.at:12"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -11109,44 +14099,50 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_223
-#AT_START_224
-at_fn_group_banner 224 'testsuite-amdsdk2_9.at:229' \
-  "gaussiannoisegl" "                                " 13
+#AT_STOP_294
+#AT_START_295
+at_fn_group_banner 295 'testsuite-piglit.at:3' \
+  "Piglit testsuite with LLVM 3.5" "                 " 17
 at_xfail=no
 (
-  $as_echo "224. $at_setup_line: testing $at_desc ..."
+  $as_echo "295. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:229" >"$at_check_line_file"
+$as_echo "testsuite-piglit.at:5" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" piglit "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:229"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:229" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:229"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-piglit.at:5"
+$as_echo "testsuite-piglit.at:6" >"$at_check_line_file"
+(! grep -q "#define LLVM_3_5" $abs_top_builddir/config.h) \
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-piglit.at:6"
+{ set +x
+$as_echo "$at_srcdir/testsuite-piglit.at:7: cd \$abs_top_builddir/examples/piglit/; ./produce_results.sh "
+at_fn_check_prepare_dynamic "cd $abs_top_builddir/examples/piglit/; ./produce_results.sh " "testsuite-piglit.at:7"
+( $at_check_trace; cd $abs_top_builddir/examples/piglit/; ./produce_results.sh
+) >>"$at_stdout" 2>>"$at_stderr" 5>&-
+at_status=$? at_failed=false
+$at_check_filter
+echo stderr:; cat "$at_stderr"
+echo stdout:; cat "$at_stdout"
+at_fn_check_skip $at_status "$at_srcdir/testsuite-piglit.at:7"
+$at_failed && at_fn_log_failure
+$at_traceon; }
 
-#doesnt work
-$as_echo "testsuite-amdsdk2_9.at:231" >"$at_check_line_file"
-at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:231"
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:232: make test_GaussianNoiseGL -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:232"
-( $at_check_trace; make test_GaussianNoiseGL -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-piglit.at:8: cd \$abs_top_builddir/examples/piglit/; LC_ALL=C comm -23 sorted_ref_llvm_3.5 sorted_result"
+at_fn_check_prepare_dynamic "cd $abs_top_builddir/examples/piglit/; LC_ALL=C comm -23 sorted_ref_llvm_3.5 sorted_result" "testsuite-piglit.at:8"
+( $at_check_trace; cd $abs_top_builddir/examples/piglit/; LC_ALL=C comm -23 sorted_ref_llvm_3.5 sorted_result
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:232"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 0 $at_status "$at_srcdir/testsuite-piglit.at:8"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -11154,41 +14150,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_224
-#AT_START_225
-at_fn_group_banner 225 'testsuite-amdsdk2_9.at:244' \
-  "hdrtonemapping" "                                 " 13
+#AT_STOP_295
+#AT_START_296
+at_fn_group_banner 296 'testsuite-opencv.at:9' \
+  "UMat" "                                           " 18
 at_xfail=no
 (
-  $as_echo "225. $at_setup_line: testing $at_desc ..."
+  $as_echo "296. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:244" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:9" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:244"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:244" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:244"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:9"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:245: make test_HDRToneMapping -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:245"
-( $at_check_trace; make test_HDRToneMapping -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:10: make test_UMat -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:10"
+( $at_check_trace; make test_UMat -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
-echo stderr:; cat "$at_stderr"
-echo >>"$at_stdout"; $as_echo "Passed!!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:245"
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:10"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -11196,42 +14186,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_225
-#AT_START_226
-at_fn_group_banner 226 'testsuite-amdsdk2_9.at:250' \
-  "helloworld" "                                     " 13
+#AT_STOP_296
+#AT_START_297
+at_fn_group_banner 297 'testsuite-opencv.at:14' \
+  "Core_UMat" "                                      " 18
 at_xfail=no
 (
-  $as_echo "226. $at_setup_line: testing $at_desc ..."
+  $as_echo "297. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:250" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:14" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:250"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:250" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:250"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:14"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:251: make test_HelloWorld -sC \$abs_top_builddir/examples/AMDSDK2.9 | egrep \"GdkknVnqkc|HelloWorld\""
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:251"
-( $at_check_trace; make test_HelloWorld -sC $abs_top_builddir/examples/AMDSDK2.9 | egrep "GdkknVnqkc|HelloWorld"
+$as_echo "$at_srcdir/testsuite-opencv.at:15: make test_Core_UMat -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:15"
+( $at_check_trace; make test_Core_UMat -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "GdkknVnqkc
-HelloWorld
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:251"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:15"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -11239,41 +14222,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_226
-#AT_START_227
-at_fn_group_banner 227 'testsuite-amdsdk2_9.at:257' \
-  "histogram-repl" "                                 " 13
+#AT_STOP_297
+#AT_START_298
+at_fn_group_banner 298 'testsuite-opencv.at:19' \
+  "Image2D" "                                        " 18
 at_xfail=no
 (
-  $as_echo "227. $at_setup_line: testing $at_desc ..."
+  $as_echo "298. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:257" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:19" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:257"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:257" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:257"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:19"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:258: POCL_WORK_GROUP_METHOD=repl make test_Histogram -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:258"
-( $at_check_trace; POCL_WORK_GROUP_METHOD=repl make test_Histogram -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:20: make test_Image2D -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:20"
+( $at_check_trace; make test_Image2D -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:258"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:20"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -11281,41 +14258,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_227
-#AT_START_228
-at_fn_group_banner 228 'testsuite-amdsdk2_9.at:263' \
-  "histogram-loops" "                                " 13
+#AT_STOP_298
+#AT_START_299
+at_fn_group_banner 299 'testsuite-opencv.at:24' \
+  "UMatBasicTests" "                                 " 18
 at_xfail=no
 (
-  $as_echo "228. $at_setup_line: testing $at_desc ..."
+  $as_echo "299. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:263" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:24" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:263"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:263" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:263"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:24"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:264: POCL_WORK_GROUP_METHOD=loops make test_Histogram -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:264"
-( $at_check_trace; POCL_WORK_GROUP_METHOD=loops make test_Histogram -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:25: make test_UMat/UMatBasicTests -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:25"
+( $at_check_trace; make test_UMat/UMatBasicTests -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:264"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:25"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -11323,41 +14294,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_228
-#AT_START_229
-at_fn_group_banner 229 'testsuite-amdsdk2_9.at:269' \
-  "histogramatomic" "                                " 13
+#AT_STOP_299
+#AT_START_300
+at_fn_group_banner 300 'testsuite-opencv.at:29' \
+  "UMatTestReshape" "                                " 18
 at_xfail=no
 (
-  $as_echo "229. $at_setup_line: testing $at_desc ..."
+  $as_echo "300. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:269" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:29" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:269"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:269" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:269"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:29"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:270: make test_HistogramAtomics -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:270"
-( $at_check_trace; make test_HistogramAtomics -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:30: make test_UMat/UMatTestReshape -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:30"
+( $at_check_trace; make test_UMat/UMatTestReshape -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:270"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:30"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -11365,42 +14330,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_229
-#AT_START_230
-at_fn_group_banner 230 'testsuite-amdsdk2_9.at:275' \
-  "imagebandwidth" "                                 " 13
+#AT_STOP_300
+#AT_START_301
+at_fn_group_banner 301 'testsuite-opencv.at:34' \
+  "UMatTestRoi" "                                    " 18
 at_xfail=no
 (
-  $as_echo "230. $at_setup_line: testing $at_desc ..."
+  $as_echo "301. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:275" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:34" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:275"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:275" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:275"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:34"
 
-# AT_SKIP_IF(true)
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:277: make test_ImageBandwidth -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:277"
-( $at_check_trace; make test_ImageBandwidth -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:35: make test_UMat/UMatTestRoi -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:35"
+( $at_check_trace; make test_UMat/UMatTestRoi -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:277"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:35"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -11408,41 +14366,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_230
-#AT_START_231
-at_fn_group_banner 231 'testsuite-amdsdk2_9.at:283' \
-  "imageoverlap" "                                   " 13
+#AT_STOP_301
+#AT_START_302
+at_fn_group_banner 302 'testsuite-opencv.at:39' \
+  "UMatTestSizeOperations" "                         " 18
 at_xfail=no
 (
-  $as_echo "231. $at_setup_line: testing $at_desc ..."
+  $as_echo "302. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:283" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:39" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:283"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:283" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:283"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:39"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:284: make test_ImageOverlap -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:284"
-( $at_check_trace; make test_ImageOverlap -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:40: make test_UMat/UMatTestSizeOperations -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:40"
+( $at_check_trace; make test_UMat/UMatTestSizeOperations -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Verifying result - Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:284"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:40"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -11450,43 +14402,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_231
-#AT_START_232
-at_fn_group_banner 232 'testsuite-amdsdk2_9.at:289' \
-  "introstatickcppkernel" "                          " 13
-at_xfail=yes
+#AT_STOP_302
+#AT_START_303
+at_fn_group_banner 303 'testsuite-opencv.at:44' \
+  "UMatTestUMatOperations" "                         " 18
+at_xfail=no
 (
-  $as_echo "232. $at_setup_line: testing $at_desc ..."
+  $as_echo "303. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:289" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:44" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:289"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:289" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:289"
-
-# Error: clBuildProgram failed. Error code : CL_INVALID_BUILD_OPTIONS (-x clc++)
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:44"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:292: make test_IntroStaticCPPKernel -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:292"
-( $at_check_trace; make test_IntroStaticCPPKernel -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:45: make test_UMat/UMatTestUMatOperations -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:45"
+( $at_check_trace; make test_UMat/UMatTestUMatOperations -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Verifying result - Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:292"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:45"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -11494,43 +14438,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_232
-#AT_START_233
-at_fn_group_banner 233 'testsuite-amdsdk2_9.at:297' \
-  "kernellauch" "                                    " 13
+#AT_STOP_303
+#AT_START_304
+at_fn_group_banner 304 'testsuite-opencv.at:51' \
+  "OCL_Channels/Merge" "                             " 19
 at_xfail=no
 (
-  $as_echo "233. $at_setup_line: testing $at_desc ..."
+  $as_echo "304. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:297" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:51" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:297"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:297" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:297"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:51"
 
-# Device does not support cl_khr_local_int32_base_atomics extension!
-# works anyway
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:300: make test_KernelLaunch -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed!"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:300"
-( $at_check_trace; make test_KernelLaunch -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed!
+$as_echo "$at_srcdir/testsuite-opencv.at:52: make test_OCL_Channels/Merge -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:52"
+( $at_check_trace; make test_OCL_Channels/Merge -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:300"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:52"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -11538,43 +14474,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_233
-#AT_START_234
-at_fn_group_banner 234 'testsuite-amdsdk2_9.at:305' \
-  "kmeansautoclustering" "                           " 13
-at_xfail=yes
+#AT_STOP_304
+#AT_START_305
+at_fn_group_banner 305 'testsuite-opencv.at:56' \
+  "OCL_Channels/Split" "                             " 19
+at_xfail=no
 (
-  $as_echo "234. $at_setup_line: testing $at_desc ..."
+  $as_echo "305. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:305" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:56" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:305"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:305" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:305"
-
-# doesn't find opencl library for some reason
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:56"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:308: make test_KmeansAutoclustering -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:308"
-( $at_check_trace; make test_KmeansAutoclustering -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:57: make test_OCL_Channels/Split -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:57"
+( $at_check_trace; make test_OCL_Channels/Split -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:308"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:57"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -11582,43 +14510,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_234
-#AT_START_235
-at_fn_group_banner 235 'testsuite-amdsdk2_9.at:314' \
-  "ldsbandwidth" "                                   " 13
+#AT_STOP_305
+#AT_START_306
+at_fn_group_banner 306 'testsuite-opencv.at:61' \
+  "OCL_Channels/MixChannels" "                       " 19
 at_xfail=no
 (
-  $as_echo "235. $at_setup_line: testing $at_desc ..."
+  $as_echo "306. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:314" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:61" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:314"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:314" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:314"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:61"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:315: make test_LDSBandwidth -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:315"
-( $at_check_trace; make test_LDSBandwidth -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:62: make test_OCL_Channels/MixChannels -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:62"
+( $at_check_trace; make test_OCL_Channels/MixChannels -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-Passed!
-Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:315"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:62"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -11626,47 +14546,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_235
-#AT_START_236
-at_fn_group_banner 236 'testsuite-amdsdk2_9.at:322' \
-  "ludecomposition" "                                " 13
+#AT_STOP_306
+#AT_START_307
+at_fn_group_banner 307 'testsuite-opencv.at:66' \
+  "OCL_Channels/InsertChannel" "                     " 19
 at_xfail=no
-      grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc && at_xfail=yes
-      grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q armv && at_xfail=yes
 (
-  $as_echo "236. $at_setup_line: testing $at_desc ..."
+  $as_echo "307. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:322" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:66" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:322"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:322" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:322"
-
-
-#test uses doubles
-
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:66"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:327: make test_LUDecomposition -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:327"
-( $at_check_trace; make test_LUDecomposition -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:67: make test_OCL_Channels/InsertChannels -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:67"
+( $at_check_trace; make test_OCL_Channels/InsertChannels -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
-echo stderr:; cat "$at_stderr"
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:327"
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:67"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -11674,48 +14582,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_236
-#AT_START_237
-at_fn_group_banner 237 'testsuite-amdsdk2_9.at:332' \
-  "mandelbrot" "                                     " 13
+#AT_STOP_307
+#AT_START_308
+at_fn_group_banner 308 'testsuite-opencv.at:71' \
+  "OCL_Channels/ExtractChannel" "                    " 19
 at_xfail=no
 (
-  $as_echo "237. $at_setup_line: testing $at_desc ..."
+  $as_echo "308. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:332" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:71" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:332"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:332" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:332"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:71"
 
-$as_echo "testsuite-amdsdk2_9.at:333" >"$at_check_line_file"
-( grep "undef HAVE_GLEW" $abs_top_builddir/config.h ) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:333"
-$as_echo "testsuite-amdsdk2_9.at:334" >"$at_check_line_file"
-( ! test -e $abs_top_builddir/examples/AMDSDK2.9/AMD-APP-SDK-v2.9-RC-lnx64/samples/opencl/cl/Mandelbrot/bin/x86_64/Release/Mandelbrot) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:334"
-# undefined symbol: _Z7std_fmaDv4_fS_S_ with VML
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:336: make test_Mandelbrot -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:336"
-( $at_check_trace; make test_Mandelbrot -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:72: make test_OCL_Channels/ExtractChannels -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:72"
+( $at_check_trace; make test_OCL_Channels/ExtractChannels -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
-echo stderr:; cat "$at_stderr"
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:336"
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:72"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -11723,41 +14618,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_237
-#AT_START_238
-at_fn_group_banner 238 'testsuite-amdsdk2_9.at:341' \
-  "matrixmuldouble" "                                " 13
+#AT_STOP_308
+#AT_START_309
+at_fn_group_banner 309 'testsuite-opencv.at:78' \
+  "Lut" "                                            " 20
 at_xfail=no
 (
-  $as_echo "238. $at_setup_line: testing $at_desc ..."
+  $as_echo "309. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:341" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:78" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:341"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:341" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:341"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:78"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:342: make test_MatrixMulDouble -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:342"
-( $at_check_trace; make test_MatrixMulDouble -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:79: make test_OCL_Arithm/Lut -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:79"
+( $at_check_trace; make test_OCL_Arithm/Lut -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:342"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:79"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -11765,41 +14654,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_238
-#AT_START_239
-at_fn_group_banner 239 'testsuite-amdsdk2_9.at:347' \
-  "matrixmulimage" "                                 " 13
+#AT_STOP_309
+#AT_START_310
+at_fn_group_banner 310 'testsuite-opencv.at:83' \
+  "Add" "                                            " 20
 at_xfail=no
 (
-  $as_echo "239. $at_setup_line: testing $at_desc ..."
+  $as_echo "310. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:347" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:83" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:347"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:347" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:347"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:83"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:348: make test_MatrixMulImage -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:348"
-( $at_check_trace; make test_MatrixMulImage -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:84: make test_OCL_Arithm/Add -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:84"
+( $at_check_trace; make test_OCL_Arithm/Add -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
-echo stderr:; cat "$at_stderr"
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:348"
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:84"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -11807,43 +14690,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_239
-#AT_START_240
-at_fn_group_banner 240 'testsuite-amdsdk2_9.at:353' \
-  "matrixmultiplication" "                           " 13
+#AT_STOP_310
+#AT_START_311
+at_fn_group_banner 311 'testsuite-opencv.at:88' \
+  "Subtract" "                                       " 20
 at_xfail=no
 (
-  $as_echo "240. $at_setup_line: testing $at_desc ..."
+  $as_echo "311. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:353" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:88" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:353"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:353" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:353"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:88"
 
-# pocl error: encountered unimplemented part of the OpenCL specs in clCreateImage2D.c:119
-#AT_XFAIL_IF(true)
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:356: make test_MatrixMultiplication -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:356"
-( $at_check_trace; make test_MatrixMultiplication -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:89: make test_OCL_Arithm/Subtract -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:89"
+( $at_check_trace; make test_OCL_Arithm/Subtract -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:356"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:89"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -11851,41 +14726,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_240
-#AT_START_241
-at_fn_group_banner 241 'testsuite-amdsdk2_9.at:361' \
-  "matrixtranspose" "                                " 13
+#AT_STOP_311
+#AT_START_312
+at_fn_group_banner 312 'testsuite-opencv.at:93' \
+  "Mul" "                                            " 20
 at_xfail=no
 (
-  $as_echo "241. $at_setup_line: testing $at_desc ..."
+  $as_echo "312. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:361" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:93" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:361"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:361" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:361"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:93"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:362: make test_MatrixTranspose -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:362"
-( $at_check_trace; make test_MatrixTranspose -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:94: make test_OCL_Arithm/Mul -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:94"
+( $at_check_trace; make test_OCL_Arithm/Mul -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:362"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:94"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -11893,41 +14762,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_241
-#AT_START_242
-at_fn_group_banner 242 'testsuite-amdsdk2_9.at:367' \
-  "memorymodel-repl" "                               " 13
+#AT_STOP_312
+#AT_START_313
+at_fn_group_banner 313 'testsuite-opencv.at:98' \
+  "Div" "                                            " 20
 at_xfail=no
 (
-  $as_echo "242. $at_setup_line: testing $at_desc ..."
+  $as_echo "313. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:367" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:98" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:367"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:367" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:367"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:98"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:368: POCL_WORK_GROUP_METHOD=repl make test_MemoryModel -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:368"
-( $at_check_trace; POCL_WORK_GROUP_METHOD=repl make test_MemoryModel -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:99: make test_OCL_Arithm/Div -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:99"
+( $at_check_trace; make test_OCL_Arithm/Div -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:368"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:99"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -11935,41 +14798,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_242
-#AT_START_243
-at_fn_group_banner 243 'testsuite-amdsdk2_9.at:373' \
-  "memorymodel-loops" "                              " 13
+#AT_STOP_313
+#AT_START_314
+at_fn_group_banner 314 'testsuite-opencv.at:103' \
+  "Min" "                                            " 20
 at_xfail=no
 (
-  $as_echo "243. $at_setup_line: testing $at_desc ..."
+  $as_echo "314. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:373" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:103" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:373"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:373" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:373"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:103"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:374: POCL_WORK_GROUP_METHOD=loops make test_MemoryModel -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:374"
-( $at_check_trace; POCL_WORK_GROUP_METHOD=loops make test_MemoryModel -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:104: make test_OCL_Arithm/Min -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:104"
+( $at_check_trace; make test_OCL_Arithm/Min -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:374"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:104"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -11977,65 +14834,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_243
-#AT_START_244
-at_fn_group_banner 244 'testsuite-amdsdk2_9.at:379' \
-  "memoryoptimizations" "                            " 13
+#AT_STOP_314
+#AT_START_315
+at_fn_group_banner 315 'testsuite-opencv.at:108' \
+  "Max" "                                            " 20
 at_xfail=no
 (
-  $as_echo "244. $at_setup_line: testing $at_desc ..."
+  $as_echo "315. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:379" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:108" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:379"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:379" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:379"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:108"
 
-#Device does not support global_int32_base_atomics
-#AT_SKIP_IF(true)
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:382: make test_MemoryOptimizations -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:382"
-( $at_check_trace; make test_MemoryOptimizations -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:109: make test_OCL_Arithm/Max -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:109"
+( $at_check_trace; make test_OCL_Arithm/Max -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
-echo stderr:; cat "$at_stderr"
-echo >>"$at_stdout"; $as_echo "Passed!
-Passed!
-Passed!
-Passed!
-Passed!
-Passed!
-Passed!
-Passed!
-Passed!
-Passed!
-Passed!
-Passed!
-Passed!
-Passed!
-Passed!
-Passed!
-Passed!
-Passed!
-Passed!
-Passed!
-Passed!
-Passed!
-Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:382"
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:109"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -12043,44 +14870,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_244
-#AT_START_245
-at_fn_group_banner 245 'testsuite-amdsdk2_9.at:409' \
-  "merzennetwister" "                                " 13
+#AT_STOP_315
+#AT_START_316
+at_fn_group_banner 316 'testsuite-opencv.at:113' \
+  "AddWeighted" "                                    " 20
 at_xfail=no
 (
-  $as_echo "245. $at_setup_line: testing $at_desc ..."
+  $as_echo "316. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:409" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:113" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:409"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:409" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:409"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:113"
 
-#Build parameter clc++ is not supported
-$as_echo "testsuite-amdsdk2_9.at:411" >"$at_check_line_file"
-at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:411"
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:412: make test_MersenneTwister -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:412"
-( $at_check_trace; make test_MersenneTwister -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:114: make test_OCL_Arithm/AddWeighted -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:114"
+( $at_check_trace; make test_OCL_Arithm/AddWeighted -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
-echo stderr:; cat "$at_stderr"
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:412"
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:114"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -12088,45 +14906,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_245
-#AT_START_246
-at_fn_group_banner 246 'testsuite-amdsdk2_9.at:417' \
-  "montecarloasian" "                                " 13
-at_xfail=yes
+#AT_STOP_316
+#AT_START_317
+at_fn_group_banner 317 'testsuite-opencv.at:118' \
+  "Absdiff" "                                        " 20
+at_xfail=no
 (
-  $as_echo "246. $at_setup_line: testing $at_desc ..."
+  $as_echo "317. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:417" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:118" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:417"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:417" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:417"
-
-# kernel compilation fails due to
-# error: can't convert between vector values of different size ('float4' and 'int')
-# It should be a legal implicit conversion according to 6.3 Operators. Works also with Intel OCL
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:118"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:422: make test_MonteCarloAsian -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:422"
-( $at_check_trace; make test_MonteCarloAsian -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:119: make test_OCL_Arithm/Absdiff -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:119"
+( $at_check_trace; make test_OCL_Arithm/Absdiff -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:422"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:119"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -12134,45 +14942,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_246
-#AT_START_247
-at_fn_group_banner 247 'testsuite-amdsdk2_9.at:427' \
-  "montecarloasiandp" "                              " 13
-at_xfail=yes
+#AT_STOP_317
+#AT_START_318
+at_fn_group_banner 318 'testsuite-opencv.at:123' \
+  "CartToPolar" "                                    " 20
+at_xfail=no
 (
-  $as_echo "247. $at_setup_line: testing $at_desc ..."
+  $as_echo "318. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:427" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:123" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:427"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:427" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:427"
-
-
-# error: can't convert between vector values of different size ('double4' and 'int')
-# It should be a legal implicit conversion according to 6.3 Operators. Works also with Intel OCL
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:123"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:432: make test_MonteCarloAsianDP -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:432"
-( $at_check_trace; make test_MonteCarloAsianDP -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:124: make test_OCL_Arithm/CartToPolar -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:124"
+( $at_check_trace; make test_OCL_Arithm/CartToPolar -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
-echo stderr:; cat "$at_stderr"
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:432"
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:124"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -12180,45 +14978,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_247
-#AT_START_248
-at_fn_group_banner 248 'testsuite-amdsdk2_9.at:437' \
-  "montecarloasianmultigpu" "                        " 13
-at_xfail=yes
+#AT_STOP_318
+#AT_START_319
+at_fn_group_banner 319 'testsuite-opencv.at:128' \
+  "PolarToCart" "                                    " 20
+at_xfail=no
 (
-  $as_echo "248. $at_setup_line: testing $at_desc ..."
+  $as_echo "319. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:437" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:128" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:437"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:437" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:437"
-
-# kernel compilation fails due to
-# error: can't convert between vector values of different size ('float4' and 'int')
-# It should be a legal implicit conversion according to 6.3 Operators. Works also with Intel OCL
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:128"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:442: make test_MonteCarloAsianMultiGPU -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:442"
-( $at_check_trace; make test_MonteCarloAsianMultiGPU -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:129: make test_OCL_Arithm/PolarToCart -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:129"
+( $at_check_trace; make test_OCL_Arithm/PolarToCart -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:442"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:129"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -12226,47 +15014,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_248
-#AT_START_249
-at_fn_group_banner 249 'testsuite-amdsdk2_9.at:447' \
-  "nbody" "                                          " 13
+#AT_STOP_319
+#AT_START_320
+at_fn_group_banner 320 'testsuite-opencv.at:133' \
+  "Transpose" "                                      " 20
 at_xfail=no
 (
-  $as_echo "249. $at_setup_line: testing $at_desc ..."
+  $as_echo "320. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:447" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:133" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:447"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:447" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:447"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:133"
 
-$as_echo "testsuite-amdsdk2_9.at:448" >"$at_check_line_file"
-( grep "undef HAVE_GLEW" $abs_top_builddir/config.h ) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:448"
-$as_echo "testsuite-amdsdk2_9.at:449" >"$at_check_line_file"
-( ! test -e $abs_top_builddir/examples/AMDSDK2.9/AMD-APP-SDK-v2.9-RC-lnx64/samples/opencl/cl/NBody/bin/x86_64/Release/NBody) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:449"
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:450: make test_NBody -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:450"
-( $at_check_trace; make test_NBody -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:134: make test_OCL_Arithm/Transpose -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:134"
+( $at_check_trace; make test_OCL_Arithm/Transpose -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:450"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:134"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -12274,41 +15050,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_249
-#AT_START_250
-at_fn_group_banner 250 'testsuite-amdsdk2_9.at:455' \
-  "prefixsum" "                                      " 13
+#AT_STOP_320
+#AT_START_321
+at_fn_group_banner 321 'testsuite-opencv.at:138' \
+  "Bitwise_and" "                                    " 20
 at_xfail=no
 (
-  $as_echo "250. $at_setup_line: testing $at_desc ..."
+  $as_echo "321. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:455" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:138" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:455"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:455" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:455"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:138"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:456: make test_PrefixSum -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:456"
-( $at_check_trace; make test_PrefixSum -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:139: make test_OCL_Arithm/Bitwise_and -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:139"
+( $at_check_trace; make test_OCL_Arithm/Bitwise_and -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:456"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:139"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -12316,41 +15086,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_250
-#AT_START_251
-at_fn_group_banner 251 'testsuite-amdsdk2_9.at:461' \
-  "quasirandomsequence" "                            " 13
+#AT_STOP_321
+#AT_START_322
+at_fn_group_banner 322 'testsuite-opencv.at:143' \
+  "Bitwise_or" "                                     " 20
 at_xfail=no
 (
-  $as_echo "251. $at_setup_line: testing $at_desc ..."
+  $as_echo "322. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:461" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:143" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:461"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:461" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:461"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:143"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:462: make test_QuasiRandomSequence -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:462"
-( $at_check_trace; make test_QuasiRandomSequence -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:144: make test_OCL_Arithm/Bitwise_or -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:144"
+( $at_check_trace; make test_OCL_Arithm/Bitwise_or -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:462"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:144"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -12358,41 +15122,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_251
-#AT_START_252
-at_fn_group_banner 252 'testsuite-amdsdk2_9.at:467' \
-  "radixsort" "                                      " 13
+#AT_STOP_322
+#AT_START_323
+at_fn_group_banner 323 'testsuite-opencv.at:148' \
+  "Bitwise_xor" "                                    " 20
 at_xfail=no
 (
-  $as_echo "252. $at_setup_line: testing $at_desc ..."
+  $as_echo "323. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:467" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:148" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:467"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:467" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:467"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:148"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:468: make test_RadixSort -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:468"
-( $at_check_trace; make test_RadixSort -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:149: make test_OCL_Arithm/Bitwise_xor -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:149"
+( $at_check_trace; make test_OCL_Arithm/Bitwise_xor -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
-echo stderr:; cat "$at_stderr"
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:468"
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:149"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -12400,41 +15158,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_252
-#AT_START_253
-at_fn_group_banner 253 'testsuite-amdsdk2_9.at:473' \
-  "recursivegaussian" "                              " 13
+#AT_STOP_323
+#AT_START_324
+at_fn_group_banner 324 'testsuite-opencv.at:153' \
+  "Bitwise_not" "                                    " 20
 at_xfail=no
 (
-  $as_echo "253. $at_setup_line: testing $at_desc ..."
+  $as_echo "324. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:473" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:153" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:473"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:473" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:473"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:153"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:474: make test_RecursiveGaussian -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:474"
-( $at_check_trace; make test_RecursiveGaussian -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:154: make test_OCL_Arithm/Bitwise_not -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:154"
+( $at_check_trace; make test_OCL_Arithm/Bitwise_not -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:474"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:154"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -12442,41 +15194,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_253
-#AT_START_254
-at_fn_group_banner 254 'testsuite-amdsdk2_9.at:479' \
-  "reduction" "                                      " 13
+#AT_STOP_324
+#AT_START_325
+at_fn_group_banner 325 'testsuite-opencv.at:158' \
+  "Compare" "                                        " 20
 at_xfail=no
 (
-  $as_echo "254. $at_setup_line: testing $at_desc ..."
+  $as_echo "325. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:479" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:158" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:479"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:479" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:479"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:158"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:480: make test_Reduction -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:480"
-( $at_check_trace; make test_Reduction -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:159: make test_OCL_Arithm/Compare -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:159"
+( $at_check_trace; make test_OCL_Arithm/Compare -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:480"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:159"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -12484,42 +15230,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_254
-#AT_START_255
-at_fn_group_banner 255 'testsuite-amdsdk2_9.at:485' \
-  "scanlargearrays" "                                " 13
+#AT_STOP_325
+#AT_START_326
+at_fn_group_banner 326 'testsuite-opencv.at:163' \
+  "Pow" "                                            " 20
 at_xfail=no
 (
-  $as_echo "255. $at_setup_line: testing $at_desc ..."
+  $as_echo "326. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:485" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:163" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:485"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:485" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:485"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:163"
 
-# Fails with vectorization. With wiloops and no unrolling, the vectorization won't apply.
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:487: make test_ScanLargeArrays -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:487"
-( $at_check_trace; make test_ScanLargeArrays -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:164: make test_OCL_Arithm/Pow -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:164"
+( $at_check_trace; make test_OCL_Arithm/Pow -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:487"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:164"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -12527,41 +15266,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_255
-#AT_START_256
-at_fn_group_banner 256 'testsuite-amdsdk2_9.at:492' \
-  "simpleconvolution" "                              " 13
+#AT_STOP_326
+#AT_START_327
+at_fn_group_banner 327 'testsuite-opencv.at:168' \
+  "SetIdentity" "                                    " 20
 at_xfail=no
 (
-  $as_echo "256. $at_setup_line: testing $at_desc ..."
+  $as_echo "327. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:492" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:168" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:492"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:492" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:492"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:168"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:493: make test_SimpleConvolution -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:493"
-( $at_check_trace; make test_SimpleConvolution -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:169: make test_OCL_Arithm/SetIdentity -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:169"
+( $at_check_trace; make test_OCL_Arithm/SetIdentity -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:493"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:169"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -12569,43 +15302,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_256
-#AT_START_257
-at_fn_group_banner 257 'testsuite-amdsdk2_9.at:498' \
-  "simplegl" "                                       " 13
-at_xfail=yes
+#AT_STOP_327
+#AT_START_328
+at_fn_group_banner 328 'testsuite-opencv.at:173' \
+  "Repeat" "                                         " 20
+at_xfail=no
 (
-  $as_echo "257. $at_setup_line: testing $at_desc ..."
+  $as_echo "328. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:498" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:173" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:498"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:498" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:498"
-
-# doesn't find opecl library
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:173"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:501: make test_SimpleGL -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:501"
-( $at_check_trace; make test_SimpleGL -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:174: make test_OCL_Arithm/Repeat -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:174"
+( $at_check_trace; make test_OCL_Arithm/Repeat -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:501"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:174"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -12613,42 +15338,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_257
-#AT_START_258
-at_fn_group_banner 258 'testsuite-amdsdk2_9.at:506' \
-  "simpleimage" "                                    " 13
+#AT_STOP_328
+#AT_START_329
+at_fn_group_banner 329 'testsuite-opencv.at:178' \
+  "CountNonZero" "                                   " 20
 at_xfail=no
 (
-  $as_echo "258. $at_setup_line: testing $at_desc ..."
+  $as_echo "329. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:506" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:178" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:506"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:506" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:506"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:178"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:507: make test_SimpleImage -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:507"
-( $at_check_trace; make test_SimpleImage -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:179: make test_OCL_Arithm/CountNonZero -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:179"
+( $at_check_trace; make test_OCL_Arithm/CountNonZero -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Verifying 2D copy result - Passed!
-Verifying 3D copy result - Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:507"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:179"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -12656,45 +15374,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_258
-#AT_START_259
-at_fn_group_banner 259 'testsuite-amdsdk2_9.at:513' \
-  "soaversusaos" "                                   " 13
+#AT_STOP_329
+#AT_START_330
+at_fn_group_banner 330 'testsuite-opencv.at:183' \
+  "Sum" "                                            " 20
 at_xfail=no
 (
-  $as_echo "259. $at_setup_line: testing $at_desc ..."
+  $as_echo "330. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:513" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:183" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:513"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:513" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:513"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:183"
 
-#Build Options are : -x clc++ -D num1=4096 -D num2=4096
-#Error: clBuildProgram failed. Error code : CL_INVALID_BUILD_OPTIONS
-$as_echo "testsuite-amdsdk2_9.at:516" >"$at_check_line_file"
-at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:516"
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:517: make test_SoAversusAoS -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:517"
-( $at_check_trace; make test_SoAversusAoS -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:184: make test_OCL_Arithm/Sum -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:184"
+( $at_check_trace; make test_OCL_Arithm/Sum -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:517"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:184"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -12702,41 +15410,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_259
-#AT_START_260
-at_fn_group_banner 260 'testsuite-amdsdk2_9.at:522' \
-  "sobelfilter" "                                    " 13
+#AT_STOP_330
+#AT_START_331
+at_fn_group_banner 331 'testsuite-opencv.at:188' \
+  "MeanStdDev" "                                     " 20
 at_xfail=no
 (
-  $as_echo "260. $at_setup_line: testing $at_desc ..."
+  $as_echo "331. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:522" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:188" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:522"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:522" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:522"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:188"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:523: make test_SobelFilter -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:523"
-( $at_check_trace; make test_SobelFilter -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:189: make test_OCL_Arithm/MeanStdDev -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:189"
+( $at_check_trace; make test_OCL_Arithm/MeanStdDev -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:523"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:189"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -12744,43 +15446,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_260
-#AT_START_261
-at_fn_group_banner 261 'testsuite-amdsdk2_9.at:528' \
-  "sobelfilterimage" "                               " 13
-at_xfail=yes
+#AT_STOP_331
+#AT_START_332
+at_fn_group_banner 332 'testsuite-opencv.at:193' \
+  "Log" "                                            " 20
+at_xfail=no
 (
-  $as_echo "261. $at_setup_line: testing $at_desc ..."
+  $as_echo "332. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:528" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:193" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:528"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:528" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:528"
-
-# segfault
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:193"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:531: make test_SobelFilterImage -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:531"
-( $at_check_trace; make test_SobelFilterImage -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:194: make test_OCL_Arithm/Log -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:194"
+( $at_check_trace; make test_OCL_Arithm/Log -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:531"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:194"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -12788,42 +15482,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_261
-#AT_START_262
-at_fn_group_banner 262 'testsuite-amdsdk2_9.at:536' \
-  "stringsearch" "                                   " 13
+#AT_STOP_332
+#AT_START_333
+at_fn_group_banner 333 'testsuite-opencv.at:198' \
+  "Exp" "                                            " 20
 at_xfail=no
 (
-  $as_echo "262. $at_setup_line: testing $at_desc ..."
+  $as_echo "333. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:536" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:198" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:536"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:536" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:536"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:198"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:537: make test_StringSearch -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:537"
-( $at_check_trace; make test_StringSearch -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:199: make test_OCL_Arithm/Exp -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:199"
+( $at_check_trace; make test_OCL_Arithm/Exp -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:537"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:199"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -12831,41 +15518,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_262
-#AT_START_263
-at_fn_group_banner 263 'testsuite-amdsdk2_9.at:543' \
-  "template" "                                       " 13
+#AT_STOP_333
+#AT_START_334
+at_fn_group_banner 334 'testsuite-opencv.at:203' \
+  "Phase" "                                          " 20
 at_xfail=no
 (
-  $as_echo "263. $at_setup_line: testing $at_desc ..."
+  $as_echo "334. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:543" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:203" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:543"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:543" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:543"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:203"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:544: make test_Template -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:544"
-( $at_check_trace; make test_Template -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:204: make test_OCL_Arithm/Phase -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:204"
+( $at_check_trace; make test_OCL_Arithm/Phase -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:544"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:204"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -12873,41 +15554,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_263
-#AT_START_264
-at_fn_group_banner 264 'testsuite-amdsdk2_9.at:549' \
-  "transferoverlap" "                                " 13
+#AT_STOP_334
+#AT_START_335
+at_fn_group_banner 335 'testsuite-opencv.at:208' \
+  "Magnitude" "                                      " 20
 at_xfail=no
 (
-  $as_echo "264. $at_setup_line: testing $at_desc ..."
+  $as_echo "335. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:549" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:208" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:549"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:549" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:549"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:208"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:550: make test_TransferOverlap -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep \"Passed\""
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:550"
-( $at_check_trace; make test_TransferOverlap -sC $abs_top_builddir/examples/AMDSDK2.9 | grep "Passed"
+$as_echo "$at_srcdir/testsuite-opencv.at:209: make test_OCL_Arithm/Magnitude -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:209"
+( $at_check_trace; make test_OCL_Arithm/Magnitude -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:550"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:209"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -12915,43 +15590,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_264
-#AT_START_265
-at_fn_group_banner 265 'testsuite-amdsdk2_9.at:555' \
-  "transferoverlapcpp" "                             " 13
-at_xfail=yes
+#AT_STOP_335
+#AT_START_336
+at_fn_group_banner 336 'testsuite-opencv.at:213' \
+  "Flip" "                                           " 20
+at_xfail=no
 (
-  $as_echo "265. $at_setup_line: testing $at_desc ..."
+  $as_echo "336. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:555" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:213" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:555"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:555" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:555"
-
-# Expected Error: Device does not support cl_khr_local_int32_base_atomics extension! and segfault
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:213"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:558: make test_TransferOverlapCPP -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep \"Passed\""
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:558"
-( $at_check_trace; make test_TransferOverlapCPP -sC $abs_top_builddir/examples/AMDSDK2.9 | grep "Passed"
+$as_echo "$at_srcdir/testsuite-opencv.at:214: make test_OCL_Arithm/Flip -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:214"
+( $at_check_trace; make test_OCL_Arithm/Flip -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:558"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:214"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -12959,43 +15626,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_265
-#AT_START_266
-at_fn_group_banner 266 'testsuite-amdsdk2_9.at:563' \
-  "unsharpmask" "                                    " 13
-at_xfail=yes
+#AT_STOP_336
+#AT_START_337
+at_fn_group_banner 337 'testsuite-opencv.at:218' \
+  "MinMaxIdx" "                                      " 20
+at_xfail=no
 (
-  $as_echo "266. $at_setup_line: testing $at_desc ..."
+  $as_echo "337. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:563" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:218" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:563"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:563" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:563"
-
-# doesn't find opencl library
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:218"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:566: make test_UnsharpMask -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:566"
-( $at_check_trace; make test_UnsharpMask -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed
+$as_echo "$at_srcdir/testsuite-opencv.at:219: make test_OCL_Arithm/MinMaxIdx -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:219"
+( $at_check_trace; make test_OCL_Arithm/MinMaxIdx -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:566"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:219"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -13003,41 +15662,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_266
-#AT_START_267
-at_fn_group_banner 267 'testsuite-amdsdk2_9.at:571' \
-  "urng" "                                           " 13
+#AT_STOP_337
+#AT_START_338
+at_fn_group_banner 338 'testsuite-opencv.at:223' \
+  "MinMaxIdx_Mask" "                                 " 20
 at_xfail=no
 (
-  $as_echo "267. $at_setup_line: testing $at_desc ..."
+  $as_echo "338. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:571" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:223" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:571"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:571" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:571"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:223"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:572: make test_URNG -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed | cut -c -7"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:572"
-( $at_check_trace; make test_URNG -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed | cut -c -7
+$as_echo "$at_srcdir/testsuite-opencv.at:224: make test_OCL_Arithm/MinMaxIdx_Mask -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:224"
+( $at_check_trace; make test_OCL_Arithm/MinMaxIdx_Mask -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:572"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:224"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -13045,43 +15698,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_267
-#AT_START_268
-at_fn_group_banner 268 'testsuite-amdsdk2_9.at:577' \
-  "urngnoisegl" "                                    " 13
-at_xfail=yes
+#AT_STOP_338
+#AT_START_339
+at_fn_group_banner 339 'testsuite-opencv.at:228' \
+  "Norm" "                                           " 20
+at_xfail=no
 (
-  $as_echo "268. $at_setup_line: testing $at_desc ..."
+  $as_echo "339. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-amdsdk2_9.at:577" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:228" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" amdsdk2_9 "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:577"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-amdsdk2_9.at:577" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-amdsdk2_9.at:577"
-
-# Error: clGetPlatformIDs failed. Error code : CL_PLATFORM_NOT_FOUND_KHR
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:228"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-amdsdk2_9.at:580: make test_URNGNoiseGL -sC \$abs_top_builddir/examples/AMDSDK2.9 | grep Passed | cut -c -7"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-amdsdk2_9.at:580"
-( $at_check_trace; make test_URNGNoiseGL -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed | cut -c -7
+$as_echo "$at_srcdir/testsuite-opencv.at:229: make test_OCL_Arithm/Norm -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:229"
+( $at_check_trace; make test_OCL_Arithm/Norm -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "Passed!
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-amdsdk2_9.at:580"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:229"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -13089,40 +15734,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_268
-#AT_START_269
-at_fn_group_banner 269 'testsuite-vexcl.at:10' \
-  "fft" "                                            " 14
+#AT_STOP_339
+#AT_START_340
+at_fn_group_banner 340 'testsuite-opencv.at:233' \
+  "UMatDot" "                                        " 20
 at_xfail=no
 (
-  $as_echo "269. $at_setup_line: testing $at_desc ..."
+  $as_echo "340. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-vexcl.at:10" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:233" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" vexcl "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-vexcl.at:10"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:233"
 
-# Warnings ignored:
-# clang: warning: argument unused during compilation: '-cl-mad-enable'
-# clang: warning: argument unused during compilation: '-cl-fast-relaxed-math'
 { set +x
-$as_echo "$at_srcdir/testsuite-vexcl.at:14: cd \$abs_top_builddir/examples/VexCL/vexcl/tests ; ./fft 2>&1 | grep \"No errors\""
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-vexcl.at:14"
-( $at_check_trace; cd $abs_top_builddir/examples/VexCL/vexcl/tests ; ./fft 2>&1 | grep "No errors"
+$as_echo "$at_srcdir/testsuite-opencv.at:234: make test_OCL_Arithm/UMatDot -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:234"
+( $at_check_trace; make test_OCL_Arithm/UMatDot -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
-echo stderr:; cat "$at_stderr"
-echo >>"$at_stdout"; $as_echo "*** No errors detected
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-vexcl.at:14"
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:234"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -13130,37 +15770,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_269
-#AT_START_270
-at_fn_group_banner 270 'testsuite-vexcl.at:19' \
-  "generator" "                                      " 14
+#AT_STOP_340
+#AT_START_341
+at_fn_group_banner 341 'testsuite-opencv.at:238' \
+  "Sqrt" "                                           " 20
 at_xfail=no
 (
-  $as_echo "270. $at_setup_line: testing $at_desc ..."
+  $as_echo "341. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-vexcl.at:19" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:238" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" vexcl "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-vexcl.at:19"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:238"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-vexcl.at:20: cd \$abs_top_builddir/examples/VexCL/vexcl/tests ; ./generator 2>&1 | grep \"No errors\""
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-vexcl.at:20"
-( $at_check_trace; cd $abs_top_builddir/examples/VexCL/vexcl/tests ; ./generator 2>&1 | grep "No errors"
+$as_echo "$at_srcdir/testsuite-opencv.at:239: make test_OCL_Arithm/Sqrt -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:239"
+( $at_check_trace; make test_OCL_Arithm/Sqrt -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
-echo stderr:; cat "$at_stderr"
-echo >>"$at_stdout"; $as_echo "*** No errors detected
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-vexcl.at:20"
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:239"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -13168,37 +15806,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_270
-#AT_START_271
-at_fn_group_banner 271 'testsuite-vexcl.at:25' \
-  "multiple_objects" "                               " 14
+#AT_STOP_341
+#AT_START_342
+at_fn_group_banner 342 'testsuite-opencv.at:243' \
+  "Normalize" "                                      " 20
 at_xfail=no
 (
-  $as_echo "271. $at_setup_line: testing $at_desc ..."
+  $as_echo "342. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-vexcl.at:25" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:243" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" vexcl "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-vexcl.at:25"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:243"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-vexcl.at:26: cd \$abs_top_builddir/examples/VexCL/vexcl/tests ; ./multiple_objects 2>&1 | grep \"No errors\""
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-vexcl.at:26"
-( $at_check_trace; cd $abs_top_builddir/examples/VexCL/vexcl/tests ; ./multiple_objects 2>&1 | grep "No errors"
+$as_echo "$at_srcdir/testsuite-opencv.at:244: make test_OCL_Arithm/Normalize -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:244"
+( $at_check_trace; make test_OCL_Arithm/Normalize -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
-echo stderr:; cat "$at_stderr"
-echo >>"$at_stdout"; $as_echo "*** No errors detected
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-vexcl.at:26"
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:244"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -13206,75 +15842,71 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_271
-#AT_START_272
-at_fn_group_banner 272 'testsuite-vexcl.at:31' \
-  "multivector_arithmetics" "                        " 14
+#AT_STOP_342
+#AT_START_343
+at_fn_group_banner 343 'testsuite-opencv.at:248' \
+  "InRange" "                                        " 20
 at_xfail=no
 (
-  $as_echo "272. $at_setup_line: testing $at_desc ..."
+  $as_echo "343. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-vexcl.at:31" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:248" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" vexcl "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-vexcl.at:31"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:248"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-vexcl.at:32: cd \$abs_top_builddir/examples/VexCL/vexcl/tests ; ./multivector_arithmetics 2>&1 | grep \"No errors\""
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-vexcl.at:32"
-( $at_check_trace; cd $abs_top_builddir/examples/VexCL/vexcl/tests ; ./multivector_arithmetics 2>&1 | grep "No errors"
+$as_echo "$at_srcdir/testsuite-opencv.at:249: make test_OCL_Arithm/InRange -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:249"
+( $at_check_trace; make test_OCL_Arithm/InRange -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
-echo stderr:; cat "$at_stderr"
-echo >>"$at_stdout"; $as_echo "*** No errors detected
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-vexcl.at:32"
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:249"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
   set +x
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
-read at_status <"$at_status_file"
-#AT_STOP_272
-#AT_START_273
-at_fn_group_banner 273 'testsuite-vexcl.at:37' \
-  "multivector_create" "                             " 14
+read at_status <"$at_status_file"
+#AT_STOP_343
+#AT_START_344
+at_fn_group_banner 344 'testsuite-opencv.at:253' \
+  "ConvertScaleAbs" "                                " 20
 at_xfail=no
 (
-  $as_echo "273. $at_setup_line: testing $at_desc ..."
+  $as_echo "344. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-vexcl.at:37" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:253" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" vexcl "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-vexcl.at:37"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:253"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-vexcl.at:38: cd \$abs_top_builddir/examples/VexCL/vexcl/tests ; ./multivector_create 2>&1 | grep \"No errors\""
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-vexcl.at:38"
-( $at_check_trace; cd $abs_top_builddir/examples/VexCL/vexcl/tests ; ./multivector_create 2>&1 | grep "No errors"
+$as_echo "$at_srcdir/testsuite-opencv.at:254: make test_OCL_Arithm/ConvertScaleAbs -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:254"
+( $at_check_trace; make test_OCL_Arithm/ConvertScaleAbs -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
-echo stderr:; cat "$at_stderr"
-echo >>"$at_stdout"; $as_echo "*** No errors detected
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-vexcl.at:38"
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:254"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -13282,37 +15914,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_273
-#AT_START_274
-at_fn_group_banner 274 'testsuite-vexcl.at:43' \
-  "random" "                                         " 14
+#AT_STOP_344
+#AT_START_345
+at_fn_group_banner 345 'testsuite-opencv.at:258' \
+  "ScaleAdd" "                                       " 20
 at_xfail=no
 (
-  $as_echo "274. $at_setup_line: testing $at_desc ..."
+  $as_echo "345. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-vexcl.at:43" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:258" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" vexcl "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-vexcl.at:43"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:258"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-vexcl.at:44: cd \$abs_top_builddir/examples/VexCL/vexcl/tests ; ./random 2>&1 | grep \"No errors\""
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-vexcl.at:44"
-( $at_check_trace; cd $abs_top_builddir/examples/VexCL/vexcl/tests ; ./random 2>&1 | grep "No errors"
+$as_echo "$at_srcdir/testsuite-opencv.at:259: make test_OCL_Arithm/ScaleAdd -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:259"
+( $at_check_trace; make test_OCL_Arithm/ScaleAdd -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
-echo stderr:; cat "$at_stderr"
-echo >>"$at_stdout"; $as_echo "*** No errors detected
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-vexcl.at:44"
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:259"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -13320,37 +15950,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_274
-#AT_START_275
-at_fn_group_banner 275 'testsuite-vexcl.at:49' \
-  "spmv" "                                           " 14
+#AT_STOP_345
+#AT_START_346
+at_fn_group_banner 346 'testsuite-opencv.at:263' \
+  "PatchNaNs" "                                      " 20
 at_xfail=no
 (
-  $as_echo "275. $at_setup_line: testing $at_desc ..."
+  $as_echo "346. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-vexcl.at:49" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:263" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" vexcl "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-vexcl.at:49"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:263"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-vexcl.at:50: cd \$abs_top_builddir/examples/VexCL/vexcl/tests ; ./spmv 2>&1 | grep \"No errors\""
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-vexcl.at:50"
-( $at_check_trace; cd $abs_top_builddir/examples/VexCL/vexcl/tests ; ./spmv 2>&1 | grep "No errors"
+$as_echo "$at_srcdir/testsuite-opencv.at:264: make test_OCL_Arithm/PatchNaNs -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:264"
+( $at_check_trace; make test_OCL_Arithm/PatchNaNs -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
-echo stderr:; cat "$at_stderr"
-echo >>"$at_stdout"; $as_echo "*** No errors detected
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-vexcl.at:50"
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:264"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -13358,39 +15986,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_275
-#AT_START_276
-at_fn_group_banner 276 'testsuite-vexcl.at:55' \
-  "stencil" "                                        " 14
-at_xfail=yes
+#AT_STOP_346
+#AT_START_347
+at_fn_group_banner 347 'testsuite-opencv.at:268' \
+  "Psnr" "                                           " 20
+at_xfail=no
 (
-  $as_echo "276. $at_setup_line: testing $at_desc ..."
+  $as_echo "347. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-vexcl.at:55" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:268" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" vexcl "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-vexcl.at:55"
-
-# Crash.
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:268"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-vexcl.at:58: cd \$abs_top_builddir/examples/VexCL/vexcl/tests ; ./stencil 2>&1 | grep \"No errors\""
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-vexcl.at:58"
-( $at_check_trace; cd $abs_top_builddir/examples/VexCL/vexcl/tests ; ./stencil 2>&1 | grep "No errors"
+$as_echo "$at_srcdir/testsuite-opencv.at:269: make test_OCL_Arithm/Psnr -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:269"
+( $at_check_trace; make test_OCL_Arithm/Psnr -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
-echo stderr:; cat "$at_stderr"
-echo >>"$at_stdout"; $as_echo "*** No errors detected
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-vexcl.at:58"
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:269"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -13398,37 +16022,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_276
-#AT_START_277
-at_fn_group_banner 277 'testsuite-vexcl.at:63' \
-  "vector_arithmetics" "                             " 14
+#AT_STOP_347
+#AT_START_348
+at_fn_group_banner 348 'testsuite-opencv.at:273' \
+  "ReduceSum" "                                      " 20
 at_xfail=no
 (
-  $as_echo "277. $at_setup_line: testing $at_desc ..."
+  $as_echo "348. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-vexcl.at:63" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:273" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" vexcl "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-vexcl.at:63"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:273"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-vexcl.at:64: cd \$abs_top_builddir/examples/VexCL/vexcl/tests ; ./vector_arithmetics 2>&1 | grep \"No errors\""
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-vexcl.at:64"
-( $at_check_trace; cd $abs_top_builddir/examples/VexCL/vexcl/tests ; ./vector_arithmetics 2>&1 | grep "No errors"
+$as_echo "$at_srcdir/testsuite-opencv.at:274: make test_OCL_Arithm/ReduceSum -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:274"
+( $at_check_trace; make test_OCL_Arithm/ReduceSum -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
-echo stderr:; cat "$at_stderr"
-echo >>"$at_stdout"; $as_echo "*** No errors detected
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-vexcl.at:64"
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:274"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -13436,37 +16058,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_277
-#AT_START_278
-at_fn_group_banner 278 'testsuite-vexcl.at:69' \
-  "vector_copy" "                                    " 14
+#AT_STOP_348
+#AT_START_349
+at_fn_group_banner 349 'testsuite-opencv.at:278' \
+  "ReduceMax" "                                      " 20
 at_xfail=no
 (
-  $as_echo "278. $at_setup_line: testing $at_desc ..."
+  $as_echo "349. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-vexcl.at:69" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:278" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" vexcl "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-vexcl.at:69"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:278"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-vexcl.at:70: cd \$abs_top_builddir/examples/VexCL/vexcl/tests ; ./vector_copy 2>&1 | grep \"No errors\""
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-vexcl.at:70"
-( $at_check_trace; cd $abs_top_builddir/examples/VexCL/vexcl/tests ; ./vector_copy 2>&1 | grep "No errors"
+$as_echo "$at_srcdir/testsuite-opencv.at:279: make test_OCL_Arithm/ReduceMax -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:279"
+( $at_check_trace; make test_OCL_Arithm/ReduceMax -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
-echo stderr:; cat "$at_stderr"
-echo >>"$at_stdout"; $as_echo "*** No errors detected
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-vexcl.at:70"
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:279"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -13474,37 +16094,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_278
-#AT_START_279
-at_fn_group_banner 279 'testsuite-vexcl.at:75' \
-  "vector_create" "                                  " 14
+#AT_STOP_349
+#AT_START_350
+at_fn_group_banner 350 'testsuite-opencv.at:283' \
+  "ReduceAvg" "                                      " 20
 at_xfail=no
 (
-  $as_echo "279. $at_setup_line: testing $at_desc ..."
+  $as_echo "350. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-vexcl.at:75" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:283" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" vexcl "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-vexcl.at:75"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:283"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-vexcl.at:76: cd \$abs_top_builddir/examples/VexCL/vexcl/tests ; ./vector_create 2>&1 | grep \"No errors\""
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-vexcl.at:76"
-( $at_check_trace; cd $abs_top_builddir/examples/VexCL/vexcl/tests ; ./vector_create 2>&1 | grep "No errors"
+$as_echo "$at_srcdir/testsuite-opencv.at:284: make test_OCL_Arithm/ReduceAvg -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:284"
+( $at_check_trace; make test_OCL_Arithm/ReduceAvg -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
-echo stderr:; cat "$at_stderr"
-echo >>"$at_stdout"; $as_echo "*** No errors detected
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-vexcl.at:76"
+at_fn_diff_devnull "$at_stderr" || at_failed=:
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:284"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -13512,46 +16130,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_279
-#AT_START_280
-at_fn_group_banner 280 'testsuite-halide.at:11' \
-  "tutorial12" "                                     " 15
+#AT_STOP_350
+#AT_START_351
+at_fn_group_banner 351 'testsuite-opencv.at:290' \
+  "Gemm" "                                           " 20
 at_xfail=no
 (
-  $as_echo "280. $at_setup_line: testing $at_desc ..."
+  $as_echo "351. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-halide.at:11" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:290" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" Halide "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-halide.at:11"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-halide.at:11" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-halide.at:11"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:290"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-halide.at:12: cd \$abs_top_builddir/examples/Halide/Halide/tutorial ;
-LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:../bin HL_TARGET=opencl ../bin/tutorial_lesson_12_using_the_gpu | cut -d ' ' -f 2"
-at_fn_check_prepare_notrace 'a ${...} parameter expansion' "testsuite-halide.at:12"
-( $at_check_trace; cd $abs_top_builddir/examples/Halide/Halide/tutorial ;
-LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../bin HL_TARGET=opencl ../bin/tutorial_lesson_12_using_the_gpu | cut -d ' ' -f 2
+$as_echo "$at_srcdir/testsuite-opencv.at:291: make test_OCL_Core/Gemm -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:291"
+( $at_check_trace; make test_OCL_Core/Gemm -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo "performance
-milliseconds
-performance
-milliseconds
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-halide.at:12"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:291"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -13559,41 +16166,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_280
-#AT_START_281
-at_fn_group_banner 281 'testsuite-halide.at:21' \
-  "bilateral_grid" "                                 " 15
+#AT_STOP_351
+#AT_START_352
+at_fn_group_banner 352 'testsuite-opencv.at:295' \
+  "Dft" "                                            " 20
 at_xfail=no
 (
-  $as_echo "281. $at_setup_line: testing $at_desc ..."
+  $as_echo "352. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-halide.at:21" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:295" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" Halide "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-halide.at:21"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-halide.at:21" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-halide.at:21"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:295"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-halide.at:22: cd \$abs_top_builddir/examples/Halide/Halide/apps/bilateral_grid ;
-LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:../bin HL_TARGET=opencl ./filter ../images/gray.png out.png 0.1"
-at_fn_check_prepare_notrace 'a ${...} parameter expansion' "testsuite-halide.at:22"
-( $at_check_trace; cd $abs_top_builddir/examples/Halide/Halide/apps/bilateral_grid ;
-LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../bin HL_TARGET=opencl ./filter ../images/gray.png out.png 0.1
+$as_echo "$at_srcdir/testsuite-opencv.at:296: make test_OCL_Core/Dft -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:296"
+( $at_check_trace; make test_OCL_Core/Dft -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo stdout:; cat "$at_stdout"
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-halide.at:22"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:296"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -13601,41 +16202,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_281
-#AT_START_282
-at_fn_group_banner 282 'testsuite-halide.at:26' \
-  "interpolate" "                                    " 15
+#AT_STOP_352
+#AT_START_353
+at_fn_group_banner 353 'testsuite-opencv.at:302' \
+  "MultiSpectrums" "                                 " 21
 at_xfail=no
 (
-  $as_echo "282. $at_setup_line: testing $at_desc ..."
+  $as_echo "353. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-halide.at:26" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:302" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" Halide "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-halide.at:26"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-halide.at:26" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-halide.at:26"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:302"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-halide.at:27: cd \$abs_top_builddir/examples/Halide/Halide/apps/interpolate ;
-LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:../bin HL_TARGET=opencl ./interpolate ../images/rgba.png out.png"
-at_fn_check_prepare_notrace 'a ${...} parameter expansion' "testsuite-halide.at:27"
-( $at_check_trace; cd $abs_top_builddir/examples/Halide/Halide/apps/interpolate ;
-LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../bin HL_TARGET=opencl ./interpolate ../images/rgba.png out.png
+$as_echo "$at_srcdir/testsuite-opencv.at:303: make test_OCL_OCL_ImgProc/MultiSpectrums -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:303"
+( $at_check_trace; make test_OCL_OCL_ImgProc/MultiSpectrums -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo stdout:; cat "$at_stdout"
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-halide.at:27"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:303"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -13643,41 +16238,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_282
-#AT_START_283
-at_fn_group_banner 283 'testsuite-halide.at:31' \
-  "local_laplacian" "                                " 15
+#AT_STOP_353
+#AT_START_354
+at_fn_group_banner 354 'testsuite-opencv.at:309' \
+  "ConvertTo" "                                      " 22
 at_xfail=no
 (
-  $as_echo "283. $at_setup_line: testing $at_desc ..."
+  $as_echo "354. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-halide.at:31" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:309" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" Halide "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-halide.at:31"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-halide.at:31" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-halide.at:31"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:309"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-halide.at:32: cd \$abs_top_builddir/examples/Halide/Halide/apps/local_laplacian ;
-LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:../bin HL_TARGET=opencl ./process ../images/rgb.png 8 1 1 out.png"
-at_fn_check_prepare_notrace 'a ${...} parameter expansion' "testsuite-halide.at:32"
-( $at_check_trace; cd $abs_top_builddir/examples/Halide/Halide/apps/local_laplacian ;
-LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../bin HL_TARGET=opencl ./process ../images/rgb.png 8 1 1 out.png
+$as_echo "$at_srcdir/testsuite-opencv.at:310: make test_OCL_MatrixOperation/ConvertTo -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:310"
+( $at_check_trace; make test_OCL_MatrixOperation/ConvertTo -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo stdout:; cat "$at_stdout"
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-halide.at:32"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:310"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -13685,45 +16274,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_283
-#AT_START_284
-at_fn_group_banner 284 'testsuite-cloverleaf.at:11' \
-  "cloverleaf" "                                     " 16
+#AT_STOP_354
+#AT_START_355
+at_fn_group_banner 355 'testsuite-opencv.at:314' \
+  "CopyTo" "                                         " 22
 at_xfail=no
 (
-  $as_echo "284. $at_setup_line: testing $at_desc ..."
+  $as_echo "355. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-  $as_echo "testsuite-cloverleaf.at:11" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:314" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" CloverLeaf "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-cloverleaf.at:11"
-  # AMD APP SDK tests require ICD loader with
-  $as_echo "testsuite-cloverleaf.at:11" >"$at_check_line_file"
-(! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-cloverleaf.at:11"
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:314"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-cloverleaf.at:12: cd \$abs_top_builddir/examples/CloverLeaf/CloverLeaf_OpenCL ;
-./clover_leaf 2>&1 |grep First | cut -c-6
-"
-at_fn_check_prepare_notrace 'an embedded newline' "testsuite-cloverleaf.at:12"
-( $at_check_trace; cd $abs_top_builddir/examples/CloverLeaf/CloverLeaf_OpenCL ;
-./clover_leaf 2>&1 |grep First | cut -c-6
-
+$as_echo "$at_srcdir/testsuite-opencv.at:315: make test_OCL_MatrixOperation/CopyTo -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:315"
+( $at_check_trace; make test_OCL_MatrixOperation/CopyTo -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
-echo >>"$at_stdout"; $as_echo " First
-" | \
-  $at_diff - "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-cloverleaf.at:12"
+at_fn_diff_devnull "$at_stdout" || at_failed=:
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:315"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -13731,51 +16310,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_284
-#AT_START_285
-at_fn_group_banner 285 'testsuite-piglit.at:3' \
-  "Piglit testsuite with LLVM 3.4" "                 " 17
+#AT_STOP_355
+#AT_START_356
+at_fn_group_banner 356 'testsuite-opencv.at:319' \
+  "SetTo" "                                          " 22
 at_xfail=no
 (
-  $as_echo "285. $at_setup_line: testing $at_desc ..."
+  $as_echo "356. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-$as_echo "testsuite-piglit.at:5" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:319" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" piglit "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-piglit.at:5"
-$as_echo "testsuite-piglit.at:6" >"$at_check_line_file"
-(! grep -q "#define LLVM_3_4" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-piglit.at:6"
-#AT_CHECK([make -s -C $abs_top_builddir/examples/piglit/piglit], ignore, ignore, ignore)
-{ set +x
-$as_echo "$at_srcdir/testsuite-piglit.at:8: cd \$abs_top_builddir/examples/piglit/; piglit/piglit-run.py -v piglit/tests/all_cl.tests piglit/results/all 2>&1 | grep \"pass ::\" > result"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-piglit.at:8"
-( $at_check_trace; cd $abs_top_builddir/examples/piglit/; piglit/piglit-run.py -v piglit/tests/all_cl.tests piglit/results/all 2>&1 | grep "pass ::" > result
-) >>"$at_stdout" 2>>"$at_stderr" 5>&-
-at_status=$? at_failed=false
-$at_check_filter
-echo stderr:; cat "$at_stderr"
-echo stdout:; cat "$at_stdout"
-at_fn_check_skip $at_status "$at_srcdir/testsuite-piglit.at:8"
-$at_failed && at_fn_log_failure
-$at_traceon; }
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:319"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-piglit.at:9: cd \$abs_top_builddir/examples/piglit/; LC_ALL=C sort result -o sorted_result; LC_ALL=C comm -23 sorted_ref sorted_result"
-at_fn_check_prepare_dynamic "cd $abs_top_builddir/examples/piglit/; LC_ALL=C sort result -o sorted_result; LC_ALL=C comm -23 sorted_ref sorted_result" "testsuite-piglit.at:9"
-( $at_check_trace; cd $abs_top_builddir/examples/piglit/; LC_ALL=C sort result -o sorted_result; LC_ALL=C comm -23 sorted_ref sorted_result
+$as_echo "$at_srcdir/testsuite-opencv.at:320: make test_OCL_MatrixOperation/SetTo -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:320"
+( $at_check_trace; make test_OCL_MatrixOperation/SetTo -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 at_fn_diff_devnull "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-piglit.at:9"
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:320"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -13783,51 +16346,35 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_285
-#AT_START_286
-at_fn_group_banner 286 'testsuite-piglit.at:12' \
-  "Piglit testsuite with LLVM 3.5" "                 " 17
+#AT_STOP_356
+#AT_START_357
+at_fn_group_banner 357 'testsuite-opencv.at:324' \
+  "UMatExpr" "                                       " 22
 at_xfail=no
 (
-  $as_echo "286. $at_setup_line: testing $at_desc ..."
+  $as_echo "357. $at_setup_line: testing $at_desc ..."
   $at_traceon
 
 
-$as_echo "testsuite-piglit.at:14" >"$at_check_line_file"
+  $as_echo "testsuite-opencv.at:324" >"$at_check_line_file"
 (case " $POAT_TESTSUITES " in #(
-  *" piglit "*) :
+  *" OpenCV "*) :
     false ;; #(
   *) :
     : ;;
 esac) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-piglit.at:14"
-$as_echo "testsuite-piglit.at:15" >"$at_check_line_file"
-(! grep -q "#define LLVM_3_5" $abs_top_builddir/config.h) \
-  && at_fn_check_skip 77 "$at_srcdir/testsuite-piglit.at:15"
-#AT_CHECK([make -s -C $abs_top_builddir/examples/piglit/piglit], ignore, ignore, ignore)
-{ set +x
-$as_echo "$at_srcdir/testsuite-piglit.at:17: cd \$abs_top_builddir/examples/piglit/; piglit/piglit-run.py -v piglit/tests/all_cl.tests piglit/results/all 2>&1 | grep \"pass ::\" > result"
-at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-piglit.at:17"
-( $at_check_trace; cd $abs_top_builddir/examples/piglit/; piglit/piglit-run.py -v piglit/tests/all_cl.tests piglit/results/all 2>&1 | grep "pass ::" > result
-) >>"$at_stdout" 2>>"$at_stderr" 5>&-
-at_status=$? at_failed=false
-$at_check_filter
-echo stderr:; cat "$at_stderr"
-echo stdout:; cat "$at_stdout"
-at_fn_check_skip $at_status "$at_srcdir/testsuite-piglit.at:17"
-$at_failed && at_fn_log_failure
-$at_traceon; }
+  && at_fn_check_skip 77 "$at_srcdir/testsuite-opencv.at:324"
 
 { set +x
-$as_echo "$at_srcdir/testsuite-piglit.at:18: cd \$abs_top_builddir/examples/piglit/; LC_ALL=C sort result -o sorted_result; LC_ALL=C comm -23 sorted_ref_llvm_3.5 sorted_result"
-at_fn_check_prepare_dynamic "cd $abs_top_builddir/examples/piglit/; LC_ALL=C sort result -o sorted_result; LC_ALL=C comm -23 sorted_ref_llvm_3.5 sorted_result" "testsuite-piglit.at:18"
-( $at_check_trace; cd $abs_top_builddir/examples/piglit/; LC_ALL=C sort result -o sorted_result; LC_ALL=C comm -23 sorted_ref_llvm_3.5 sorted_result
+$as_echo "$at_srcdir/testsuite-opencv.at:325: make test_OCL_MatrixOperation/UMatExpr -sC \$abs_top_builddir/examples/OpenCV | grep \"FAILED\""
+at_fn_check_prepare_notrace 'a shell pipeline' "testsuite-opencv.at:325"
+( $at_check_trace; make test_OCL_MatrixOperation/UMatExpr -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"
 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-
 at_status=$? at_failed=false
 $at_check_filter
 at_fn_diff_devnull "$at_stderr" || at_failed=:
 at_fn_diff_devnull "$at_stdout" || at_failed=:
-at_fn_check_status 0 $at_status "$at_srcdir/testsuite-piglit.at:18"
+at_fn_check_status 1 $at_status "$at_srcdir/testsuite-opencv.at:325"
 $at_failed && at_fn_log_failure
 $at_traceon; }
 
@@ -13835,4 +16382,4 @@ $at_traceon; }
   $at_times_p && times >"$at_times_file"
 ) 5>&1 2>&1 7>&- | eval $at_tee_pipe
 read at_status <"$at_status_file"
-#AT_STOP_286
+#AT_STOP_357
diff --git a/tests/testsuite-amd.at b/tests/testsuite-amd.at
index 6c65272..c5b0a3b 100644
--- a/tests/testsuite-amd.at
+++ b/tests/testsuite-amd.at
@@ -208,12 +208,6 @@ AT_CHECK_UNQUOTED([POCL_WORK_GROUP_METHOD=loops make test_MemoryModel -sC $abs_t
 AT_CLEANUP
 
 POAT_AMDSDK_SETUP([montecarloasian])
-# kernel compilation fails due to 
-# error: can't convert between vector values of different size ('float4' and 'int')
-# It should be a legal implicit conversion according to 6.3 Operators. Works also with Intel OCL
-# Seems this is a regression in LLVM 3.5
-AT_XFAIL_IF([grep -q "#define LLVM_3_5" $abs_top_builddir/config.h])
-AT_XFAIL_IF([grep -q "#define LLVM_3_6" $abs_top_builddir/config.h])
 AT_CHECK_UNQUOTED([make test_MonteCarloAsian -sC $abs_top_builddir/examples/AMD | grep Passed], 0, 
 [Passed!
 ])
@@ -305,8 +299,6 @@ AT_CHECK_UNQUOTED([make test_TemplateC -sC $abs_top_builddir/examples/AMD | grep
 AT_CLEANUP
 
 POAT_AMDSDK_SETUP([transferoverlap])
-# Expected Error: Device does not support cl_khr_local_int32_base_atomics extension!
-AT_XFAIL_IF(true)
 AT_CHECK_UNQUOTED([make test_TransferOverlap -sC $abs_top_builddir/examples/AMD | grep "Passed"], 0, 
 [Passed!
 ])
diff --git a/tests/testsuite-amdsdk2_9.at b/tests/testsuite-amdsdk2_9.at
index c0b5323..8989935 100644
--- a/tests/testsuite-amdsdk2_9.at
+++ b/tests/testsuite-amdsdk2_9.at
@@ -6,6 +6,15 @@ m4_define([POAT_AMDSDK_SETUP],[
   AT_SKIP_IF([! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h])
 ])
 
+m4_define([POAT_AMDSDK_HSA_SETUP],[
+  AT_SETUP([$1])
+  AT_KEYWORDS([hsa amdsdk2.9 amdsdk long $1 $2])
+  AT_SKIP_IF([AS_CASE([" $POAT_TESTSUITES "],[*" amdsdk2_9 "*],[false],[:])])
+  # AMD APP SDK tests require ICD loader with
+  AT_SKIP_IF([! grep -q "#define BUILD_ICD" $abs_top_builddir/config.h])
+])
+
+
 AT_BANNER([AMD APP SDK 2.9 tests])
 
 POAT_AMDSDK_SETUP([asyncdatatransfer])
@@ -37,7 +46,7 @@ AT_CHECK_UNQUOTED([make test_BasicDebug -sC $abs_top_builddir/examples/AMDSDK2.9
 ], ignore)
 AT_CLEANUP
 
-POAT_AMDSDK_SETUP([binarysearch])
+POAT_AMDSDK_HSA_SETUP([binarysearch])
 AT_CHECK_UNQUOTED([make test_BinarySearch -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed], 0, 
 [Passed!
 ])
@@ -51,7 +60,7 @@ AT_CHECK_UNQUOTED([POCL_WORK_GROUP_METHOD=repl make test_BinomialOption -sC $abs
 ])
 AT_CLEANUP
 
-POAT_AMDSDK_SETUP([binomialoption-loops])
+POAT_AMDSDK_HSA_SETUP([binomialoption-loops])
 AT_CHECK_UNQUOTED([POCL_WORK_GROUP_METHOD=loops make test_BinomialOption -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed], 0, 
 [Passed!
 ])
@@ -64,13 +73,13 @@ AT_CHECK_UNQUOTED([make test_BinomialOptionMultiGPU -sC $abs_top_builddir/exampl
 ])
 AT_CLEANUP
 
-POAT_AMDSDK_SETUP([bitonicsort])
+POAT_AMDSDK_HSA_SETUP([bitonicsort])
 AT_CHECK_UNQUOTED([make test_BitonicSort -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed], 0, 
 [Passed!
 ])
 AT_CLEANUP
 
-POAT_AMDSDK_SETUP([blackscholes])
+POAT_AMDSDK_HSA_SETUP([blackscholes])
 AT_CHECK_UNQUOTED([make test_BlackScholes -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed], 0, 
 [Passed!
 ])
@@ -144,7 +153,7 @@ AT_CHECK_UNQUOTED([make test_CplusplusWrapper -sC $abs_top_builddir/examples/AMD
 ])
 AT_CLEANUP
 
-POAT_AMDSDK_SETUP([dct])
+POAT_AMDSDK_HSA_SETUP([dct])
 AT_CHECK_UNQUOTED([make test_DCT -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed], 0, 
 [Passed!
 ])
@@ -189,13 +198,13 @@ AT_CHECK_UNQUOTED([make test_EigenValue -sC $abs_top_builddir/examples/AMDSDK2.9
 ])
 AT_CLEANUP
 
-POAT_AMDSDK_SETUP([fastwalshtransform])
+POAT_AMDSDK_HSA_SETUP([fastwalshtransform])
 AT_CHECK_UNQUOTED([make test_FastWalshTransform -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed], 0, 
 [Passed!
 ])
 AT_CLEANUP
 
-POAT_AMDSDK_SETUP([floydwarshall])
+POAT_AMDSDK_HSA_SETUP([floydwarshall])
 AT_CHECK_UNQUOTED([make test_FloydWarshall -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed], 0, 
 [Passed!
 ])
@@ -247,7 +256,7 @@ AT_CHECK_UNQUOTED([make test_HDRToneMapping -sC $abs_top_builddir/examples/AMDSD
 ], ignore)
 AT_CLEANUP
 
-POAT_AMDSDK_SETUP([helloworld])
+POAT_AMDSDK_HSA_SETUP([helloworld])
 AT_CHECK_UNQUOTED([make test_HelloWorld -sC $abs_top_builddir/examples/AMDSDK2.9 | egrep "GdkknVnqkc|HelloWorld"], 0, 
 [GdkknVnqkc
 HelloWorld
@@ -260,7 +269,7 @@ AT_CHECK_UNQUOTED([POCL_WORK_GROUP_METHOD=repl make test_Histogram -sC $abs_top_
 ])     
 AT_CLEANUP
 
-POAT_AMDSDK_SETUP([histogram-loops])
+POAT_AMDSDK_HSA_SETUP([histogram-loops])
 AT_CHECK_UNQUOTED([POCL_WORK_GROUP_METHOD=loops make test_Histogram -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed], 0, 
 [Passed!
 ])     
@@ -350,7 +359,7 @@ AT_CHECK_UNQUOTED([make test_MatrixMulImage -sC $abs_top_builddir/examples/AMDSD
 ], ignore)
 AT_CLEANUP
 
-POAT_AMDSDK_SETUP([matrixmultiplication])
+POAT_AMDSDK_HSA_SETUP([matrixmultiplication])
 # pocl error: encountered unimplemented part of the OpenCL specs in clCreateImage2D.c:119
 #AT_XFAIL_IF(true)
 AT_CHECK_UNQUOTED([make test_MatrixMultiplication -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed], 0, 
@@ -358,7 +367,7 @@ AT_CHECK_UNQUOTED([make test_MatrixMultiplication -sC $abs_top_builddir/examples
 ])
 AT_CLEANUP
 
-POAT_AMDSDK_SETUP([matrixtranspose])
+POAT_AMDSDK_HSA_SETUP([matrixtranspose])
 AT_CHECK_UNQUOTED([make test_MatrixTranspose -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed], 0, 
 [Passed!
 ])
@@ -435,10 +444,6 @@ AT_CHECK_UNQUOTED([make test_MonteCarloAsianDP -sC $abs_top_builddir/examples/AM
 AT_CLEANUP
 
 POAT_AMDSDK_SETUP([montecarloasianmultigpu])
-# kernel compilation fails due to 
-# error: can't convert between vector values of different size ('float4' and 'int')
-# It should be a legal implicit conversion according to 6.3 Operators. Works also with Intel OCL
-AT_XFAIL_IF(true)
 AT_CHECK_UNQUOTED([make test_MonteCarloAsianMultiGPU -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed], 0, 
 [Passed!
 ])
@@ -452,13 +457,13 @@ AT_CHECK_UNQUOTED([make test_NBody -sC $abs_top_builddir/examples/AMDSDK2.9 | gr
 ])
 AT_CLEANUP
 
-POAT_AMDSDK_SETUP([prefixsum])
+POAT_AMDSDK_HSA_SETUP([prefixsum])
 AT_CHECK_UNQUOTED([make test_PrefixSum -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed], 0, 
 [Passed!
 ])
 AT_CLEANUP
 
-POAT_AMDSDK_SETUP([quasirandomsequence])
+POAT_AMDSDK_HSA_SETUP([quasirandomsequence])
 AT_CHECK_UNQUOTED([make test_QuasiRandomSequence -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed], 0, 
 [Passed!
 ])
@@ -482,14 +487,14 @@ AT_CHECK_UNQUOTED([make test_Reduction -sC $abs_top_builddir/examples/AMDSDK2.9
 ])
 AT_CLEANUP
 
-POAT_AMDSDK_SETUP([scanlargearrays])
+POAT_AMDSDK_HSA_SETUP([scanlargearrays])
 # Fails with vectorization. With wiloops and no unrolling, the vectorization won't apply.
 AT_CHECK_UNQUOTED([make test_ScanLargeArrays -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed], 0, 
 [Passed!
 ])
 AT_CLEANUP
 
-POAT_AMDSDK_SETUP([simpleconvolution])
+POAT_AMDSDK_HSA_SETUP([simpleconvolution])
 AT_CHECK_UNQUOTED([make test_SimpleConvolution -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed], 0, 
 [Passed!
 ])
@@ -519,7 +524,7 @@ AT_CHECK_UNQUOTED([make test_SoAversusAoS -sC $abs_top_builddir/examples/AMDSDK2
 ])     
 AT_CLEANUP
 
-POAT_AMDSDK_SETUP([sobelfilter])
+POAT_AMDSDK_HSA_SETUP([sobelfilter])
 AT_CHECK_UNQUOTED([make test_SobelFilter -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed], 0, 
 [Passed!
 ])     
@@ -568,7 +573,7 @@ AT_CHECK_UNQUOTED([make test_UnsharpMask -sC $abs_top_builddir/examples/AMDSDK2.
 ])     
 AT_CLEANUP
 
-POAT_AMDSDK_SETUP([urng])
+POAT_AMDSDK_HSA_SETUP([urng])
 AT_CHECK_UNQUOTED([make test_URNG -sC $abs_top_builddir/examples/AMDSDK2.9 | grep Passed | cut -c -7], 0, 
 [Passed! 
 ])     
diff --git a/tests/testsuite-opencv.at b/tests/testsuite-opencv.at
new file mode 100644
index 0000000..fe30f4d
--- /dev/null
+++ b/tests/testsuite-opencv.at
@@ -0,0 +1,327 @@
+m4_define([POAT_OPENCV_SETUP],[
+  AT_SETUP([$1])
+  AT_KEYWORDS([opencv $1 $2])
+  AT_SKIP_IF([AS_CASE([" $POAT_TESTSUITES "],[*" OpenCV "*],[false],[:])])
+])
+
+AT_BANNER([OpenCV UMat tests])
+
+POAT_OPENCV_SETUP([UMat])
+AT_CHECK_UNQUOTED([make test_UMat -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Core_UMat])
+AT_CHECK_UNQUOTED([make test_Core_UMat -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Image2D])
+AT_CHECK_UNQUOTED([make test_Image2D -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([UMatBasicTests])
+AT_CHECK_UNQUOTED([make test_UMat/UMatBasicTests -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([UMatTestReshape])
+AT_CHECK_UNQUOTED([make test_UMat/UMatTestReshape -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([UMatTestRoi])
+AT_CHECK_UNQUOTED([make test_UMat/UMatTestRoi -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([UMatTestSizeOperations])
+AT_CHECK_UNQUOTED([make test_UMat/UMatTestSizeOperations -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([UMatTestUMatOperations])
+AT_CHECK_UNQUOTED([make test_UMat/UMatTestUMatOperations -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+AT_BANNER(OpenCV Channels test)
+
+POAT_OPENCV_SETUP([OCL_Channels/Merge])
+AT_CHECK_UNQUOTED([make test_OCL_Channels/Merge -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([OCL_Channels/Split])
+AT_CHECK_UNQUOTED([make test_OCL_Channels/Split -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([OCL_Channels/MixChannels])
+AT_CHECK_UNQUOTED([make test_OCL_Channels/MixChannels -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([OCL_Channels/InsertChannel])
+AT_CHECK_UNQUOTED([make test_OCL_Channels/InsertChannels -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([OCL_Channels/ExtractChannel])
+AT_CHECK_UNQUOTED([make test_OCL_Channels/ExtractChannels -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+AT_BANNER(OpenCV Arithm tests)
+
+POAT_OPENCV_SETUP([Lut])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Lut -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Add])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Add -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Subtract])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Subtract -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Mul])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Mul -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Div])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Div -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Min])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Min -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Max])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Max -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([AddWeighted])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/AddWeighted -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Absdiff])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Absdiff -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([CartToPolar])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/CartToPolar -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([PolarToCart])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/PolarToCart -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Transpose])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Transpose -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Bitwise_and])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Bitwise_and -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Bitwise_or])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Bitwise_or -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Bitwise_xor])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Bitwise_xor -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Bitwise_not])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Bitwise_not -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Compare])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Compare -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Pow])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Pow -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([SetIdentity])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/SetIdentity -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Repeat])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Repeat -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([CountNonZero])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/CountNonZero -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Sum])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Sum -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([MeanStdDev])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/MeanStdDev -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Log])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Log -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Exp])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Exp -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Phase])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Phase -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Magnitude])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Magnitude -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Flip])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Flip -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([MinMaxIdx])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/MinMaxIdx -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([MinMaxIdx_Mask])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/MinMaxIdx_Mask -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Norm])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Norm -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([UMatDot])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/UMatDot -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Sqrt])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Sqrt -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Normalize])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Normalize -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([InRange])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/InRange -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([ConvertScaleAbs])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/ConvertScaleAbs -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([ScaleAdd])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/ScaleAdd -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([PatchNaNs])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/PatchNaNs -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Psnr])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/Psnr -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([ReduceSum])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/ReduceSum -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([ReduceMax])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/ReduceMax -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([ReduceAvg])
+AT_CHECK_UNQUOTED([make test_OCL_Arithm/ReduceAvg -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+AT_Banner(OpenCV Core tests)
+
+POAT_OPENCV_SETUP([Gemm])
+AT_CHECK_UNQUOTED([make test_OCL_Core/Gemm -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([Dft])
+AT_CHECK_UNQUOTED([make test_OCL_Core/Dft -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+AT_BANNER(OpenCV ImgProc test)
+
+POAT_OPENCV_SETUP([MultiSpectrums])
+AT_CHECK_UNQUOTED([make test_OCL_OCL_ImgProc/MultiSpectrums -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+AT_BANNER(OpenCV MatrixOperation tests)
+
+POAT_OPENCV_SETUP([ConvertTo])
+AT_CHECK_UNQUOTED([make test_OCL_MatrixOperation/ConvertTo -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([CopyTo])
+AT_CHECK_UNQUOTED([make test_OCL_MatrixOperation/CopyTo -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([SetTo])
+AT_CHECK_UNQUOTED([make test_OCL_MatrixOperation/SetTo -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
+
+POAT_OPENCV_SETUP([UMatExpr])
+AT_CHECK_UNQUOTED([make test_OCL_MatrixOperation/UMatExpr -sC $abs_top_builddir/examples/OpenCV | grep "FAILED"], 1, 
+)
+AT_CLEANUP
diff --git a/tests/testsuite-piglit.at b/tests/testsuite-piglit.at
index 1e8435f..39c8058 100644
--- a/tests/testsuite-piglit.at
+++ b/tests/testsuite-piglit.at
@@ -1,19 +1,9 @@
 AT_BANNER([Piglit OpenCL tests])
 
-AT_SETUP([Piglit testsuite with LLVM 3.4])
-AT_KEYWORDS([piglit long])
-AT_SKIP_IF([AS_CASE([" $POAT_TESTSUITES "],[*" piglit "*],[false],[:])])
-AT_SKIP_IF([! grep -q "#define LLVM_3_4" $abs_top_builddir/config.h])
-#AT_CHECK([make -s -C $abs_top_builddir/examples/piglit/piglit], ignore, ignore, ignore)
-AT_CHECK([cd $abs_top_builddir/examples/piglit/; piglit/piglit-run.py -v piglit/tests/all_cl.tests piglit/results/all 2>&1 | grep "pass ::" > result], ignore, ignore, ignore)
-AT_CHECK([cd $abs_top_builddir/examples/piglit/; LC_ALL=C sort result -o sorted_result; LC_ALL=C comm -23 sorted_ref sorted_result])
-AT_CLEANUP
-
 AT_SETUP([Piglit testsuite with LLVM 3.5])
 AT_KEYWORDS([piglit long])
 AT_SKIP_IF([AS_CASE([" $POAT_TESTSUITES "],[*" piglit "*],[false],[:])])
 AT_SKIP_IF([! grep -q "#define LLVM_3_5" $abs_top_builddir/config.h])
-#AT_CHECK([make -s -C $abs_top_builddir/examples/piglit/piglit], ignore, ignore, ignore)
-AT_CHECK([cd $abs_top_builddir/examples/piglit/; piglit/piglit-run.py -v piglit/tests/all_cl.tests piglit/results/all 2>&1 | grep "pass ::" > result], ignore, ignore, ignore)
-AT_CHECK([cd $abs_top_builddir/examples/piglit/; LC_ALL=C sort result -o sorted_result; LC_ALL=C comm -23 sorted_ref_llvm_3.5 sorted_result])
+AT_CHECK([cd $abs_top_builddir/examples/piglit/; ./produce_results.sh ], ignore, ignore, ignore)
+AT_CHECK([cd $abs_top_builddir/examples/piglit/; LC_ALL=C comm -23 sorted_ref_llvm_3.5 sorted_result])
 AT_CLEANUP
diff --git a/tests/testsuite-regression.at b/tests/testsuite-regression.at
index dc0bbee..f0b28f7 100644
--- a/tests/testsuite-regression.at
+++ b/tests/testsuite-regression.at
@@ -241,3 +241,26 @@ value is changed at global_id: 6, local_id 2, group_id 1, to: 3
 ])
 AT_CHECK([POCL_WORK_GROUP_METHOD=loops $abs_top_builddir/tests/regression/test_assign_loop_variable_to_privvar_makes_it_local_2], 0, expout)
 AT_CLEANUP
+
+# See: https://github.com/pocl/pocl/issues/195
+# Possibly still fails with multi-AS targets.
+AT_SETUP([local struct arrays produce illegal AS casts])
+AT_KEYWORDS([regression local_struct_array])
+# The HSA branch of LLVM 3.7 is probably outdated in comparison
+# to the upstream trunk and makes this case fail.
+AT_SKIP_IF([grep -q "#define BUILD_HSA" $abs_top_builddir/config.h])
+AT_CHECK_UNQUOTED([$abs_top_builddir/tests/kernel/kernel test_local_struct_array], 0,
+[Running test test_local_struct_array...
+OK
+])
+AT_XFAIL_IF([grep -q "#define LLVM_BUILT_WITH_ASSERTS" $abs_top_builddir/config.h && \
+! grep -q "#define LLVM_3_2" $abs_top_builddir/config.h && \
+! grep -q "#define LLVM_3_3" $abs_top_builddir/config.h])
+AT_CLEANUP
+
+
+# https://github.com/pocl/pocl/issues/231
+AT_SETUP([LoopVectorizer crash with Haswell and Broadwell - issue 231])
+AT_KEYWORDS([regression issue_231])
+AT_CHECK([$abs_top_builddir/tests/regression/test_issue_231], 0)
+AT_CLEANUP
diff --git a/tests/testsuite-runtime.at b/tests/testsuite-runtime.at
index c7e4d4e..e5d2258 100644
--- a/tests/testsuite-runtime.at
+++ b/tests/testsuite-runtime.at
@@ -16,6 +16,21 @@ AT_KEYWORDS([runtime])
 AT_CHECK([$abs_top_builddir/tests/runtime/test_clGetEventInfo])
 AT_CLEANUP
 
+AT_SETUP([read/copy/write buffer])
+AT_KEYWORDS([runtime])
+AT_CHECK([$abs_top_builddir/tests/runtime/test_read-copy-write-buffer])
+AT_CLEANUP
+
+AT_SETUP([event cycle])
+AT_KEYWORDS([runtime])
+AT_CHECK([$abs_top_builddir/tests/runtime/test_event_cycle])
+AT_CLEANUP
+
+AT_SETUP([event freeing])
+AT_KEYWORDS([runtime])
+AT_CHECK([$abs_top_builddir/tests/runtime/test_event_free])
+AT_CLEANUP
+
 AT_SETUP([clCreateProgramWithBinary])
 AT_KEYWORDS([runtime])
 AT_CHECK([$abs_top_builddir/tests/runtime/test_clCreateProgramWithBinary])
@@ -27,6 +42,21 @@ AT_KEYWORDS([runtime])
 AT_CHECK([cd $abs_top_srcdir/tests/runtime/; $abs_top_builddir/tests/runtime/test_clBuildProgram], 0, ignore, ignore)
 AT_CLEANUP
 
+#test_kernel_cache_includes tests include paths so it must be executed in the directory
+AT_SETUP([test_kernel_cache_includes])
+AT_KEYWORDS([runtime])
+AT_CHECK_UNQUOTED([cd $abs_top_builddir/tests/runtime/; $abs_top_builddir/tests/runtime/test_kernel_cache_includes], 0,
+[$(cat $abs_top_srcdir/tests/runtime/test_kernel_cache_includes_expout.txt)
+])
+AT_CLEANUP
+
+AT_SETUP([clBuildProgram link error])
+AT_XFAIL_IF(true)
+AT_KEYWORDS([runtime])
+AT_CHECK([$abs_top_builddir/tests/runtime/test_link_error])
+AT_CLEANUP
+
+
 AT_SETUP([clFinish])
 AT_KEYWORDS([runtime])
 AT_CHECK_UNQUOTED([$abs_top_builddir/tests/runtime/test_clFinish | grep "ABABC"], 0, [ABABC
@@ -64,3 +94,8 @@ AT_XFAIL_IF([grep -q "#define LLVM_3_2" $abs_top_builddir/config.h])
 AT_KEYWORDS([runtime])
 AT_CHECK([$abs_top_builddir/tests/runtime/test_clGetKernelArgInfo], 0, ignore, ignore)
 AT_CLEANUP
+
+AT_SETUP([clCreateSubDevices])
+AT_KEYWORDS([runtime])
+AT_CHECK([$abs_top_builddir/tests/runtime/test_clCreateSubDevices])
+AT_CLEANUP
diff --git a/tests/testsuite-tce.at b/tests/testsuite-tce.at
index 012ed3d..ff60c0e 100644
--- a/tests/testsuite-tce.at
+++ b/tests/testsuite-tce.at
@@ -36,7 +36,7 @@ AT_CLEANUP
 
 AT_SETUP([Half-precision floats on ttasim (loopvec)])
 AT_KEYWORDS([tce tta ttasim half])
-AT_SKIP_IF([! grep -c "define TCE_AVAILABLE" $abs_top_builddir/config.h])
+AT_SKIP_IF([! grep -c "define TCEMC_AVAILABLE" $abs_top_builddir/config.h])
 AT_CHECK([make -s -C $abs_top_builddir/tests/tce/fp16 run | egrep -v "^make"], 0, 
 [through conversion: 42
 2.500000
diff --git a/tests/testsuite-viennacl.at b/tests/testsuite-viennacl.at
index acf5c9d..9b18409 100644
--- a/tests/testsuite-viennacl.at
+++ b/tests/testsuite-viennacl.at
@@ -90,8 +90,6 @@ AT_CLEANUP
 #AT_CLEANUP
 #
 POAT_VCL_SETUP([global_variables-test-opencl])
-#This spinns on LLVM 3.6
-AT_SKIP_IF([egrep -q "#define LLVM_3_6" $abs_top_builddir/config.h])
 POAT_VCL_CHECK_RUN(tests/global_variables-test-opencl)
 AT_CLEANUP
 
diff --git a/tests/testsuite.at b/tests/testsuite.at
index f909299..a216bab 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -3,6 +3,7 @@
 # Makefile.am for pocl/lib/kernel.
 # 
 # Copyright (c) 2011 Universidad Rey Juan Carlos
+#               2011-2015 pocl developers
 # 
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
@@ -34,7 +35,7 @@ AT_CLEANUP
 AT_BANNER([OpenCL specification tests])
 
 AT_SETUP([example1: dot product])
-AT_KEYWORDS([tce])
+AT_KEYWORDS([tce hsa])
 AT_CHECK_UNQUOTED([$abs_top_builddir/examples/example1/example1], 0,
 [$(cat $abs_top_srcdir/tests/example_expout.txt)
 ])
@@ -61,13 +62,13 @@ AT_CHECK_UNQUOTED([$abs_top_builddir/examples/example1-spir32/example1-spir32],
 AT_CLEANUP
 
 AT_SETUP([example2: matrix transpose])
-AT_KEYWORDS([tce])
+AT_KEYWORDS([tce hsa])
 AT_CHECK([$abs_top_builddir/examples/example2/example2], 0, [OK
 ])
 AT_CLEANUP
 
 AT_SETUP([example2a: matrix transpose (automatic locals)])
-AT_KEYWORDS([tce])
+AT_KEYWORDS([tce hsa])
 AT_CHECK([$abs_top_builddir/examples/example2a/example2a], 0, [OK
 ])
 AT_CLEANUP
@@ -163,6 +164,16 @@ OK
 AT_CHECK([$abs_top_builddir/tests/kernel/kernel test_min_max], 0, expout)
 AT_CLEANUP
 
+AT_SETUP([Kernel functions length, distance, and normalize])
+# This tests in particular for unintended overflow
+AT_KEYWORDS([length_distance])
+AT_DATA([expout],
+[Running test test_length_distance...
+OK
+])
+AT_CHECK([$abs_top_builddir/tests/kernel/kernel test_length_distance], 0, expout)
+AT_CLEANUP
+
 AT_SETUP([Kernel functions fmin, fmax, fma])
 AT_KEYWORDS([fmin_fmax_fma])
 AT_XFAIL_IF([grep HOST_CPU $abs_top_builddir/config.h | cut -d\" -f2 | grep -q powerpc ])
@@ -173,6 +184,18 @@ OK
 AT_CHECK([$abs_top_builddir/tests/kernel/kernel test_fmin_fmax_fma], 0, expout)
 AT_CLEANUP
 
+AT_SETUP([Kernel functions frexp modf])
+AT_KEYWORDS([frexp_modf])
+AT_DATA([expout],
+[Running test test_frexp_modf...
+frexp(8e2f): 0.8 10
+modf(1.5f): 0.5 1.000000
+OK
+])
+AT_CHECK([$abs_top_builddir/tests/kernel/kernel test_frexp_modf], 0, expout)
+AT_XFAIL_IF([grep -q "#undef USE_VECMATHLIB" $abs_top_builddir/config.h])
+AT_CLEANUP
+
 # This was a an LLVM 3.3 code gen bug.
 AT_SETUP([A saturating conversion from long to uint])
 AT_KEYWORDS([convert_sat_regression])
@@ -381,3 +404,4 @@ m4_include(testsuite-vexcl.at)
 m4_include(testsuite-halide.at)
 m4_include(testsuite-cloverleaf.at)
 m4_include(testsuite-piglit.at)
+m4_include(testsuite-opencv.at)
diff --git a/tests/workgroup/Makefile.in b/tests/workgroup/Makefile.in
index fb65a4c..e488b9a 100644
--- a/tests/workgroup/Makefile.in
+++ b/tests/workgroup/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -39,7 +39,17 @@
 # THE SOFTWARE.
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -105,8 +115,6 @@ host_triplet = @host@
 target_triplet = @target@
 noinst_PROGRAMS = run_kernel$(EXEEXT)
 subdir = tests/workgroup
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/config/depcomp
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -115,6 +123,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -187,6 +196,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -238,6 +248,9 @@ HOST_SIZEOF_DOUBLE = @HOST_SIZEOF_DOUBLE@
 HOST_SIZEOF_HALF = @HOST_SIZEOF_HALF@
 HOST_SIZEOF_LONG = @HOST_SIZEOF_LONG@
 HOST_SIZEOF_VOID_P = @HOST_SIZEOF_VOID_P@
+HSAILASM = @HSAILASM@
+HSA_INCLUDES = @HSA_INCLUDES@
+HSA_LIBS = @HSA_LIBS@
 HWLOC_CFLAGS = @HWLOC_CFLAGS@
 HWLOC_LIBS = @HWLOC_LIBS@
 ICD_LD_FLAGS = @ICD_LD_FLAGS@
@@ -274,6 +287,7 @@ LLVM_VERSION = @LLVM_VERSION@
 LN_S = @LN_S@
 LTDL_LIBS = @LTDL_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -412,7 +426,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/workgroup/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign tests/workgroup/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -682,6 +695,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/tests/workgroup/run_kernel.c b/tests/workgroup/run_kernel.c
index 16c434e..154588e 100644
--- a/tests/workgroup/run_kernel.c
+++ b/tests/workgroup/run_kernel.c
@@ -92,7 +92,7 @@ main (int argc, char **argv)
     return -1; 
 
   clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &cb); 
-  devices = (cl_device_id *) malloc(cb); 
+  devices = (cl_device_id *) malloc(cb);
   clGetContextInfo(context, CL_CONTEXT_DEVICES, cb, devices, NULL); 
  
   cmd_queue = clCreateCommandQueue(context, devices[0], 0, NULL); 
diff --git a/tools/patches/clang-3.7-hsail-branch.patch b/tools/patches/clang-3.7-hsail-branch.patch
new file mode 100644
index 0000000..b9f52f2
--- /dev/null
+++ b/tools/patches/clang-3.7-hsail-branch.patch
@@ -0,0 +1,2139 @@
+Index: include/clang/Basic/BuiltinsHSAIL.def
+===================================================================
+--- /dev/null
++++ include/clang/Basic/BuiltinsHSAIL.def
+@@ -0,0 +1,181 @@
++//==- BuiltinsHSAIL.def - HSAIL Builtin function database ----------*- C++ -*-==//
++//
++//                     The LLVM Compiler Infrastructure
++//
++// This file is distributed under the University of Illinois Open Source
++// License. See LICENSE.TXT for details.
++//
++//===----------------------------------------------------------------------===//
++//
++// This file defines the HSAIL-specific builtin function database. Users of this
++// file must define the BUILTIN macro to make use of this information.
++//
++//===----------------------------------------------------------------------===//
++
++// The format of this database matches clang/Basic/Builtins.def.
++
++// 5.2 Integer Arithmetic Instructions
++BUILTIN(__builtin_hsail_smulhi, "iii", "nc")
++BUILTIN(__builtin_hsail_smulhil, "WiWiWi", "nc")
++BUILTIN(__builtin_hsail_umulhi, "UiUiUi", "nc")
++BUILTIN(__builtin_hsail_umulhil, "UWiUWiUWi", "nc")
++
++// 5.4 24-Bit Integer Optimization Instructions
++BUILTIN(__builtin_hsail_smad24, "iiii", "nc")
++BUILTIN(__builtin_hsail_umad24, "UiUiUiUi", "nc")
++BUILTIN(__builtin_hsail_smad24hi, "iiii", "nc")
++BUILTIN(__builtin_hsail_umad24hi, "UiUiUiUi", "nc")
++BUILTIN(__builtin_hsail_smul24, "iii", "nc")
++BUILTIN(__builtin_hsail_umul24, "UiUiUi", "nc")
++BUILTIN(__builtin_hsail_smul24hi, "iii", "nc")
++BUILTIN(__builtin_hsail_umul24hi, "UiUiUi", "nc")
++
++// 5.7 Bit String Instructions
++BUILTIN(__builtin_hsail_sbitextract, "iiUiUi", "nc")
++BUILTIN(__builtin_hsail_sbitextractl, "WiWiUiUi", "nc")
++BUILTIN(__builtin_hsail_ubitextract, "UiUiUiUi", "nc")
++BUILTIN(__builtin_hsail_ubitextractl, "UWiUWiUiUi", "nc")
++BUILTIN(__builtin_hsail_sbitinsert, "iiiUiUi", "nc")
++BUILTIN(__builtin_hsail_sbitinsertl, "WiWiWiUiUi", "nc")
++BUILTIN(__builtin_hsail_ubitinsert, "iiiUiUi", "nc")
++BUILTIN(__builtin_hsail_ubitinsertl, "UWiUWiUWiUiUi", "nc")
++BUILTIN(__builtin_hsail_bitmask, "UiUiUi", "nc")
++BUILTIN(__builtin_hsail_bitmaskl, "UWiUiUi", "nc")
++BUILTIN(__builtin_hsail_bitrev, "UiUi", "nc")
++BUILTIN(__builtin_hsail_bitrevl, "UWiUWi", "nc")
++BUILTIN(__builtin_hsail_bitselect, "UiUiUiUi", "nc")
++BUILTIN(__builtin_hsail_bitselectl, "UWiUWiUWiUWi", "nc")
++BUILTIN(__builtin_hsail_sfirstbit, "ii", "nc")
++BUILTIN(__builtin_hsail_sfirstbitl, "iWi", "nc")
++BUILTIN(__builtin_hsail_ufirstbit, "UiUi", "nc")
++BUILTIN(__builtin_hsail_ufirstbitl, "UiUWi", "nc")
++BUILTIN(__builtin_hsail_lastbit, "UiUi", "nc")
++BUILTIN(__builtin_hsail_lastbitl, "UiUWi", "nc")
++
++// 5.11 Floating-Point Arithmetic Instructions
++BUILTIN(__builtin_hsail_fadd, "dIbIidd", "nc")
++BUILTIN(__builtin_hsail_faddf, "fIbIiff", "nc")
++
++BUILTIN(__builtin_hsail_fceil, "dIbd", "nc")
++BUILTIN(__builtin_hsail_fceilf, "fIbf", "nc")
++
++BUILTIN(__builtin_hsail_fdiv, "dIbIidd", "nc")
++BUILTIN(__builtin_hsail_fdivf, "fIbIiff", "nc")
++
++BUILTIN(__builtin_hsail_ffloor, "dIbd", "nc")
++BUILTIN(__builtin_hsail_ffloorf, "fIbf", "nc")
++
++BUILTIN(__builtin_hsail_ffma, "dIbIiddd", "nc")
++BUILTIN(__builtin_hsail_ffmaf, "fIbIifff", "nc")
++
++BUILTIN(__builtin_hsail_ffract, "dIbd", "nc")
++BUILTIN(__builtin_hsail_ffractf, "fIbf", "nc")
++
++BUILTIN(__builtin_hsail_fmax, "dIbdd", "nc")
++BUILTIN(__builtin_hsail_fmaxf, "fIbff", "nc")
++
++BUILTIN(__builtin_hsail_fmin, "dIbdd", "nc")
++BUILTIN(__builtin_hsail_fminf, "fIbff", "nc")
++
++BUILTIN(__builtin_hsail_fmul, "dIbIidd", "nc")
++BUILTIN(__builtin_hsail_fmulf, "fIbIiff", "nc")
++
++BUILTIN(__builtin_hsail_frint, "dIbd", "nc")
++BUILTIN(__builtin_hsail_frintf, "fIbf", "nc")
++
++BUILTIN(__builtin_hsail_fsqrt, "dIbIid", "nc")
++BUILTIN(__builtin_hsail_fsqrtf, "fIbIif", "nc")
++
++BUILTIN(__builtin_hsail_fsub, "dIbIidd", "nc")
++BUILTIN(__builtin_hsail_fsubf, "fIbIiff", "nc")
++
++
++// 5.12 Floating-Point Optimization Instruction
++BUILTIN(__builtin_hsail_fmad, "dIbIiddd", "nc")
++BUILTIN(__builtin_hsail_fmadf, "fIbIifff", "nc")
++
++
++// 5.13 Floating-Point Bit Instructions
++BUILTIN(__builtin_hsail_class, "bdi", "nc")
++BUILTIN(__builtin_hsail_classf, "bfi", "nc")
++
++
++// 5.14 Native Floating-Point Instructions
++BUILTIN(__builtin_hsail_ncosf, "ff", "nc")
++BUILTIN(__builtin_hsail_nexp2f, "ff", "nc")
++BUILTIN(__builtin_hsail_nfma, "dddd", "nc")
++BUILTIN(__builtin_hsail_nfmaf, "ffff", "nc")
++BUILTIN(__builtin_hsail_nlog2f, "ff", "nc")
++BUILTIN(__builtin_hsail_nrcpf, "ff", "nc")
++BUILTIN(__builtin_hsail_nrsqrtf, "ff", "nc")
++BUILTIN(__builtin_hsail_nsinf, "ff", "nc")
++BUILTIN(__builtin_hsail_nsqrtf, "ff", "nc")
++
++// 5.15 Multimedia Instructions
++BUILTIN(__builtin_hsail_bitalign, "iiii", "nc")
++BUILTIN(__builtin_hsail_bytealign, "iiii", "nc")
++BUILTIN(__builtin_hsail_lerp, "iiii", "nc")
++BUILTIN(__builtin_hsail_packcvt, "iffff", "nc")
++BUILTIN(__builtin_hsail_unpackcvt, "fiIi", "nc")
++BUILTIN(__builtin_hsail_sad_u32_u32, "UiUiUiUi", "nc")
++BUILTIN(__builtin_hsail_sad_u32_u16x2, "UiUiUiUi", "nc")
++BUILTIN(__builtin_hsail_sad_u32_u8x4, "UiUiUiUi", "nc")
++BUILTIN(__builtin_hsail_sadhi, "UiUiUiUi", "nc")
++
++// 5.16 Segment Checking (segmentp) Instruction
++BUILTIN(__builtin_hsail_segmentp, "bIiIbc*4", "nc")
++
++// 6.9 Memory Fence (memfence) Instruction
++BUILTIN(__builtin_hsail_memfence, "vIiIi", "n")
++
++// 7.6 Image Fence (imagefence) Instruction
++BUILTIN(__builtin_hsail_imagefence, "v", "n")
++
++// 9.1 Barrier Instructions
++BUILTIN(__builtin_hsail_barrier, "vIi", "n")
++BUILTIN(__builtin_hsail_wavebarrier, "v", "n")
++
++// 9.4 Cross-Lane Instructions
++BUILTIN(__builtin_hsail_activelanecount, "UiIib", "nc")
++BUILTIN(__builtin_hsail_activelaneid, "UiIi", "nc")
++BUILTIN(__builtin_hsail_activelanemask, "E4WiIib", "n")
++BUILTIN(__builtin_hsail_activelanepermute, "UiIiiiib", "n")
++BUILTIN(__builtin_hsail_activelanepermutel, "UWiIiWiiWib", "n")
++
++// 11.1 Kernel Dispatch Packet Instructions
++BUILTIN(__builtin_hsail_currentworkgroupsize, "UiIi", "nc")
++BUILTIN(__builtin_hsail_currentworkitemflatid, "Ui", "nc")
++BUILTIN(__builtin_hsail_dim, "Ui", "nc")
++BUILTIN(__builtin_hsail_gridgroups, "UiIi", "nc")
++BUILTIN(__builtin_hsail_gridsize, "UiIi", "nc")
++// __builtin_hsail_packetcompletionsig
++BUILTIN(__builtin_hsail_packetid, "UWi", "nc")
++BUILTIN(__builtin_hsail_workgroupid, "UiIi", "nc")
++BUILTIN(__builtin_hsail_workgroupsize, "UiIi", "nc")
++BUILTIN(__builtin_hsail_workitemabsid, "UiIi", "nc")
++BUILTIN(__builtin_hsail_workitemabsidl, "UWiIi", "nc")
++BUILTIN(__builtin_hsail_workitemflatabsid, "Ui", "nc")
++BUILTIN(__builtin_hsail_workitemflatabsidl, "UWi", "nc")
++BUILTIN(__builtin_hsail_workitemflatid, "Ui", "nc")
++BUILTIN(__builtin_hsail_workitemid, "UiIi", "nc")
++
++// 11.4 Miscellaneous Instructions
++BUILTIN(__builtin_hsail_clock, "UWi", "n")
++BUILTIN(__builtin_hsail_cuid, "Ui", "nc")
++BUILTIN(__builtin_hsail_groupbaseptr, "c*3", "nc")
++BUILTIN(__builtin_hsail_kernargbaseptr, "c*7", "nc")
++BUILTIN(__builtin_hsail_laneid, "Ui", "nc")
++BUILTIN(__builtin_hsail_maxcuid, "Ui", "nc")
++BUILTIN(__builtin_hsail_maxwaveid, "Ui", "nc")
++
++BUILTIN(__builtin_hsail_waveid, "Ui", "nc")
++
++// GCN extensions
++BUILTIN(__builtin_hsail_gcn_bfm, "UiUiUi", "nc")
++BUILTIN(__builtin_hsail_gcn_msad, "UiUiUiUi", "nc")
++BUILTIN(__builtin_hsail_gcn_qsad, "UWiUWiUWiUWi", "nc")
++BUILTIN(__builtin_hsail_gcn_mqsad, "UWiUWiUiUWi", "nc")
++BUILTIN(__builtin_hsail_gcn_sadw, "UiUiUiUi", "nc")
++BUILTIN(__builtin_hsail_gcn_sadd, "UiUiUiUi", "nc")
++
++#undef BUILTIN
+Index: include/clang/Basic/TargetBuiltins.h
+===================================================================
+--- include/clang/Basic/TargetBuiltins.h
++++ include/clang/Basic/TargetBuiltins.h
+@@ -146,6 +146,16 @@
+     };
+   }
+ 
++  /// \brief HSAIL builtins
++  namespace HSAIL {
++  enum {
++    LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
++  #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
++  #include "clang/Basic/BuiltinsHSAIL.def"
++    LastTSBuiltin
++  };
++  }
++
+   /// \brief MIPS builtins
+   namespace Mips {
+     enum {
+Index: include/clang/module.modulemap
+===================================================================
+--- include/clang/module.modulemap
++++ include/clang/module.modulemap
+@@ -28,6 +28,7 @@
+   textual header "Basic/BuiltinsARM.def"
+   textual header "Basic/Builtins.def"
+   textual header "Basic/BuiltinsHexagon.def"
++  textual header "Basic/BuiltinsHSAIL.def"
+   textual header "Basic/BuiltinsLe64.def"
+   textual header "Basic/BuiltinsMips.def"
+   textual header "Basic/BuiltinsNEON.def"
+Index: lib/Basic/Targets.cpp
+===================================================================
+--- lib/Basic/Targets.cpp
++++ lib/Basic/Targets.cpp
+@@ -5483,6 +5483,130 @@
+ #include "clang/Basic/BuiltinsHexagon.def"
+ };
+ 
++static const unsigned HSAILAddrSpaceMap[] = {
++  1,    // opencl_global
++  3,    // opencl_local
++  2,    // opencl_constant
++  4,    // opencl_generic
++  1,    // cuda_device
++  2,    // cuda_constant
++  3     // cuda_shared
++};
++
++// If you edit the description strings, make sure you update
++// getPointerWidthV().
++
++static const char *DescriptionStringHSAIL =
++  "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
++  "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64";
++
++static const char *DescriptionStringHSAIL64 =
++  "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32"
++  "-p6:32:32-p7:64:64-p8:32:32-p9:64:64"
++  "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
++  "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64";
++
++class HSAILTargetInfo : public TargetInfo {
++  static const Builtin::Info BuiltinInfo[];
++  bool IsLargeModel;
++  bool FullProfile;
++
++  enum DeviceKind {
++    HSAIL_NONE,
++    HSAIL_KAVERI
++  } Device;
++
++public:
++  HSAILTargetInfo(const llvm::Triple &Triple)
++    : TargetInfo(Triple),
++      IsLargeModel(false),
++      FullProfile(true) {
++
++    if (Triple.getArch() == llvm::Triple::hsail) {
++      DescriptionString = DescriptionStringHSAIL;
++    } else {
++      DescriptionString = DescriptionStringHSAIL64;
++      IsLargeModel = true;
++    }
++
++    AddrSpaceMap = &HSAILAddrSpaceMap;
++    UseAddrSpaceMapMangling = true;
++  }
++
++  uint64_t getPointerWidthV(unsigned AddrSpace) const override {
++    switch (AddrSpace) {
++      default:
++        return 64;
++      case 0:
++      case 3:
++      case 5:
++        return 32;
++    }
++  }
++
++  const char *getClobbers() const override {
++    return "";
++  }
++
++  void getGCCRegNames(const char *const *&Names,
++                      unsigned &NumNames) const override {
++    Names = nullptr;
++    NumNames = 0;
++  }
++
++  void getGCCRegAliases(const GCCRegAlias *&Aliases,
++                        unsigned &NumAliases) const override {
++    Aliases = nullptr;
++    NumAliases = 0;
++  }
++
++  bool validateAsmConstraint(const char *&Name,
++                             TargetInfo::ConstraintInfo &info) const override {
++    return true;
++  }
++
++  void getTargetBuiltins(const Builtin::Info *&Records,
++                         unsigned &NumRecords) const override {
++    Records = BuiltinInfo;
++    NumRecords = clang::HSAIL::LastTSBuiltin - Builtin::FirstTSBuiltin;
++  }
++
++  void getTargetDefines(const LangOptions &Opts,
++                        MacroBuilder &Builder) const override {
++    if (IsLargeModel)
++      Builder.defineMacro("__HSAIL64__");
++    else
++      Builder.defineMacro("__HSAIL__");
++
++    if (FullProfile && Opts.OpenCL) {
++      Builder.defineMacro("cl_khr_fp64");
++    }
++  }
++
++  BuiltinVaListKind getBuiltinVaListKind() const override {
++    return TargetInfo::CharPtrBuiltinVaList;
++  }
++
++  bool setCPU(const std::string &Name) override {
++    llvm_unreachable("meatspin");
++
++    Device = llvm::StringSwitch<DeviceKind>(Name)
++      .Case("kaveri", HSAIL_KAVERI)
++      .Default(HSAIL_NONE);
++
++    if (Device == HSAIL_NONE)
++      return false;
++
++    return true;
++  }
++};
++
++const Builtin::Info HSAILTargetInfo::BuiltinInfo[] = {
++#define BUILTIN(ID, TYPE, ATTRS)                \
++  { #ID, TYPE, ATTRS, 0, ALL_LANGUAGES },
++#include "clang/Basic/BuiltinsHSAIL.def"
++};
++
+ // Shared base class for SPARC v8 (32-bit) and SPARC v9 (64-bit).
+ class SparcTargetInfo : public TargetInfo {
+   static const TargetInfo::GCCRegAlias GCCRegAliases[];
+@@ -7203,6 +7327,10 @@
+   case llvm::Triple::r600:
+     return new AMDGPUTargetInfo(Triple);
+ 
++  case llvm::Triple::hsail:
++  case llvm::Triple::hsail64:
++    return new HSAILTargetInfo(Triple);
++
+   case llvm::Triple::sparc:
+     switch (os) {
+     case llvm::Triple::Linux:
+Index: lib/CodeGen/CGBuiltin.cpp
+===================================================================
+--- lib/CodeGen/CGBuiltin.cpp
++++ lib/CodeGen/CGBuiltin.cpp
+@@ -1877,6 +1877,9 @@
+   case llvm::Triple::r600:
+   case llvm::Triple::amdgcn:
+     return EmitAMDGPUBuiltinExpr(BuiltinID, E);
++  case llvm::Triple::hsail:
++  case llvm::Triple::hsail64:
++    return EmitHSAILBuiltinExpr(BuiltinID, E);
+   case llvm::Triple::systemz:
+     return EmitSystemZBuiltinExpr(BuiltinID, E);
+   case llvm::Triple::nvptx:
+@@ -6814,6 +6817,355 @@
+   }
+ }
+ 
++static Value *emitHSAILBitExtractBuiltin(CodeGenFunction &CGF,
++                                         const CallExpr *E,
++                                         unsigned IntrinsicID) {
++  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, CGF.ConvertType(E->getType()));
++
++  Value *Args[] = {
++    CGF.EmitScalarExpr(E->getArg(0)),
++    CGF.EmitScalarExpr(E->getArg(1)),
++    CGF.EmitScalarExpr(E->getArg(2))
++  };
++
++  return CGF.Builder.CreateCall(F, Args);
++}
++
++static Value *emitHSAILBitInsertBuiltin(CodeGenFunction &CGF,
++                                        const CallExpr *E,
++                                        unsigned IntrinsicID) {
++  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, CGF.ConvertType(E->getType()));
++
++  Value *Args[] = {
++    CGF.EmitScalarExpr(E->getArg(0)),
++    CGF.EmitScalarExpr(E->getArg(1)),
++    CGF.EmitScalarExpr(E->getArg(2)),
++    CGF.EmitScalarExpr(E->getArg(3))
++  };
++
++  return CGF.Builder.CreateCall(F, Args);
++}
++
++static Value *emitHSAILUnaryRetTypeBuiltin(CodeGenFunction &CGF,
++                                           const CallExpr *E,
++                                           unsigned IntrinsicID) {
++  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, CGF.ConvertType(E->getType()));
++
++  Value *Args[] = {
++    CGF.EmitScalarExpr(E->getArg(0))
++  };
++
++  return CGF.Builder.CreateCall(F, Args);
++}
++
++static Value *emitHSAILUnarySrcTypeBuiltin(CodeGenFunction &CGF,
++                                           const CallExpr *E,
++                                           unsigned IntrinsicID) {
++  Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
++  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
++  return CGF.Builder.CreateCall(F, Src0);
++}
++
++static Value *emitHSAILBinaryRetTypeBuiltin(CodeGenFunction &CGF,
++                                            const CallExpr *E,
++                                            unsigned IntrinsicID) {
++  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, CGF.ConvertType(E->getType()));
++
++  Value *Args[] = {
++    CGF.EmitScalarExpr(E->getArg(0)),
++    CGF.EmitScalarExpr(E->getArg(1))
++  };
++
++  return CGF.Builder.CreateCall(F, Args);
++}
++
++static Value *emitHSAILTernaryRetTypeBuiltin(CodeGenFunction &CGF,
++                                             const CallExpr *E,
++                                             unsigned IntrinsicID) {
++  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, CGF.ConvertType(E->getType()));
++
++  Value *Args[] = {
++    CGF.EmitScalarExpr(E->getArg(0)),
++    CGF.EmitScalarExpr(E->getArg(1)),
++    CGF.EmitScalarExpr(E->getArg(2))
++  };
++
++  return CGF.Builder.CreateCall(F, Args);
++}
++
++static Value *emitHSAILInstModBuiltin(CodeGenFunction &CGF,
++                                      const CallExpr *E,
++                                      unsigned IntrinsicID) {
++  Value *FTZ = CGF.EmitScalarExpr(E->getArg(0));
++  Value *Round = CGF.EmitScalarExpr(E->getArg(1));
++
++  Value *Src0 = CGF.EmitScalarExpr(E->getArg(2));
++  Value *Src1 = nullptr;
++  Value *Src2 = nullptr;
++
++  unsigned NumArgs = E->getNumArgs();
++  switch (NumArgs) {
++  case 3:
++    break;
++  case 4:
++    Src1 = CGF.EmitScalarExpr(E->getArg(3));
++    break;
++  case 5:
++    Src1 = CGF.EmitScalarExpr(E->getArg(3));
++    Src2 = CGF.EmitScalarExpr(E->getArg(4));
++    break;
++  default:
++    return nullptr;
++  }
++
++  Value *Args[5] = {
++    FTZ,
++    Round,
++    Src0,
++    Src1,
++    Src2
++  };
++
++  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
++  return CGF.Builder.CreateCall(F, makeArrayRef(Args, NumArgs));
++}
++
++static Value *emitHSAILInstModNoRoundBuiltin(CodeGenFunction &CGF,
++                                             const CallExpr *E,
++                                             unsigned IntrinsicID) {
++  Value *FTZ = CGF.EmitScalarExpr(E->getArg(0));
++  Value *Src0 = CGF.EmitScalarExpr(E->getArg(1));
++  Value *Src1 = nullptr;
++
++  unsigned NumArgs = E->getNumArgs();
++  switch (NumArgs) {
++  case 2:
++    break;
++  case 3:
++    Src1 = CGF.EmitScalarExpr(E->getArg(2));
++    break;
++  default:
++    return nullptr;
++  }
++
++  Value *Args[3] = {
++    FTZ,
++    Src0,
++    Src1
++  };
++
++  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
++  return CGF.Builder.CreateCall(F, makeArrayRef(Args, NumArgs));
++}
++
++static Value *emitHSAILActiveLaneMaskBuiltin(CodeGenFunction &CGF,
++                                             const CallExpr *E,
++                                             unsigned IntrinsicID) {
++  Value *Args[] = {
++    CGF.EmitScalarExpr(E->getArg(0)),
++    CGF.EmitScalarExpr(E->getArg(1)),
++  };
++
++  // Intrinsic returns a struct of 4 elements, the builtin returns a
++  // 4-vector. Pack the struct elements into the vector.
++  Value *F = CGF.CGM.getIntrinsic(IntrinsicID);
++  Value *Call = CGF.Builder.CreateCall(F, Args);
++
++  llvm::VectorType *V4I64Ty
++    = llvm::VectorType::get(CGF.Builder.getInt64Ty(), 4);
++  Value *Vec = UndefValue::get(V4I64Ty);
++
++  for (unsigned I = 0; I < 4; ++I) {
++    Value *Elt = CGF.Builder.CreateExtractValue(Call, I);
++    Value *EltIdx = CGF.Builder.getInt32(I);
++    Vec = CGF.Builder.CreateInsertElement(Vec, Elt, EltIdx);
++  }
++
++  return Vec;
++}
++
++static Value *emitHSAILActiveLanePermuteBuiltin(CodeGenFunction &CGF,
++                                                const CallExpr *E,
++                                                unsigned IntrinsicID) {
++  Value *Args[5];
++  for (unsigned I = 0; I < 5; ++I)
++    Args[I] = CGF.EmitScalarExpr(E->getArg(I));
++
++  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, CGF.ConvertType(E->getType()));
++  return CGF.Builder.CreateCall(F, Args);
++}
++
++// Builtin with overloaded return type and one operand.
++static Value *emitHSAILWorkSizeBuiltin(CodeGenFunction &CGF,
++                                       const CallExpr *E,
++                                       unsigned IntrinsicID) {
++  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, CGF.ConvertType(E->getType()));
++  return CGF.Builder.CreateCall(F, CGF.EmitScalarExpr(E->getArg(0)));
++}
++
++// Overloaded return type, no arguments.
++static Value *emitHSAILWorkitemFlatBuiltin(CodeGenFunction &CGF,
++                                           const CallExpr *E,
++                                           unsigned IntrinsicID) {
++  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, CGF.ConvertType(E->getType()));
++  return CGF.Builder.CreateCall(F, {});
++}
++
++Value *CodeGenFunction::EmitHSAILBuiltinExpr(unsigned BuiltinID,
++                                             const CallExpr *E) {
++  switch (BuiltinID) {
++  case HSAIL::BI__builtin_hsail_smulhi:
++  case HSAIL::BI__builtin_hsail_smulhil:
++    return emitHSAILBinaryRetTypeBuiltin(*this, E, Intrinsic::hsail_smulhi);
++  case HSAIL::BI__builtin_hsail_umulhi:
++  case HSAIL::BI__builtin_hsail_umulhil:
++    return emitHSAILBinaryRetTypeBuiltin(*this, E, Intrinsic::hsail_umulhi);
++
++  case HSAIL::BI__builtin_hsail_sbitextract:
++  case HSAIL::BI__builtin_hsail_sbitextractl:
++    return emitHSAILBitExtractBuiltin(*this, E, Intrinsic::hsail_sbitextract);
++
++  case HSAIL::BI__builtin_hsail_ubitextract:
++  case HSAIL::BI__builtin_hsail_ubitextractl:
++    return emitHSAILBitExtractBuiltin(*this, E, Intrinsic::hsail_ubitextract);
++
++  case HSAIL::BI__builtin_hsail_sbitinsert:
++  case HSAIL::BI__builtin_hsail_sbitinsertl:
++    return emitHSAILBitInsertBuiltin(*this, E, Intrinsic::hsail_sbitinsert);
++
++  case HSAIL::BI__builtin_hsail_ubitinsert:
++  case HSAIL::BI__builtin_hsail_ubitinsertl:
++    return emitHSAILBitInsertBuiltin(*this, E, Intrinsic::hsail_ubitinsert);
++
++  case HSAIL::BI__builtin_hsail_bitmask:
++  case HSAIL::BI__builtin_hsail_bitmaskl:
++    return emitHSAILBinaryRetTypeBuiltin(*this, E, Intrinsic::hsail_bitmask);
++
++  case HSAIL::BI__builtin_hsail_bitrev:
++  case HSAIL::BI__builtin_hsail_bitrevl:
++    return emitHSAILUnaryRetTypeBuiltin(*this, E, Intrinsic::hsail_bitrev);
++
++  case HSAIL::BI__builtin_hsail_bitselect:
++  case HSAIL::BI__builtin_hsail_bitselectl:
++    return emitHSAILTernaryRetTypeBuiltin(*this, E, Intrinsic::hsail_bitselect);
++
++  case HSAIL::BI__builtin_hsail_sfirstbit:
++  case HSAIL::BI__builtin_hsail_sfirstbitl:
++    return emitHSAILUnarySrcTypeBuiltin(*this, E, Intrinsic::hsail_sfirstbit);
++
++  case HSAIL::BI__builtin_hsail_ufirstbit:
++  case HSAIL::BI__builtin_hsail_ufirstbitl:
++    return emitHSAILUnarySrcTypeBuiltin(*this, E, Intrinsic::hsail_ufirstbit);
++
++  case HSAIL::BI__builtin_hsail_lastbit:
++  case HSAIL::BI__builtin_hsail_lastbitl:
++    return emitHSAILUnarySrcTypeBuiltin(*this, E, Intrinsic::hsail_lastbit);
++
++  case HSAIL::BI__builtin_hsail_fadd:
++  case HSAIL::BI__builtin_hsail_faddf:
++    return emitHSAILInstModBuiltin(*this, E, Intrinsic::hsail_fadd);
++
++  case HSAIL::BI__builtin_hsail_fceil:
++  case HSAIL::BI__builtin_hsail_fceilf:
++    return emitHSAILInstModNoRoundBuiltin(*this, E, Intrinsic::hsail_fceil);
++
++  case HSAIL::BI__builtin_hsail_fdiv:
++  case HSAIL::BI__builtin_hsail_fdivf:
++    return emitHSAILInstModBuiltin(*this, E, Intrinsic::hsail_fdiv);
++
++  case HSAIL::BI__builtin_hsail_ffloor:
++  case HSAIL::BI__builtin_hsail_ffloorf:
++    return emitHSAILInstModNoRoundBuiltin(*this, E, Intrinsic::hsail_ffloor);
++
++  case HSAIL::BI__builtin_hsail_ffma:
++  case HSAIL::BI__builtin_hsail_ffmaf:
++    return emitHSAILInstModBuiltin(*this, E, Intrinsic::hsail_ffma);
++
++  case HSAIL::BI__builtin_hsail_ffract:
++  case HSAIL::BI__builtin_hsail_ffractf:
++    return emitHSAILInstModNoRoundBuiltin(*this, E, Intrinsic::hsail_ffract);
++
++  case HSAIL::BI__builtin_hsail_fmax:
++  case HSAIL::BI__builtin_hsail_fmaxf:
++    return emitHSAILInstModNoRoundBuiltin(*this, E, Intrinsic::hsail_fmax);
++
++  case HSAIL::BI__builtin_hsail_fmin:
++  case HSAIL::BI__builtin_hsail_fminf:
++    return emitHSAILInstModNoRoundBuiltin(*this, E, Intrinsic::hsail_fmin);
++
++  case HSAIL::BI__builtin_hsail_fmul:
++  case HSAIL::BI__builtin_hsail_fmulf:
++    return emitHSAILInstModBuiltin(*this, E, Intrinsic::hsail_fmul);
++
++  case HSAIL::BI__builtin_hsail_frint:
++  case HSAIL::BI__builtin_hsail_frintf:
++    return emitHSAILInstModNoRoundBuiltin(*this, E, Intrinsic::hsail_frint);
++
++  case HSAIL::BI__builtin_hsail_fsqrt:
++  case HSAIL::BI__builtin_hsail_fsqrtf:
++    return emitHSAILInstModBuiltin(*this, E, Intrinsic::hsail_fsqrt);
++
++  case HSAIL::BI__builtin_hsail_fsub:
++  case HSAIL::BI__builtin_hsail_fsubf:
++    return emitHSAILInstModBuiltin(*this, E, Intrinsic::hsail_fsub);
++
++
++
++  case HSAIL::BI__builtin_hsail_fmad:
++  case HSAIL::BI__builtin_hsail_fmadf:
++    return emitHSAILInstModBuiltin(*this, E, Intrinsic::hsail_fmad);
++
++
++  case HSAIL::BI__builtin_hsail_class:
++  case HSAIL::BI__builtin_hsail_classf:
++    return emitFPIntBuiltin(*this, E, Intrinsic::hsail_class);
++
++  case HSAIL::BI__builtin_hsail_ncosf:
++    return emitUnaryFPBuiltin(*this, E, Intrinsic::hsail_ncos);
++
++  case HSAIL::BI__builtin_hsail_nexp2f:
++    return emitUnaryFPBuiltin(*this, E, Intrinsic::hsail_nexp2);
++
++  case HSAIL::BI__builtin_hsail_nfma:
++  case HSAIL::BI__builtin_hsail_nfmaf:
++    return emitTernaryFPBuiltin(*this, E, Intrinsic::hsail_nfma);
++
++  case HSAIL::BI__builtin_hsail_nrcpf:
++    return emitUnaryFPBuiltin(*this, E, Intrinsic::hsail_nrcp);
++
++  case HSAIL::BI__builtin_hsail_nrsqrtf:
++    return emitUnaryFPBuiltin(*this, E, Intrinsic::hsail_nrsqrt);
++
++  case HSAIL::BI__builtin_hsail_nsinf:
++    return emitUnaryFPBuiltin(*this, E, Intrinsic::hsail_nsin);
++
++  case HSAIL::BI__builtin_hsail_nsqrtf:
++    return emitUnaryFPBuiltin(*this, E, Intrinsic::hsail_nsqrt);
++
++  case HSAIL::BI__builtin_hsail_activelanemask:
++    return emitHSAILActiveLaneMaskBuiltin(*this, E,
++                                          Intrinsic::hsail_activelanemask);
++
++  case HSAIL::BI__builtin_hsail_activelanepermute:
++  case HSAIL::BI__builtin_hsail_activelanepermutel:
++    return emitHSAILActiveLanePermuteBuiltin(*this, E,
++                                             Intrinsic::hsail_activelanepermute);
++
++
++  case HSAIL::BI__builtin_hsail_workitemabsid:
++  case HSAIL::BI__builtin_hsail_workitemabsidl:
++    return emitHSAILWorkSizeBuiltin(*this, E, Intrinsic::hsail_workitemabsid);
++
++  case HSAIL::BI__builtin_hsail_workitemflatabsid:
++  case HSAIL::BI__builtin_hsail_workitemflatabsidl:
++    return emitHSAILWorkitemFlatBuiltin(*this, E,
++                                        Intrinsic::hsail_workitemflatabsid);
++
++  default:
++    return nullptr;
++  }
++}
++
+ /// Handle a SystemZ function in which the final argument is a pointer
+ /// to an int that receives the post-instruction CC value.  At the LLVM level
+ /// this is represented as a function that returns a {result, cc} pair.
+Index: lib/CodeGen/CodeGenFunction.h
+===================================================================
+--- lib/CodeGen/CodeGenFunction.h
++++ lib/CodeGen/CodeGenFunction.h
+@@ -2621,6 +2621,7 @@
+   llvm::Value *EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E);
+   llvm::Value *EmitPPCBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
+   llvm::Value *EmitAMDGPUBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
++  llvm::Value *EmitHSAILBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
+   llvm::Value *EmitSystemZBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
+   llvm::Value *EmitNVPTXBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
+ 
+Index: lib/Driver/Tools.cpp
+===================================================================
+--- lib/Driver/Tools.cpp
++++ lib/Driver/Tools.cpp
+@@ -1332,6 +1332,13 @@
+   return "";
+ }
+ 
++static std::string getHSAILTargetDevice(const ArgList &Args) {
++  if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
++    return A->getValue();
++  }
++  return "";
++}
++
+ void Clang::AddSparcTargetArgs(const ArgList &Args,
+                                ArgStringList &CmdArgs) const {
+   const Driver &D = getToolChain().getDriver();
+@@ -1526,6 +1533,10 @@
+   case llvm::Triple::r600:
+   case llvm::Triple::amdgcn:
+     return getR600TargetGPU(Args);
++
++  case llvm::Triple::hsail:
++  case llvm::Triple::hsail64:
++    return getHSAILTargetDevice(Args);
+   }
+ }
+ 
+Index: test/CodeGen/target-data.c
+===================================================================
+--- test/CodeGen/target-data.c
++++ test/CodeGen/target-data.c
+@@ -182,3 +182,11 @@
+ // RUN: %clang_cc1 -triple bpfeb -o - -emit-llvm %s | \
+ // RUN: FileCheck %s -check-prefix=BPFEB
+ // BPFEB: target datalayout = "E-m:e-p:64:64-i64:64-n32:64-S128"
++
++// RUN: %clang_cc1 -triple hsail-unknown-unknown -o - -emit-llvm %s | \
++// RUN: FileCheck %s -check-prefix=HSAIL32
++// HSAIL32: target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
++
++// RUN: %clang_cc1 -triple hsail64-unknown-unknown -o - -emit-llvm %s | \
++// RUN: FileCheck %s -check-prefix=HSAIL64
++// HSAIL64: target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-p24:64:64-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
+Index: test/CodeGenOpenCL/builtins-hsail.cl
+===================================================================
+--- /dev/null
++++ test/CodeGenOpenCL/builtins-hsail.cl
+@@ -0,0 +1,1228 @@
++// REQUIRES: hsail-registered-target
++// RUN: %clang_cc1 -triple hsail-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
++
++#pragma OPENCL EXTENSION cl_khr_fp64 : enable
++
++typedef __attribute__((ext_vector_type(4))) long long4;
++
++
++// CHECK-LABEL: @test_smulhi(
++// CHECK: tail call i32 @llvm.hsail.smulhi.i32(i32 %x, i32 %y)
++
++// CHECK: declare i32 @llvm.hsail.smulhi.i32(i32, i32) #1
++void test_smulhi(volatile global int* out, int x, int y)
++{
++  *out = __builtin_hsail_smulhi(x, y);
++}
++
++// CHECK-LABEL: @test_smulhil(
++// CHECK: tail call i64 @llvm.hsail.smulhi.i64(i64 %x, i64 %y)
++
++// CHECK: declare i64 @llvm.hsail.smulhi.i64(i64, i64) #1
++void test_smulhil(volatile global long* out, long x, long y)
++{
++  *out = __builtin_hsail_smulhil(x, y);
++}
++
++// CHECK-LABEL: @test_umulhi(
++// CHECK: tail call i32 @llvm.hsail.umulhi.i32(i32 %x, i32 %y)
++
++// CHECK: declare i32 @llvm.hsail.umulhi.i32(i32, i32) #1
++void test_umulhi(volatile global int* out, int x, int y)
++{
++  *out = __builtin_hsail_umulhi(x, y);
++}
++
++// CHECK-LABEL: @test_umulhil(
++// CHECK: tail call i64 @llvm.hsail.umulhi.i64(i64 %x, i64 %y)
++
++// CHECK: declare i64 @llvm.hsail.umulhi.i64(i64, i64) #1
++void test_umulhil(volatile global long* out, long x, long y)
++{
++  *out = __builtin_hsail_umulhil(x, y);
++}
++
++// CHECK-LABEL: @test_smad24(
++// CHECK: tail call i32 @llvm.hsail.smad24(i32 %x, i32 %y, i32 %z)
++
++// CHECK: declare i32 @llvm.hsail.smad24(i32, i32, i32) #1
++void test_smad24(volatile global int* out, int x, int y, int z)
++{
++  *out = __builtin_hsail_smad24(x, y, z);
++}
++
++// CHECK-LABEL: @test_umad24(
++// CHECK: tail call i32 @llvm.hsail.umad24(i32 %x, i32 %y, i32 %z)
++
++// CHECK: declare i32 @llvm.hsail.umad24(i32, i32, i32) #1
++void test_umad24(volatile global int* out, int x, int y, int z)
++{
++  *out = __builtin_hsail_umad24(x, y, z);
++}
++
++// CHECK-LABEL: @test_smad24hi(
++// CHECK: tail call i32 @llvm.hsail.smad24hi(i32 %x, i32 %y, i32 %z)
++
++// CHECK: declare i32 @llvm.hsail.smad24hi(i32, i32, i32) #1
++void test_smad24hi(volatile global int* out, int x, int y, int z)
++{
++  *out = __builtin_hsail_smad24hi(x, y, z);
++}
++
++// CHECK-LABEL: @test_umad24hi(
++// CHECK: tail call i32 @llvm.hsail.umad24hi(i32 %x, i32 %y, i32 %z)
++
++// CHECK: declare i32 @llvm.hsail.umad24hi(i32, i32, i32) #1
++void test_umad24hi(volatile global int* out, int x, int y, int z)
++{
++  *out = __builtin_hsail_umad24hi(x, y, z);
++}
++
++// CHECK-LABEL: @test_smul24(
++// CHECK: tail call i32 @llvm.hsail.smul24(i32 %x, i32 %y)
++
++// CHECK: declare i32 @llvm.hsail.smul24(i32, i32) #1
++void test_smul24(volatile global int* out, int x, int y)
++{
++  *out = __builtin_hsail_smul24(x, y);
++}
++
++// CHECK-LABEL: @test_umul24(
++// CHECK: tail call i32 @llvm.hsail.umul24(i32 %x, i32 %y)
++
++// CHECK: declare i32 @llvm.hsail.umul24(i32, i32) #1
++void test_umul24(volatile global int* out, int x, int y)
++{
++  *out = __builtin_hsail_umul24(x, y);
++}
++
++// CHECK-LABEL: @test_smul24hi(
++// CHECK: tail call i32 @llvm.hsail.smul24hi(i32 %x, i32 %y)
++
++// CHECK: declare i32 @llvm.hsail.smul24hi(i32, i32) #1
++void test_smul24hi(volatile global int* out, int x, int y)
++{
++  *out = __builtin_hsail_smul24hi(x, y);
++}
++
++// CHECK-LABEL: @test_umul24hi(
++// CHECK: tail call i32 @llvm.hsail.umul24hi(i32 %x, i32 %y)
++
++// CHECK: declare i32 @llvm.hsail.umul24hi(i32, i32) #1
++void test_umul24hi(volatile global int* out, int x, int y)
++{
++  *out = __builtin_hsail_umul24hi(x, y);
++}
++
++// CHECK-LABEL: @test_sbitextract(
++// CHECK: tail call i32 @llvm.hsail.sbitextract.i32(i32 %x, i32 %y, i32 %z)
++
++// CHECK: declare i32 @llvm.hsail.sbitextract.i32(i32, i32, i32) #1
++void test_sbitextract(volatile global int* out, int x, int y, int z)
++{
++  *out = __builtin_hsail_sbitextract(x, y, z);
++}
++
++// CHECK-LABEL: @test_sbitextractl(
++// CHECK: tail call i64 @llvm.hsail.sbitextract.i64(i64 %x, i32 %y, i32 %z)
++
++// CHECK: declare i64 @llvm.hsail.sbitextract.i64(i64, i32, i32) #1
++void test_sbitextractl(volatile global int* out, long x, int y, int z)
++{
++  *out = __builtin_hsail_sbitextractl(x, y, z);
++}
++
++// CHECK-LABEL: @test_ubitextract(
++// CHECK: tail call i32 @llvm.hsail.ubitextract.i32(i32 %x, i32 %y, i32 %z)
++
++// CHECK: declare i32 @llvm.hsail.ubitextract.i32(i32, i32, i32) #1
++void test_ubitextract(volatile global int* out, int x, int y, int z)
++{
++  *out = __builtin_hsail_ubitextract(x, y, z);
++}
++
++// CHECK-LABEL: @test_ubitextractl(
++// CHECK: tail call i64 @llvm.hsail.ubitextract.i64(i64 %x, i32 %y, i32 %z)
++
++// CHECK: declare i64 @llvm.hsail.ubitextract.i64(i64, i32, i32) #1
++void test_ubitextractl(volatile global int* out, long x, int y, int z)
++{
++  *out = __builtin_hsail_ubitextractl(x, y, z);
++}
++
++// CHECK-LABEL: @test_sbitinsert(
++// CHECK: tail call i32 @llvm.hsail.sbitinsert.i32(i32 %x, i32 %y, i32 %z, i32 %w)
++
++// CHECK: declare i32 @llvm.hsail.sbitinsert.i32(i32, i32, i32, i32) #1
++void test_sbitinsert(volatile global int* out, int x, int y, int z, int w)
++{
++  *out = __builtin_hsail_sbitinsert(x, y, z, w);
++}
++
++// CHECK-LABEL: @test_sbitinsertl(
++// CHECK: tail call i64 @llvm.hsail.sbitinsert.i64(i64 %x, i64 %y, i32 %z, i32 %w)
++
++// CHECK: declare i64 @llvm.hsail.sbitinsert.i64(i64, i64, i32, i32) #1
++void test_sbitinsertl(volatile global long* out, long x, long y, int z, int w)
++{
++  *out = __builtin_hsail_sbitinsertl(x, y, z, w);
++}
++
++// CHECK-LABEL: @test_ubitinsert(
++// CHECK: tail call i32 @llvm.hsail.ubitinsert.i32(i32 %x, i32 %y, i32 %z, i32 %w)
++
++// CHECK: declare i32 @llvm.hsail.ubitinsert.i32(i32, i32, i32, i32) #1
++void test_ubitinsert(volatile global int* out, int x, int y, int z, int w)
++{
++  *out = __builtin_hsail_ubitinsert(x, y, z, w);
++}
++
++// CHECK-LABEL: @test_ubitinsertl(
++// CHECK: tail call i64 @llvm.hsail.ubitinsert.i64(i64 %x, i64 %y, i32 %z, i32 %w)
++
++// CHECK: declare i64 @llvm.hsail.ubitinsert.i64(i64, i64, i32, i32) #1
++void test_ubitinsertl(volatile global long* out, long x, long y, int z, int w)
++{
++  *out = __builtin_hsail_ubitinsertl(x, y, z, w);
++}
++
++// CHECK-LABEL: @test_bitmask(
++// CHECK: tail call i32 @llvm.hsail.bitmask.i32(i32 %x, i32 %y)
++// CHECK: tail call i32 @llvm.hsail.bitmask.i32(i32 1, i32 %y)
++// CHECK: tail call i32 @llvm.hsail.bitmask.i32(i32 %x, i32 2)
++
++// CHECK: declare i32 @llvm.hsail.bitmask.i32(i32, i32) #1
++void test_bitmask(volatile global int* out, int x, int y)
++{
++  *out = __builtin_hsail_bitmask(x, y);
++  *out = __builtin_hsail_bitmask(1, y);
++  *out = __builtin_hsail_bitmask(x, 2);
++}
++
++// CHECK-LABEL: @test_bitmaskl(
++// CHECK: tail call i64 @llvm.hsail.bitmask.i64(i32 %x, i32 %y)
++// CHECK: tail call i64 @llvm.hsail.bitmask.i64(i32 1, i32 %y)
++// CHECK: tail call i64 @llvm.hsail.bitmask.i64(i32 %x, i32 2)
++
++// CHECK: declare i64 @llvm.hsail.bitmask.i64(i32, i32) #1
++void test_bitmaskl(volatile global int* out, int x, int y)
++{
++  *out = __builtin_hsail_bitmaskl(x, y);
++  *out = __builtin_hsail_bitmaskl(1, y);
++  *out = __builtin_hsail_bitmaskl(x, 2);
++}
++
++// CHECK-LABEL: @test_bitrev(
++// CHECK: tail call i32 @llvm.hsail.bitrev.i32(i32 %x)
++
++// CHECK: declare i32 @llvm.hsail.bitrev.i32(i32) #1
++void test_bitrev(volatile global int* out, int x)
++{
++  *out = __builtin_hsail_bitrev(x);
++}
++
++// CHECK-LABEL: @test_bitrevl(
++// CHECK: tail call i64 @llvm.hsail.bitrev.i64(i64 %x)
++// CHECK: declare i64 @llvm.hsail.bitrev.i64(i64) #1
++void test_bitrevl(volatile global long* out, long x)
++{
++  *out = __builtin_hsail_bitrevl(x);
++}
++
++// CHECK-LABEL: @test_bitselect(
++// CHECK: tail call i32 @llvm.hsail.bitselect.i32(i32 %x, i32 %y, i32 %z)
++
++// CHECK: declare i32 @llvm.hsail.bitselect.i32(i32, i32, i32) #1
++void test_bitselect(volatile global int* out, int x, int y, int z)
++{
++  *out = __builtin_hsail_bitselect(x, y, z);
++}
++
++// CHECK-LABEL: @test_bitselectl(
++// CHECK: tail call i64 @llvm.hsail.bitselect.i64(i64 %x, i64 %y, i64 %z)
++
++// CHECK: declare i64 @llvm.hsail.bitselect.i64(i64, i64, i64) #1
++void test_bitselectl(volatile global long* out, long x, long y, long z)
++{
++  *out = __builtin_hsail_bitselectl(x, y, z);
++}
++
++// CHECK-LABEL: @test_sfirstbit(
++// CHECK: tail call i32 @llvm.hsail.sfirstbit.i32(i32 %x)
++
++// CHECK: declare i32 @llvm.hsail.sfirstbit.i32(i32) #1
++void test_sfirstbit(volatile global int* out, int x)
++{
++  *out = __builtin_hsail_sfirstbit(x);
++}
++
++// CHECK-LABEL: @test_sfirstbitl(
++// CHECK: tail call i32 @llvm.hsail.sfirstbit.i64(i64 %x)
++
++// CHECK: declare i32 @llvm.hsail.sfirstbit.i64(i64) #1
++void test_sfirstbitl(volatile global int* out, long x)
++{
++  *out = __builtin_hsail_sfirstbitl(x);
++}
++
++// CHECK-LABEL: @test_ufirstbit(
++// CHECK: tail call i32 @llvm.hsail.ufirstbit.i32(i32 %x)
++
++// CHECK: declare i32 @llvm.hsail.ufirstbit.i32(i32) #1
++void test_ufirstbit(volatile global int* out, int x)
++{
++  *out = __builtin_hsail_ufirstbit(x);
++}
++
++// CHECK-LABEL: @test_ufirstbitl(
++// CHECK: tail call i32 @llvm.hsail.ufirstbit.i64(i64 %x)
++
++// CHECK: declare i32 @llvm.hsail.ufirstbit.i64(i64) #1
++void test_ufirstbitl(volatile global int* out, long x)
++{
++  *out = __builtin_hsail_ufirstbitl(x);
++}
++
++// CHECK-LABEL: @test_lastbit(
++// CHECK: tail call i32 @llvm.hsail.lastbit.i32(i32 %x)
++
++// CHECK: declare i32 @llvm.hsail.lastbit.i32(i32) #1
++void test_lastbit(volatile global int* out, int x)
++{
++  *out = __builtin_hsail_lastbit(x);
++}
++
++// CHECK-LABEL: @test_lastbitl(
++// CHECK: tail call i32 @llvm.hsail.lastbit.i64(i64 %x)
++
++// CHECK: declare i32 @llvm.hsail.lastbit.i64(i64) #1
++void test_lastbitl(volatile global int* out, long x)
++{
++  *out = __builtin_hsail_lastbitl(x);
++}
++
++// CHECK-LABEL: @test_fadd_f64(
++// CHECK: call double @llvm.hsail.fadd.f64(i1 false, i32 0, double %x, double %y)
++// CHECK: call double @llvm.hsail.fadd.f64(i1 true, i32 0, double %x, double %y)
++// CHECK: call double @llvm.hsail.fadd.f64(i1 true, i32 2, double %x, double %y)
++
++// CHECK: declare double @llvm.hsail.fadd.f64(i1, i32, double, double) #1
++void test_fadd_f64(volatile global double* out, double x, double y)
++{
++  *out = __builtin_hsail_fadd(0, 0, x, y);
++  *out = __builtin_hsail_fadd(1, 0, x, y);
++  *out = __builtin_hsail_fadd(1, 2, x, y);
++}
++
++// CHECK-LABEL: @test_fadd_f32(
++// CHECK: call float @llvm.hsail.fadd.f32(i1 false, i32 0, float %x, float %y)
++// CHECK: call float @llvm.hsail.fadd.f32(i1 true, i32 0, float %x, float %y)
++// CHECK: call float @llvm.hsail.fadd.f32(i1 true, i32 3, float %x, float %y)
++
++// CHECK: declare float @llvm.hsail.fadd.f32(i1, i32, float, float) #1
++void test_fadd_f32(volatile global float* out, float x, float y)
++{
++  *out = __builtin_hsail_faddf(0, 0, x, y);
++  *out = __builtin_hsail_faddf(1, 0, x, y);
++  *out = __builtin_hsail_faddf(1, 3, x, y);
++}
++
++// CHECK-LABEL: @test_ceil_f64(
++// CHECK: call double @llvm.hsail.fceil.f64(i1 false, double %x)
++// CHECK: call double @llvm.hsail.fceil.f64(i1 true, double %x)
++
++// CHECK: declare double @llvm.hsail.fceil.f64(i1, double) #1
++void test_ceil_f64(volatile global double* out, double x)
++{
++  *out = __builtin_hsail_fceil(0, x);
++  *out = __builtin_hsail_fceil(1, x);
++}
++
++// CHECK-LABEL: @test_ceil_f32(
++// CHECK: call float @llvm.hsail.fceil.f32(i1 false, float %x)
++// CHECK: call float @llvm.hsail.fceil.f32(i1 true, float %x)
++
++// CHECK: declare float @llvm.hsail.fceil.f32(i1, float) #1
++void test_ceil_f32(volatile global float* out, float x)
++{
++  *out = __builtin_hsail_fceilf(0, x);
++  *out = __builtin_hsail_fceilf(1, x);
++}
++
++// CHECK-LABEL: @test_fdiv_f64(
++// CHECK: call double @llvm.hsail.fdiv.f64(i1 false, i32 0, double %x, double %y)
++// CHECK: call double @llvm.hsail.fdiv.f64(i1 true, i32 0, double %x, double %y)
++// CHECK: call double @llvm.hsail.fdiv.f64(i1 true, i32 2, double %x, double %y)
++
++// CHECK: declare double @llvm.hsail.fdiv.f64(i1, i32, double, double) #1
++void test_fdiv_f64(volatile global double* out, double x, double y)
++{
++  *out = __builtin_hsail_fdiv(0, 0, x, y);
++  *out = __builtin_hsail_fdiv(1, 0, x, y);
++  *out = __builtin_hsail_fdiv(1, 2, x, y);
++}
++
++// CHECK-LABEL: @test_fdiv_f32(
++// CHECK: call float @llvm.hsail.fdiv.f32(i1 false, i32 0, float %x, float %y)
++// CHECK: call float @llvm.hsail.fdiv.f32(i1 true, i32 0, float %x, float %y)
++// CHECK: call float @llvm.hsail.fdiv.f32(i1 true, i32 3, float %x, float %y)
++
++// CHECK: declare float @llvm.hsail.fdiv.f32(i1, i32, float, float) #1
++void test_fdiv_f32(volatile global float* out, float x, float y)
++{
++  *out = __builtin_hsail_fdivf(0, 0, x, y);
++  *out = __builtin_hsail_fdivf(1, 0, x, y);
++  *out = __builtin_hsail_fdivf(1, 3, x, y);
++}
++
++// CHECK-LABEL: @test_floor_f64(
++// CHECK: call double @llvm.hsail.ffloor.f64(i1 false, double %x)
++// CHECK: call double @llvm.hsail.ffloor.f64(i1 true, double %x)
++
++// CHECK: declare double @llvm.hsail.ffloor.f64(i1, double) #1
++void test_floor_f64(volatile global double* out, double x)
++{
++  *out = __builtin_hsail_ffloor(0, x);
++  *out = __builtin_hsail_ffloor(1, x);
++}
++
++// CHECK-LABEL: @test_floor_f32(
++// CHECK: call float @llvm.hsail.ffloor.f32(i1 false, float %x)
++// CHECK: call float @llvm.hsail.ffloor.f32(i1 true, float %x)
++
++// CHECK: declare float @llvm.hsail.ffloor.f32(i1, float) #1
++void test_floor_f32(volatile global float* out, float x)
++{
++  *out = __builtin_hsail_ffloorf(0, x);
++  *out = __builtin_hsail_ffloorf(1, x);
++}
++
++// CHECK-LABEL: @test_ffma_f64(
++// CHECK: call double @llvm.hsail.ffma.f64(i1 false, i32 0, double %x, double %y, double %z)
++// CHECK: call double @llvm.hsail.ffma.f64(i1 true, i32 0, double %x, double %y, double %z)
++// CHECK: call double @llvm.hsail.ffma.f64(i1 true, i32 2, double %x, double %y, double %z)
++
++// CHECK: declare double @llvm.hsail.ffma.f64(i1, i32, double, double, double) #1
++void test_ffma_f64(volatile global double* out, double x, double y, double z)
++{
++  *out = __builtin_hsail_ffma(0, 0, x, y, z);
++  *out = __builtin_hsail_ffma(1, 0, x, y, z);
++  *out = __builtin_hsail_ffma(1, 2, x, y, z);
++}
++
++// CHECK-LABEL: @test_ffma_f32(
++// CHECK: call float @llvm.hsail.ffma.f32(i1 false, i32 0, float %x, float %y, float %z)
++// CHECK: call float @llvm.hsail.ffma.f32(i1 true, i32 0, float %x, float %y, float %z)
++// CHECK: call float @llvm.hsail.ffma.f32(i1 true, i32 3, float %x, float %y, float %z)
++
++// CHECK: declare float @llvm.hsail.ffma.f32(i1, i32, float, float, float) #1
++void test_ffma_f32(volatile global float* out, float x, float y, float z)
++{
++  *out = __builtin_hsail_ffmaf(0, 0, x, y, z);
++  *out = __builtin_hsail_ffmaf(1, 0, x, y, z);
++  *out = __builtin_hsail_ffmaf(1, 3, x, y, z);
++}
++
++// CHECK-LABEL: @test_fract_f64(
++// CHECK: call double @llvm.hsail.ffract.f64(i1 false, double %x)
++// CHECK: call double @llvm.hsail.ffract.f64(i1 true, double %x)
++
++// CHECK: declare double @llvm.hsail.ffract.f64(i1, double) #1
++void test_fract_f64(volatile global double* out, double x)
++{
++  *out = __builtin_hsail_ffract(0, x);
++  *out = __builtin_hsail_ffract(1, x);
++}
++
++// CHECK-LABEL: @test_fract_f32(
++// CHECK: call float @llvm.hsail.ffract.f32(i1 false, float %x)
++// CHECK: call float @llvm.hsail.ffract.f32(i1 true, float %x)
++
++// CHECK: declare float @llvm.hsail.ffract.f32(i1, float) #1
++void test_fract_f32(volatile global float* out, float x)
++{
++  *out = __builtin_hsail_ffractf(0, x);
++  *out = __builtin_hsail_ffractf(1, x);
++}
++
++// CHECK-LABEL: @test_fmax_f64(
++// CHECK: call double @llvm.hsail.fmax.f64(i1 false, double %x, double %y)
++// CHECK: call double @llvm.hsail.fmax.f64(i1 true, double %x, double %y)
++
++// CHECK: declare double @llvm.hsail.fmax.f64(i1, double, double) #1
++void test_fmax_f64(volatile global double* out, double x, double y)
++{
++  *out = __builtin_hsail_fmax(0, x, y);
++  *out = __builtin_hsail_fmax(1, x, y);
++}
++
++// CHECK-LABEL: @test_fmax_f32(
++// CHECK: call float @llvm.hsail.fmax.f32(i1 false, float %x, float %y)
++// CHECK: call float @llvm.hsail.fmax.f32(i1 true, float %x, float %y)
++
++// CHECK: declare float @llvm.hsail.fmax.f32(i1, float, float) #1
++void test_fmax_f32(volatile global float* out, float x, float y)
++{
++  *out = __builtin_hsail_fmaxf(0, x, y);
++  *out = __builtin_hsail_fmaxf(1, x, y);
++}
++
++// CHECK-LABEL: @test_fmin_f64(
++// CHECK: call double @llvm.hsail.fmin.f64(i1 false, double %x, double %y)
++// CHECK: call double @llvm.hsail.fmin.f64(i1 true, double %x, double %y)
++
++// CHECK: declare double @llvm.hsail.fmin.f64(i1, double, double) #1
++void test_fmin_f64(volatile global double* out, double x, double y)
++{
++  *out = __builtin_hsail_fmin(0, x, y);
++  *out = __builtin_hsail_fmin(1, x, y);
++}
++
++// CHECK-LABEL: @test_fmin_f32(
++// CHECK: call float @llvm.hsail.fmin.f32(i1 false, float %x, float %y)
++// CHECK: call float @llvm.hsail.fmin.f32(i1 true, float %x, float %y)
++
++// CHECK: declare float @llvm.hsail.fmin.f32(i1, float, float) #1
++void test_fmin_f32(volatile global float* out, float x, float y)
++{
++  *out = __builtin_hsail_fminf(0, x, y);
++  *out = __builtin_hsail_fminf(1, x, y);
++}
++
++// CHECK-LABEL: @test_fmul_f64(
++// CHECK: call double @llvm.hsail.fmul.f64(i1 false, i32 0, double %x, double %y)
++// CHECK: call double @llvm.hsail.fmul.f64(i1 true, i32 0, double %x, double %y)
++// CHECK: call double @llvm.hsail.fmul.f64(i1 true, i32 2, double %x, double %y)
++
++// CHECK: declare double @llvm.hsail.fmul.f64(i1, i32, double, double) #1
++void test_fmul_f64(volatile global double* out, double x, double y)
++{
++  *out = __builtin_hsail_fmul(0, 0, x, y);
++  *out = __builtin_hsail_fmul(1, 0, x, y);
++  *out = __builtin_hsail_fmul(1, 2, x, y);
++}
++
++// CHECK-LABEL: @test_fmul_f32(
++// CHECK: call float @llvm.hsail.fmul.f32(i1 false, i32 0, float %x, float %y)
++// CHECK: call float @llvm.hsail.fmul.f32(i1 true, i32 0, float %x, float %y)
++// CHECK: call float @llvm.hsail.fmul.f32(i1 true, i32 3, float %x, float %y)
++
++// CHECK: declare float @llvm.hsail.fmul.f32(i1, i32, float, float) #1
++void test_fmul_f32(volatile global float* out, float x, float y)
++{
++  *out = __builtin_hsail_fmulf(0, 0, x, y);
++  *out = __builtin_hsail_fmulf(1, 0, x, y);
++  *out = __builtin_hsail_fmulf(1, 3, x, y);
++}
++
++// CHECK-LABEL: @test_rint_f64(
++// CHECK: call double @llvm.hsail.frint.f64(i1 false, double %x)
++// CHECK: call double @llvm.hsail.frint.f64(i1 true, double %x)
++
++// CHECK: declare double @llvm.hsail.frint.f64(i1, double) #1
++void test_rint_f64(volatile global double* out, double x)
++{
++  *out = __builtin_hsail_frint(0, x);
++  *out = __builtin_hsail_frint(1, x);
++}
++
++// CHECK-LABEL: @test_rint_f32(
++// CHECK: call float @llvm.hsail.frint.f32(i1 false, float %x)
++// CHECK: call float @llvm.hsail.frint.f32(i1 true, float %x)
++
++// CHECK: declare float @llvm.hsail.frint.f32(i1, float) #1
++void test_rint_f32(volatile global float* out, float x)
++{
++  *out = __builtin_hsail_frintf(0, x);
++  *out = __builtin_hsail_frintf(1, x);
++}
++
++// CHECK-LABEL: @test_sqrt_f64(
++// CHECK: call double @llvm.hsail.fsqrt.f64(i1 false, i32 0, double %x)
++// CHECK: call double @llvm.hsail.fsqrt.f64(i1 true, i32 0, double %x)
++// CHECK: call double @llvm.hsail.fsqrt.f64(i1 true, i32 2, double %x)
++
++// CHECK: declare double @llvm.hsail.fsqrt.f64(i1, i32, double) #1
++void test_sqrt_f64(volatile global double* out, double x)
++{
++  *out = __builtin_hsail_fsqrt(0, 0, x);
++  *out = __builtin_hsail_fsqrt(1, 0, x);
++  *out = __builtin_hsail_fsqrt(1, 2, x);
++}
++
++// CHECK-LABEL: @test_sqrt_f32(
++// CHECK: call float @llvm.hsail.fsqrt.f32(i1 false, i32 0, float %x)
++// CHECK: call float @llvm.hsail.fsqrt.f32(i1 true, i32 0, float %x)
++// CHECK: call float @llvm.hsail.fsqrt.f32(i1 true, i32 3, float %x)
++
++// CHECK: declare float @llvm.hsail.fsqrt.f32(i1, i32, float) #1
++void test_sqrt_f32(volatile global float* out, float x)
++{
++  *out = __builtin_hsail_fsqrtf(0, 0, x);
++  *out = __builtin_hsail_fsqrtf(1, 0, x);
++  *out = __builtin_hsail_fsqrtf(1, 3, x);
++}
++
++// CHECK-LABEL: @test_fsub_f64(
++// CHECK: call double @llvm.hsail.fsub.f64(i1 false, i32 0, double %x, double %y)
++// CHECK: call double @llvm.hsail.fsub.f64(i1 true, i32 0, double %x, double %y)
++// CHECK: call double @llvm.hsail.fsub.f64(i1 true, i32 2, double %x, double %y)
++
++// CHECK: declare double @llvm.hsail.fsub.f64(i1, i32, double, double) #1
++void test_fsub_f64(volatile global double* out, double x, double y)
++{
++  *out = __builtin_hsail_fsub(0, 0, x, y);
++  *out = __builtin_hsail_fsub(1, 0, x, y);
++  *out = __builtin_hsail_fsub(1, 2, x, y);
++}
++
++// CHECK-LABEL: @test_fsub_f32(
++// CHECK: call float @llvm.hsail.fsub.f32(i1 false, i32 0, float %x, float %y)
++// CHECK: call float @llvm.hsail.fsub.f32(i1 true, i32 0, float %x, float %y)
++// CHECK: call float @llvm.hsail.fsub.f32(i1 true, i32 3, float %x, float %y)
++
++// CHECK: declare float @llvm.hsail.fsub.f32(i1, i32, float, float) #1
++void test_fsub_f32(volatile global float* out, float x, float y)
++{
++  *out = __builtin_hsail_fsubf(0, 0, x, y);
++  *out = __builtin_hsail_fsubf(1, 0, x, y);
++  *out = __builtin_hsail_fsubf(1, 3, x, y);
++}
++
++// CHECK-LABEL: @test_fmad_f64(
++// CHECK: call double @llvm.hsail.fmad.f64(i1 false, i32 0, double %x, double %y, double %z)
++// CHECK: call double @llvm.hsail.fmad.f64(i1 true, i32 0, double %x, double %y, double %z)
++// CHECK: call double @llvm.hsail.fmad.f64(i1 true, i32 2, double %x, double %y, double %z)
++
++// CHECK: declare double @llvm.hsail.fmad.f64(i1, i32, double, double, double) #1
++void test_fmad_f64(volatile global double* out, double x, double y, double z)
++{
++  *out = __builtin_hsail_fmad(0, 0, x, y, z);
++  *out = __builtin_hsail_fmad(1, 0, x, y, z);
++  *out = __builtin_hsail_fmad(1, 2, x, y, z);
++}
++
++// CHECK-LABEL: @test_fmad_f32(
++// CHECK: call float @llvm.hsail.fmad.f32(i1 false, i32 0, float %x, float %y, float %z)
++// CHECK: call float @llvm.hsail.fmad.f32(i1 true, i32 0, float %x, float %y, float %z)
++// CHECK: call float @llvm.hsail.fmad.f32(i1 true, i32 3, float %x, float %y, float %z)
++
++// CHECK: declare float @llvm.hsail.fmad.f32(i1, i32, float, float, float) #1
++void test_fmad_f32(volatile global float* out, float x, float y, float z)
++{
++  *out = __builtin_hsail_fmadf(0, 0, x, y, z);
++  *out = __builtin_hsail_fmadf(1, 0, x, y, z);
++  *out = __builtin_hsail_fmadf(1, 3, x, y, z);
++}
++
++// CHECK-LABEL: @test_class_f32(
++// CHECK: call i1 @llvm.hsail.class.f32(float %x, i32 1)
++// CHECK: call i1 @llvm.hsail.class.f32(float %x, i32 %y)
++
++// CHECK: declare i1 @llvm.hsail.class.f32(float, i32) #1
++void test_class_f32(volatile global int* out, float x, int y)
++{
++  *out = __builtin_hsail_classf(x, 1);
++  *out = __builtin_hsail_classf(x, y);
++
++}
++
++// CHECK-LABEL: @test_class_f64(
++// CHECK: call i1 @llvm.hsail.class.f64(double %x, i32 1)
++// CHECK: call i1 @llvm.hsail.class.f64(double %x, i32 %y)
++
++// CHECK: declare i1 @llvm.hsail.class.f64(double, i32) #1
++void test_class_f64(volatile global int* out, double x, int y)
++{
++  *out = __builtin_hsail_class(x, 1);
++  *out = __builtin_hsail_class(x, y);
++}
++
++
++// CHECK-LABEL: @test_ncosf(
++// CHECK: tail call float @llvm.hsail.ncos.f32(float %x)
++
++// CHECK: declare float @llvm.hsail.ncos.f32(float) #1
++void test_ncosf(volatile global float* out, float x)
++{
++  *out = __builtin_hsail_ncosf(x);
++}
++
++// CHECK-LABEL: @test_nexp2f(
++// CHECK: tail call float @llvm.hsail.nexp2.f32(float %x)
++
++// CHECK: declare float @llvm.hsail.nexp2.f32(float) #1
++void test_nexp2f(volatile global float* out, float x)
++{
++  *out = __builtin_hsail_nexp2f(x);
++}
++
++// CHECK-LABEL: @test_nfma(
++// CHECK: tail call double @llvm.hsail.nfma.f64(double %x, double %y, double %z)
++
++// CHECK: declare double @llvm.hsail.nfma.f64(double, double, double) #1
++void test_nfma(volatile global double* out, double x, double y, double z)
++{
++  *out = __builtin_hsail_nfma(x, y, z);
++}
++
++// CHECK-LABEL: @test_nfmaf(
++// CHECK: tail call float @llvm.hsail.nfma.f32(float %x, float %y, float %z)
++
++// CHECK: declare float @llvm.hsail.nfma.f32(float, float, float) #1
++void test_nfmaf(volatile global float* out, float x, float y, float z)
++{
++  *out = __builtin_hsail_nfmaf(x, y, z);
++}
++
++// CHECK-LABEL: @test_nrcpf(
++// CHECK: tail call float @llvm.hsail.nrcp.f32(float %x)
++
++// CHECK: declare float @llvm.hsail.nrcp.f32(float) #1
++void test_nrcpf(volatile global float* out, float x)
++{
++  *out = __builtin_hsail_nrcpf(x);
++}
++
++// CHECK-LABEL: @test_nrsqrtf(
++// CHECK: tail call float @llvm.hsail.nrsqrt.f32(float %x)
++
++// CHECK: declare float @llvm.hsail.nrsqrt.f32(float) #1
++void test_nrsqrtf(volatile global float* out, float x)
++{
++  *out = __builtin_hsail_nrsqrtf(x);
++}
++
++// CHECK-LABEL: @test_nsinf(
++// CHECK: tail call float @llvm.hsail.nsin.f32(float %x)
++
++// CHECK: declare float @llvm.hsail.nsin.f32(float) #1
++void test_nsinf(volatile global float* out, float x)
++{
++  *out = __builtin_hsail_nsinf(x);
++}
++
++// CHECK-LABEL: @test_nsqrtf(
++// CHECK: tail call float @llvm.hsail.nsqrt.f32(float %x)
++
++// CHECK: declare float @llvm.hsail.nsqrt.f32(float) #1
++void test_nsqrtf(volatile global float* out, float x)
++{
++  *out = __builtin_hsail_nsqrtf(x);
++}
++
++// CHECK-LABEL: @test_bitalign(
++// CHECK: tail call i32 @llvm.hsail.bitalign(i32 %x, i32 %y, i32 %z)
++
++// CHECK: declare i32 @llvm.hsail.bitalign(i32, i32, i32) #1
++void test_bitalign(volatile global int* out, int x, int y, int z)
++{
++  *out = __builtin_hsail_bitalign(x, y, z);
++}
++
++// CHECK-LABEL: @test_bytealign(
++// CHECK: tail call i32 @llvm.hsail.bytealign(i32 %x, i32 %y, i32 %z)
++
++// CHECK: declare i32 @llvm.hsail.bytealign(i32, i32, i32) #1
++void test_bytealign(volatile global int* out, int x, int y, int z)
++{
++  *out = __builtin_hsail_bytealign(x, y, z);
++}
++
++// CHECK-LABEL: @test_lerp(
++// CHECK: tail call i32 @llvm.hsail.lerp(i32 %x, i32 %y, i32 %z)
++
++// CHECK: declare i32 @llvm.hsail.lerp(i32, i32, i32) #1
++void test_lerp(volatile global int* out, int x, int y, int z)
++{
++  *out = __builtin_hsail_lerp(x, y, z);
++}
++
++// CHECK-LABEL: @test_packcvt(
++// CHECK: tail call i32 @llvm.hsail.packcvt(float %x, float %y, float %z, float %w)
++
++// declare i32 @llvm.hsail.packcvt(float, float, float, float) #1
++void test_packcvt(volatile global int* out, float x, float y, float z, float w)
++{
++  *out = __builtin_hsail_packcvt(x, y, z, w);
++}
++
++// CHECK-LABEL: @test_unpackcvt(
++// CHECK: tail call float @llvm.hsail.unpackcvt(i32 %x, i32 0)
++// CHECK: tail call float @llvm.hsail.unpackcvt(i32 %x, i32 1)
++// CHECK: tail call float @llvm.hsail.unpackcvt(i32 %x, i32 2)
++// CHECK: tail call float @llvm.hsail.unpackcvt(i32 %x, i32 3)
++
++// CHECK: declare float @llvm.hsail.unpackcvt(i32, i32) #1
++void test_unpackcvt(volatile global float* out, int x)
++{
++  *out = __builtin_hsail_unpackcvt(x, 0);
++  *out = __builtin_hsail_unpackcvt(x, 1);
++  *out = __builtin_hsail_unpackcvt(x, 2);
++  *out = __builtin_hsail_unpackcvt(x, 3);
++}
++
++// CHECK-LABEL: @test_sad_u32_u32(
++// CHECK: tail call i32 @llvm.hsail.sad.u32.u32(i32 %x, i32 %y, i32 %z)
++// CHECK: tail call i32 @llvm.hsail.sad.u32.u32(i32 1, i32 %y, i32 %z)
++// CHECK: tail call i32 @llvm.hsail.sad.u32.u32(i32 %x, i32 2, i32 %z)
++// CHECK: tail call i32 @llvm.hsail.sad.u32.u32(i32 %x, i32 %y, i32 3)
++
++// CHECK: declare i32 @llvm.hsail.sad.u32.u32(i32, i32, i32) #1
++void test_sad_u32_u32(volatile global int* out, int x, int y, int z)
++{
++  *out = __builtin_hsail_sad_u32_u32(x, y, z);
++  *out = __builtin_hsail_sad_u32_u32(1, y, z);
++  *out = __builtin_hsail_sad_u32_u32(x, 2, z);
++  *out = __builtin_hsail_sad_u32_u32(x, y, 3);
++}
++
++// CHECK-LABEL: @test_sad_u32_u16x2(
++// CHECK: tail call i32 @llvm.hsail.sad.u32.u16x2(i32 %x, i32 %y, i32 %z)
++// CHECK: tail call i32 @llvm.hsail.sad.u32.u16x2(i32 1, i32 %y, i32 %z)
++// CHECK: tail call i32 @llvm.hsail.sad.u32.u16x2(i32 %x, i32 2, i32 %z)
++// CHECK: tail call i32 @llvm.hsail.sad.u32.u16x2(i32 %x, i32 %y, i32 3)
++
++// CHECK: declare i32 @llvm.hsail.sad.u32.u16x2(i32, i32, i32) #1
++void test_sad_u32_u16x2(volatile global int* out, int x, int y, int z)
++{
++  *out = __builtin_hsail_sad_u32_u16x2(x, y, z);
++  *out = __builtin_hsail_sad_u32_u16x2(1, y, z);
++  *out = __builtin_hsail_sad_u32_u16x2(x, 2, z);
++  *out = __builtin_hsail_sad_u32_u16x2(x, y, 3);
++}
++
++// CHECK-LABEL: @test_sad_u32_u8x4(
++// CHECK: tail call i32 @llvm.hsail.sad.u32.u8x4(i32 %x, i32 %y, i32 %z)
++// CHECK: tail call i32 @llvm.hsail.sad.u32.u8x4(i32 1, i32 %y, i32 %z)
++// CHECK: tail call i32 @llvm.hsail.sad.u32.u8x4(i32 %x, i32 2, i32 %z)
++// CHECK: tail call i32 @llvm.hsail.sad.u32.u8x4(i32 %x, i32 %y, i32 3)
++
++// CHECK: declare i32 @llvm.hsail.sad.u32.u8x4(i32, i32, i32) #1
++void test_sad_u32_u8x4(volatile global int* out, int x, int y, int z)
++{
++  *out = __builtin_hsail_sad_u32_u8x4(x, y, z);
++  *out = __builtin_hsail_sad_u32_u8x4(1, y, z);
++  *out = __builtin_hsail_sad_u32_u8x4(x, 2, z);
++  *out = __builtin_hsail_sad_u32_u8x4(x, y, 3);
++}
++
++// CHECK-LABEL: @test_sadhi(
++// CHECK: tail call i32 @llvm.hsail.sadhi(i32 %x, i32 %y, i32 %z)
++// CHECK: tail call i32 @llvm.hsail.sadhi(i32 1, i32 %y, i32 %z)
++// CHECK: tail call i32 @llvm.hsail.sadhi(i32 %x, i32 2, i32 %z)
++// CHECK: tail call i32 @llvm.hsail.sadhi(i32 %x, i32 %y, i32 3)
++
++// CHECK: declare i32 @llvm.hsail.sadhi(i32, i32, i32) #1
++void test_sadhi(volatile global int* out, int x, int y, int z)
++{
++  *out = __builtin_hsail_sadhi(x, y, z);
++  *out = __builtin_hsail_sadhi(1, y, z);
++  *out = __builtin_hsail_sadhi(x, 2, z);
++  *out = __builtin_hsail_sadhi(x, y, 3);
++}
++
++// CHECK-LABLE: @test_segmentp(
++// CHECK: tail call i1 @llvm.hsail.segmentp(i32 0, i1 false, i8 addrspace(4)* null)
++// CHECK: tail call i1 @llvm.hsail.segmentp(i32 1, i1 false, i8 addrspace(4)* null)
++// CHECK: tail call i1 @llvm.hsail.segmentp(i32 3, i1 false, i8 addrspace(4)* null)
++// CHECK: tail call i1 @llvm.hsail.segmentp(i32 3, i1 true, i8 addrspace(4)* null)
++
++// CHECK: declare i1 @llvm.hsail.segmentp(i32, i1, i8 addrspace(4)*) #1
++void test_segmentp(volatile global int* out)
++{
++  typedef __attribute__((address_space(4))) char* flat_ptr;
++
++  *out = __builtin_hsail_segmentp(0, false, (flat_ptr)0);
++  *out = __builtin_hsail_segmentp(1, false, (flat_ptr)0);
++  *out = __builtin_hsail_segmentp(3, false, (flat_ptr)0);
++  *out = __builtin_hsail_segmentp(3, true, (flat_ptr)0);
++}
++
++// CHECK-LABEL: @test_memfence(
++// CHECK: tail call void @llvm.hsail.memfence(i32 0, i32 0)
++
++// CHECK: declare void @llvm.hsail.memfence(i32, i32) #2
++void test_memfence()
++{
++  __builtin_hsail_memfence(0, 0);
++}
++
++// CHECK-LABEL: @test_imagefence(
++// CHECK: tail call void @llvm.hsail.imagefence()
++
++// CHECK: declare void @llvm.hsail.imagefence() #2
++void test_imagefence()
++{
++  __builtin_hsail_imagefence();
++}
++
++// CHECK-LABEL: @test_barrier(
++// CHECK: tail call void @llvm.hsail.barrier(i32 1)
++// CHECK: tail call void @llvm.hsail.barrier(i32 33)
++// CHECK: tail call void @llvm.hsail.barrier(i32 34)
++void test_barrier()
++{
++  __builtin_hsail_barrier(1);
++  __builtin_hsail_barrier(33);
++  __builtin_hsail_barrier(34);
++}
++
++// CHECK: declare void @llvm.hsail.barrier(i32) #3
++
++// CHECK-LABEL: @test_wavebarrier(
++// CHECK: tail call void @llvm.hsail.wavebarrier()
++// CHECK: tail call void @llvm.hsail.wavebarrier()
++// CHECK: tail call void @llvm.hsail.wavebarrier()
++
++// CHECK: declare void @llvm.hsail.wavebarrier() #3
++void test_wavebarrier()
++{
++  __builtin_hsail_wavebarrier();
++  __builtin_hsail_wavebarrier();
++  __builtin_hsail_wavebarrier();
++}
++
++// CHECK-LABEL: @test_activelanecount(
++// CHECK: tail call i32 @llvm.hsail.activelanecount(i32 1, i1 false)
++// CHECK: tail call i32 @llvm.hsail.activelanecount(i32 34, i1 %tobool)
++
++// CHECK: declare i32 @llvm.hsail.activelanecount(i32, i1) #4
++void test_activelanecount(volatile int* out, int x)
++{
++  *out = __builtin_hsail_activelanecount(1, 0);
++  *out = __builtin_hsail_activelanecount(34, x);
++}
++
++
++// CHECK-LABEL: @test_activelaneid(
++// CHECK: tail call i32 @llvm.hsail.activelaneid(i32 1)
++// CHECK: tail call i32 @llvm.hsail.activelaneid(i32 34)
++
++// CHECK: declare i32 @llvm.hsail.activelaneid(i32) #5
++void test_activelaneid(volatile int* out, int x)
++{
++  *out = __builtin_hsail_activelaneid(1);
++  *out = __builtin_hsail_activelaneid(34);
++}
++
++// CHECK-LABEL: @test_activelanemask(
++// CHECK: [[CALL0:%[0-9]+]] = tail call { i64, i64, i64, i64 } @llvm.hsail.activelanemask(i32 34, i1 true)
++// CHECK-DAG: [[CALL0_ELT0:%[0-9]+]] = extractvalue { i64, i64, i64, i64 } [[CALL0]], 0
++// CHECK-DAG: [[CALL0_ELT1:%[0-9]+]] = extractvalue { i64, i64, i64, i64 } [[CALL0]], 1
++// CHECK-DAG: [[CALL0_ELT2:%[0-9]+]] = extractvalue { i64, i64, i64, i64 } [[CALL0]], 2
++// CHECK-DAG: [[CALL0_ELT3:%[0-9]+]] = extractvalue { i64, i64, i64, i64 } [[CALL0]], 3
++
++// CHECK-DAG: [[CALL0_INSERT0:%[0-9]+]] = insertelement <4 x i64> undef, i64 [[CALL0_ELT0]], i32 0
++// CHECK-DAG: [[CALL0_INSERT1:%[0-9]+]] = insertelement <4 x i64> [[CALL0_INSERT0]], i64 [[CALL0_ELT1]], i32 1
++// CHECK-DAG: [[CALL0_INSERT2:%[0-9]+]] = insertelement <4 x i64> [[CALL0_INSERT1]], i64 [[CALL0_ELT2]], i32 2
++// CHECK-DAG: [[CALL0_INSERT3:%[0-9]+]] = insertelement <4 x i64> [[CALL0_INSERT2]], i64 [[CALL0_ELT3]], i32 3
++// CHECK: store volatile <4 x i64> [[CALL0_INSERT3]],
++
++// CHECK: tail call { i64, i64, i64, i64 } @llvm.hsail.activelanemask(i32 1, i1 false)
++// CHECK: tail call { i64, i64, i64, i64 } @llvm.hsail.activelanemask(i32 34, i1 %tobool)
++
++// CHECK: declare { i64, i64, i64, i64 } @llvm.hsail.activelanemask(i32, i1) #4
++void test_activelanemask(volatile global long4* out, int x)
++{
++  *out = __builtin_hsail_activelanemask(34, true);
++  *out = __builtin_hsail_activelanemask(1, false);
++  *out = __builtin_hsail_activelanemask(34, x);
++}
++
++// CHECK-LABEL: @test_activelanepermute(
++// CHECK: tail call i32 @llvm.hsail.activelanepermute.i32(i32 31, i32 %x, i32 %y, i32 %z, i1 %tobool)
++// CHECK: tail call i32 @llvm.hsail.activelanepermute.i32(i32 31, i32 42, i32 %y, i32 %z, i1 %tobool)
++// CHECK: tail call i32 @llvm.hsail.activelanepermute.i32(i32 31, i32 %x, i32 7, i32 %z, i1 %tobool)
++// CHECK: tail call i32 @llvm.hsail.activelanepermute.i32(i32 31, i32 %x, i32 %y, i32 9, i1 %tobool)
++// CHECK: tail call i32 @llvm.hsail.activelanepermute.i32(i32 31, i32 %x, i32 %y, i32 %z, i1 true)
++void test_activelanepermute(volatile global int* out, int x, int y, int z, int w)
++{
++  *out = __builtin_hsail_activelanepermute(31, x, y, z, w);
++  *out = __builtin_hsail_activelanepermute(31, 42, y, z, w);
++  *out = __builtin_hsail_activelanepermute(31, x, 7, z, w);
++  *out = __builtin_hsail_activelanepermute(31, x, y, 9, w);
++  *out = __builtin_hsail_activelanepermute(31, x, y, z, true);
++}
++
++// CHECK: declare i32 @llvm.hsail.activelanepermute.i32(i32, i32, i32, i32, i1) #6
++
++// CHECK-LABEL: @test_activelanepermutel(
++// CHECK: tail call i64 @llvm.hsail.activelanepermute.i64(i32 31, i64 %conv, i32 %conv1, i64 %z, i1 %tobool)
++// CHECK: tail call i64 @llvm.hsail.activelanepermute.i64(i32 31, i64 42, i32 %conv1, i64 %z, i1 %tobool)
++// CHECK: tail call i64 @llvm.hsail.activelanepermute.i64(i32 31, i64 %conv, i32 7, i64 %z, i1 %tobool)
++// CHECK: tail call i64 @llvm.hsail.activelanepermute.i64(i32 31, i64 %conv, i32 %conv1, i64 9, i1 %tobool)
++// CHECK: tail call i64 @llvm.hsail.activelanepermute.i64(i32 31, i64 %conv, i32 %conv1, i64 %z, i1 true)
++
++// CHECK: declare i64 @llvm.hsail.activelanepermute.i64(i32, i64, i32, i64, i1) #6
++void test_activelanepermutel(volatile global long* out, int x, long y, long z, int w)
++{
++  *out = __builtin_hsail_activelanepermutel(31, x, y, z, w);
++  *out = __builtin_hsail_activelanepermutel(31, 42, y, z, w);
++  *out = __builtin_hsail_activelanepermutel(31, x, 7, z, w);
++  *out = __builtin_hsail_activelanepermutel(31, x, y, 9, w);
++  *out = __builtin_hsail_activelanepermutel(31, x, y, z, true);
++}
++
++// CHECK-LABEL: @test_currentworkgroupsize(
++// CHECK: tail call i32 @llvm.hsail.currentworkgroupsize(i32 0)
++// CHECK: tail call i32 @llvm.hsail.currentworkgroupsize(i32 1)
++// CHECK: tail call i32 @llvm.hsail.currentworkgroupsize(i32 2)
++
++// CHECK: declare i32 @llvm.hsail.currentworkgroupsize(i32) #1
++void test_currentworkgroupsize(volatile global int* out)
++{
++  *out = __builtin_hsail_currentworkgroupsize(0);
++  *out = __builtin_hsail_currentworkgroupsize(1);
++  *out = __builtin_hsail_currentworkgroupsize(2);
++}
++
++// CHECK-LABEL: @test_currentworkitemflatid(
++// CHECK: tail call i32 @llvm.hsail.currentworkitemflatid()
++
++// CHECK: declare i32 @llvm.hsail.currentworkitemflatid() #1
++void test_currentworkitemflatid(volatile global int* out)
++{
++  *out = __builtin_hsail_currentworkitemflatid();
++}
++
++// CHECK-LABEL: @test_dim(
++// CHECK: tail call i32 @llvm.hsail.dim()
++
++// CHECK: declare i32 @llvm.hsail.dim() #1
++void test_dim(volatile global int* out)
++{
++  *out = __builtin_hsail_dim();
++}
++
++// CHECK-LABEL: @test_gridgroups(
++// CHECK: tail call i32 @llvm.hsail.gridgroups(i32 0)
++// CHECK: tail call i32 @llvm.hsail.gridgroups(i32 1)
++// CHECK: tail call i32 @llvm.hsail.gridgroups(i32 2)
++
++// CHECK: declare i32 @llvm.hsail.gridgroups(i32) #1
++void test_gridgroups(volatile global int* out)
++{
++  *out = __builtin_hsail_gridgroups(0);
++  *out = __builtin_hsail_gridgroups(1);
++  *out = __builtin_hsail_gridgroups(2);
++}
++
++// CHECK-LABEL: @test_workgroupid(
++// CHECK: tail call i32 @llvm.hsail.workgroupid(i32 0)
++// CHECK: tail call i32 @llvm.hsail.workgroupid(i32 1)
++// CHECK: tail call i32 @llvm.hsail.workgroupid(i32 2)
++
++// CHECK: declare i32 @llvm.hsail.workgroupid(i32) #1
++void test_workgroupid(volatile global int* out)
++{
++  *out = __builtin_hsail_workgroupid(0);
++  *out = __builtin_hsail_workgroupid(1);
++  *out = __builtin_hsail_workgroupid(2);
++}
++
++// CHECK-LABEL: @test_workgroupsize(
++// CHECK: tail call i32 @llvm.hsail.workgroupsize(i32 0)
++// CHECK: tail call i32 @llvm.hsail.workgroupsize(i32 1)
++// CHECK: tail call i32 @llvm.hsail.workgroupsize(i32 2)
++
++// CHECK: declare i32 @llvm.hsail.workgroupsize(i32) #1
++void test_workgroupsize(volatile global int* out)
++{
++  *out = __builtin_hsail_workgroupsize(0);
++  *out = __builtin_hsail_workgroupsize(1);
++  *out = __builtin_hsail_workgroupsize(2);
++}
++
++// CHECK-LABEL: @test_workitemabsid(
++// CHECK: tail call i32 @llvm.hsail.workitemabsid.i32(i32 0)
++// CHECK: tail call i32 @llvm.hsail.workitemabsid.i32(i32 1)
++// CHECK: tail call i32 @llvm.hsail.workitemabsid.i32(i32 2)
++
++// CHECK: declare i32 @llvm.hsail.workitemabsid.i32(i32) #1
++void test_workitemabsid(volatile global int* out)
++{
++  *out = __builtin_hsail_workitemabsid(0);
++  *out = __builtin_hsail_workitemabsid(1);
++  *out = __builtin_hsail_workitemabsid(2);
++}
++
++// CHECK-LABEL: @test_workitemabsidl(
++// CHECK: tail call i64 @llvm.hsail.workitemabsid.i64(i32 0)
++// CHECK: tail call i64 @llvm.hsail.workitemabsid.i64(i32 1)
++// CHECK: tail call i64 @llvm.hsail.workitemabsid.i64(i32 2)
++
++// CHECK: declare i64 @llvm.hsail.workitemabsid.i64(i32) #1
++void test_workitemabsidl(volatile global long* out)
++{
++  *out = __builtin_hsail_workitemabsidl(0);
++  *out = __builtin_hsail_workitemabsidl(1);
++  *out = __builtin_hsail_workitemabsidl(2);
++}
++
++// CHECK-LABEL: @test_workitemflatabsid(
++// CHECK: tail call i32 @llvm.hsail.workitemflatabsid.i32()
++
++// CHECK: declare i32 @llvm.hsail.workitemflatabsid.i32() #1
++void test_workitemflatabsid(volatile global int* out)
++{
++  *out = __builtin_hsail_workitemflatabsid();
++}
++
++// CHECK-LABEL: @test_workitemflatabsidl(
++// CHECK: tail call i64 @llvm.hsail.workitemflatabsid.i64()
++
++// CHECK: declare i64 @llvm.hsail.workitemflatabsid.i64() #1
++void test_workitemflatabsidl(volatile global long* out)
++{
++  *out = __builtin_hsail_workitemflatabsidl();
++}
++
++// CHECK-LABEL: @test_workitemflatid(
++// CHECK: tail call i32 @llvm.hsail.workitemflatid()
++
++// CHECK: declare i32 @llvm.hsail.workitemflatid() #1
++void test_workitemflatid(volatile global int* out)
++{
++  *out = __builtin_hsail_workitemflatid();
++}
++
++// CHECK-LABEL: @test_workitemid(
++// CHECK: tail call i32 @llvm.hsail.workitemid(i32 0)
++// CHECK: tail call i32 @llvm.hsail.workitemid(i32 1)
++// CHECK: tail call i32 @llvm.hsail.workitemid(i32 2)
++
++// CHECK: declare i32 @llvm.hsail.workitemid(i32) #1
++void test_workitemid(volatile global int* out)
++{
++  *out = __builtin_hsail_workitemid(0);
++  *out = __builtin_hsail_workitemid(1);
++  *out = __builtin_hsail_workitemid(2);
++}
++
++// CHECK-LABEL: @test_clock(
++// CHECK: tail call i64 @llvm.hsail.clock()
++void test_clock(volatile long* out)
++{
++  *out = __builtin_hsail_clock();
++}
++
++// CHECK: declare i64 @llvm.hsail.clock() #2
++
++// CHECK-LABEL: @test_cuid(
++// CHECK: tail call i32 @llvm.hsail.cuid()
++
++// CHECK: declare i32 @llvm.hsail.cuid() #1
++void test_cuid(volatile int* out)
++{
++  *out = __builtin_hsail_cuid();
++}
++
++// CHECK-LABEL: @test_groupbaseptr(
++// CHECK: tail call i8 addrspace(3)* @llvm.hsail.groupbaseptr()
++// CHECK: load i8, i8 addrspace(3)*
++
++// CHECK: declare i8 addrspace(3)* @llvm.hsail.groupbaseptr() #1
++void test_groupbaseptr(volatile char* out)
++{
++  *out = *__builtin_hsail_groupbaseptr();
++}
++
++// CHECK-LABEL: @test_kernargbaseptr(
++// CHECK: tail call i8 addrspace(7)* @llvm.hsail.kernargbaseptr()
++// CHECK: load i8, i8 addrspace(7)*
++
++// CHECK: declare i8 addrspace(7)* @llvm.hsail.kernargbaseptr() #1
++void test_kernargbaseptr(volatile char* out)
++{
++  *out = *__builtin_hsail_kernargbaseptr();
++}
++
++// CHECK-LABEL: @test_laneid(
++// CHECK: tail call i32 @llvm.hsail.laneid()
++void test_laneid(volatile int* out)
++{
++  *out = __builtin_hsail_laneid();
++}
++
++// CHECK: declare i32 @llvm.hsail.laneid() #1
++
++// CHECK-LABEL: @test_maxcuid(
++// CHECK: tail call i32 @llvm.hsail.maxcuid()
++void test_maxcuid(volatile int* out)
++{
++  *out = __builtin_hsail_maxcuid();
++}
++
++// CHECK: declare i32 @llvm.hsail.maxcuid() #1
++
++// CHECK-LABEL: @test_maxwaveid(
++// CHECK: tail call i32 @llvm.hsail.maxwaveid()
++void test_maxwaveid(volatile int* out)
++{
++  *out = __builtin_hsail_maxwaveid();
++}
++
++// CHECK: declare i32 @llvm.hsail.maxwaveid() #1
++
++
++// CHECK-LABEL: @test_waveid(
++// CHECK: tail call i32 @llvm.hsail.waveid()
++void test_waveid(volatile int* out)
++{
++  *out = __builtin_hsail_waveid();
++}
++
++// CHECK: declare i32 @llvm.hsail.waveid() #1
++
++// CHECK-LABEL: @test_gcn_msad(
++// CHECK: tail call i32 @llvm.hsail.gcn.msad(i32 %x, i32 %y, i32 %z)
++
++// CHECK: declare i32 @llvm.hsail.gcn.msad(i32, i32, i32) #1
++void test_gcn_msad(volatile global int* out, int x, int y, int z)
++{
++  *out = __builtin_hsail_gcn_msad(x, y, z);
++}
++
++// CHECK-LABEL: @test_gcn_qsad(
++// CHECK: tail call i64 @llvm.hsail.gcn.qsad(i64 %x, i64 %y, i64 %z)
++
++// CHECK: declare i64 @llvm.hsail.gcn.qsad(i64, i64, i64) #1
++void test_gcn_qsad(volatile global long* out, long x, long y, long z)
++{
++  *out = __builtin_hsail_gcn_qsad(x, y, z);
++}
++
++// CHECK-LABEL: @test_gcn_mqsad(
++// CHECK: tail call i64 @llvm.hsail.gcn.mqsad(i64 %x, i32 %y, i64 %z)
++
++// CHECK: declare i64 @llvm.hsail.gcn.mqsad(i64, i32, i64) #1
++void test_gcn_mqsad(volatile global long* out, long x, int y, long z)
++{
++  *out = __builtin_hsail_gcn_mqsad(x, y, z);
++}
++
++// CHECK-LABEL: @test_gcn_sadw(
++// CHECK: tail call i32 @llvm.hsail.gcn.sadw(i32 %x, i32 %y, i32 %z)
++
++// CHECK: declare i32 @llvm.hsail.gcn.sadw(i32, i32, i32) #1
++void test_gcn_sadw(volatile global int* out, int x, int y, int z)
++{
++  *out = __builtin_hsail_gcn_sadw(x, y, z);
++}
++
++// CHECK-LABEL: @test_gcn_sadd(
++// CHECK: tail call i32 @llvm.hsail.gcn.sadd(i32 %x, i32 %y, i32 %z)
++
++// CHECK: declare i32 @llvm.hsail.gcn.sadd(i32, i32, i32) #1
++void test_gcn_sadd(volatile global int* out, int x, int y, int z)
++{
++  *out = __builtin_hsail_gcn_sadd(x, y, z);
++}
++
++// CHECK: attributes #1 = { nounwind readnone }
++// CHECK: attributes #2 = { nounwind }
++// CHECK: attributes #3 = { convergent noduplicate nounwind }
++// CHECK: attributes #4 = { convergent nounwind readonly }
++// CHECK: attributes #5 = { nounwind readonly }
++// CHECK: attributes #6 = { convergent nounwind }
+Index: test/Driver/hsail-mcpu.cl
+===================================================================
+--- /dev/null
++++ test/Driver/hsail-mcpu.cl
+@@ -0,0 +1,7 @@
++// Check that -mcpu works for all supported GPUs
++
++// RUN: %clang -### -target hsail -x cl -S -emit-llvm < %s
++// RUN: %clang -### -target hsail -x cl -S -emit-llvm -mcpu=kaveri %s -o - 2>&1 | FileCheck -check-prefix=KAVERI %s
++// RUN: %clang -### -target hsail64 -x cl -S -emit-llvm -mcpu=kaveri %s -o - 2>&1 | FileCheck -check-prefix=KAVERI %s
++
++// KAVERI:  "-target-cpu" "kaveri"
+Index: test/Preprocessor/init.c
+===================================================================
+--- test/Preprocessor/init.c
++++ test/Preprocessor/init.c
+@@ -6606,6 +6606,10 @@
+ // RUN: %clang_cc1 -x cl -E -dM -ffreestanding -triple=amdgcn < /dev/null | FileCheck -check-prefix AMDGCN %s
+ // AMDGCN:#define cl_khr_fp64 1
+ 
++// RUN: %clang_cc1 -x cl -E -dM -ffreestanding -triple=hsail < /dev/null | FileCheck -check-prefix=HSAIL %s
++// RUN: %clang_cc1 -x cl -E -dM -ffreestanding -triple=hsail64 < /dev/null | FileCheck -check-prefix=HSAIL %s
++// HSAIL:#define cl_khr_fp64 1
++
+ // RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-none -fno-signed-char < /dev/null | FileCheck -check-prefix S390X %s
+ //
+ // S390X:#define __BIGGEST_ALIGNMENT__ 8
+Index: test/SemaOpenCL/builtins-hsail-restrictions.cl
+===================================================================
+--- /dev/null
++++ test/SemaOpenCL/builtins-hsail-restrictions.cl
+@@ -0,0 +1,82 @@
++// REQUIRES: hsail-registered-target
++// RUN: %clang_cc1 -triple hsail-unknown-unknown -verify -pedantic -fsyntax-only %s
++
++#pragma OPENCL EXTENSION cl_khr_fp64 : enable
++
++typedef __attribute__((ext_vector_type(4))) long long4;
++
++
++void test_sqrt_builtin(volatile global double* out,
++                       volatile float* outf,
++                       double x,
++                       float xf,
++                       int var)
++{
++  *out = __builtin_hsail_fsqrt(var, 0, x); // expected-error {{argument to '__builtin_hsail_fsqrt' must be a constant integer}}
++  *outf = __builtin_hsail_fsqrtf(var, 0, xf); // expected-error {{argument to '__builtin_hsail_fsqrtf' must be a constant integer}}
++
++  *out = __builtin_hsail_fsqrt(0, var, x); // expected-error {{argument to '__builtin_hsail_fsqrt' must be a constant integer}}
++  *outf = __builtin_hsail_fsqrtf(0, var, xf); // expected-error {{argument to '__builtin_hsail_fsqrtf' must be a constant integer}}
++}
++
++void test_unpackcvt(volatile global float* out, int x, int y)
++{
++  *out = __builtin_hsail_unpackcvt(x, y); // expected-error {{argument to '__builtin_hsail_unpackcvt' must be a constant integer}}
++}
++
++void test_segmentp(volatile global int* out, int x)
++{
++  *out = __builtin_hsail_segmentp(x, false, (__attribute__((address_space(4))) char*)0); // expected-error {{argument to '__builtin_hsail_segmentp' must be a constant integer}}
++  *out = __builtin_hsail_segmentp(0, x, (__attribute__((address_space(4))) char*)0); // expected-error {{argument to '__builtin_hsail_segmentp' must be a constant integer}}
++}
++
++void test_memfence(int x)
++{
++  __builtin_hsail_memfence(x, 0); // expected-error {{argument to '__builtin_hsail_memfence' must be a constant integer}}
++  __builtin_hsail_memfence(0, x); // expected-error {{argument to '__builtin_hsail_memfence' must be a constant integer}}
++}
++
++void test_barrier_builtin(int x)
++{
++  __builtin_hsail_barrier(x); // expected-error {{argument to '__builtin_hsail_barrier' must be a constant integer}}
++}
++
++void test_activelanecount(volatile global int* out, int x)
++{
++  *out = __builtin_hsail_activelanecount(x, 0); // expected-error {{argument to '__builtin_hsail_activelanecount' must be a constant integer}}
++}
++
++void test_activelaneid(volatile global int* out, int x)
++{
++  *out = __builtin_hsail_activelaneid(x); // expected-error {{argument to '__builtin_hsail_activelaneid' must be a constant integer}}
++}
++
++void test_activelanemask(volatile global long4* out, int x)
++{
++  *out = __builtin_hsail_activelanemask(x, false); // expected-error {{argument to '__builtin_hsail_activelanemask' must be a constant integer}}
++}
++
++void test_activelanepermute(volatile global int* out, int x)
++{
++  *out = __builtin_hsail_activelanepermute(x, 0, 0, 0, 0); // expected-error {{argument to '__builtin_hsail_activelanepermute' must be a constant integer}}
++}
++
++void test_activelanepermutel(volatile global long* out, int x)
++{
++  *out = __builtin_hsail_activelanepermutel(x, 0, 0, 0, 0); // expected-error {{argument to '__builtin_hsail_activelanepermutel' must be a constant integer}}
++}
++
++void test_currentworkgroupsize(volatile global int* out, int x)
++{
++  *out = __builtin_hsail_currentworkgroupsize(x); // expected-error {{argument to '__builtin_hsail_currentworkgroupsize' must be a constant integer}}
++}
++
++void test_workitemabsid(volatile global int* out, int x)
++{
++  *out = __builtin_hsail_workitemabsid(x); // expected-error {{argument to '__builtin_hsail_workitemabsid' must be a constant integer}}
++}
++
++void test_workitemabsidl(volatile global long* out, int x)
++{
++  *out = __builtin_hsail_workitemabsidl(x); // expected-error {{argument to '__builtin_hsail_workitemabsidl' must be a constant integer}}
++}
diff --git a/tools/patches/khronos-icd-loader.patch b/tools/patches/khronos-icd-loader.patch
new file mode 100644
index 0000000..3d86efb
--- /dev/null
+++ b/tools/patches/khronos-icd-loader.patch
@@ -0,0 +1,86 @@
+Patch for the Khronos-distributed http://www.khronos.org/registry/cl/ ICD Loader
+to make it usable for regression testing in pocl development:
+- Allow overriding the .icd search path with env OCL_ICD_VENDORS (like ocl-icd does)
+- Do not fail in case the directory contains non .icd files.
+- Allow paths without '/' suffix.
+- Load drivers in guaranteed order.
+
+--- icd/icd_linux.c
++++ icd/icd_linux.c
+@@ -55,21 +55,26 @@
+ // go through the list of vendors in the two configuration files
+ void khrIcdOsVendorsEnumerate(void)
+ {
+-    DIR *dir = NULL;
+-    struct dirent *dirEntry = NULL;
+-    char *vendorPath = "/etc/OpenCL/vendors/";
+-
+-    // open the directory
+-    dir = opendir(vendorPath);
+-    if (NULL == dir) 
++    struct dirent **dirEntries = NULL;
++    int i;
++    char *vendorPath = getenv("OCL_ICD_VENDORS");
++    if (vendorPath == NULL || strncmp(vendorPath, "", 1) == 0)
++    {
++        vendorPath = "/etc/OpenCL/vendors";
++    }
++
++    // read the directory in guaranteed order
++    const int numEntries = scandir(vendorPath, &dirEntries, NULL, alphasort);
++    if (numEntries < 0)
+     {
+         KHR_ICD_TRACE("Failed to open path %s\n", vendorPath);
+         goto Cleanup;
+     }
+ 
+     // attempt to load all files in the directory
+-    for (dirEntry = readdir(dir); dirEntry; dirEntry = readdir(dir) )
++    for (i = 0; i < numEntries; ++i)
+     {
++        const struct dirent *dirEntry = dirEntries[i];
+         switch(dirEntry->d_type)
+         {
+         case DT_UNKNOWN:
+@@ -85,21 +90,21 @@
+                 // make sure the file name ends in .icd
+                 if (strlen(extension) > strlen(dirEntry->d_name) )
+                 {
+-                    break;
++                    continue;
+                 }
+                 if (strcmp(dirEntry->d_name + strlen(dirEntry->d_name) - strlen(extension), extension) ) 
+                 {
+-                    break;
++                    continue;
+                 }
+ 
+                 // allocate space for the full path of the vendor library name
+-                fileName = malloc(strlen(dirEntry->d_name) + strlen(vendorPath) + 1);
++                fileName = malloc(strlen(dirEntry->d_name) + strlen(vendorPath) + 2);
+                 if (!fileName) 
+                 {
+                     KHR_ICD_TRACE("Failed allocate space for ICD file path\n");
+                     break;
+                 }
+-                sprintf(fileName, "%s%s", vendorPath, dirEntry->d_name);
++                sprintf(fileName, "%s/%s", vendorPath, dirEntry->d_name);
+ 
+                 // open the file and read its contents
+                 fin = fopen(fileName, "r");
+@@ -146,9 +151,13 @@
+ Cleanup:
+ 
+     // free resources and exit
+-    if (dir) 
++    if (dirEntries)
+     {
+-        closedir(dir);
++        for (i = 0; i < numEntries; ++i)
++        {
++            free(dirEntries[i]);
++        }
++        free(dirEntries);
+     }
+ }
+ 
diff --git a/tools/patches/llvm-3.7-hsail-branch.patch b/tools/patches/llvm-3.7-hsail-branch.patch
new file mode 100644
index 0000000..0f58e2b
--- /dev/null
+++ b/tools/patches/llvm-3.7-hsail-branch.patch
@@ -0,0 +1,32 @@
+diff --git a/lib/Target/HSAIL/HSAILUtilityFunctions.cpp b/lib/Target/HSAIL/HSAILUtilityFunctions.cpp
+index 49f99fc..10baf50 100644
+--- a/lib/Target/HSAIL/HSAILUtilityFunctions.cpp
++++ b/lib/Target/HSAIL/HSAILUtilityFunctions.cpp
+@@ -166,6 +166,7 @@ unsigned getAlignTypeQualifier(Type *ty, const DataLayout &DL,
+ static bool isKernelFunc(StringRef str) {
+   if (str.startswith("__OpenCL_") && str.endswith("_kernel"))
+     return true;
++
+   return false;
+ }
+ 
+@@ -173,6 +174,19 @@ bool isKernelFunc(const Function *F) {
+   if (CallingConv::SPIR_KERNEL == F->getCallingConv())
+     return true;
+ 
++  NamedMDNode *kernels = F->getParent()->getNamedMetadata("opencl.kernels");
++  if (kernels != NULL) {
++    for (unsigned i = 0, e = kernels->getNumOperands(); i != e; ++i) {
++      if (kernels->getOperand(i)->getOperand(0) == NULL)
++        continue; // globaldce might have removed uncalled kernels
++      Function *k =
++        cast<Function>(dyn_cast<ValueAsMetadata>(
++          kernels->getOperand(i)->getOperand(0))->getValue());
++      if (k == F)
++        return true;
++    }
++  }
++
+   return isKernelFunc(F->getName());
+ }
+ 
diff --git a/tools/scripts/devel-envs.sh b/tools/scripts/devel-envs.sh
new file mode 100755
index 0000000..a070e7a
--- /dev/null
+++ b/tools/scripts/devel-envs.sh
@@ -0,0 +1,25 @@
+if [ "$1" = "cmake" ]; then
+  libs_subdir=.
+else
+  libs_subdir=.libs
+fi
+
+# source this while in the pocl build dir
+export POCL_BUILDING=1
+export OCL_ICD_VENDORS=$PWD/ocl-vendors
+
+# AMDSDK supports the overriding via other env name.
+export OPENCL_VENDOR_PATH=$OCL_ICD_VENDORS
+
+#pocl test-cases don't link against pthreads, but libpocl does.
+#this confuses gdb, unless we preload libpthread
+#If libpocl is not built yet, this will fail...
+export LD_PRELOAD=$(ldd lib/CL/$libs_subdir/libpocl.so | grep pthread | cut -f 3 -d' ')
+
+#make sure we use the new built pocl, not some installed version.
+#also, this is needed if the test binaries are run in gdb without the wrapper
+#shell script automake generates
+export LD_LIBRARY_PATH=$PWD/lib/CL/$libs_subdir:$PWD/lib/poclu/$libs_subdir/:$LD_LIBRARY_PATH
+
+#sometimes useful variable when ICD fails (and we use ocl-icd)
+#export OCL_ICD_DEBUG=15
diff --git a/include/Makefile.am b/tools/scripts/run_hsa_tests
old mode 100644
new mode 100755
similarity index 67%
copy from include/Makefile.am
copy to tools/scripts/run_hsa_tests
index eb63f08..f54433a
--- a/include/Makefile.am
+++ b/tools/scripts/run_hsa_tests
@@ -1,19 +1,18 @@
-# Process this file with automake to produce Makefile.in (in this,
-# and all subdirectories).
-# Makefile.am for pocl/include.
-# 
-# Copyright (c) 2011 Universidad Rey Juan Carlos
-# 
+#!/bin/bash
+# run_hsa_tests - Runs tests against HSA devices.
+#
+# Copyright (c) 2012 Pekka Jääskeläinen / Tampere Univ. of Technology
+#
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
 # in the Software without restriction, including without limitation the rights
 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 # copies of the Software, and to permit persons to whom the Software is
 # furnished to do so, subject to the following conditions:
-# 
+#
 # The above copyright notice and this permission notice shall be included in
 # all copies or substantial portions of the Software.
-# 
+#
 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,13 +21,6 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 
-# Directory containing "private" headers
-pkgdataincludedir = $(pkgdatadir)/include
-pkgdatainclude_HEADERS = _kernel.h _kernel_c.h pocl_types.h pocl_features.h pocl_device.h pocl.h pocl_tests.h
-
-# Public - and default - includes dir
-include_HEADERS = poclu.h utlist.h
-
-EXTRA_DIST = vccompat.hpp CMakeLists.txt
-
-SUBDIRS = CL OpenCL
+export POCL_BUILDING=1
+export POCL_DEVICES="hsa"
+make check TESTSUITEFLAGS="-k hsa"

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/pocl.git



More information about the Pkg-opencl-commits mailing list