#define HAVE_SYSDEP
#include <sys/systeminfo.h>
static void
check_sysdep (conf_t * conf)
{
  char tmp[64];

  conf->flags |= F_USEARCH;

  strcpy (conf->cplusplus,
	  "CC -DNO_BUILTINS -I. -features=no%except -xvector=no");

  if (sysinfo (SI_ARCHITECTURE, tmp, sizeof (tmp)) == -1)
    {
      perror ("sysinfo SI_ARCHITECTURE");
      exit (-1);
    }
  printf ("Arch: %s\n", tmp);
#if 0
  if (sysinfo (SI_ARCHITECTURE_32, tmp, sizeof (tmp)) == -1)
    {
      perror ("sysinfo SI_ARCHITECTURE_32");
      exit (-1);
    }
  printf ("Arch 32: %s\n", tmp);

  if (sysinfo (SI_ARCHITECTURE_64, tmp, sizeof (tmp)) == -1)
    {
      perror ("sysinfo SI_ARCHITECTURE_64");
    }
  else
    printf ("Arch 64: %s\n", tmp);

  if (sysinfo (SI_ARCHITECTURE_K, tmp, sizeof (tmp)) == -1)
    {
      perror ("sysinfo SI_ARCHITECTURE_K");
      exit (-1);
    }
#endif
  if (getenv ("SOL9") != NULL)
    strcat (conf->OSflags, "-DSOL9 ");
  if (getenv ("SOL8") != NULL)
    strcat (conf->OSflags, "-DSOL8 ");

  if (*arch)
    strcpy (tmp, arch);
  printf ("Arch K: %s\n", tmp);
  strcpy (conf->arch, tmp);

  if (strcmp (tmp, "amd64") == 0)
    {
      strcpy (conf->OSflags, "-xarch=$(ARCH) -xmodel=kernel");
      strcpy (conf->platform, "i86pc");
    }
  else if (strcmp (tmp, "sparcv9") == 0)
    {
      strcpy (conf->OSflags, "-xarch=v9 -dalign");
      strcpy (conf->platform, "sparc");
    }
  else if (strcmp (tmp, "sparc") == 0)
    {
      strcpy (conf->OSflags, "-Dsparc32");
      strcpy (conf->platform, "sparc");
    }
  else if (strcmp (tmp, "i386") == 0)
    {
      strcpy (conf->OSflags, "-xarch=386");
      strcpy (conf->platform, "i86pc");
    }
  else
    {
      strcpy (conf->OSflags, "-xarch=$(ARCH)");
      fprintf (stderr, "Cannot determine platform for '%s'\n", tmp);
      exit (-1);
    }
#if 0
  if (sysinfo (SI_ARCHITECTURE_NATIVE, tmp, sizeof (tmp)) == -1)
    {
      perror ("sysinfo SI_ARCHITECTURE_NATIVE");
      exit (-1);
    }
  printf ("Arch native: %s\n", tmp);
#endif
  if (getenv ("SOL9") != NULL)
    strcat (conf->OSflags, " -DSOL9");
  if (getenv ("SOL8") != NULL)
    strcat (conf->OSflags, " -DSOL8");
}
