<commit_before># Copyright (c) 2015 <NAME>, <NAME>
# All rights reserved.
#
# This function builds an autotools based project.
#
# It forwards to ExternalProject_Add the following parameters:
#   URL, URL_HASH, DOWNLOAD_DIR, SOURCE_DIR and INSTALL_DIR
#
# Adds to the environment variables:
#   PATH=<root-id>/bin
#   PKG_CONFIG_LIBDIR=<root-id>/{lib,share}/pkgconfig
#
# Adds to autotools flags:
#   CPPFLAGS=-I<root-id>/include
#   LDFLAGS=-L<root-id>/lib

# Usage example:
# hunter_autotools_project("@HUNTER_EP_NAME@" # target name
#     HUNTER_SELF                             # hunter home
#       "@HUNTER_SELF@"
#     URL                                     # external project URL
#       @HUNTER_PACKAGE_URL@
#     URL_HASH                                # external project URL_HASH
#       SHA1=@HUNTER_PACKAGE_SHA1@
#     DOWNLOAD_DIR                            # external project DOWNLOAD_DIR
#       "@HUNTER_PACKAGE_DOWNLOAD_DIR@"
#     SOURCE_DIR                              # external project SOURCE_DIR
#       "@HUNTER_PACKAGE_SOURCE_DIR@"
#     BUILD_DIR                               # build directory
#       "@HUNTER_PACKAGE_BUILD_DIR@"
#     INSTALL_DIR                             # external project INSTALL_DIR
#       "@HUNTER_PACKAGE_INSTALL_PREFIX@"
#     GLOBAL_INSTALL_DIR                      # global installation directory
#       "@HUNTER_INSTALL_PREFIX@"
#     PARALLEL_JOBS                           # number of parallel jobs for make
#       "@HUNTER_JOBS_OPTION@"
#     PACKAGE_CONFIGURATION_TYPES             # build configuration (Release|Debug)
#       "@HUNTER_PACKAGE_CONFIGURATION_TYPES@"
#     CPPFLAGS                                # C pre-processor flags
#       "-DEXAMPLE -I/usr/local/include/library"
#     CFLAGS                                  # C Compiler flags
#       "-super-optimation"
#     CXXFLAGS                                # CXX compiler flags
#       "-super-optimation"
#     LDFLAGS                                 # Linker flags
#       "-L/usr/local/lib -llibrary"
#     EXTRA_FLAGS                             # any other flag that will go at the end
#       --enable-feature
#       --disable-other
#       --with-library
#     BOOTSTRAP                               # add a bootstrap command to be run
#       "./autogen.sh"                        # before ./configure such as 
#                                             # ./autogen.sh or ./bootstrap
# )

include(ExternalProject) # ExternalProject_Add
include(CMakeParseArguments) # cmake_parse_arguments

include(hunter_autotools_configure_command)
include(hunter_fatal_error)
include(hunter_status_debug)
include(hunter_test_string_not_empty)

