# Don't build the shared library for build.
if [ -n "${with_build_subdir}" ]; then
  enable_shared=no
fi

frag=
case "${host}" in
  rs6000-ibm-aix3.1 | rs6000-ibm-aix)
                        frag=mh-aix ;;
  *-*-cxux7*)		frag=mh-cxux7 ;;
  *-*-freebsd2.1.*)	frag=mh-fbsd21 ;;
  *-*-freebsd2.2.[012])	frag=mh-fbsd21 ;;
  i370-*-opened*)       frag=mh-openedition ;;
  i[345]86-*-windows*)	frag=mh-windows ;;
esac

if [ -n "${frag}" ]; then
  frags=${libiberty_topdir}/libiberty/config/$frag
else
  frags=
fi

# If they didn't specify --enable-shared, don't generate shared libs.
case "${enable_shared}" in
  yes) shared=yes ;;
  no) shared=no ;;
  "") shared=no ;;
  *) shared=yes ;;
esac
if [ "${shared}" = "yes" ]; then
  frag=
  case "${host}" in
    *-*-cygwin*)	;;
    alpha*-*-linux*)	frag=mh-elfalphapic ;;
    arm*-*-*)		frag=mh-armpic ;;
    hppa*-*-*)		frag=mh-papic ;;
    i[3456]86-*-* | x86_64-*-*)
			frag=mh-x86pic ;;
    powerpc*-*-aix*)	;;
    powerpc*-*-*)	frag=mh-ppcpic ;;
    sparc*-*-*)		frag=mh-sparcpic ;;
    s390*-*-*)		frag=mh-s390pic ;;
    *)			frag=mh-${host_cpu}pic ;;
  esac
  if [ -n "${frag}" ]; then
    frags="${frags} ${libiberty_topdir}/config/${frag}"
  fi
fi

echo "# Warning: this fragment is automatically generated" > temp-frag

for frag in ${frags}; do
  if [ -f ${frag} ]; then
    echo "Appending ${frag} to xhost-mkfrag"
    echo "# Following fragment copied from ${frag}" >> temp-frag
    cat ${frag} >> temp-frag
  fi
done

# record if we want to build shared libs.
if [ "${shared}" = "yes" ]; then
  echo enable_shared = yes >> temp-frag
else
  echo enable_shared = no >> temp-frag
fi

frag=xhost-mkfrag
${CONFIG_SHELL-/bin/sh} ${libiberty_topdir}/move-if-change temp-frag xhost-mkfrag
