1dnl Process this file with autoconf to produce a configure script.
2AC_INIT(Makefile.in)
3sinclude(../common/acinclude.m4)
4
5AC_PROG_INSTALL
6AC_PROG_CC
7
8# Put a plausible default for CC_FOR_BUILD in Makefile.
9if test "x$cross_compiling" = "xno"; then
10  CC_FOR_BUILD='$(CC)'
11else
12  CC_FOR_BUILD=gcc
13fi
14CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-${CFLAGS}}
15
16dnl We don't use gettext, but bfd does.  So we do the appropriate checks
17dnl to see if there are intl libraries we should link against.
18ALL_LINGUAS=
19ZW_GNU_GETTEXT_SISTER_DIR(../../intl)
20
21
22AC_ARG_ENABLE(sim-alignment,
23[  --enable-sim-alignment=align		Specify strict or nonstrict alignment.],
24[case "${enableval}" in
25  yes | strict | STRICT)	sim_alignment="-DWITH_ALIGNMENT=STRICT_ALIGNMENT";;
26  no | nonstrict | NONSTRICT)	sim_alignment="-DWITH_ALIGNMENT=NONSTRICT_ALIGNMENT";;
27  0 | default | DEFAULT)	sim_alignment="-DWITH_ALIGNMENT=0";;
28  *)				AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-alignment"); sim_alignment="";;
29esac
30if test x"$silent" != x"yes" && test x"$sim_alignment" != x""; then
31  echo "Setting alignment flags = $sim_alignment" 6>&1
32fi],[sim_alignment=""])dnl
33
34
35AC_MSG_CHECKING([whether to enable sim asserts])
36sim_assert="1"
37AC_ARG_ENABLE(sim-assert,
38[  --enable-sim-assert			Specify whether to perform random assertions.],
39[case "${enableval}" in
40  yes)	sim_assert="1";;
41  no)	sim_assert="0";;
42  *)	AC_MSG_ERROR([--enable-sim-assert does not take a value]);;
43esac])dnl
44AC_DEFINE_UNQUOTED([WITH_ASSERT], [$sim_assert], [Sim assert settings])
45AC_MSG_RESULT($sim_assert)
46
47
48AC_ARG_ENABLE(sim-bitsize,
49[  --enable-sim-bitsize=n		Specify target bitsize (32 or 64).],
50[case "${enableval}" in
51  32|64) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=$enableval";;
52  *)	 AC_MSG_ERROR("--enable-sim-bitsize was given $enableval.  Expected 32 or 64"); sim_bitsize="";;
53esac
54if test x"$silent" != x"yes" && test x"$sim_bitsize" != x""; then
55  echo "Setting bitsize flags = $sim_bitsize" 6>&1
56fi],[sim_bitsize=""])dnl
57
58
59AC_ARG_ENABLE(sim-config,
60[  --enable-sim-config=file		Override default config file],
61[case "${enableval}" in
62  yes|no)	AC_MSG_ERROR("No value supplied for --enable-sim-config=file");;
63  *)		if test -f "${srcdir}/${enableval}"; then
64		  sim_config="${enableval}";
65		elif test -f "${srcdir}/${enableval}-config.h"; then
66		  sim_config="${enableval}-config.h"
67		else
68		  AC_MSG_ERROR("Config file $enableval was not found");
69		  sim_config=std-config.h
70		fi;;
71esac
72if test x"$silent" != x"yes" && test x"$sim_config" != x""; then
73  echo "Setting config flags = $sim_config" 6>&1
74fi],[sim_config="std-config.h"
75if test x"$silent" != x"yes"; then
76  echo "Setting config flags = $sim_config" 6>&1
77fi])dnl
78
79
80AC_ARG_ENABLE(sim-decode-mechanism,
81[  --enable-sim-decode-mechanism=which		Specify the instruction decode mechanism.],
82[case "${enableval}" in
83  yes|no)	AC_MSG_ERROR("No value supplied for --enable-sim-decode-mechanism=file");;
84  array|switch|padded-switch|goto-switch)	sim_decode_mechanism="-T ${enableval}";;
85  *)		AC_MSG_ERROR("File $enableval is not an opcode rules file");
86		sim_decode_mechanism="switch";;
87esac
88if test x"$silent" != x"yes" && test x"$sim_decode_mechanism" != x""; then
89  echo "Setting decode mechanism flags = $sim_decode_mechanism" 6>&1
90fi],[sim_decode_mechanism=""
91if test x"$silent" != x"yes"; then
92  echo "Setting decode mechanism flags = $sim_decode_mechanism"
93fi])dnl
94
95
96AC_ARG_ENABLE(sim-default-model,
97[  --enable-sim-default-model=which	Specify default PowerPC to model.],
98[case "${enableval}" in
99  yes|no)	AC_MSG_ERROR("No value supplied for --enable-sim-default-model=model");;
100  *)		sim_default_model="-DWITH_DEFAULT_MODEL=${enableval}";;
101esac
102if test x"$silent" != x"yes" && test x"$sim_default_model" != x""; then
103  echo "Setting default-model flags = $sim_default_model" 6>&1
104fi],[sim_default_model=""])dnl
105
106
107AC_ARG_ENABLE(sim-duplicate,
108[  --enable-sim-duplicate		Expand (duplicate) semantic functions.],
109[case "${enableval}" in
110  yes)	sim_dup="-E";;
111  no)	sim_dup="";;
112  *)	AC_MSG_ERROR("--enable-sim-duplicate does not take a value"); sim_dup="";;
113esac
114if test x"$silent" != x"yes" && test x"$sim_dup" != x""; then
115  echo "Setting duplicate flags = $sim_dup" 6>&1
116fi],[sim_dup="-E"
117if test x"$silent" != x"yes"; then
118  echo "Setting duplicate flags = $sim_dup" 6>&1
119fi])dnl
120
121
122AC_ARG_ENABLE(sim-endian,
123[  --enable-sim-endian=endian		Specify target byte endian orientation.],
124[case "${enableval}" in
125  yes)	case "$target" in
126	  *powerpc-*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BIG_ENDIAN";;
127	  *powerpcle-*) sim_endian="-DWITH_TARGET_BYTE_ORDER=LITTLE_ENDIAN";;
128	  *) echo "Unknown target $target" 1>&6; sim_endian="-DWITH_TARGET_BYTE_ORDER=0";;
129	esac;;
130  no)	 sim_endian="-DWITH_TARGET_BYTE_ORDER=0";;
131  b*|B*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BIG_ENDIAN";;
132  l*|L*) sim_endian="-DWITH_TARGET_BYTE_ORDER=LITTLE_ENDIAN";;
133  *)	 AC_MSG_ERROR("Unknown value $enableval for --enable-sim-endian"); sim_endian="";;
134esac
135if test x"$silent" != x"yes" && test x"$sim_endian" != x""; then
136  echo "Setting endian flags = $sim_endian" 6>&1
137fi],[sim_endian=""])dnl
138
139
140AC_MSG_CHECKING([default sim environment setting])
141sim_env="0"
142AC_ARG_ENABLE(sim-env,
143[  --enable-sim-env=env			Specify target environment (operating, virtual, user).],
144[case "${enableval}" in
145  operating | os | oea)	sim_env="OPERATING_ENVIRONMENT";;
146  virtual | vea)	sim_env="VIRTUAL_ENVIRONMENT";;
147  user | uea)		sim_env="USER_ENVIRONMENT";;
148  no)			sim_env="0";;
149  *)			AC_MSG_ERROR([Unknown value $enableval passed to --enable-sim-env]);;
150esac])dnl
151AC_DEFINE_UNQUOTED([WITH_ENVIRONMENT], [$sim_env], [Sim default environment])
152AC_MSG_RESULT($sim_env)
153
154
155AC_ARG_ENABLE(sim-filter,
156[  --enable-sim-filter=rule		Specify filter rules.],
157[case "${enableval}" in
158  yes)	AC_MSG_ERROR("--enable-sim-filter must be specified with a rule to filter or no"); sim_filter="";;
159  no)	sim_filter="";;
160  *)	sim_filter="-F $enableval";;
161esac
162if test x"$silent" != x"yes" && test x"$sim_filter" != x""; then
163  echo "Setting filter flags = $sim_filter" 6>&1
164fi],[sim_filter="-F 32,f,o"
165if test x"$silent" != x"yes"; then
166  echo "Setting filter flags = $sim_filter" 6>&1
167fi])dnl
168
169
170AC_ARG_ENABLE(sim-float,
171[  --enable-sim-float			Specify whether the target has hard, soft, altivec or e500 floating point.],
172[case "${enableval}" in
173  yes | hard)	sim_float="-DWITH_FLOATING_POINT=HARD_FLOATING_POINT";;
174  no | soft)	sim_float="-DWITH_FLOATING_POINT=SOFT_FLOATING_POINT";;
175  altivec)      sim_float="-DWITH_ALTIVEC" ; sim_filter="${sim_filter},av" ;;
176  *spe*|*simd*) sim_float="-DWITH_E500" ; sim_filter="${sim_filter},e500" ;;
177  *)		AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-float"); sim_float="";;
178esac
179if test x"$silent" != x"yes" && test x"$sim_float" != x""; then
180  echo "Setting float flags = $sim_float" 6>&1
181fi],[
182case "${target}" in
183  *altivec*) sim_float="-DWITH_ALTIVEC" ; sim_filter="${sim_filter},av" ;;
184  *spe*|*simd*)	sim_float="-DWITH_E500" ; sim_filter="${sim_filter},e500" ;;
185  *) sim_float=""
186esac
187])dnl
188
189AC_CACHE_CHECK([if union semun defined],
190  ac_cv_HAS_UNION_SEMUN,
191  [AC_TRY_COMPILE([
192#include <sys/types.h>
193#include <sys/ipc.h>
194#include <sys/sem.h>],
195[union semun arg ;],
196[ac_cv_has_union_semun="yes"],
197[ac_cv_has_union_semun="no"])
198AC_MSG_RESULT($ac_cv_has_union_semun)
199])
200
201
202if test "$ac_cv_has_union_semun" = "yes"; then
203  AC_CACHE_CHECK(whether System V semaphores are supported,
204  ac_cv_sysv_sem,
205  [
206  AC_TRY_RUN(
207  [
208  #include <sys/types.h>
209  #include <sys/ipc.h>
210  #include <sys/sem.h>
211  int main () {
212    union semun arg ;
213
214    int id=semget(IPC_PRIVATE,1,IPC_CREAT|0400);
215    if (id == -1)
216      exit(1);
217    arg.val = 0; /* avoid implicit type cast to union */
218    if (semctl(id, 0, IPC_RMID, arg) == -1)
219      exit(1);
220    exit(0);
221  }
222  ],
223  ac_cv_sysv_sem="yes", ac_cv_sysv_sem="no", :)
224  ])
225else  # semun is not defined
226  AC_CACHE_CHECK(whether System V semaphores are supported,
227  ac_cv_sysv_sem,
228  [
229  AC_TRY_RUN(
230  [
231  #include <sys/types.h>
232  #include <sys/ipc.h>
233  #include <sys/sem.h>
234  union semun {
235    int val;
236    struct semid_ds *buf;
237    ushort *array;
238  };
239  int main () {
240    union semun arg ;
241
242    int id=semget(IPC_PRIVATE,1,IPC_CREAT|0400);
243    if (id == -1)
244      exit(1);
245    arg.val = 0; /* avoid implicit type cast to union */
246    if (semctl(id, 0, IPC_RMID, arg) == -1)
247      exit(1);
248    exit(0);
249  }
250  ],
251  ac_cv_sysv_sem="yes", ac_cv_sysv_sem="no", :)
252  ])
253fi
254
255AC_CACHE_CHECK(whether System V shared memory is supported,
256ac_cv_sysv_shm,
257[
258AC_TRY_RUN([
259#include <sys/types.h>
260#include <sys/ipc.h>
261#include <sys/shm.h>
262int main () {
263  int id=shmget(IPC_PRIVATE,1,IPC_CREAT|0400);
264  if (id == -1)
265    exit(1);
266  if (shmctl(id, IPC_RMID, 0) == -1)
267    exit(1);
268  exit(0);
269}
270],
271ac_cv_sysv_shm="yes", ac_cv_sysv_shm="no", :)
272])
273
274if test x"$ac_cv_sysv_shm" = x"yes" -a x"$ac_cv_sysv_sem" = x"yes" ; then
275  sim_sysv_ipc_hw=",sem,shm";
276else
277  sim_sysv_ipc_hw="";
278fi
279
280if test x"$ac_cv_has_union_semun" = x"yes" -a x"$ac_cv_sysv_sem" = x"yes" ; then
281  AC_DEFINE(HAVE_UNION_SEMUN, 1,
282	    [Define if union semun is defined in <sys/sem.h>])
283fi
284
285
286AC_ARG_ENABLE(sim-hardware,
287[  --enable-sim-hardware=list		Specify the hardware to be included in the build.],
288[hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide${sim_sysv_ipc_hw}"
289case "${enableval}" in
290  yes)	;;
291  no)	AC_MSG_ERROR("List of hardware must be specified for --enable-sim-hardware"); hardware="";;
292  ,*)   hardware="${hardware}${enableval}";;
293  *,)   hardware="${enableval}${hardware}";;
294  *)	hardware="${enableval}"'';;
295esac
296sim_hw_src=`echo $hardware | sed -e 's/,/.c hw_/g' -e 's/^/hw_/' -e s'/$/.c/'`
297sim_hw_obj=`echo $sim_hw_src | sed -e 's/\.c/.o/g'`
298if test x"$silent" != x"yes" && test x"$hardware" != x""; then
299  echo "Setting hardware to $sim_hw_src, $sim_hw_obj"
300fi],[hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide${sim_sysv_ipc_hw}"
301sim_hw_src=`echo $hardware | sed -e 's/,/.c hw_/g' -e 's/^/hw_/' -e s'/$/.c/'`
302sim_hw_obj=`echo $sim_hw_src | sed -e 's/\.c/.o/g'`
303if test x"$silent" != x"yes"; then
304  echo "Setting hardware to $sim_hw_src, $sim_hw_obj"
305fi])dnl
306
307AC_ARG_ENABLE(sim-hostbitsize,
308[  --enable-sim-hostbitsize=32|64	Specify host bitsize (32 or 64).],
309[case "${enableval}" in
310  32|64) sim_hostbitsize="-DWITH_HOST_WORD_BITSIZE=$enableval";;
311  *)	 AC_MSG_ERROR("--enable-sim-hostbitsize was given $enableval.  Expected 32 or 64"); sim_hostbitsize="";;
312esac
313if test x"$silent" != x"yes" && test x"$sim_hostbitsize" != x""; then
314  echo "Setting hostbitsize flags = $sim_hostbitsize" 6>&1
315fi],[sim_hostbitsize=""])dnl
316
317
318AC_ARG_ENABLE(sim-hostendian,
319[  --enable-sim-hostendian=end		Specify host byte endian orientation.],
320[case "${enableval}" in
321  no)	 sim_hostendian="-DWITH_HOST_BYTE_ORDER=0";;
322  b*|B*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN";;
323  l*|L*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN";;
324  *)	 AC_MSG_ERROR("Unknown value $enableval for --enable-sim-hostendian"); sim_hostendian="";;
325esac
326if test x"$silent" != x"yes" && test x"$sim_hostendian" != x""; then
327  echo "Setting hostendian flags = $sim_hostendian" 6>&1
328fi],[
329if test "x$cross_compiling" = "xno"; then
330  AC_C_BIGENDIAN
331  if test $ac_cv_c_bigendian = yes; then
332    sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN"
333  else
334    sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN"
335  fi
336else
337  sim_hostendian="-DWITH_HOST_BYTE_ORDER=0"
338fi])dnl
339
340
341AC_ARG_ENABLE(sim-icache,
342[  --enable-sim-icache=size		Specify instruction-decode cache size and type.],
343[icache="-R"
344 case "${enableval}" in
345  yes)		icache="1024"; sim_icache="-I $icache";;
346  no)		sim_icache="-R";;
347  *) icache=1024
348     sim_icache="-"
349     for x in `echo "${enableval}" | sed -e "s/,/ /g"`; do
350       case "$x" in
351         define)	sim_icache="${sim_icache}R";;
352         semantic)	sim_icache="${sim_icache}C";;
353	 insn)		sim_icache="${sim_icache}S";;
354	 0*|1*|2*|3*|4*|5*|6*|7*|8*|9*)	icache=$x;;
355         *)		AC_MSG_ERROR("Unknown value $x for --enable-sim-icache"); sim_icache="";;
356       esac
357     done
358     sim_icache="${sim_icache}I $icache";;
359esac
360if test x"$silent" != x"yes" && test x"$icache" != x""; then
361  echo "Setting instruction cache size to $icache ($sim_icache)"
362fi],[sim_icache="-CSRI 1024"
363if test x"$silent" != x"yes"; then
364  echo "Setting instruction cache size to 1024 ($sim_icache)"
365fi])dnl
366
367
368AC_ARG_ENABLE(sim-inline,
369[  --enable-sim-inline=inlines		Specify which functions should be inlined.],
370[sim_inline=""
371case "$enableval" in
372  no)		sim_inline="-DDEFAULT_INLINE=0";;
373  0)		sim_inline="-DDEFAULT_INLINE=0";;
374  yes | 2)	sim_inline="-DDEFAULT_INLINE=ALL_INLINE";;
375  1)		sim_inline="-DDEFAULT_INLINE=PSIM_INLINE_LOCALS";;
376  *) for x in `echo "$enableval" | sed -e "s/,/ /g"`; do
377       new_flag=""
378       case "$x" in
379	 *_INLINE=*)	new_flag="-D$x";;
380	 *=*)		new_flag=`echo "$x" | sed -e "s/=/_INLINE=/" -e "s/^/-D/"`;;
381	 *_INLINE)	new_flag="-D$x=ALL_INLINE";;
382	 *)		new_flag="-D$x""_INLINE=ALL_INLINE";;
383       esac
384       if test x"$sim_inline" = x""; then
385	 sim_inline="$new_flag"
386       else
387	 sim_inline="$sim_inline $new_flag"
388       fi
389     done;;
390esac
391if test x"$silent" != x"yes" && test x"$sim_inline" != x""; then
392  echo "Setting inline flags = $sim_inline" 6>&1
393fi],[if test x"$GCC" != ""; then
394  sim_inline="-DDEFAULT_INLINE=PSIM_INLINE_LOCALS"
395  if test x"$silent" != x"yes"; then
396    echo "Setting inline flags = $sim_inline" 6>&1
397  fi
398else
399  sim_inline=""
400fi])dnl
401
402
403AC_ARG_ENABLE(sim-jump,
404[  --enable-sim-jump		Jump between semantic code (instead of call/return).],
405[case "${enableval}" in
406  yes)	sim_jump="-J";;
407  no)	sim_jump="";;
408  *)	AC_MSG_ERROR("--enable-sim-jump does not take a value"); sim_jump="";;
409esac
410if test x"$silent" != x"yes" && test x"$sim_jump" != x""; then
411  echo "Setting jump flag = $sim_jump" 6>&1
412fi],[sim_jump=""
413if test x"$silent" != x"yes"; then
414  echo "Setting jump flag = $sim_jump" 6>&1
415fi])dnl
416
417
418AC_ARG_ENABLE(sim-line-nr,
419[  --enable-sim-line-nr=opts		Generate extra CPP code that references source rather than generated code],
420[case "${enableval}" in
421  yes)	sim_line_nr="";;
422  no)	sim_line_nr="-L";;
423  *)	AC_MSG_ERROR("--enable-sim-line-nr does not take a value"); sim_line_nr="";;
424esac
425if test x"$silent" != x"yes" && test x"$sim_line_nr" != x""; then
426  echo "Setting warning flags = $sim_line_nr" 6>&1
427fi],[sim_line_nr=""])dnl
428
429
430AC_ARG_ENABLE(sim-model,
431[  --enable-sim-model=which		Specify PowerPC to model.],
432[case "${enableval}" in
433  yes|no)	AC_MSG_ERROR("No value supplied for --enable-sim-model=model");;
434  *)		sim_model="-DWITH_MODEL=${enableval}";;
435esac
436if test x"$silent" != x"yes" && test x"$sim_model" != x""; then
437  echo "Setting model flags = $sim_model" 6>&1
438fi],[sim_model=""])dnl
439
440
441AC_ARG_ENABLE(sim-model-issue,
442[  --enable-sim-model-issue		Specify whether to simulate model specific actions],
443[case "${enableval}" in
444  yes)	sim_model_issue="-DWITH_MODEL_ISSUE=MODEL_ISSUE_PROCESS";;
445  no)	sim_model_issue="-DWITH_MODEL_ISSUE=MODEL_ISSUE_IGNORE";;
446  *)	AC_MSG_ERROR("--enable-sim-model-issue does not take a value"); sim_model_issue="";;
447esac
448if test x"$silent" != x"yes"; then
449  echo "Setting model-issue flags = $sim_model_issue" 6>&1
450fi],[sim_model_issue=""])dnl
451
452
453AC_ARG_ENABLE(sim-monitor,
454[  --enable-sim-monitor=mon		Specify whether to enable monitoring events.],
455[case "${enableval}" in
456  yes)		sim_monitor="-DWITH_MON='MONITOR_INSTRUCTION_ISSUE | MONITOR_LOAD_STORE_UNIT'";;
457  no)		sim_monitor="-DWITH_MON=0";;
458  instruction)	sim_monitor="-DWITH_MON=MONITOR_INSTRUCTION_ISSUE";;
459  memory)	sim_monitor="-DWITH_MON=MONITOR_LOAD_STORE_UNIT";;
460  *)		AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-mon"); sim_env="";;
461esac
462if test x"$silent" != x"yes" && test x"$sim_monitor" != x""; then
463  echo "Setting monitor flags = $sim_monitor" 6>&1
464fi],[sim_monitor=""])dnl
465
466
467AC_ARG_ENABLE(sim-opcode,
468[  --enable-sim-opcode=which		Override default opcode lookup.],
469[case "${enableval}" in
470  yes|no)	AC_MSG_ERROR("No value supplied for --enable-sim-opcode=file");;
471  *)		if test -f "${srcdir}/${enableval}"; then
472		  sim_opcode="${enableval}"
473		elif test -f "${srcdir}/dc-${enableval}"; then
474		  sim_opcode="dc-${enableval}"
475		else
476		  AC_MSG_ERROR("File $enableval is not an opcode rules file");
477		  sim_opcode="dc-complex"
478		fi;;
479esac
480if test x"$silent" != x"yes" && test x"$sim_opcode" != x""; then
481  echo "Setting opcode flags = $sim_opcode" 6>&1
482fi],[sim_opcode="dc-complex"
483if test x"$silent" != x"yes"; then
484  echo "Setting opcode flags = $sim_opcode"
485fi])dnl
486
487
488AC_ARG_ENABLE(sim-packages,
489[  --enable-sim-packages=list		Specify the packages to be included in the build.],
490[packages=disklabel
491case "${enableval}" in
492  yes)	;;
493  no)	AC_MSG_ERROR("List of packages must be specified for --enable-sim-packages"); packages="";;
494  ,*)   packages="${packages}${enableval}";;
495  *,)   packages="${enableval}${packages}";;
496  *)	packages="${enableval}"'';;
497esac
498sim_pk_src=`echo $packages | sed -e 's/,/.c pk_/g' -e 's/^/pk_/' -e 's/$/.c/'`
499sim_pk_obj=`echo $sim_pk_src | sed -e 's/\.c/.o/g'`
500if test x"$silent" != x"yes" && test x"$packages" != x""; then
501  echo "Setting packages to $sim_pk_src, $sim_pk_obj"
502fi],[packages=disklabel
503sim_pk_src=`echo $packages | sed -e 's/,/.c pk_/g' -e 's/^/pk_/' -e 's/$/.c/'`
504sim_pk_obj=`echo $sim_pk_src | sed -e 's/\.c/.o/g'`
505if test x"$silent" != x"yes"; then
506  echo "Setting packages to $sim_pk_src, $sim_pk_obj"
507fi])dnl
508
509
510AC_ARG_ENABLE(sim-reserved-bits,
511[  --enable-sim-reserved-bits		Specify whether to check reserved bits in instruction.],
512[case "${enableval}" in
513  yes)	sim_reserved="-DWITH_RESERVED_BITS=1";;
514  no)	sim_reserved="-DWITH_RESERVED_BITS=0";;
515  *)	AC_MSG_ERROR("--enable-sim-reserved-bits does not take a value"); sim_reserved="";;
516esac
517if test x"$silent" != x"yes" && test x"$sim_reserved" != x""; then
518  echo "Setting reserved flags = $sim_reserved" 6>&1
519fi],[sim_reserved=""])dnl
520
521
522AC_ARG_ENABLE(sim-smp,
523[  --enable-sim-smp=n			Specify number of processors to configure for.],
524[case "${enableval}" in
525  yes)	sim_smp="-DWITH_SMP=5" ; sim_igen_smp="-N 5";;
526  no)	sim_smp="-DWITH_SMP=0" ; sim_igen_smp="-N 0";;
527  *)	sim_smp="-DWITH_SMP=$enableval" ; sim_igen_smp="-N $enableval";;
528esac
529if test x"$silent" != x"yes" && test x"$sim_smp" != x""; then
530  echo "Setting smp flags = $sim_smp" 6>&1
531fi],[sim_smp="-DWITH_SMP=5" ; sim_igen_smp="-N 5"
532if test x"$silent" != x"yes"; then
533  echo "Setting smp flags = $sim_smp" 6>&1
534fi])dnl
535
536
537AC_MSG_CHECKING([for sim stdio debug behavior])
538sim_stdio=0
539AC_ARG_ENABLE(sim-stdio,
540[  --enable-sim-stdio			Specify whether to use stdio for console input/output.],
541[case "${enableval}" in
542  yes)	sim_stdio="DO_USE_STDIO";;
543  no)	sim_stdio="DONT_USE_STDIO";;
544  *)	AC_MSG_ERROR([Unknown value $enableval passed to --enable-sim-stdio]);;
545esac])dnl
546AC_DEFINE_UNQUOTED([WITH_STDIO], [$sim_stdio], [How to route I/O])
547AC_MSG_RESULT($sim_stdio)
548
549
550AC_ARG_ENABLE(sim-switch,
551[  --enable-sim-switch			Use a switch instead of a table for instruction call.],
552[case "${enableval}" in
553  yes)	sim_switch="-s";;
554  no)	sim_switch="";;
555  *)	AC_MSG_ERROR("--enable-sim-switch does not take a value"); sim_switch="";;
556esac
557if test x"$silent" != x"yes" && test x"$sim_switch" != x""; then
558  echo "Setting switch flags = $sim_switch" 6>&1
559fi],[sim_switch="";
560if test x"$silent" != x"yes"; then
561  echo "Setting switch flags = $sim_switch" 6>&1
562fi])dnl
563
564
565AC_ARG_ENABLE(sim-timebase,
566[  --enable-sim-timebase			Specify whether the PPC timebase is supported.],
567[case "${enableval}" in
568  yes)	sim_timebase="-DWITH_TIME_BASE=1";;
569  no)	sim_timebase="-DWITH_TIME_BASE=0";;
570  *)	AC_MSG_ERROR("--enable-sim-timebase does not take a value"); sim_timebase="";;
571esac
572if test x"$silent" != x"yes" && test x"$sim_timebase" != x""; then
573  echo "Setting timebase flags = $sim_timebase" 6>&1
574fi],[sim_timebase=""])dnl
575
576
577AC_MSG_CHECKING([for sim trace settings])
578sim_trace="1"
579AC_ARG_ENABLE(sim-trace,
580[  --enable-sim-trace			Specify whether tracing is supported.],
581[case "${enableval}" in
582  yes)	sim_trace="1";;
583  no)	sim_trace="0";;
584  *)	AC_MSG_ERROR([--enable-sim-trace does not take a value]);;
585esac])dnl
586AC_DEFINE_UNQUOTED([WITH_TRACE], [$sim_trace], [Sim trace settings])
587AC_MSG_RESULT($sim_trace)
588
589
590AC_ARG_ENABLE(sim-warnings,
591[  --enable-sim-warnings=opts		Extra CFLAGS for turning on compiler warnings except for idecode.o, semantics.o and psim.o],
592[case "${enableval}" in
593  yes)	sim_warnings="-Werror -Wall -Wpointer-arith -Wmissing-prototypes -Wmissing-declarations ";;
594  no)	sim_warnings="-w";;
595  *)	sim_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
596esac
597if test x"$silent" != x"yes" && test x"$sim_warnings" != x""; then
598  echo "Setting warning flags = $sim_warnings" 6>&1
599fi],[sim_warnings=""])dnl
600
601
602AC_ARG_ENABLE(sim-xor-endian,
603[  --enable-sim-xor-endian=n		Specify number bytes involved in PowerPC XOR bi-endian mode (default 8).],
604[case "${enableval}" in
605  yes)	sim_xor_endian="-DWITH_XOR_ENDIAN=8";;
606  no)	sim_xor_endian="-DWITH_XOR_ENDIAN=0";;
607  *)	sim_xor_endian="-DWITH_XOR_ENDIAN=$enableval";;
608esac
609if test x"$silent" != x"yes" && test x"$sim_xor_endian" != x""; then
610  echo "Setting xor-endian flag = $sim_xor_endian" 6>&1
611fi],[sim_xor_endian=""])dnl
612
613
614ACX_PKGVERSION([GDB])
615ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
616AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
617AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
618
619AC_CANONICAL_SYSTEM
620AC_ARG_PROGRAM
621
622# BFD conditionally uses zlib, so we must link it in if libbfd does, by
623# using the same condition.
624AM_ZLIB
625
626# BFD uses libdl when when plugins enabled.
627AC_PLUGINS
628
629. ${srcdir}/../../bfd/configure.host
630
631case ${host} in
632  *mingw32*)
633    AC_DEFINE(USE_WIN32API, 1,
634              [Define if we should use the Windows API, instead of the 
635	       POSIX API.  On Windows, we use the Windows API when 
636	       building for MinGW, but the POSIX API when building 
637	       for Cygwin.])
638    ;;
639esac	    
640
641AC_CONFIG_HEADER(config.h:config.in)
642
643AC_STRUCT_ST_BLKSIZE
644AC_STRUCT_ST_BLOCKS
645AC_STRUCT_ST_RDEV
646AC_STRUCT_TIMEZONE
647
648AC_TYPE_GETGROUPS
649AC_TYPE_MODE_T
650AC_TYPE_OFF_T
651AC_TYPE_PID_T
652AC_TYPE_SIGNAL
653AC_TYPE_SIZE_T
654AC_TYPE_UID_T
655
656AC_CHECK_FUNCS(access cfgetispeed cfgetospeed cfsetispeed cfsetospeed chdir chmod chown dup dup2 fchmod fchown fcntl fstat fstatfs getdirentries getegid geteuid getgid getpid getppid getrusage gettimeofday getuid ioctl kill link lseek lstat mkdir pipe readlink rmdir setreuid setregid stat sigprocmask stat symlink tcgetattr tcsetattr tcsendbreak tcdrain tcflush tcflow tcgetpgrp tcsetpgrp time umask unlink)
657
658AC_CHECK_HEADERS(fcntl.h stdlib.h string.h strings.h sys/ioctl.h sys/mount.h sys/param.h sys/resource.h sys/stat.h sys/termio.h sys/termios.h sys/time.h sys/times.h sys/types.h time.h unistd.h sys/vfs.h sys/statfs.h)
659AC_HEADER_DIRENT
660
661dnl Figure out what type of termio/termios support there is
662sim_termio=""
663AC_MSG_CHECKING(for struct termios)
664AC_CACHE_VAL(ac_cv_termios_struct,
665[AC_TRY_COMPILE([#include <sys/types.h>
666#include <sys/termios.h>],
667[static struct termios x;
668 x.c_iflag = 0;
669 x.c_oflag = 0;
670 x.c_cflag = 0;
671 x.c_lflag = 0;
672 x.c_cc[NCCS] = 0;],
673ac_cv_termios_struct=yes, ac_cv_termios_struct=no)])
674AC_MSG_RESULT($ac_cv_termios_struct)
675if test $ac_cv_termios_struct = yes; then
676  sim_termio="$sim_termio -DHAVE_TERMIOS_STRUCTURE"
677fi
678
679if test "$ac_cv_termios_struct" = "yes"; then
680  AC_MSG_CHECKING(for c_line field in struct termios)
681  AC_CACHE_VAL(ac_cv_termios_cline,
682  [AC_TRY_COMPILE([#include <sys/types.h>
683#include <sys/termios.h>],
684[static struct termios x; x.c_line = 0;],
685  ac_cv_termios_cline=yes, ac_cv_termios_cline=no)])
686
687  AC_MSG_RESULT($ac_cv_termios_cline)
688  if test $ac_cv_termios_cline = yes; then
689    sim_termio="$sim_termio -DHAVE_TERMIOS_CLINE"
690  fi
691else
692  ac_cv_termios_cline=no
693fi
694
695if test "$ac_cv_termios_struct" != "yes"; then
696  AC_MSG_CHECKING(for struct termio)
697  AC_CACHE_VAL(ac_cv_termio_struct,
698  [AC_TRY_COMPILE([#include <sys/types.h>
699#include <sys/termio.h>],
700[static struct termio x;
701 x.c_iflag = 0;
702 x.c_oflag = 0;
703 x.c_cflag = 0;
704 x.c_lflag = 0;
705 x.c_cc[NCC] = 0;],
706ac_cv_termio_struct=yes, ac_cv_termio_struct=no)])
707  AC_MSG_RESULT($ac_cv_termio_struct)
708  if test $ac_cv_termio_struct = yes; then
709    sim_termio="$sim_termio -DHAVE_TERMIO_STRUCTURE"
710  fi
711else
712  ac_cv_termio_struct=no
713fi
714
715if test "$ac_cv_termio_struct" = "yes"; then
716  AC_MSG_CHECKING(for c_line field in struct termio)
717  AC_CACHE_VAL(ac_cv_termio_cline,
718  [AC_TRY_COMPILE([#include <sys/types.h>
719#include <sys/termio.h>],
720[static struct termio x; x.c_line = 0;],
721  ac_cv_termio_cline=yes, ac_cv_termio_cline=no)])
722
723  AC_MSG_RESULT($ac_cv_termio_cline)
724  if test $ac_cv_termio_cline = yes; then
725    sim_termio="$sim_termio -DHAVE_TERMIO_CLINE"
726  fi
727else
728  ac_cv_termio_cline=no
729fi
730
731dnl Check for struct statfs
732AC_MSG_CHECKING(for struct statfs)
733AC_CACHE_VAL(ac_cv_struct_statfs,
734[AC_TRY_COMPILE([#include <sys/types.h>
735#ifdef HAVE_SYS_PARAM_H
736#include <sys/param.h>
737#endif
738#ifdef HAVE_SYS_MOUNT_H
739#include <sys/mount.h>
740#endif
741#ifdef HAVE_SYS_VFS_H
742#include <sys/vfs.h>
743#endif
744#ifdef HAVE_SYS_STATFS_H
745#include <sys/statfs.h>
746#endif],
747[static struct statfs s;],
748ac_cv_struct_statfs=yes, ac_cv_struct_statfs=no)])
749AC_MSG_RESULT($ac_cv_struct_statfs)
750if test $ac_cv_struct_statfs = yes; then
751  AC_DEFINE(HAVE_STRUCT_STATFS, 1,
752	    [Define if struct statfs is defined in <sys/mount.h>])
753fi
754
755AC_CHECK_TYPES(long long)
756
757dnl Figure out if /dev/zero exists or not
758sim_devzero=""
759AC_MSG_CHECKING(for /dev/zero)
760AC_CACHE_VAL(ac_cv_devzero,
761[AC_TRY_RUN([#include <fcntl.h>
762main () {
763  char buf[2048];
764  int i;
765  int fd = open ("/dev/zero", O_RDONLY);
766  if (fd < 0)
767    return 1;
768  for (i = 0; i < sizeof (buf); i++)
769    buf[i] = 1;
770  if (read (fd, buf, sizeof (buf)) != sizeof (buf))
771    return 1;
772  for (i = 0; i < sizeof (buf); i++)
773    if (buf[i])
774      return 1;
775  return 0;
776}],[ac_cv_devzero=yes],[ac_cv_devzero=no],[ac_cv_devzero=no])])
777AC_MSG_RESULT($ac_cv_devzero)
778if test $ac_cv_devzero = yes; then
779  sim_devzero="-DHAVE_DEVZERO"
780else
781  sim_devzero=""
782fi
783
784dnl Figure out if we are in the new Cygnus tree with a common directory or not
785AC_MSG_CHECKING(for common simulator directory)
786if test -f "${srcdir}/../common/callback.c"; then
787  AC_MSG_RESULT(yes)
788  sim_callback="callback.o targ-map.o"
789  sim_targ_vals="targ-vals.h targ-map.c targ-vals.def"
790else
791  AC_MSG_RESULT(no)
792  sim_callback=""
793  sim_targ_vals=""
794fi
795
796AC_MSG_CHECKING(for common simulator directory fpu implementation)
797if test -f "${srcdir}/../common/sim-fpu.c"; then
798  AC_MSG_RESULT(yes)
799  sim_fpu_cflags="-DHAVE_COMMON_FPU -I../common -I${srcdir}/../common"
800  sim_fpu="sim-fpu.o"
801else
802  AC_MSG_RESULT(no)
803  sim_fpu_cflags=
804  sim_fpu=
805fi
806
807# Since we run commands on the build system, we have to create a
808# separate config header for the build system if build != host.
809if test x$host = x$build; then
810  AC_CONFIG_COMMANDS([build-config.h],[cp config.h build-config.h])
811else
812  tempdir=build.$$
813  rm -rf $tempdir
814  mkdir $tempdir
815  cd $tempdir
816  case ${srcdir} in
817  /* | [A-Za-z]:[\\/]* ) realsrcdir=${srcdir};;
818  *) realsrcdir=../${srcdir};;
819  esac
820  saved_CFLAGS="${CFLAGS}"
821  CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \
822  LDFLAGS="${LDFLAGS_FOR_BUILD}" \
823  ${realsrcdir}/configure \
824    --enable-languages=${enable_languages-all} \
825    --target=$target_alias --host=$build_alias --build=$build_alias
826  CFLAGS="${saved_CFLAGS}"
827  mv config.h ../build-config.h
828  cd ..
829  rm -rf $tempdir
830fi
831
832dnl Check for exe extension
833AC_EXEEXT
834
835AC_SUBST(CC_FOR_BUILD)
836AC_SUBST(CFLAGS_FOR_BUILD)
837AC_SUBST(CFLAGS)
838AC_SUBST(HDEFINES)
839AR=${AR-ar}
840AC_SUBST(AR)
841AC_PROG_RANLIB
842AC_SUBST(sim_warnings)
843AC_SUBST(sim_line_nr)
844AC_SUBST(sim_config)
845AC_SUBST(sim_opcode)
846AC_SUBST(sim_switch)
847AC_SUBST(sim_dup)
848AC_SUBST(sim_decode_mechanism)
849AC_SUBST(sim_jump)
850AC_SUBST(sim_filter)
851AC_SUBST(sim_icache)
852AC_SUBST(sim_hw_src)
853AC_SUBST(sim_hw_obj)
854AC_SUBST(sim_pk_src)
855AC_SUBST(sim_pk_obj)
856AC_SUBST(sim_inline)
857AC_SUBST(sim_endian)
858AC_SUBST(sim_xor_endian)
859AC_SUBST(sim_hostendian)
860AC_SUBST(sim_smp)
861AC_SUBST(sim_igen_smp)
862AC_SUBST(sim_bitsize)
863AC_SUBST(sim_hostbitsize)
864AC_SUBST(sim_timebase)
865AC_SUBST(sim_alignment)
866AC_SUBST(sim_float)
867AC_SUBST(sim_reserved)
868AC_SUBST(sim_monitor)
869AC_SUBST(sim_model)
870AC_SUBST(sim_default_model)
871AC_SUBST(sim_model_issue)
872AC_SUBST(sim_termio)
873AC_SUBST(sim_devzero)
874AC_SUBST(sim_callback)
875AC_SUBST(sim_targ_vals)
876AC_SUBST(sim_fpu_cflags)
877AC_SUBST(sim_fpu)
878
879AC_OUTPUT(Makefile,
880[case x$CONFIG_HEADERS in xconfig.h:config.in) echo > stamp-h ;; esac])
881