aboutsummaryrefslogtreecommitdiff
path: root/sim/m4/sim_ac_option_hardware.m4
blob: 75e331eb0b3390e86ef49008d0dba72f6629b5aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
dnl   Copyright (C) 1997-2021 Free Software Foundation, Inc.
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 3 of the License, or
dnl (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
dnl
dnl --enable-sim-hardware is for users of the simulator
dnl arg[1] is a space separated list of extra target specific devices.
AC_DEFUN([SIM_AC_OPTION_HARDWARE],
[
hardware="cfi core pal glue [$1]"
sim_hw_cflags="-DWITH_HW=1"
sim_hw="$hardware"
sim_hw_objs="\$(SIM_COMMON_HW_OBJS) `echo $sim_hw | sed -e 's/\([[^ ]][[^ ]]*\)/dv-\1.o/g'`"

AC_ARG_ENABLE(sim-hardware,
  [AS_HELP_STRING([--enable-sim-hardware=LIST],
                  [Specify the hardware to be included in the build.])],
  ,[enable_sim_hardware="yes"])
case ${enable_sim_hardware} in
  yes|no) ;;
  ,*) hardware="${hardware} `echo ${enableval} | sed -e 's/,/ /'`";;
  *,) hardware="`echo ${enableval} | sed -e 's/,/ /'` ${hardware}";;
  *)  hardware="`echo ${enableval} | sed -e 's/,/ /'`"'';;
esac

if test "$enable_sim_hardware" = no; then
  sim_hw_objs=
  sim_hw_cflags="-DWITH_HW=0"
  sim_hw=
else
  sim_hw_cflags="-DWITH_HW=1"
  # remove duplicates
  sim_hw=""
  sim_hw_objs="\$(SIM_COMMON_HW_OBJS)"
  for i in $hardware ; do
    case " $sim_hw " in
      *" $i "*) ;;
      *) sim_hw="$sim_hw $i" ; sim_hw_objs="$sim_hw_objs dv-$i.o";;
    esac
  done
  # mingw does not support sockser
  case ${host} in
    *mingw*) ;;
    *) # TODO: We don't add dv-sockser to sim_hw as it is not a "real" device
       # that you instatiate.  Instead, other code will call into it directly.
       # At some point, we should convert it over.
       sim_hw_objs="$sim_hw_objs dv-sockser.o"
       AC_DEFINE_UNQUOTED(
         [HAVE_DV_SOCKSER], 1, [Define if dv-sockser is usable.])
       ;;
  esac
  if test x"$silent" != x"yes"; then
    echo "Setting hardware to $sim_hw_cflags, $sim_hw, $sim_hw_objs"
  fi
  dnl Some devices require extra libraries.
  case " $hardware " in
    *" cfi "*) AC_CHECK_LIB(m, log2);;
  esac
fi
])
AC_SUBST(sim_hw_cflags)
AC_SUBST(sim_hw_objs)
AC_SUBST(sim_hw)