# Packages to test this function:
# * xau
function(hunter_autotools_project target_name)
  set(optional_params)
  set(one_value_params
      HUNTER_SELF
      URL
      URL_HASH
      DOWNLOAD_DIR
      SOURCE_DIR
      BUILD_DIR
      INSTALL_DIR
      GLOBAL_INSTALL_DIR
      PARALLEL_JOBS
      CPPFLAGS
      CFLAGS
      CXXFLAGS
      LDFLAGS
      BOOTSTRAP
  )
  set(multi_value_params
      PACKAGE_CONFIGURATION_TYPES
      EXTRA_FLAGS
  )
  cmake_parse_arguments(
      PARAM
      "${optional_params}"
      "${one_value_params}"
      "${multi_value_params}"
      ${ARGN}
  )
  # -> PARAM_BUILD_DIR
  # -> PARAM_GLOBAL_INSTALL_DIR
  # -> PARAM_INSTALL_DIR

  if(PARAM_UNPARSED_ARGUMENTS)
    hunter_internal_error(
        "Invalid arguments passed to hunter_autotools_project:"
        " ${PARAM_UNPARSED_ARGUMENTS}"
    )
  endif()

  hunter_test_string_not_empty("${PARAM_BUILD_DIR}")
  hunter_test_string_not_empty("${PARAM_GLOBAL_INSTALL_DIR}")
  hunter_test_string_not_empty("${PARAM_INSTALL_DIR}")
  hunter_test_string_not_empty("${PARAM_PACKAGE_CONFIGURATION_TYPES}")

  set(default_path "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin")
  set(shell_env_path "PATH=${PARAM_GLOBAL_INSTALL_DIR}/bin:${default_path}")

  set(shell_ld_path "LD_LIBRARY_PATH=${PARAM_GLOBAL_INSTALL_DIR}/lib")

  set(d1 "${PARAM_GLOBAL_INSTALL_DIR}/lib/pkgconfig")
  set(d2 "${PARAM_GLOBAL_INSTALL_DIR}/share/pkgconfig")
  set(shell_pkg_config_libdir "PKG_CONFIG_LIBDIR=${d1}:${d2}")

  set(clear_vars_shell_script "${PARAM_HUNTER_SELF}/scripts/clear-all.sh")

  set(shell_env
      .
      ${clear_vars_shell_script}
      &&
      ${shell_env_path}
      ${shell_pkg_config_libdir}
      ${shell_ld_path}
  )

  # Build command and options
  set(autotools_build_command "make")
  string(COMPARE NOTEQUAL "${PARAM_PARALLEL_JOBS}" "" have_jobs)
  if(have_jobs)
    list(APPEND autotools_build_command "-j" "${PARAM_PARALLEL_JOBS}")
  endif()

  set(build_command ${shell_env} ${autotools_build_command})

  string(COMPARE NOTEQUAL "${IPHONEOS_ARCHS}${IPHONESIMULATOR_ARCHS}" "" is_ios)
  if(is_ios)
    hunter_status_debug("Autotools iOS IPHONEOS_ARCHS: ${IPHONEOS_ARCHS} IPHONESIMULATOR_ARCHS: ${IPHONESIMULATOR_ARCHS}")<commit_msg>Don't clobber LD_LIBRARY_PATH for autotools projects<commit_after># Copyright (c) 2015 <NAME>, <NAME>
# All rights reserved.
#
# This function builds an autotools based project.
#
# It forwards to ExternalProject_Add the following parameters:
#   URL, URL_HASH, DOWNLOAD_DIR, SOURCE_DIR and INSTALL_DIR
#
# Adds to the environment variables:
#   PATH=<root-id>/bin
#   PKG_CONFIG_LIBDIR=<root-id>/{lib,share}/pkgconfig
#
# Adds to autotools flags:
#   CPPFLAGS=-I<root-id>/include
#   LDFLAGS=-L<root-id>/lib

# Usage example:
# hunter_autotools_project("@HUNTER_EP_NAME@" # target name
#     HUNTER_SELF                             # hunter home
#       "@HUNTER_SELF@"
#     URL                                     # external project URL
#       @HUNTER_PACKAGE_URL@
#     URL_HASH                                # external project URL_HASH
#       SHA1=@HUNTER_PACKAGE_SHA1@
#     DOWNLOAD_DIR                            # external project DOWNLOAD_DIR
#       "@HUNTER_PACKAGE_DOWNLOAD_DIR@"
#     SOURCE_DIR                              # external project SOURCE_DIR
#       "@HUNTER_PACKAGE_SOURCE_DIR@"
#     BUILD_DIR                               # build directory
#       "@HUNTER_PACKAGE_BUILD_DIR@"
#     INSTALL_DIR                             # external project INSTALL_DIR
#       "@HUNTER_PACKAGE_INSTALL_PREFIX@"
#     GLOBAL_INSTALL_DIR                      # global installation directory
#       "@HUNTER_INSTALL_PREFIX@"
#     PARALLEL_JOBS                           # number of parallel jobs for make
#       "@HUNTER_JOBS_OPTION@"
#     PACKAGE_CONFIGURATION_TYPES             # build configuration (Release|Debug)
#       "@HUNTER_PACKAGE_CONFIGURATION_TYPES@"
#     CPPFLAGS                                # C pre-processor flags
#       "-DEXAMPLE -I/usr/local/include/library"
#     CFLAGS                                  # C Compiler flags
#       "-super-optimation"
#     CXXFLAGS                                # CXX compiler flags
#       "-super-optimation"
#     LDFLAGS                                 # Linker flags
#       "-L/usr/local/lib -llibrary"
#     EXTRA_FLAGS                             # any other flag that will go at the end
#       --enable-feature
#       --disable-other
#       --with-library
#     BOOTSTRAP                               # add a bootstrap command to be run
#       "./autogen.sh"                        # before ./configure such as 
#                                             # ./autogen.sh or ./bootstrap
# )

