acinclude.m4 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. # AC_PROG_NASM
  2. # --------------------------
  3. # Check that NASM exists and determine flags
  4. AC_DEFUN([AC_PROG_NASM],[
  5. AC_CHECK_PROGS(NASM, [nasm nasmw yasm])
  6. test -z "$NASM" && AC_MSG_ERROR([no nasm (Netwide Assembler) found])
  7. AC_MSG_CHECKING([for object file format of host system])
  8. case "$host_os" in
  9. cygwin* | mingw* | pw32* | interix*)
  10. case "$host_cpu" in
  11. x86_64)
  12. objfmt='Win64-COFF'
  13. ;;
  14. *)
  15. objfmt='Win32-COFF'
  16. ;;
  17. esac
  18. ;;
  19. msdosdjgpp* | go32*)
  20. objfmt='COFF'
  21. ;;
  22. os2-emx*) # not tested
  23. objfmt='MSOMF' # obj
  24. ;;
  25. linux*coff* | linux*oldld*)
  26. objfmt='COFF' # ???
  27. ;;
  28. linux*aout*)
  29. objfmt='a.out'
  30. ;;
  31. linux*)
  32. case "$host_cpu" in
  33. x86_64)
  34. objfmt='ELF64'
  35. ;;
  36. *)
  37. objfmt='ELF'
  38. ;;
  39. esac
  40. ;;
  41. kfreebsd* | freebsd* | netbsd* | openbsd*)
  42. if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
  43. objfmt='BSD-a.out'
  44. else
  45. case "$host_cpu" in
  46. x86_64 | amd64)
  47. objfmt='ELF64'
  48. ;;
  49. *)
  50. objfmt='ELF'
  51. ;;
  52. esac
  53. fi
  54. ;;
  55. solaris* | sunos* | sysv* | sco*)
  56. case "$host_cpu" in
  57. x86_64)
  58. objfmt='ELF64'
  59. ;;
  60. *)
  61. objfmt='ELF'
  62. ;;
  63. esac
  64. ;;
  65. darwin* | rhapsody* | nextstep* | openstep* | macos*)
  66. case "$host_cpu" in
  67. x86_64)
  68. objfmt='Mach-O64'
  69. ;;
  70. *)
  71. objfmt='Mach-O'
  72. ;;
  73. esac
  74. ;;
  75. *)
  76. objfmt='ELF ?'
  77. ;;
  78. esac
  79. AC_MSG_RESULT([$objfmt])
  80. if test "$objfmt" = 'ELF ?'; then
  81. objfmt='ELF'
  82. AC_MSG_WARN([unexpected host system. assumed that the format is $objfmt.])
  83. fi
  84. AC_MSG_CHECKING([for object file format specifier (NAFLAGS) ])
  85. case "$objfmt" in
  86. MSOMF) NAFLAGS='-fobj -DOBJ32';;
  87. Win32-COFF) NAFLAGS='-fwin32 -DWIN32';;
  88. Win64-COFF) NAFLAGS='-fwin64 -DWIN64 -D__x86_64__';;
  89. COFF) NAFLAGS='-fcoff -DCOFF';;
  90. a.out) NAFLAGS='-faout -DAOUT';;
  91. BSD-a.out) NAFLAGS='-faoutb -DAOUT';;
  92. ELF) NAFLAGS='-felf -DELF';;
  93. ELF64) NAFLAGS='-felf64 -DELF -D__x86_64__';;
  94. RDF) NAFLAGS='-frdf -DRDF';;
  95. Mach-O) NAFLAGS='-fmacho -DMACHO';;
  96. Mach-O64) NAFLAGS='-fmacho64 -DMACHO -D__x86_64__';;
  97. esac
  98. AC_MSG_RESULT([$NAFLAGS])
  99. AC_SUBST([NAFLAGS])
  100. AC_MSG_CHECKING([whether the assembler ($NASM $NAFLAGS) works])
  101. cat > conftest.asm <<EOF
  102. [%line __oline__ "configure"
  103. section .text
  104. global _main,main
  105. _main:
  106. main: xor eax,eax
  107. ret
  108. ]EOF
  109. try_nasm='$NASM $NAFLAGS -o conftest.o conftest.asm'
  110. if AC_TRY_EVAL(try_nasm) && test -s conftest.o; then
  111. AC_MSG_RESULT(yes)
  112. else
  113. echo "configure: failed program was:" >&AC_FD_CC
  114. cat conftest.asm >&AC_FD_CC
  115. rm -rf conftest*
  116. AC_MSG_RESULT(no)
  117. AC_MSG_ERROR([installation or configuration problem: assembler cannot create object files.])
  118. fi
  119. AC_MSG_CHECKING([whether the linker accepts assembler output])
  120. try_nasm='${CC-cc} -o conftest${ac_exeext} $LDFLAGS conftest.o $LIBS 1>&AC_FD_CC'
  121. if AC_TRY_EVAL(try_nasm) && test -s conftest${ac_exeext}; then
  122. rm -rf conftest*
  123. AC_MSG_RESULT(yes)
  124. else
  125. rm -rf conftest*
  126. AC_MSG_RESULT(no)
  127. AC_MSG_ERROR([configuration problem: maybe object file format mismatch.])
  128. fi
  129. ])
  130. # AC_CHECK_COMPATIBLE_ARM_ASSEMBLER_IFELSE
  131. # --------------------------
  132. # Test whether the assembler is suitable and supports NEON instructions
  133. AC_DEFUN([AC_CHECK_COMPATIBLE_ARM_ASSEMBLER_IFELSE],[
  134. ac_good_gnu_arm_assembler=no
  135. ac_save_CC="$CC"
  136. ac_save_CFLAGS="$CFLAGS"
  137. CFLAGS="$CCASFLAGS -x assembler-with-cpp"
  138. CC="$CCAS"
  139. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  140. .text
  141. .fpu neon
  142. .arch armv7a
  143. .object_arch armv4
  144. .arm
  145. pld [r0]
  146. vmovn.u16 d0, q0]])], ac_good_gnu_arm_assembler=yes)
  147. ac_use_gas_preprocessor=no
  148. if test "x$ac_good_gnu_arm_assembler" = "xno" ; then
  149. CC="gas-preprocessor.pl $CCAS"
  150. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  151. .text
  152. .fpu neon
  153. .arch armv7a
  154. .object_arch armv4
  155. .arm
  156. pld [r0]
  157. vmovn.u16 d0, q0]])], ac_use_gas_preprocessor=yes)
  158. fi
  159. CFLAGS="$ac_save_CFLAGS"
  160. CC="$ac_save_CC"
  161. if test "x$ac_use_gas_preprocessor" = "xyes" ; then
  162. CCAS="gas-preprocessor.pl $CCAS"
  163. AC_SUBST([CCAS])
  164. ac_good_gnu_arm_assembler=yes
  165. fi
  166. if test "x$ac_good_gnu_arm_assembler" = "xyes" ; then
  167. $1
  168. else
  169. $2
  170. fi
  171. ])