1dnl Process this file with autoconf to produce a configure script.
2AC_INIT(vmips.cc)
3
4dnl Get the canonical and user-supplied names for the host and target.
5AC_CANONICAL_SYSTEM
6program_prefix=NONE
7AM_INIT_AUTOMAKE(vmips, 1.5.1)
8AM_CONFIG_HEADER(config.h)
9
10dnl Look for mips tool installation:
11AC_ARG_WITH(mips,
12[  --with-mips=MDIR        specify installation prefix of mips cross tools
13                           (default MDIR = /opt/mips)],
14[mipsdir="$withval"],
15[mipsdir="/opt/mips"])dnl
16
17dnl Look for mips tool binaries:
18AC_ARG_WITH(mips-bin,
19[  --with-mips-bin=DIR     specify path to mips cross tools' executables
20                           (default MDIR/bin)],
21[mipsbin="$withval"],
22[mipsbin="${mipsdir}/bin"])dnl
23
24dnl Sanity check the above settings.
25test -d "$mipsdir" || \
26 AC_MSG_WARN([--with-mips directory \"$mipsdir\" does not exist])
27test -d "$mipsbin" || \
28 AC_MSG_WARN([--with-mips-bin directory \"$mipsbin\" does not exist])
29
30dnl Check for C compiler.
31dnl We have to do this early because AC_TRY_CPP depends on it.
32AC_PROG_CC
33
34dnl Try to use extensions to C or POSIX where possible.
35AC_USE_SYSTEM_EXTENSIONS
36
37dnl Check for executable extension.
38dnl Note that this is also required for the testsuite to function (see the
39dnl automake-1.7.8 manual) because the testsuite Makefile.am files
40dnl explicitly set EXEEXT.
41AC_EXEEXT
42
43AC_MSG_CHECKING([for mips tool prefix])
44mipstoolprefix=""
45for file in ${mipsdir}/mips*/bin/*gcc$EXEEXT ${mipsbin}/*gcc$EXEEXT
46do
47	case $file in
48		*\**) mipstoolprefix="";;
49		*\*) mipstoolprefix="";;
50		*) mipstoolprefix=`echo "$file" |sed "s/gcc$EXEEXT//"`;;
51	esac
52done
53AC_MSG_RESULT($mipstoolprefix)
54TESTCODE_DIR="test_code"
55SAMPLE_CODE_TARGETS="setup.o build_xmboot"
56if test "x$mipstoolprefix" = "x"
57then
58AC_MSG_WARN([cannot seem to find any mips tools under $mipsbin])
59AC_MSG_WARN([xmboot and test_code will not be built])
60TESTCODE_DIR=""
61SAMPLE_CODE_TARGETS=""
62fi
63
64MIPSTOOLPREFIX="mipstoolprefix='${mipstoolprefix}'"
65AC_SUBST(TESTCODE_DIR)
66AC_SUBST(SAMPLE_CODE_TARGETS)
67AC_SUBST(mipsbin)
68AC_SUBST(MIPSTOOLPREFIX)
69
70AC_MSG_CHECKING([for cross tools target endianness])
71AC_ARG_WITH(mips-endianness,
72[  --with-mips-endianness=VAL      specify mips cross tools target endianness
73                                   (defaults to guessing from objdump -i)],
74[mipsendianness="$withval"],
75[mipsendianness=no
76 objdump="${mipstoolprefix}objdump"
77 if test -x "$objdump"
78 then
79   mipsendianness=`$objdump -i | awk '/endian/ { print; exit }'`
80 fi
81 case $mipsendianness in
82 *data\ big\ endian*)    mipsendianness="big" ;;
83 *data\ little\ endian*) mipsendianness="little" ;;
84 *)                      mipsendianness="no" ;;
85 esac])dnl
86case $mipsendianness in
87big) BIGENDIAN="bigendian" ;;
88little) BIGENDIAN="nobigendian" ;;
89no) BIGENDIAN="nobigendian"
90    AC_MSG_WARN([defaulting to little-endian VMIPS]) ;;
91*)  AC_MSG_ERROR([endianness, if specified, must be 'big' or 'little']) ;;
92esac
93AC_MSG_RESULT($mipsendianness)
94AC_SUBST(BIGENDIAN)
95
96AC_ARG_ENABLE(profiling,
97[  --enable-profiling      build profiled VMIPS executable for gprof/gcov])
98AC_MSG_CHECKING([whether to build a profiled version])
99XTRACFLAGS=""
100XTRALDFLAGS=""
101case "x$enable_profiling" in
102xyes)
103  XTRACFLAGS="$XTRACFLAGS -pg -fprofile-arcs -ftest-coverage"
104  XTRALDFLAGS="$XTRALDFLAGS -pg"
105  enable_profiling="yes"
106  ;;
107*)
108  enable_profiling="no"
109  ;;
110esac
111AC_MSG_RESULT($enable_profiling)
112
113AC_PROG_AWK
114AC_PROG_CXX
115if test "x$GXX" = "xyes"
116then
117	XTRACFLAGS="$XTRACFLAGS -fno-strict-aliasing"
118fi
119AC_SUBST(XTRACFLAGS)
120AC_SUBST(XTRALDFLAGS)
121VMIPS_CXX_TEMPLATE_FUNCTIONS
122AC_PROG_CPP
123AM_PROG_AS
124AC_PROG_RANLIB
125AC_PROG_INSTALL
126AC_PROG_LN_S
127AC_PROG_MAKE_SET
128AC_PROG_GCC_TRADITIONAL
129
130dnl We run our tests using the C compiler, because it turns out that
131dnl lots of autoconf tests are broken using the C++ compiler, and using the
132dnl C results can actually get us farther.
133
134dnl Checks for header files.
135AC_HEADER_STDC
136AC_CHECK_HEADERS(fcntl.h limits.h sys/ioctl.h sys/time.h unistd.h)
137
138dnl Checks for typedefs, structures, and compiler characteristics.
139AC_C_CONST
140AC_C_INLINE
141AC_TYPE_OFF_T
142AC_TYPE_PID_T
143AC_TYPE_SIZE_T
144AC_HEADER_TIME
145VMIPS_TYPE_SOCKLEN_T
146VMIPS_CXX_ATTRIBUTE_NORETURN
147VMIPS_CXX_ATTRIBUTE_FORMAT
148
149dnl Cross compiling will assume 32-bit target...
150dnl we can probably figure out a better way to do this, though.
151AC_CHECK_SIZEOF(long long, 8)
152AC_CHECK_SIZEOF(long, 4)
153AC_CHECK_SIZEOF(int, 4)
154AC_CHECK_SIZEOF(short, 2)
155AC_CHECK_SIZEOF(char, 1)
156
157dnl Checks for library functions.
158AC_FUNC_MMAP
159AC_FUNC_VPRINTF
160AC_CHECK_FUNCS(gettimeofday strdup strerror random select)
161AC_SEARCH_LIBS(socket, socket)
162AC_SEARCH_LIBS(inet_ntoa, nsl)
163dnl Work around automake 1.5 and 1.6 bugs.
164AC_DEFINE(ASFLAGS,[],[Currently not used.])
165AC_SUBST(ASFLAGS)
166AC_DEFINE(AS,[],[Currently not used.])
167AC_SUBST(AS)
168AC_DEFINE(CCASFLAGS,[],[Currently not used.])
169AC_SUBST(CCASFLAGS)
170AC_DEFINE(CCAS,[],[Currently not used.])
171AC_SUBST(CCAS)
172
173AC_OUTPUT([Makefile
174 vmips.spec
175 vmipsrc
176 doc/Makefile
177 libopcodes_mips/Makefile
178 sample_code/Makefile
179 sample_code/xmboot/Makefile
180 test_code/Makefile
181 test_code/vmips.misc-tests/Makefile
182 test_code/vmips.outcheck/Makefile
183 test_code/vmips.regcheck/Makefile])
184