blob: 9150799b0f4498bfdfbea80ca470f2298f2efafa [file] [log] [blame]
Pierre Ossman82c7f312009-03-09 13:21:27 +00001# AC_PROG_NASM
2# --------------------------
3# Check that NASM exists and determine flags
4AC_DEFUN([AC_PROG_NASM],[
5
6AC_CHECK_PROGS(NASM, [nasm nasmw])
7test -z "$NASM" && AC_MSG_ERROR([no nasm (Netwide Assembler) found])
8
9AC_MSG_CHECKING([for object file format of host system])
10case "$host_os" in
11 cygwin* | mingw* | pw32* | interix*)
12 objfmt='Win32-COFF'
13 ;;
14 msdosdjgpp* | go32*)
15 objfmt='COFF'
16 ;;
17 os2-emx*) # not tested
18 objfmt='MSOMF' # obj
19 ;;
20 linux*coff* | linux*oldld*)
21 objfmt='COFF' # ???
22 ;;
23 linux*aout*)
24 objfmt='a.out'
25 ;;
26 linux*)
27 objfmt='ELF'
28 ;;
29 freebsd* | netbsd* | openbsd*)
30 if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
31 objfmt='BSD-a.out'
32 else
33 objfmt='ELF'
34 fi
35 ;;
36 solaris* | sunos* | sysv* | sco*)
37 objfmt='ELF'
38 ;;
39 darwin* | rhapsody* | nextstep* | openstep* | macos*)
40 objfmt='Mach-O'
41 ;;
42 *)
43 objfmt='ELF ?'
44 ;;
45esac
46
47AC_MSG_RESULT([$objfmt])
48if test "$objfmt" = 'ELF ?'; then
49 objfmt='ELF'
50 AC_MSG_WARN([unexpected host system. assumed that the format is $objfmt.])
51fi
52
53AC_MSG_CHECKING([for object file format specifier (NAFLAGS) ])
54case "$objfmt" in
55 MSOMF) NAFLAGS='-fobj -DOBJ32';;
56 Win32-COFF) NAFLAGS='-fwin32 -DWIN32';;
57 COFF) NAFLAGS='-fcoff -DCOFF';;
58 a.out) NAFLAGS='-faout -DAOUT';;
59 BSD-a.out) NAFLAGS='-faoutb -DAOUT';;
60 ELF) NAFLAGS='-felf -DELF';;
61 RDF) NAFLAGS='-frdf -DRDF';;
62 Mach-O) NAFLAGS='-fmacho -DMACHO';;
63esac
64AC_MSG_RESULT([$NAFLAGS])
65AC_SUBST([NAFLAGS])
66
67AC_MSG_CHECKING([whether the assembler ($NASM $NAFLAGS) works])
68cat > conftest.asm <<EOF
69[%line __oline__ "configure"
70 section .text
71 bits 32
72 global _main,main
73_main:
74main: xor eax,eax
75 ret
76]EOF
77try_nasm='$NASM $NAFLAGS -o conftest.o conftest.asm'
78if AC_TRY_EVAL(try_nasm) && test -s conftest.o; then
79 AC_MSG_RESULT(yes)
80else
81 echo "configure: failed program was:" >&AC_FD_CC
82 cat conftest.asm >&AC_FD_CC
83 rm -rf conftest*
84 AC_MSG_RESULT(no)
85 AC_MSG_ERROR([installation or configuration problem: assembler cannot create object files.])
86fi
87
88AC_MSG_CHECKING([whether the linker accepts assembler output])
89try_nasm='${CC-cc} -o conftest${ac_exeext} $LDFLAGS conftest.o $LIBS 1>&AC_FD_CC'
90if AC_TRY_EVAL(try_nasm) && test -s conftest${ac_exeext}; then
91 rm -rf conftest*
92 AC_MSG_RESULT(yes)
93else
94 rm -rf conftest*
95 AC_MSG_RESULT(no)
96 AC_MSG_ERROR([configuration problem: maybe object file format mismatch.])
97fi
98
99])