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