build.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. # Set flags
  3. export CFLAGS=$(echo ${CFLAGS} | sed 's|-O2|-O3|g')
  4. export CPPFLAGS=$(echo ${CPPFLAGS} | sed 's|-O2|-O3|g')
  5. MACH=$(${CC} -dumpmachine)
  6. if [[ ${MACH} =~ x86_64.* ]] || [[ ${MACH} =~ i?86.* ]]; then
  7. export CFLAGS="${CFLAGS} -DUNALIGNED_OK"
  8. fi
  9. export CFLAGS="${CFLAGS} -fPIC"
  10. export CXXFLAGS="${CXXFLAGS} -fPIC"
  11. # linux-aarch64 activations fails to set `ar` tool. This can be
  12. # removed when activations is corrected.
  13. if [[ "${target_platform}" == linux-aarch64 ]]; then
  14. if [[ -n "$AR" ]]; then
  15. CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_AR=${AR}"
  16. fi
  17. fi
  18. # Isolate the build.
  19. mkdir -p Build
  20. cd Build || exit 1
  21. # Generate the build files.
  22. echo "Generating the build files."
  23. cmake .. ${CMAKE_ARGS} \
  24. -G"Unix Makefiles" \
  25. -DCMAKE_PREFIX_PATH=$PREFIX \
  26. -DCMAKE_INSTALL_PREFIX=$PREFIX \
  27. -DCMAKE_BUILD_TYPE=Release \
  28. # Build.
  29. echo "Building..."
  30. make -j${CPU_COUNT} || exit 1
  31. # Perform tests.
  32. echo "Testing..."
  33. ctest -VV --output-on-failure || exit 1
  34. # Installing
  35. echo "Installing..."
  36. make install || exit 1
  37. # Remove man files.
  38. rm -rf $PREFIX/share
  39. # Copy license file to the source directory so conda-build can find it.
  40. cp $RECIPE_DIR/license.txt $SRC_DIR/license.txt
  41. # Error free exit!
  42. echo "Error free exit!"
  43. exit 0