include(ExternalProject) # ExternalProject_Add
include(CMakeParseArguments) # cmake_parse_arguments

include(hunter_autotools_configure_command)
include(hunter_fatal_error)
include(hunter_status_debug)
include(hunter_test_string_not_empty)

# Packages to test this function:
# * xau
function(hunter_autotools_project target_name)
  set(optional_params)
  set(one_value_params
      HUNTER_SELF
      URL
      URL_HASH
      DOWNLOAD_DIR
      SOURCE_DIR
      BUILD_DIR
      INSTALL_DIR
      GLOBAL_INSTALL_DIR
      PARALLEL_JOBS
      CPPFLAGS
      CFLAGS
      CXXFLAGS
      LDFLAGS
      BOOTSTRAP
  )
  set(multi_value_params
      PACKAGE_CONFIGURATION_TYPES
      EXTRA_FLAGS
  )
  cmake_parse_arguments(
      PARAM
      "${optional_params}"
      "${one_value_params}"
      "${multi_value_params}"
      ${ARGN}
  )
  # -> PARAM_BUILD_DIR
  # -> PARAM_GLOBAL_INSTALL_DIR
  # -> PARAM_INSTALL_DIR

  if(PARAM_UNPARSED_ARGUMENTS)
    hunter_internal_error(
        "Invalid arguments passed to hunter_autotools_project:"
        " ${PARAM_UNPARSED_ARGUMENTS}"
    )
  endif()

  hunter_test_string_not_empty("${PARAM_BUILD_DIR}")
  hunter_test_string_not_empty("${PARAM_GLOBAL_INSTALL_DIR}")
  hunter_test_string_not_empty("${PARAM_INSTALL_DIR}")
  hunter_test_string_not_empty("${PARAM_PACKAGE_CONFIGURATION_TYPES}")

  set(default_path "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin")
  set(shell_env_path "PATH=${PARAM_GLOBAL_INSTALL_DIR}/bin:${default_path}")

  set(shell_ld_path "LD_LIBRARY_PATH=${PARAM_GLOBAL_INSTALL_DIR}/lib:$ENV{LD_LIBRARY_PATH}")

  set(d1 "${PARAM_GLOBAL_INSTALL_DIR}/lib/pkgconfig")
  set(d2 "${PARAM_GLOBAL_INSTALL_DIR}/share/pkgconfig")
  set(shell_pkg_config_libdir "PKG_CONFIG_LIBDIR=${d1}:${d2}")

  set(clear_vars_shell_script "${PARAM_HUNTER_SELF}/scripts/clear-all.sh")

  set(shell_env
      .
      ${clear_vars_shell_script}
      &&
      ${shell_env_path}
      ${shell_pkg_config_libdir}
      ${shell_ld_path}
  )

  # Build command and options
  set(autotools_build_command "make")
  string(COMPARE NOTEQUAL "${PARAM_PARALLEL_JOBS}" "" have_jobs)
  if(have_jobs)
    list(APPEND autotools_build_command "-j" "${PARAM_PARALLEL_JOBS}")
  endif()

  set(build_command ${shell_env} ${autotools_build_command})

  string(COMPARE NOTEQUAL "${IPHONEOS_ARCHS}${IPHONESIMULATOR_ARCHS}" "" is_ios)
  if(is_ios)
    hunter_status_debug("Autotools iOS IPHONEOS_ARCHS: ${IPHONEOS_ARCHS} IPHONESIMULATOR_ARCHS: ${IPHONESIMULATOR_ARCHS}")
{'fraction_non_alphanumeric': 0.09444275736410568, 'fraction_numerical': 0.002024496406518878, 'mean_word_length': 2.531093638313081, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4219583', 'n_tokens_mistral': 3344, 'n_tokens_neox': 3225, 'n_words': 512}