acinclude.m4 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. # AC_PROG_NASM
  2. # --------------------------
  3. # Check that NASM exists and determine flags
  4. AC_DEFUN([AC_PROG_NASM],[
  5. AC_ARG_VAR(NASM, [NASM command (used to build the x86/x86-64 SIMD code)])
  6. if test "x$NASM" = "x"; then
  7. AC_CHECK_PROGS(NASM, [nasm nasmw yasm])
  8. test -z "$NASM" && AC_MSG_ERROR([no nasm (Netwide Assembler) found])
  9. fi
  10. AC_MSG_CHECKING([for object file format of host system])
  11. case "$host_os" in
  12. cygwin* | mingw* | pw32* | interix*)
  13. case "$host_cpu" in
  14. x86_64)
  15. objfmt='Win64-COFF'
  16. ;;
  17. *)
  18. objfmt='Win32-COFF'
  19. ;;
  20. esac
  21. ;;
  22. msdosdjgpp* | go32*)
  23. objfmt='COFF'
  24. ;;
  25. os2-emx*) # not tested
  26. objfmt='MSOMF' # obj
  27. ;;
  28. linux*coff* | linux*oldld*)
  29. objfmt='COFF' # ???
  30. ;;
  31. linux*aout*)
  32. objfmt='a.out'
  33. ;;
  34. linux*)
  35. case "$host_cpu" in
  36. x86_64)
  37. objfmt='ELF64'
  38. ;;
  39. *)
  40. objfmt='ELF'
  41. ;;
  42. esac
  43. ;;
  44. kfreebsd* | freebsd* | netbsd* | openbsd*)
  45. if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
  46. objfmt='BSD-a.out'
  47. else
  48. case "$host_cpu" in
  49. x86_64 | amd64)
  50. objfmt='ELF64'
  51. ;;
  52. *)
  53. objfmt='ELF'
  54. ;;
  55. esac
  56. fi
  57. ;;
  58. solaris* | sunos* | sysv* | sco*)
  59. case "$host_cpu" in
  60. x86_64)
  61. objfmt='ELF64'
  62. ;;
  63. *)
  64. objfmt='ELF'
  65. ;;
  66. esac
  67. ;;
  68. darwin* | rhapsody* | nextstep* | openstep* | macos*)
  69. case "$host_cpu" in
  70. x86_64)
  71. objfmt='Mach-O64'
  72. ;;
  73. *)
  74. objfmt='Mach-O'
  75. ;;
  76. esac
  77. ;;
  78. *)
  79. objfmt='ELF ?'
  80. ;;
  81. esac
  82. AC_MSG_RESULT([$objfmt])
  83. if test "$objfmt" = 'ELF ?'; then
  84. objfmt='ELF'
  85. AC_MSG_WARN([unexpected host system. assumed that the format is $objfmt.])
  86. fi
  87. AC_MSG_CHECKING([for object file format specifier (NAFLAGS) ])
  88. case "$objfmt" in
  89. MSOMF) NAFLAGS='-fobj -DOBJ32';;
  90. Win32-COFF) NAFLAGS='-fwin32 -DWIN32';;
  91. Win64-COFF) NAFLAGS='-fwin64 -DWIN64 -D__x86_64__';;
  92. COFF) NAFLAGS='-fcoff -DCOFF';;
  93. a.out) NAFLAGS='-faout -DAOUT';;
  94. BSD-a.out) NAFLAGS='-faoutb -DAOUT';;
  95. ELF) NAFLAGS='-felf -DELF';;
  96. ELF64) NAFLAGS='-felf64 -DELF -D__x86_64__';;
  97. RDF) NAFLAGS='-frdf -DRDF';;
  98. Mach-O) NAFLAGS='-fmacho -DMACHO';;
  99. Mach-O64) NAFLAGS='-fmacho64 -DMACHO -D__x86_64__';;
  100. esac
  101. AC_MSG_RESULT([$NAFLAGS])
  102. AC_SUBST([NAFLAGS])
  103. AC_MSG_CHECKING([whether the assembler ($NASM $NAFLAGS) works])
  104. cat > conftest.asm <<EOF
  105. [%line __oline__ "configure"
  106. section .text
  107. global _main,main
  108. _main:
  109. main: xor eax,eax
  110. ret
  111. ]EOF
  112. try_nasm='$NASM $NAFLAGS -o conftest.o conftest.asm'
  113. if AC_TRY_EVAL(try_nasm) && test -s conftest.o; then
  114. AC_MSG_RESULT(yes)
  115. else
  116. echo "configure: failed program was:" >&AC_FD_CC
  117. cat conftest.asm >&AC_FD_CC
  118. rm -rf conftest*
  119. AC_MSG_RESULT(no)
  120. AC_MSG_ERROR([installation or configuration problem: assembler cannot create object files.])
  121. fi
  122. AC_MSG_CHECKING([whether the linker accepts assembler output])
  123. try_nasm='${CC-cc} -o conftest${ac_exeext} $LDFLAGS conftest.o $LIBS 1>&AC_FD_CC'
  124. if AC_TRY_EVAL(try_nasm) && test -s conftest${ac_exeext}; then
  125. rm -rf conftest*
  126. AC_MSG_RESULT(yes)
  127. else
  128. rm -rf conftest*
  129. AC_MSG_RESULT(no)
  130. AC_MSG_ERROR([configuration problem: maybe object file format mismatch.])
  131. fi
  132. ])
  133. # AC_CHECK_COMPATIBLE_ARM_ASSEMBLER_IFELSE
  134. # --------------------------
  135. # Test whether the assembler is suitable and supports NEON instructions
  136. AC_DEFUN([AC_CHECK_COMPATIBLE_ARM_ASSEMBLER_IFELSE],[
  137. ac_good_gnu_arm_assembler=no
  138. ac_save_CC="$CC"
  139. ac_save_CFLAGS="$CFLAGS"
  140. CFLAGS="$CCASFLAGS -x assembler-with-cpp"
  141. CC="$CCAS"
  142. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  143. .text
  144. .fpu neon
  145. .arch armv7a
  146. .object_arch armv4
  147. .arm
  148. pld [r0]
  149. vmovn.u16 d0, q0]])], ac_good_gnu_arm_assembler=yes)
  150. ac_use_gas_preprocessor=no
  151. if test "x$ac_good_gnu_arm_assembler" = "xno" ; then
  152. CC="gas-preprocessor.pl $CCAS"
  153. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  154. .text
  155. .fpu neon
  156. .arch armv7a
  157. .object_arch armv4
  158. .arm
  159. pld [r0]
  160. vmovn.u16 d0, q0]])], ac_use_gas_preprocessor=yes)
  161. fi
  162. CFLAGS="$ac_save_CFLAGS"
  163. CC="$ac_save_CC"
  164. if test "x$ac_use_gas_preprocessor" = "xyes" ; then
  165. CCAS="gas-preprocessor.pl $CCAS"
  166. AC_SUBST([CCAS])
  167. ac_good_gnu_arm_assembler=yes
  168. fi
  169. if test "x$ac_good_gnu_arm_assembler" = "xyes" ; then
  170. $1
  171. else
  172. $2
  173. fi
  174. ])
  175. # AC_CHECK_COMPATIBLE_MIPSEL_ASSEMBLER_IFELSE
  176. # --------------------------
  177. # Test whether the assembler is suitable and supports MIPS instructions
  178. AC_DEFUN([AC_CHECK_COMPATIBLE_MIPS_ASSEMBLER_IFELSE],[
  179. have_mips_dspr2=no
  180. ac_save_CFLAGS="$CFLAGS"
  181. CFLAGS="$CCASFLAGS -mdspr2"
  182. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  183. int main ()
  184. {
  185. int c = 0, a = 0, b = 0;
  186. __asm__ __volatile__ (
  187. "precr.qb.ph %[c], %[a], %[b] \n\t"
  188. : [c] "=r" (c)
  189. : [a] "r" (a), [b] "r" (b)
  190. );
  191. return c;
  192. }
  193. ]])], have_mips_dspr2=yes)
  194. CFLAGS=$ac_save_CFLAGS
  195. if test "x$have_mips_dspr2" = "xyes" ; then
  196. $1
  197. else
  198. $2
  199. fi
  200. ])
  201. AC_DEFUN([AC_CHECK_COMPATIBLE_ARM64_ASSEMBLER_IFELSE],[
  202. ac_good_gnu_arm_assembler=no
  203. ac_save_CC="$CC"
  204. ac_save_CFLAGS="$CFLAGS"
  205. CFLAGS="$CCASFLAGS -x assembler-with-cpp"
  206. CC="$CCAS"
  207. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  208. .text
  209. MYVAR .req x0
  210. movi v0.16b, #100
  211. mov MYVAR, #100
  212. .unreq MYVAR]])], ac_good_gnu_arm_assembler=yes)
  213. ac_use_gas_preprocessor=no
  214. if test "x$ac_good_gnu_arm_assembler" = "xno" ; then
  215. CC="gas-preprocessor.pl $CCAS"
  216. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  217. .text
  218. MYVAR .req x0
  219. movi v0.16b, #100
  220. mov MYVAR, #100
  221. .unreq MYVAR]])], ac_use_gas_preprocessor=yes)
  222. fi
  223. CFLAGS="$ac_save_CFLAGS"
  224. CC="$ac_save_CC"
  225. if test "x$ac_use_gas_preprocessor" = "xyes" ; then
  226. CCAS="gas-preprocessor.pl $CCAS"
  227. AC_SUBST([CCAS])
  228. ac_good_gnu_arm_assembler=yes
  229. fi
  230. if test "x$ac_good_gnu_arm_assembler" = "xyes" ; then
  231. $1
  232. else
  233. $2
  234. fi
  235. ])