Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
3.4KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_check_x86_features.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_CHECK_X86_FEATURES([ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
  8. #
  9. # DESCRIPTION
  10. #
  11. # Checks if the host cpu supports various x86 instruction set, the
  12. # instructions that will get tested are "mmx, popcnt, sse, sse2, sse3,
  13. # sse4.1, sse4.2, sse4a, avx, avx2, avx512f, fma, fma4, bmi, bmi2". If the
  14. # instruction set is supported by the host cpu, the C preprocessor macro
  15. # HAVE_XXX_INSTRUCTIONS is set to 1. The XXX is up-cased instruction case
  16. # with dot replaced by underscore. For example, the test for "sse4.2"
  17. # would export HAVE_SSE4_2_INSTRUCTIONS=1. Also the compiler flag
  18. # "-msse4.2" would be added to X86_FEATURE_CFLAGS variable, that can be
  19. # obtained in Makefile.am using @X86_FEATURE_CFLAGS@.
  20. #
  21. # If any of the test for the instruction set were succeeded, the configure
  22. # script would run ACTION-IF-FOUND if it is specified, or append
  23. # X86_FEATURE_CFLAGS to CFLAGS. If none of the instruction were found,
  24. # ACTION-IF-NOT-FOUND hook is triggered.
  25. #
  26. # This macro requires gcc extended builtin function "__builtin_cpu_init"
  27. # and "__builtin_cpu_supports" to detect the cpu features. It will error
  28. # out if the compiler doesn't has these builtins.
  29. #
  30. # See also AX_GCC_X86_CPU_SUPPORTS, which is the actual macro that perform
  31. # the checks for the instruction sets.
  32. #
  33. # LICENSE
  34. #
  35. # Copyright (c) 2016 Felix Chern <idryman@gmail.com>
  36. #
  37. # This program is free software; you can redistribute it and/or modify it
  38. # under the terms of the GNU General Public License as published by the
  39. # Free Software Foundation; either version 2 of the License, or (at your
  40. # option) any later version.
  41. #
  42. # This program is distributed in the hope that it will be useful, but
  43. # WITHOUT ANY WARRANTY; without even the implied warranty of
  44. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  45. # Public License for more details.
  46. #
  47. # You should have received a copy of the GNU General Public License along
  48. # with this program. If not, see <https://www.gnu.org/licenses/>.
  49. #
  50. # As a special exception, the respective Autoconf Macro's copyright owner
  51. # gives unlimited permission to copy, distribute and modify the configure
  52. # scripts that are the output of Autoconf when processing the Macro. You
  53. # need not follow the terms of the GNU General Public License when using
  54. # or distributing such scripts, even though portions of the text of the
  55. # Macro appear in them. The GNU General Public License (GPL) does govern
  56. # all other use of the material that constitutes the Autoconf Macro.
  57. #
  58. # This special exception to the GPL applies to versions of the Autoconf
  59. # Macro released by the Autoconf Archive. When you make and distribute a
  60. # modified version of the Autoconf Macro, you may extend this special
  61. # exception to the GPL to apply to your modified version as well.
  62. #serial 2
  63. AC_DEFUN([AX_CHECK_X86_FEATURES],
  64. [m4_foreach_w(
  65. [ax_x86_feature],
  66. [mmx popcnt sse sse2 sse3 sse4.1 sse4.2 sse4a avx avx2 avx512f fma fma4 bmi bmi2],
  67. [AX_GCC_X86_CPU_SUPPORTS(ax_x86_feature,
  68. [X86_FEATURE_CFLAGS="$X86_FEATURE_CFLAGS -m[]ax_x86_feature"],
  69. [])
  70. ])
  71. AC_SUBST([X86_FEATURE_CFLAGS])
  72. m4_ifval([$1],[$1],
  73. [CFLAGS="$CFLAGS $X86_FEATURE_CFLAGS"])
  74. $2
  75. ])