int
main(int argc, char *argv[]){

    int n, depth;

    ask_parameters(&n, &depth);
    printf("%.15lf\n", f(depth, n) );

    return EXIT_SUCCESS;
}
Esempio n. 2
0
void
dump_script (void)
{
  int             i;

  for (i = 0; i <= OPT_LAST; i++)
    if (!(DUMMY_OPTS & B (i)))
      if (!(DISABLED_OPTIONS & B (i)))
	{
	  printf ("bool '%s' CONFIG_%s\n", questions[i], hw_table[i].macro);
	}

/*
 * Some "hardcoded" options
 */

  dump_only = 1;
  selected_options = 0;
  ask_parameters ();

  printf ("#\n$MAKE -C drivers/sound kernelconfig || exit 1\n");
}
Esempio n. 3
0
int
main (int argc, char *argv[])
{
  int             i, full_driver = 1;
  char            old_config_file[200];

  if (getuid () != 0)		/* Not root */
    {
      char           *home;

      if ((home = getenv ("HOME")) != NULL)
	{
	  sprintf (old_config_file, "%s/.soundconf", home);
	  oldconf = old_config_file;
	}
    }

  if (argc > 1)
    {
      if (strcmp (argv[1], "-o") == 0 &&
	  use_old_config (oldconf))
	exit (0);
      else if (strcmp (argv[1], "script") == 0)
	{
	  dump_script ();
	  exit (0);
	}
      else if (strcmp (argv[1], "fixedlocal") == 0)
	{
	  dump_fixed_local ();
	  exit (0);
	}
      else if (strcmp (argv[1], "fixeddefines") == 0)
	{
	  dump_fixed_defines ();
	  exit (0);
	}
    }

  fprintf (stderr, "\nConfiguring Sound Support\n\n");

  if (access (oldconf, R_OK) == 0)
    {
      char            str[255];

      sprintf (str, "Old configuration exists in `%s'. Use it", oldconf);
      if (think_positively (str, 1,
      "Enable this option to load the previously saved configuration file\n"
			    "for all of the sound driver parameters.\n"))
	if (use_old_config (oldconf))
	  exit (0);
    }

  printf ("/*\tGenerated by configure. Don't edit!!!!\t*/\n");
  printf ("/*\tMaking changes to this file is not as simple as it may look.\t*/\n\n");
  printf ("/*\tIf you change the CONFIG_ settings in local.h you\t*/\n");
  printf ("/*\t_have_ to edit .defines too.\t*/\n\n");

  {
    /*
     * Partial driver
     */

    full_driver = 0;

    for (i = 0; i <= OPT_LAST; i++)
      if (can_select_option (i))
	{
	  if (!(selected_options & B (i)))	/*
						 * Not selected yet
						 */
	    if (!hw_table[i].verify)
	      {
		if (hw_table[i].alias)
		  selected_options |= B (hw_table[i].alias);
		else
		  selected_options |= B (i);
	      }
	    else
	      {
		int             def_answ = hw_table[i].default_answ;

		if (think_positively (questions[i], def_answ, help[i]))
		  if (hw_table[i].alias)
		    selected_options |= B (hw_table[i].alias);
		  else
		    selected_options |= B (i);
	      }
	}
  }

  if (selected_options & B (OPT_SB))
    {
      if (think_positively (
			     "Support for the SG NX Pro mixer", 0,
       "Enable this if you want to support the additional mixer functions\n"
			  "provided on Sound Galaxy NX Pro sound cards.\n"))
	printf ("#define __SGNXPRO__\n");
    }

  if (selected_options & B (OPT_SB))
    {
      if (think_positively ("Support for the MV Jazz16 (ProSonic etc.)", 0,
	  "Enable this if you have an MV Jazz16 or ProSonic sound card.\n"))
	{
	  if (think_positively ("Do you have SoundMan Wave", 0,
				"Enable this option of you have the Logitech SoundMan Wave sound card.\n"))
	    {
	      printf ("#define SM_WAVE\n");

	    midi0001_again:
	      if (think_positively (
			   "Do you have access to the MIDI0001.BIN file", 1,
				     "The Logitech SoundMan Wave has a microcontroller which must be\n"
				     "initialized before MIDI emulation works. This is possible only if the\n"
			   "microcode file is compiled into the driver.\n"))
		{
		  char            path[512];

		  fprintf (stderr,
			   "Enter full name of the MIDI0001.BIN file (pwd is sound): ");
		  scanf ("%s", path);
		  fprintf (stderr, "including microcode file %s\n", path);

		  if (!bin2hex (path, "smw-midi0001.h", "smw_ucode"))
		    {
		      fprintf (stderr, "Couldn't open file %s\n",
			       path);
		      if (think_positively ("Try again with correct path", 1,
					    "The specified file could not be opened. Enter the correct path to the\n"
					    "file.\n"))
			goto midi0001_again;
		    }
		  else
		    {
		      printf ("#define SMW_MIDI0001_INCLUDED\n");
		      printf ("/*build bin2hex %s smw-midi0001.h smw_ucode */\n", path);
		    }
		}
	    }
	}
    }

  if (selected_options & B (OPT_SB))
    {
      if (think_positively ("Do you have a Logitech SoundMan Games", 0,
	 "The Logitech SoundMan Games supports 44 kHz in stereo while the\n"
      "standard SB Pro supports just 22 kHz stereo. You have the option of\n"
			    "enabling SM Games mode.  However, enable it only if you are sure that\n"
      "your card is an SM Games. Enabling this feature with a plain old SB\n"
			    "Pro will cause troubles with stereo mode.\n\n"
		  "DANGER! Read the above once again before answering 'y'\n"
			    "Answer 'n' if you are unsure what to do!\n"))
	printf ("#define SM_GAMES\n");
    }

  if (selected_options & B (OPT_AEDSP16))
    {
      int             sel1 = 0;

      if (selected_options & B (OPT_SB))
	{

	  if (think_positively (
	    "Do you want support for the Audio Excel Sound Blaster Pro mode",
				 1,
				 "Enable this option if you want the Audio Excel sound card to operate\n"
				 "in Sound Blaster Pro mode.\n"))
	    {
	      printf ("#define AEDSP16_SBPRO\n");
	      sel1 = 1;
	    }
	}

      if ((selected_options & B (OPT_MSS)) && (sel1 == 0))
	{

	  if (think_positively (
				 "Do you want support for the Audio Excel Microsoft Sound System mode",
				 1,
				 "Enable this option if you want the Audio Excel sound card to operate\n"
				 "in Microsoft Sound System mode.\n"))
	    {
	      printf ("#define AEDSP16_MSS\n");
	      sel1 = 1;
	    }
	}

      if (sel1 == 0)
	{
	  printf ("invalid_configuration__run_make_config_again\n");
	  fprintf (stderr, "ERROR!!!!!\nYou must select at least one mode when using Audio Excel!\n");
	  exit (-1);
	}
      if (selected_options & B (OPT_MPU401))
	printf ("#define AEDSP16_MPU401\n");
    }

  if (selected_options & B (OPT_PSS))
    {
    genld_again:
      if (think_positively ("Do you wish to include an LD file", 1,
			    "If you want to emulate the Sound Blaster card and you have a DSPxxx.LD\n"
		      "file then you must include the LD in the kernel.\n"))
	{
	  char            path[512];

	  fprintf (stderr,
		   "Enter the path to your LD file (pwd is sound): ");
	  scanf ("%s", path);
	  fprintf (stderr, "including LD file %s\n", path);

	  if (!bin2hex (path, "synth-ld.h", "pss_synth"))
	    {
	      fprintf (stderr, "couldn't open `%s' as the LD file\n", path);
	      if (think_positively ("try again with correct path", 1,
				    "The given LD file could not opened.\n"))
		goto genld_again;
	    }
	  else
	    {
	      printf ("#define PSS_HAVE_LD\n");
	      printf ("/*build bin2hex %s synth-ld.h pss_synth */\n", path);
	    }
	}
      else
	{
	  FILE           *sf = fopen ("synth-ld.h", "w");

	  fprintf (sf, "/* automatically generated by configure */\n");
	  fprintf (sf, "unsigned char pss_synth[1];\n"
		   "#define pss_synthLen 0\n");
	  fclose (sf);
	}
    }

  if (selected_options & B (OPT_TRIX))
    {
    hex2hex_again:

      if (think_positively ("Do you want to include TRXPRO.HEX in your kernel",
			    1,
	"The MediaTrix AudioTrix Pro has an on-board microcontroller which\n"
			    "needs to be initialized by downloading the code from the file TRXPRO.HEX\n"
			    "in the DOS driver directory. If you don't have the TRXPRO.HEX file handy\n"
			    "you may skip this step. However, the SB and MPU-401 modes of AudioTrix\n"
			    "Pro will not work without this file!\n"))
	{
	  char            path[512];

	  fprintf (stderr,
		 "Enter the path to your TRXPRO.HEX file (pwd is sound): ");
	  scanf ("%s", path);
	  fprintf (stderr, "including HEX file `%s'\n", path);

	  if (!hex2hex (path, "trix_boot.h", "trix_boot"))
	    goto hex2hex_again;
	  printf ("/*build hex2hex %s trix_boot.h trix_boot */\n", path);
	  printf ("#define INCLUDE_TRIX_BOOT\n");
	}
    }

  if (selected_options & B (OPT_MSS))
    {
      if (think_positively ("Support for builtin sound of Compaq Deskpro XL", 0,
			    "Enable this if you have Compaq Deskpro XL.\n"))
	{
	  printf ("#define DESKPROXL\n");
	}
    }

  if (selected_options & B (OPT_MAUI))
    {
    oswf_again:
      if (think_positively (
			     "Do you have access to the OSWF.MOT file", 1,
			     "TB Maui and Tropez have a microcontroller which needs to be initialized\n"
			     "prior use. OSWF.MOT is a file distributed with card's DOS/Windows drivers\n"
			     "which is required during initialization\n"))
	{
	  char            path[512];

	  fprintf (stderr,
		   "Enter full name of the OSWF.MOT file (pwd is sound): ");
	  scanf ("%s", path);
	  fprintf (stderr, "including microcode file %s\n", path);

	  if (!bin2hex (path, "maui_boot.h", "maui_os"))
	    {
	      fprintf (stderr, "Couldn't open file %s\n",
		       path);
	      if (think_positively ("Try again with correct path", 1,
				    "The specified file could not be opened. Enter the correct path to the\n"
				    "file.\n"))
		goto oswf_again;
	    }
	  else
	    {
	      printf ("#define HAVE_MAUI_BOOT\n");
	      printf ("/*build bin2hex %s maui_boot.h maui_os */\n", path);
	    }
	}
    }

  if (!(selected_options & ANY_DEVS))
    {
      printf ("invalid_configuration__run_make_config_again\n");
      fprintf (stderr, "\n*** This combination is useless. Sound driver disabled!!! ***\n*** You need to enable support for at least one device    ***\n\n");
      exit (0);
    }

  for (i = 0; i <= OPT_LAST; i++)
    if (!hw_table[i].alias)
      if (selected_options & B (i))
	printf ("#define CONFIG_%s\n", hw_table[i].macro);
      else
	printf ("#undef  CONFIG_%s\n", hw_table[i].macro);

  printf ("\n");

  i = 0;

  while (extra_options[i].name != NULL)
    {
      if (selected_options & extra_options[i].mask)
	printf ("#define CONFIG_%s\n", extra_options[i].name);
      else
	printf ("#undef  CONFIG_%s\n", extra_options[i].name);
      i++;
    }

  printf ("\n");

  ask_parameters ();

  printf ("#define SELECTED_SOUND_OPTIONS\t0x%08lx\n", selected_options);
  fprintf (stderr, "\nThe sound driver is now configured.\n");

#if defined(SCO) || defined(ISC) || defined(SYSV)
  fprintf (stderr, "Remember to update the System file\n");
#endif

  if (!old_config_used)
    {
      char            str[255];

      sprintf (str, "Save copy of this configuration to `%s'", oldconf);
      if (think_positively (str, 1,
	"If you enable this option then the sound driver configuration is\n"
      "saved to a file. If you later need to recompile the kernel you have\n"
			  "the option of using the saved configuration.\n"))
	{
	  char            cmd[200];

	  sprintf (cmd, "cp local.h %s", oldconf);

	  fclose (stdout);
	  if (system (cmd) != 0)
	    perror (cmd);
	}
    }
  exit (0);
}