root/drivers/sound/configure.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. can_select_option
  2. think_positively
  3. ask_value
  4. ask_int_choice
  5. rebuild_file
  6. use_old_config
  7. build_defines
  8. ask_parameters
  9. dump_script
  10. dump_fixed_local
  11. dump_fixed_defines
  12. main
  13. bin2hex

   1 #define DISABLED_OPTIONS        (B(OPT_PNP)|B(OPT_AEDSP16))
   2 /*
   3  * sound/configure.c  - Configuration program for the Linux Sound Driver
   4  *
   5  * Copyright by Hannu Savolainen 1993-1995
   6  *
   7  * Redistribution and use in source and binary forms, with or without
   8  * modification, are permitted provided that the following conditions are
   9  * met: 1. Redistributions of source code must retain the above copyright
  10  * notice, this list of conditions and the following disclaimer. 2.
  11  * Redistributions in binary form must reproduce the above copyright notice,
  12  * this list of conditions and the following disclaimer in the documentation
  13  * and/or other materials provided with the distribution.
  14  *
  15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
  16  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
  19  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  21  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  22  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  25  * SUCH DAMAGE.
  26  *
  27  */
  28 
  29 #include <stdio.h>
  30 #include <unistd.h>
  31 #include <stdlib.h>
  32 
  33 #define B(x)    (1 << (x))
  34 
  35 /*
  36  * Option numbers
  37  */
  38 
  39 #define OPT_PAS         0
  40 #define OPT_SB          1
  41 #define OPT_ADLIB       2
  42 #define OPT_LAST_MUTUAL 2
  43 
  44 #define OPT_GUS         3
  45 #define OPT_MPU401      4
  46 #define OPT_UART6850    5
  47 #define OPT_PSS         6
  48 #define OPT_GUS16       7
  49 #define OPT_GUSMAX      8
  50 #define OPT_MSS         9
  51 #define OPT_SSCAPE      10
  52 #define OPT_TRIX        11
  53 #define OPT_MAD16       12
  54 #define OPT_CS4232      13
  55 #define OPT_MAUI        14
  56 #define OPT_PNP         15
  57 
  58 #define OPT_HIGHLEVEL   16      /* This must be same than the next one */
  59 #define OPT_SBPRO       16
  60 #define OPT_SB16        17
  61 #define OPT_AEDSP16     18
  62 #define OPT_AUDIO       19
  63 #define OPT_MIDI_AUTO   20
  64 #define OPT_MIDI        21
  65 #define OPT_YM3812_AUTO 22
  66 #define OPT_YM3812      23
  67 #define OPT_SEQUENCER   24
  68 #define OPT_LAST        24      /* Last defined OPT number */
  69 
  70 #define DUMMY_OPTS (B(OPT_MIDI_AUTO)|B(OPT_YM3812_AUTO))
  71 
  72 #define ANY_DEVS (B(OPT_AUDIO)|B(OPT_MIDI)|B(OPT_SEQUENCER)|B(OPT_GUS)| \
  73                   B(OPT_MPU401)|B(OPT_PSS)|B(OPT_GUS16)|B(OPT_GUSMAX)| \
  74                   B(OPT_MSS)|B(OPT_SSCAPE)|B(OPT_UART6850)|B(OPT_TRIX)| \
  75                   B(OPT_MAD16)|B(OPT_CS4232)|B(OPT_MAUI))
  76 #define AUDIO_CARDS (B (OPT_PSS) | B (OPT_SB) | B (OPT_PAS) | B (OPT_GUS) | \
  77                 B (OPT_MSS) | B (OPT_GUS16) | B (OPT_GUSMAX) | B (OPT_TRIX) | \
  78                 B (OPT_SSCAPE)| B(OPT_MAD16) | B(OPT_CS4232))
  79 #define MIDI_CARDS (B (OPT_PSS) | B (OPT_SB) | B (OPT_PAS) | B (OPT_MPU401) | \
  80                     B (OPT_GUS) | B (OPT_TRIX) | B (OPT_SSCAPE)|B(OPT_MAD16) | \
  81                     B (OPT_CS4232)|B(OPT_MAUI))
  82 #define MPU_DEVS (B(OPT_PSS)|B(OPT_SSCAPE)|B(OPT_TRIX)|B(OPT_MAD16)|\
  83                   B(OPT_CS4232)|B(OPT_PNP)|B(OPT_MAUI))
  84 #define AD1848_DEVS (B(OPT_GUS16)|B(OPT_MSS)|B(OPT_PSS)|B(OPT_GUSMAX)|\
  85                      B(OPT_SSCAPE)|B(OPT_TRIX)|B(OPT_MAD16)|B(OPT_CS4232)|\
  86                      B(OPT_PNP))
  87 /*
  88  * Options that have been disabled for some reason (incompletely implemented
  89  * and/or tested). Don't remove from this list before looking at file
  90  * experimental.txt for further info.
  91  */
  92 
  93 typedef struct
  94   {
  95     unsigned long   conditions;
  96     unsigned long   exclusive_options;
  97     char            macro[20];
  98     int             verify;
  99     int             alias;
 100     int             default_answ;
 101   }
 102 
 103 hw_entry;
 104 
 105 
 106 /*
 107  * The rule table for the driver options. The first field defines a set of
 108  * options which must be selected before this entry can be selected. The
 109  * second field is a set of options which are not allowed with this one. If
 110  * the fourth field is zero, the option is selected without asking
 111  * confirmation from the user.
 112  *
 113  * With this version of the rule table it is possible to select just one type of
 114  * hardware.
 115  *
 116  * NOTE!        Keep the following table and the questions array in sync with the
 117  * option numbering!
 118  */
 119 
 120 hw_entry        hw_table[] =
 121 {
 122 /*
 123  * 0
 124  */
 125   {0, 0, "PAS", 1, 0, 0},
 126   {0, 0, "SB", 1, 0, 0},
 127   {0, B (OPT_PAS) | B (OPT_SB), "ADLIB", 1, 0, 0},
 128 
 129   {0, 0, "GUS", 1, 0, 0},
 130   {0, 0, "MPU401", 1, 0, 0},
 131   {0, 0, "UART6850", 1, 0, 0},
 132   {0, 0, "PSS", 1, 0, 0},
 133   {B (OPT_GUS), 0, "GUS16", 1, 0, 0},
 134   {B (OPT_GUS), B (OPT_GUS16), "GUSMAX", 1, 0, 0},
 135   {0, 0, "MSS", 1, 0, 0},
 136   {0, 0, "SSCAPE", 1, 0, 0},
 137   {0, 0, "TRIX", 1, 0, 0},
 138   {0, 0, "MAD16", 1, 0, 0},
 139   {0, 0, "CS4232", 1, 0, 0},
 140   {0, 0, "MAUI", 1, 0, 0},
 141   {0, 0, "PNP", 1, 0, 0},
 142 
 143   {B (OPT_SB), B (OPT_PAS), "SBPRO", 1, 0, 1},
 144   {B (OPT_SB) | B (OPT_SBPRO), B (OPT_PAS), "SB16", 1, 0, 1},
 145   {B (OPT_SBPRO) | B (OPT_MSS) | B (OPT_MPU401), 0, "AEDSP16", 1, 0, 0},
 146   {AUDIO_CARDS, 0, "AUDIO", 1, 0, 1},
 147   {B (OPT_MPU401) | B (OPT_MAUI), 0, "MIDI_AUTO", 0, OPT_MIDI, 0},
 148   {MIDI_CARDS, 0, "MIDI", 1, 0, 1},
 149   {B (OPT_ADLIB), 0, "YM3812_AUTO", 0, OPT_YM3812, 0},
 150   {B (OPT_PSS) | B (OPT_SB) | B (OPT_PAS) | B (OPT_ADLIB) | B (OPT_MSS) | B (OPT_PSS), B (OPT_YM3812_AUTO), "YM3812", 1, 0, 1},
 151   {B (OPT_MIDI) | B (OPT_YM3812) | B (OPT_YM3812_AUTO) | B (OPT_GUS), 0, "SEQUENCER", 0, 0, 1}
 152 };
 153 
 154 char           *questions[] =
 155 {
 156   "ProAudioSpectrum 16 support",
 157   "SoundBlaster support",
 158   "Generic OPL2/OPL3 FM synthesizer support",
 159   "Gravis Ultrasound support",
 160   "MPU-401 support (NOT for SB16)",
 161   "6850 UART Midi support",
 162   "PSS (ECHO-ADI2111) support",
 163   "16 bit sampling option of GUS (_NOT_ GUS MAX)",
 164   "GUS MAX support",
 165   "Microsoft Sound System support",
 166   "Ensoniq Soundscape support",
 167   "MediaTriX AudioTriX Pro support",
 168   "Support for MAD16 and/or Mozart based cards",
 169   "Support for Crystal CS4232 based (PnP) cards",
 170   "Support for Turtle Beach Wave Front (Maui, Tropez) synthesizers",
 171   "Support for PnP soundcards (_EXPERIMENTAL_)",
 172 
 173   "SoundBlaster Pro support",
 174   "SoundBlaster 16 support",
 175   "Audio Excel DSP 16 initialization support",
 176   "/dev/dsp and /dev/audio supports (usually required)",
 177   "This should not be asked",
 178   "MIDI interface support",
 179   "This should not be asked",
 180   "FM synthesizer (YM3812/OPL-3) support",
 181   "/dev/sequencer support",
 182   "Is the sky really falling"
 183 };
 184 
 185 struct kludge
 186   {
 187     char           *name;
 188     int             mask;
 189   }
 190 extra_options[] =
 191 {
 192   {
 193     "MPU_EMU", MPU_DEVS
 194   }
 195   ,
 196   {
 197     "AD1848", AD1848_DEVS
 198   }
 199   ,
 200   {
 201     NULL, 0
 202   }
 203 };
 204 
 205 char           *oldconf = "/etc/soundconf";
 206 
 207 int             old_config_used = 0;
 208 int             def_size, sb_base = 0;
 209 
 210 unsigned long   selected_options = 0;
 211 int             sb_dma = 0;
 212 
 213 int             dump_only = 0;
 214 
 215 void            build_defines (void);
 216 
 217 #include "hex2hex.h"
 218 int             bin2hex (char *path, char *target, char *varname);
 219 
 220 int
 221 can_select_option (int nr)
     /* [previous][next][first][last][top][bottom][index][help] */
 222 {
 223 
 224   if (hw_table[nr].conditions)
 225     if (!(hw_table[nr].conditions & selected_options))
 226       return 0;
 227 
 228   if (hw_table[nr].exclusive_options)
 229     if (hw_table[nr].exclusive_options & selected_options)
 230       return 0;
 231 
 232   if (DISABLED_OPTIONS & B (nr))
 233     return 0;
 234 
 235   return 1;
 236 }
 237 
 238 int
 239 think_positively (int def_answ)
     /* [previous][next][first][last][top][bottom][index][help] */
 240 {
 241   char            answ[512];
 242   int             len;
 243 
 244   if ((len = read (0, answ, sizeof (answ))) < 1)
 245     {
 246       fprintf (stderr, "\n\nERROR! Cannot read stdin\n");
 247 
 248       perror ("stdin");
 249       printf ("invalid_configuration__run_make_config_again\n");
 250       exit (-1);
 251     }
 252 
 253   if (len < 2)                  /*
 254                                  * There is an additional LF at the end
 255                                  */
 256     return def_answ;
 257 
 258   answ[len - 1] = 0;
 259 
 260   if (!strcmp (answ, "y") || !strcmp (answ, "Y"))
 261     return 1;
 262 
 263   return 0;
 264 }
 265 
 266 int
 267 ask_value (char *format, int default_answer)
     /* [previous][next][first][last][top][bottom][index][help] */
 268 {
 269   char            answ[512];
 270   int             len, num;
 271 
 272 play_it_again_Sam:
 273 
 274   if ((len = read (0, answ, sizeof (answ))) < 1)
 275     {
 276       fprintf (stderr, "\n\nERROR! Cannot read stdin\n");
 277 
 278       perror ("stdin");
 279       printf ("invalid_configuration__run_make_config_again\n");
 280       exit (-1);
 281     }
 282 
 283   if (len < 2)                  /*
 284                                  * There is an additional LF at the end
 285                                  */
 286     return default_answer;
 287 
 288   answ[len - 1] = 0;
 289 
 290   if (sscanf (answ, format, &num) != 1)
 291     {
 292       fprintf (stderr, "Illegal format. Try again: ");
 293       goto play_it_again_Sam;
 294     }
 295 
 296   return num;
 297 }
 298 
 299 #define FMT_HEX 1
 300 #define FMT_INT 2
 301 
 302 void
 303 ask_int_choice (int mask, char *macro,
     /* [previous][next][first][last][top][bottom][index][help] */
 304                 char *question,
 305                 int format,
 306                 int defa,
 307                 char *choices)
 308 {
 309   int             num, i;
 310 
 311   if (dump_only)
 312     {
 313 
 314       for (i = 0; i < OPT_LAST; i++)
 315         if (mask == B (i))
 316           {
 317             int             j;
 318 
 319             for (j = 0; j < strlen (choices); j++)
 320               if (choices[j] == '\'')
 321                 choices[j] = '_';
 322 
 323             printf ("\nif [ \"$CONFIG_%s\" = \"y\" ]; then\n",
 324                     hw_table[i].macro);
 325             if (format == FMT_INT)
 326               printf ("int '%s %s' %s %d\n", question, choices, macro, defa);
 327             else
 328               printf ("hex '%s %s' %s %x\n", question, choices, macro, defa);
 329             printf ("fi\n");
 330           }
 331     }
 332   else
 333     {
 334       if (!(mask & selected_options))
 335         return;
 336 
 337       fprintf (stderr, "\n%s\n", question);
 338       fprintf (stderr, "Possible values are: %s\n", choices);
 339 
 340       if (format == FMT_INT)
 341         {
 342           if (defa == -1)
 343             fprintf (stderr, "\t(-1 disables this feature)\n");
 344           fprintf (stderr, "The default value is %d\n", defa);
 345           fprintf (stderr, "Enter the value: ");
 346           num = ask_value ("%d", defa);
 347           if (num == -1)
 348             return;
 349           fprintf (stderr, "%s set to %d.\n", question, num);
 350           printf ("#define %s %d\n", macro, num);
 351         }
 352       else
 353         {
 354           if (defa == 0)
 355             fprintf (stderr, "\t(0 disables this feature)\n");
 356           fprintf (stderr, "The default value is %x\n", defa);
 357           fprintf (stderr, "Enter the value: ");
 358           num = ask_value ("%x", defa);
 359           if (num == 0)
 360             return;
 361           fprintf (stderr, "%s set to %x.\n", question, num);
 362           printf ("#define %s 0x%x\n", macro, num);
 363         }
 364     }
 365 }
 366 
 367 void
 368 rebuild_file (char *line)
     /* [previous][next][first][last][top][bottom][index][help] */
 369 {
 370   char           *method, *new, *old, *var, *p;
 371 
 372   method = p = line;
 373 
 374   while (*p && *p != ' ')
 375     p++;
 376   *p++ = 0;
 377 
 378   old = p;
 379   while (*p && *p != ' ')
 380     p++;
 381   *p++ = 0;
 382 
 383   new = p;
 384   while (*p && *p != ' ')
 385     p++;
 386   *p++ = 0;
 387 
 388   var = p;
 389   while (*p && *p != ' ')
 390     p++;
 391   *p++ = 0;
 392 
 393   fprintf (stderr, "Rebuilding file %s (%s %s)\n", new, method, old);
 394 
 395   if (strcmp (method, "bin2hex") == 0)
 396     {
 397       if (!bin2hex (old, new, var))
 398         {
 399           fprintf (stderr, "Rebuild failed\n");
 400           exit (-1);
 401         }
 402     }
 403   else if (strcmp (method, "hex2hex") == 0)
 404     {
 405       if (!hex2hex (old, new, var))
 406         {
 407           fprintf (stderr, "Rebuild failed\n");
 408           exit (-1);
 409         }
 410     }
 411   else
 412     {
 413       fprintf (stderr, "Failed to build '%s' - unknown method %s\n",
 414                new, method);
 415       exit (-1);
 416     }
 417 }
 418 
 419 int
 420 use_old_config (char *filename)
     /* [previous][next][first][last][top][bottom][index][help] */
 421 {
 422   char            buf[1024];
 423   int             i = 0;
 424 
 425   FILE           *oldf;
 426 
 427   fprintf (stderr, "Copying old configuration from %s\n", filename);
 428 
 429   if ((oldf = fopen (filename, "r")) == NULL)
 430     {
 431       fprintf (stderr, "Couldn't open previous configuration file\n");
 432       perror (filename);
 433       return 0;
 434     }
 435 
 436   while (fgets (buf, 1024, oldf) != NULL)
 437     {
 438       char            tmp[100];
 439 
 440       if (buf[0] != '#')
 441         {
 442           printf ("%s", buf);
 443 
 444           strncpy (tmp, buf, 8);
 445           tmp[8] = 0;
 446 
 447           if (strcmp (tmp, "/*build ") == 0)
 448             rebuild_file (&buf[8]);
 449 
 450           continue;
 451         }
 452 
 453       strncpy (tmp, buf, 8);
 454       tmp[8] = 0;
 455 
 456       if (strcmp (tmp, "#define ") == 0)
 457         {
 458           char           *id = &buf[8];
 459 
 460           i = 0;
 461           while (id[i] && id[i] != ' ' &&
 462                  id[i] != '\t' && id[i] != '\n')
 463             i++;
 464 
 465           strncpy (tmp, id, i);
 466           tmp[i] = 0;
 467 
 468           if (strcmp (tmp, "SELECTED_SOUND_OPTIONS") == 0)
 469             continue;
 470 
 471           if (strcmp (tmp, "KERNEL_SOUNDCARD") == 0)
 472             continue;
 473 
 474           tmp[8] = 0;           /* Truncate the string */
 475           if (strcmp (tmp, "EXCLUDE_") == 0)
 476             continue;           /* Skip excludes */
 477 
 478           strncpy (tmp, id, i);
 479           tmp[7] = 0;           /* Truncate the string */
 480 
 481           if (strcmp (tmp, "CONFIG_") == 0)
 482             {
 483               strncpy (tmp, &id[7], i - 7);
 484               tmp[i - 7] = 0;
 485 
 486               for (i = 0; i <= OPT_LAST; i++)
 487                 if (strcmp (hw_table[i].macro, tmp) == 0)
 488                   {
 489                     selected_options |= (1 << i);
 490                     break;
 491                   }
 492               continue;
 493             }
 494 
 495           printf ("%s", buf);
 496           continue;
 497         }
 498 
 499       if (strcmp (tmp, "#undef  ") == 0)
 500         {
 501           char           *id = &buf[8];
 502 
 503           i = 0;
 504           while (id[i] && id[i] != ' ' &&
 505                  id[i] != '\t' && id[i] != '\n')
 506             i++;
 507 
 508           strncpy (tmp, id, i);
 509           tmp[7] = 0;           /* Truncate the string */
 510           if (strcmp (tmp, "CONFIG_") == 0)
 511             continue;
 512 
 513           strncpy (tmp, id, i);
 514 
 515           tmp[8] = 0;           /* Truncate the string */
 516           if (strcmp (tmp, "EXCLUDE_") != 0)
 517             continue;           /* Not a #undef  EXCLUDE_ line */
 518           strncpy (tmp, &id[8], i - 8);
 519           tmp[i - 8] = 0;
 520 
 521           for (i = 0; i <= OPT_LAST; i++)
 522             if (strcmp (hw_table[i].macro, tmp) == 0)
 523               {
 524                 selected_options |= (1 << i);
 525                 break;
 526               }
 527           continue;
 528         }
 529 
 530       printf ("%s", buf);
 531     }
 532   fclose (oldf);
 533 
 534   for (i = 0; i <= OPT_LAST; i++)
 535     if (!hw_table[i].alias)
 536       if (selected_options & B (i))
 537         printf ("#define CONFIG_%s\n", hw_table[i].macro);
 538       else
 539         printf ("#undef  CONFIG_%s\n", hw_table[i].macro);
 540 
 541 
 542   printf ("\n");
 543 
 544   i = 0;
 545 
 546   while (extra_options[i].name != NULL)
 547     {
 548       if (selected_options & extra_options[i].mask)
 549         printf ("#define CONFIG_%s\n", extra_options[i].name);
 550       else
 551         printf ("#undef  CONFIG_%s\n", extra_options[i].name);
 552       i++;
 553     }
 554 
 555   printf ("\n");
 556 
 557   printf ("#define SELECTED_SOUND_OPTIONS\t0x%08x\n", selected_options);
 558   fprintf (stderr, "Old configuration copied.\n");
 559 
 560   build_defines ();
 561   old_config_used = 1;
 562   return 1;
 563 }
 564 
 565 void
 566 build_defines (void)
     /* [previous][next][first][last][top][bottom][index][help] */
 567 {
 568   FILE           *optf;
 569   int             i;
 570 
 571   if ((optf = fopen (".defines", "w")) == NULL)
 572     {
 573       perror (".defines");
 574       exit (-1);
 575     }
 576 
 577 
 578   for (i = 0; i <= OPT_LAST; i++)
 579     if (!hw_table[i].alias)
 580       if (selected_options & B (i))
 581         fprintf (optf, "CONFIG_%s=y\n", hw_table[i].macro);
 582 
 583 
 584   fprintf (optf, "\n");
 585 
 586   i = 0;
 587 
 588   while (extra_options[i].name != NULL)
 589     {
 590       if (selected_options & extra_options[i].mask)
 591         fprintf (optf, "CONFIG_%s=y\n", extra_options[i].name);
 592       i++;
 593     }
 594 
 595   fprintf (optf, "\n");
 596   fclose (optf);
 597 }
 598 
 599 void
 600 ask_parameters (void)
     /* [previous][next][first][last][top][bottom][index][help] */
 601 {
 602   int             num;
 603 
 604   build_defines ();
 605   /*
 606    * IRQ and DMA settings
 607    */
 608 
 609   ask_int_choice (B (OPT_AEDSP16), "AEDSP16_BASE",
 610                   "I/O base for Audio Excel DSP 16",
 611                   FMT_HEX,
 612                   0x220,
 613                   "220 or 240");
 614 
 615   ask_int_choice (B (OPT_SB), "SBC_BASE",
 616                   "I/O base for SB",
 617                   FMT_HEX,
 618                   0x220,
 619                   "");
 620 
 621   ask_int_choice (B (OPT_SB), "SBC_IRQ",
 622                   "SoundBlaster IRQ",
 623                   FMT_INT,
 624                   7,
 625                   "");
 626 
 627   ask_int_choice (B (OPT_SB), "SBC_DMA",
 628                   "SoundBlaster DMA",
 629                   FMT_INT,
 630                   1,
 631                   "");
 632 
 633   ask_int_choice (B (OPT_SB), "SB_DMA2",
 634                   "SoundBlaster 16 bit DMA (if required)",
 635                   FMT_INT,
 636                   -1,
 637                   "5, 6 or 7");
 638 
 639   ask_int_choice (B (OPT_SB), "SB_MPU_BASE",
 640                   "MPU401 I/O base of SB16, Jazz16 and ES1688",
 641                   FMT_HEX,
 642                   0,
 643                   "");
 644 
 645   ask_int_choice (B (OPT_SB), "SB_MPU_IRQ",
 646                   "SB MPU401 IRQ (SB16, Jazz16 and ES1688)",
 647                   FMT_INT,
 648                   -1,
 649                   "");
 650 
 651   ask_int_choice (B (OPT_PAS), "PAS_IRQ",
 652                   "PAS16 IRQ",
 653                   FMT_INT,
 654                   10,
 655                   "");
 656 
 657   ask_int_choice (B (OPT_PAS), "PAS_DMA",
 658                   "PAS16 DMA",
 659                   FMT_INT,
 660                   3,
 661                   "");
 662 
 663   if (selected_options & B (OPT_PAS))
 664     {
 665       fprintf (stderr, "\nEnable Joystick port on ProAudioSpectrum (n/y) ? ");
 666       if (think_positively (0))
 667         printf ("#define PAS_JOYSTICK_ENABLE\n");
 668 
 669 
 670       fprintf (stderr, "PAS16 could be noisy with some mother boards\n"
 671                "There is a command line switch (was it :T?)\n"
 672                "in the DOS driver for PAS16 which solves this.\n"
 673                "Don't enable this feature unless you have problems!\n"
 674                "Do you have to use this switch with DOS (y/n) ?");
 675       if (think_positively (0))
 676         printf ("#define BROKEN_BUS_CLOCK\n");
 677     }
 678 
 679 
 680   ask_int_choice (B (OPT_GUS), "GUS_BASE",
 681                   "I/O base for Gravis UltraSound (GUS)",
 682                   FMT_HEX,
 683                   0x220,
 684                   "210, 220, 230, 240, 250 or 260");
 685 
 686 
 687   ask_int_choice (B (OPT_GUS), "GUS_IRQ",
 688                   "GUS IRQ",
 689                   FMT_INT,
 690                   15,
 691                   "");
 692 
 693   ask_int_choice (B (OPT_GUS), "GUS_DMA",
 694                   "GUS DMA",
 695                   FMT_INT,
 696                   6,
 697                   "");
 698 
 699   ask_int_choice (B (OPT_GUS), "GUS_DMA2",
 700                   "Second DMA channel for GUS",
 701                   FMT_INT,
 702                   -1,
 703                   "");
 704 
 705   ask_int_choice (B (OPT_GUS16), "GUS16_BASE",
 706                   "I/O base for the 16 bit daughtercard of GUS",
 707                   FMT_HEX,
 708                   0x530,
 709                   "530, 604, E80 or F40");
 710 
 711 
 712   ask_int_choice (B (OPT_GUS16), "GUS16_IRQ",
 713                   "GUS 16 bit daughtercard IRQ",
 714                   FMT_INT,
 715                   7,
 716                   "3, 4, 5, 7, or 9");
 717 
 718   ask_int_choice (B (OPT_GUS16), "GUS16_DMA",
 719                   "GUS DMA",
 720                   FMT_INT,
 721                   3,
 722                   "0, 1 or 3");
 723 
 724   ask_int_choice (B (OPT_MPU401), "MPU_BASE",
 725                   "I/O base for MPU401",
 726                   FMT_HEX,
 727                   0x330,
 728                   "");
 729 
 730   ask_int_choice (B (OPT_MPU401), "MPU_IRQ",
 731                   "MPU401 IRQ",
 732                   FMT_INT,
 733                   9,
 734                   "");
 735 
 736   ask_int_choice (B (OPT_MAUI), "MAUI_BASE",
 737                   "I/O base for Maui",
 738                   FMT_HEX,
 739                   0x330,
 740                   "210, 230, 260, 290, 300, 320, 338 or 330");
 741 
 742   ask_int_choice (B (OPT_MAUI), "MAUI_IRQ",
 743                   "Maui IRQ",
 744                   FMT_INT,
 745                   9,
 746                   "5, 9, 12 or 15");
 747 
 748   ask_int_choice (B (OPT_UART6850), "U6850_BASE",
 749                   "I/O base for UART 6850 MIDI port",
 750                   FMT_HEX,
 751                   0,
 752                   "(Unknown)");
 753 
 754   ask_int_choice (B (OPT_UART6850), "U6850_IRQ",
 755                   "UART6850 IRQ",
 756                   FMT_INT,
 757                   -1,
 758                   "(Unknown)");
 759 
 760   ask_int_choice (B (OPT_PSS), "PSS_BASE",
 761                   "PSS I/O base",
 762                   FMT_HEX,
 763                   0x220,
 764                   "220 or 240");
 765 
 766   ask_int_choice (B (OPT_PSS), "PSS_MSS_BASE",
 767                   "PSS audio I/O base",
 768                   FMT_HEX,
 769                   0x530,
 770                   "530, 604, E80 or F40");
 771 
 772   ask_int_choice (B (OPT_PSS), "PSS_MSS_IRQ",
 773                   "PSS audio IRQ",
 774                   FMT_INT,
 775                   11,
 776                   "7, 9, 10 or 11");
 777 
 778   ask_int_choice (B (OPT_PSS), "PSS_MSS_DMA",
 779                   "PSS audio DMA",
 780                   FMT_INT,
 781                   3,
 782                   "0, 1 or 3");
 783 
 784   ask_int_choice (B (OPT_PSS), "PSS_MPU_BASE",
 785                   "PSS MIDI I/O base",
 786                   FMT_HEX,
 787                   0x330,
 788                   "");
 789 
 790   ask_int_choice (B (OPT_PSS), "PSS_MPU_IRQ",
 791                   "PSS MIDI IRQ",
 792                   FMT_INT,
 793                   9,
 794                   "3, 4, 5, 7 or 9");
 795 
 796   ask_int_choice (B (OPT_MSS), "MSS_BASE",
 797                   "MSS/WSS I/O base",
 798                   FMT_HEX,
 799                   0x530,
 800                   "530, 604, E80 or F40");
 801 
 802   ask_int_choice (B (OPT_MSS), "MSS_IRQ",
 803                   "MSS/WSS IRQ",
 804                   FMT_INT,
 805                   11,
 806                   "7, 9, 10 or 11");
 807 
 808   ask_int_choice (B (OPT_MSS), "MSS_DMA",
 809                   "MSS/WSS DMA",
 810                   FMT_INT,
 811                   3,
 812                   "0, 1 or 3");
 813 
 814   ask_int_choice (B (OPT_SSCAPE), "SSCAPE_BASE",
 815                   "Soundscape MIDI I/O base",
 816                   FMT_HEX,
 817                   0x330,
 818                   "");
 819 
 820   ask_int_choice (B (OPT_SSCAPE), "SSCAPE_IRQ",
 821                   "Soundscape MIDI IRQ",
 822                   FMT_INT,
 823                   9,
 824                   "");
 825 
 826   ask_int_choice (B (OPT_SSCAPE), "SSCAPE_DMA",
 827                   "Soundscape initialization DMA",
 828                   FMT_INT,
 829                   3,
 830                   "0, 1 or 3");
 831 
 832   ask_int_choice (B (OPT_SSCAPE), "SSCAPE_MSS_BASE",
 833                   "Soundscape audio I/O base",
 834                   FMT_HEX,
 835                   0x534,
 836                   "534, 608, E84 or F44");
 837 
 838   ask_int_choice (B (OPT_SSCAPE), "SSCAPE_MSS_IRQ",
 839                   "Soundscape audio IRQ",
 840                   FMT_INT,
 841                   11,
 842                   "7, 9, 10 or 11");
 843 
 844   ask_int_choice (B (OPT_SSCAPE), "SSCAPE_MSS_DMA",
 845                   "Soundscape audio DMA",
 846                   FMT_INT,
 847                   0,
 848                   "0, 1 or 3");
 849 
 850   if (selected_options & B (OPT_SSCAPE))
 851     {
 852       int             reveal_spea;
 853 
 854       fprintf (stderr, "Is your SoundScape card made/marketed by Reveal or Spea? ");
 855       reveal_spea = think_positively (0);
 856       if (reveal_spea)
 857         printf ("#define REVEAL_SPEA\n");
 858 
 859     }
 860 
 861   ask_int_choice (B (OPT_TRIX), "TRIX_BASE",
 862                   "AudioTriX audio I/O base",
 863                   FMT_HEX,
 864                   0x530,
 865                   "530, 604, E80 or F40");
 866 
 867   ask_int_choice (B (OPT_TRIX), "TRIX_IRQ",
 868                   "AudioTriX audio IRQ",
 869                   FMT_INT,
 870                   11,
 871                   "7, 9, 10 or 11");
 872 
 873   ask_int_choice (B (OPT_TRIX), "TRIX_DMA",
 874                   "AudioTriX audio DMA",
 875                   FMT_INT,
 876                   0,
 877                   "0, 1 or 3");
 878 
 879   ask_int_choice (B (OPT_TRIX), "TRIX_DMA2",
 880                   "AudioTriX second (duplex) DMA",
 881                   FMT_INT,
 882                   3,
 883                   "0, 1 or 3");
 884 
 885   ask_int_choice (B (OPT_TRIX), "TRIX_MPU_BASE",
 886                   "AudioTriX MIDI I/O base",
 887                   FMT_HEX,
 888                   0x330,
 889                   "330, 370, 3B0 or 3F0");
 890 
 891   ask_int_choice (B (OPT_TRIX), "TRIX_MPU_IRQ",
 892                   "AudioTriX MIDI IRQ",
 893                   FMT_INT,
 894                   9,
 895                   "3, 4, 5, 7 or 9");
 896 
 897   ask_int_choice (B (OPT_TRIX), "TRIX_SB_BASE",
 898                   "AudioTriX SB I/O base",
 899                   FMT_HEX,
 900                   0x220,
 901                   "220, 210, 230, 240, 250, 260 or 270");
 902 
 903   ask_int_choice (B (OPT_TRIX), "TRIX_SB_IRQ",
 904                   "AudioTriX SB IRQ",
 905                   FMT_INT,
 906                   7,
 907                   "3, 4, 5 or 7");
 908 
 909   ask_int_choice (B (OPT_TRIX), "TRIX_SB_DMA",
 910                   "AudioTriX SB DMA",
 911                   FMT_INT,
 912                   1,
 913                   "1 or 3");
 914 
 915   ask_int_choice (B (OPT_CS4232), "CS4232_BASE",
 916                   "CS4232 audio I/O base",
 917                   FMT_HEX,
 918                   0x530,
 919                   "530, 604, E80 or F40");
 920 
 921   ask_int_choice (B (OPT_CS4232), "CS4232_IRQ",
 922                   "CS4232 audio IRQ",
 923                   FMT_INT,
 924                   11,
 925                   "5, 7, 9, 11, 12 or 15");
 926 
 927   ask_int_choice (B (OPT_CS4232), "CS4232_DMA",
 928                   "CS4232 audio DMA",
 929                   FMT_INT,
 930                   0,
 931                   "0, 1 or 3");
 932 
 933   ask_int_choice (B (OPT_CS4232), "CS4232_DMA2",
 934                   "CS4232 second (duplex) DMA",
 935                   FMT_INT,
 936                   3,
 937                   "0, 1 or 3");
 938 
 939   ask_int_choice (B (OPT_CS4232), "CS4232_MPU_BASE",
 940                   "CS4232 MIDI I/O base",
 941                   FMT_HEX,
 942                   0x330,
 943                   "330, 370, 3B0 or 3F0");
 944 
 945   ask_int_choice (B (OPT_CS4232), "CS4232_MPU_IRQ",
 946                   "CS4232 MIDI IRQ",
 947                   FMT_INT,
 948                   9,
 949                   "5, 7, 9, 11, 12 or 15");
 950 
 951   ask_int_choice (B (OPT_MAD16), "MAD16_BASE",
 952                   "MAD16 audio I/O base",
 953                   FMT_HEX,
 954                   0x530,
 955                   "530, 604, E80 or F40");
 956 
 957   ask_int_choice (B (OPT_MAD16), "MAD16_IRQ",
 958                   "MAD16 audio IRQ",
 959                   FMT_INT,
 960                   11,
 961                   "7, 9, 10 or 11");
 962 
 963   ask_int_choice (B (OPT_MAD16), "MAD16_DMA",
 964                   "MAD16 audio DMA",
 965                   FMT_INT,
 966                   3,
 967                   "0, 1 or 3");
 968 
 969   ask_int_choice (B (OPT_MAD16), "MAD16_DMA2",
 970                   "MAD16 second (duplex) DMA",
 971                   FMT_INT,
 972                   0,
 973                   "0, 1 or 3");
 974 
 975   ask_int_choice (B (OPT_MAD16), "MAD16_MPU_BASE",
 976                   "MAD16 MIDI I/O base",
 977                   FMT_HEX,
 978                   0x330,
 979                   "300, 310, 320 or 330 (0 disables)");
 980 
 981   ask_int_choice (B (OPT_MAD16), "MAD16_MPU_IRQ",
 982                   "MAD16 MIDI IRQ",
 983                   FMT_INT,
 984                   9,
 985                   "5, 7, 9 or 10");
 986   ask_int_choice (B (OPT_AUDIO), "DSP_BUFFSIZE",
 987                   "Audio DMA buffer size",
 988                   FMT_INT,
 989                   65536,
 990                   "4096, 16384, 32768 or 65536");
 991 }
 992 
 993 void
 994 dump_script (void)
     /* [previous][next][first][last][top][bottom][index][help] */
 995 {
 996   int             i;
 997 
 998   for (i = 0; i <= OPT_LAST; i++)
 999     if (!(DUMMY_OPTS & B (i)))
1000       if (!(DISABLED_OPTIONS & B (i)))
1001         {
1002           printf ("bool '%s' CONFIG_%s\n", questions[i], hw_table[i].macro);
1003         }
1004 
1005   dump_only = 1;
1006   selected_options = 0;
1007   ask_parameters ();
1008 
1009   printf ("#\n$MAKE -C drivers/sound kernelconfig || exit 1\n");
1010 }
1011 
1012 void
1013 dump_fixed_local (void)
     /* [previous][next][first][last][top][bottom][index][help] */
1014 {
1015   int             i = 0;
1016 
1017   printf ("/* Computer generated file. Please don't edit! */\n\n");
1018   printf ("#define KERNEL_COMPATIBLE_CONFIG\n\n");
1019   printf ("#define SELECTED_SOUND_OPTIONS\t0x%08x\n\n", selected_options);
1020 
1021   while (extra_options[i].name != NULL)
1022     {
1023       int             n = 0, j;
1024 
1025       printf ("#if ");
1026 
1027       for (j = 0; j < OPT_LAST; j++)
1028         if (!(DISABLED_OPTIONS & B (j)))
1029           if (extra_options[i].mask & B (j))
1030             {
1031               if (n)
1032                 printf (" || ");
1033               if (!(n++ % 2))
1034                 printf ("\\\n  ");
1035 
1036               printf ("defined(CONFIG_%s)", hw_table[j].macro);
1037             }
1038 
1039       printf ("\n");
1040       printf ("#\tdefine CONFIG_%s\n", extra_options[i].name);
1041       printf ("#endif\n\n");
1042       i++;
1043     }
1044 }
1045 
1046 void
1047 dump_fixed_defines (void)
     /* [previous][next][first][last][top][bottom][index][help] */
1048 {
1049   int             i = 0;
1050 
1051   printf ("# Computer generated file. Please don't edit\n\n");
1052 
1053   while (extra_options[i].name != NULL)
1054     {
1055       int             n = 0, j;
1056 
1057       for (j = 0; j < OPT_LAST; j++)
1058         if (!(DISABLED_OPTIONS & B (j)))
1059           if (extra_options[i].mask & B (j))
1060             {
1061               printf ("ifdef CONFIG_%s\n", hw_table[j].macro);
1062               printf ("CONFIG_%s=y\n", extra_options[i].name);
1063               printf ("endif\n\n");
1064             }
1065 
1066       i++;
1067     }
1068 }
1069 
1070 int
1071 main (int argc, char *argv[])
     /* [previous][next][first][last][top][bottom][index][help] */
1072 {
1073   int             i, num, full_driver = 1;
1074   char            answ[10];
1075   char            old_config_file[200];
1076 
1077   if (getuid () != 0)           /* Not root */
1078     {
1079       char           *home;
1080 
1081       if ((home = getenv ("HOME")) != NULL)
1082         {
1083           sprintf (old_config_file, "%s/.soundconf", home);
1084           oldconf = old_config_file;
1085         }
1086     }
1087 
1088   if (argc > 1)
1089     {
1090       if (strcmp (argv[1], "-o") == 0 &&
1091           use_old_config (oldconf))
1092         exit (0);
1093       else if (strcmp (argv[1], "script") == 0)
1094         {
1095           dump_script ();
1096           exit (0);
1097         }
1098       else if (strcmp (argv[1], "fixedlocal") == 0)
1099         {
1100           dump_fixed_local ();
1101           exit (0);
1102         }
1103       else if (strcmp (argv[1], "fixeddefines") == 0)
1104         {
1105           dump_fixed_defines ();
1106           exit (0);
1107         }
1108     }
1109 
1110   fprintf (stderr, "\nConfiguring the sound support\n\n");
1111 
1112   if (access (oldconf, R_OK) == 0)
1113     {
1114       fprintf (stderr, "Old configuration exists in %s. Use it (y/n) ? ",
1115                oldconf);
1116       if (think_positively (1))
1117         if (use_old_config (oldconf))
1118           exit (0);
1119 
1120     }
1121 
1122   printf ("/*\tGenerated by configure. Don't edit!!!!\t*/\n");
1123   printf ("/*\tMaking changes to this file is not as simple as it may look.\t*/\n\n");
1124   printf ("/*\tIf you change the CONFIG_ settings in local.h you\t*/\n");
1125   printf ("/*\t_have_ to edit .defines too.\t*/\n\n");
1126 
1127   {
1128     /*
1129      * Partial driver
1130      */
1131 
1132     full_driver = 0;
1133 
1134     for (i = 0; i <= OPT_LAST; i++)
1135       if (can_select_option (i))
1136         {
1137           if (!(selected_options & B (i)))      /*
1138                                                  * Not selected yet
1139                                                  */
1140             if (!hw_table[i].verify)
1141               {
1142                 if (hw_table[i].alias)
1143                   selected_options |= B (hw_table[i].alias);
1144                 else
1145                   selected_options |= B (i);
1146               }
1147             else
1148               {
1149                 int             def_answ = hw_table[i].default_answ;
1150 
1151                 fprintf (stderr,
1152                          def_answ ? "  %s (y/n) ? " : "  %s (n/y) ? ",
1153                          questions[i]);
1154                 if (think_positively (def_answ))
1155                   if (hw_table[i].alias)
1156                     selected_options |= B (hw_table[i].alias);
1157                   else
1158                     selected_options |= B (i);
1159               }
1160         }
1161   }
1162 
1163   if (selected_options & B (OPT_SBPRO))
1164     {
1165       fprintf (stderr, "Do you want support for the mixer of SG NX Pro ? ");
1166       if (think_positively (0))
1167         printf ("#define __SGNXPRO__\n");
1168     }
1169 
1170   if (selected_options & B (OPT_SB))
1171     {
1172       fprintf (stderr, "Do you want support for the MV Jazz16 (ProSonic etc.) ? ");
1173       if (think_positively (0))
1174         {
1175           fprintf (stderr, "Do you have SoundMan Wave (n/y) ? ");
1176 
1177           if (think_positively (0))
1178             {
1179               printf ("#define SM_WAVE\n");
1180 
1181             midi0001_again:
1182               fprintf
1183                 (stderr,
1184                  "Logitech SoundMan Wave has a microcontroller which must be initialized\n"
1185                  "before MIDI emulation works. This is possible only if the microcode\n"
1186                  "file is compiled into the driver.\n"
1187                  "Do you have access to the MIDI0001.BIN file (y/n) ? ");
1188               if (think_positively (1))
1189                 {
1190                   char            path[512];
1191 
1192                   fprintf (stderr,
1193                            "Enter full name of the MIDI0001.BIN file (pwd is sound): ");
1194                   scanf ("%s", path);
1195                   fprintf (stderr, "including microcode file %s\n", path);
1196 
1197                   if (!bin2hex (path, "smw-midi0001.h", "smw_ucode"))
1198                     {
1199                       fprintf (stderr, "couldn't open %s file\n",
1200                                path);
1201                       fprintf (stderr, "try again with correct path? ");
1202                       if (think_positively (1))
1203                         goto midi0001_again;
1204                     }
1205                   else
1206                     {
1207                       printf ("#define SMW_MIDI0001_INCLUDED\n");
1208                       printf ("/*build bin2hex %s smw-midi0001.h smw_ucode */\n", path);
1209                     }
1210                 }
1211             }
1212         }
1213     }
1214 
1215   if (selected_options & B (OPT_SBPRO))
1216     {
1217       fprintf (stderr, "\n\nThe Logitech SoundMan Games supports 44 kHz in stereo\n"
1218                "while the standard SB Pro supports just 22 kHz/stereo\n"
1219                "You have an option to enable the SM Games mode.\n"
1220                "However do enable it only if you are _sure_ that your\n"
1221                "card is a SM Games. Enabling this feature with a\n"
1222                "plain old SB Pro _will_ cause troubles with stereo mode.\n"
1223                "\n"
1224                "DANGER! Read the above once again before answering 'y'\n"
1225                "Answer 'n' in case you are unsure what to do!\n");
1226       fprintf (stderr, "Do you have a Logitech SoundMan Games (n/y) ? ");
1227       if (think_positively (0))
1228         printf ("#define SM_GAMES\n");
1229     }
1230 
1231   if (selected_options & B (OPT_SB16))
1232     selected_options |= B (OPT_SBPRO);
1233 
1234   if (selected_options & B (OPT_AEDSP16))
1235     {
1236       int             sel1 = 0;
1237 
1238       if (selected_options & B (OPT_SBPRO))
1239         {
1240           fprintf (stderr, "Do you want support for the Audio Excel SoundBlaster pro mode ? ");
1241           if (think_positively (1))
1242             {
1243               printf ("#define AEDSP16_SBPRO\n");
1244               sel1 = 1;
1245             }
1246         }
1247 
1248       if ((selected_options & B (OPT_MSS)) && (sel1 == 0))
1249         {
1250           fprintf (stderr, "Do you want support for the Audio Excel Microsoft Sound System mode? ");
1251           if (think_positively (1))
1252             {
1253               printf ("#define AEDSP16_MSS\n");
1254               sel1 = 1;
1255             }
1256         }
1257 
1258       if (sel1 == 0)
1259         {
1260           printf ("invalid_configuration__run_make_config_again\n");
1261           fprintf (stderr, "ERROR!!!!!\nYou must select at least one mode when using Audio Excel!\n");
1262           exit (-1);
1263         }
1264       if (selected_options & B (OPT_MPU401))
1265         printf ("#define AEDSP16_MPU401\n");
1266     }
1267 
1268   if (selected_options & B (OPT_PSS))
1269     {
1270     genld_again:
1271       fprintf
1272         (stderr,
1273        "if you wish to emulate the soundblaster and you have a DSPxxx.LD.\n"
1274          "then you must include the LD in the kernel.\n"
1275          "Do you wish to include a LD (y/n) ? ");
1276       if (think_positively (1))
1277         {
1278           char            path[512];
1279 
1280           fprintf (stderr,
1281                    "Enter the path to your LD file (pwd is sound): ");
1282           scanf ("%s", path);
1283           fprintf (stderr, "including LD file %s\n", path);
1284 
1285           if (!bin2hex (path, "synth-ld.h", "pss_synth"))
1286             {
1287               fprintf (stderr, "couldn't open %s as the ld file\n",
1288                        path);
1289               fprintf (stderr, "try again with correct path? ");
1290               if (think_positively (1))
1291                 goto genld_again;
1292             }
1293           else
1294             {
1295               printf ("#define PSS_HAVE_LD\n");
1296               printf ("/*build bin2hex %s synth-ld.h pss_synth */\n", path);
1297             }
1298         }
1299       else
1300         {
1301           FILE           *sf = fopen ("synth-ld.h", "w");
1302 
1303           fprintf (sf, "/* automaticaly generated by configure */\n");
1304           fprintf (sf, "unsigned char pss_synth[1];\n"
1305                    "#define pss_synthLen 0\n");
1306           fclose (sf);
1307         }
1308     }
1309 
1310   if (selected_options & B (OPT_TRIX))
1311     {
1312     hex2hex_again:
1313       fprintf (stderr, "MediaTriX audioTriX Pro has a onboard microcontroller\n"
1314                "which needs to be initialized by downloading\n"
1315                "the code from file TRXPRO.HEX in the DOS driver\n"
1316                "directory. If you don't have the TRXPRO.HEX handy\n"
1317                "you may skip this step. However SB and MPU-401\n"
1318                "modes of AudioTriX Pro will not work without\n"
1319                "this file!\n"
1320                "\n"
1321                "Do you want to include TRXPRO.HEX in your kernel (y/n) ? ");
1322 
1323       if (think_positively (1))
1324         {
1325           char            path[512];
1326 
1327           fprintf (stderr,
1328                  "Enter the path to your TRXPRO.HEX file (pwd is sound): ");
1329           scanf ("%s", path);
1330           fprintf (stderr, "including HEX file %s\n", path);
1331 
1332           if (!hex2hex (path, "trix_boot.h", "trix_boot"))
1333             goto hex2hex_again;
1334           printf ("/*build hex2hex %s trix_boot.h trix_boot */\n", path);
1335           printf ("#define INCLUDE_TRIX_BOOT\n");
1336         }
1337     }
1338 
1339   if (!(selected_options & ANY_DEVS))
1340     {
1341       printf ("invalid_configuration__run_make_config_again\n");
1342       fprintf (stderr, "\n*** This combination is useless. Sound driver disabled!!! ***\n\n");
1343       exit (0);
1344     }
1345 
1346   for (i = 0; i <= OPT_LAST; i++)
1347     if (!hw_table[i].alias)
1348       if (selected_options & B (i))
1349         printf ("#define CONFIG_%s\n", hw_table[i].macro);
1350       else
1351         printf ("#undef  CONFIG_%s\n", hw_table[i].macro);
1352 
1353 
1354   printf ("\n");
1355 
1356   i = 0;
1357 
1358   while (extra_options[i].name != NULL)
1359     {
1360       if (selected_options & extra_options[i].mask)
1361         printf ("#define CONFIG_%s\n", extra_options[i].name);
1362       else
1363         printf ("#undef  CONFIG_%s\n", extra_options[i].name);
1364       i++;
1365     }
1366 
1367   printf ("\n");
1368 
1369   ask_parameters ();
1370 
1371   printf ("#define SELECTED_SOUND_OPTIONS\t0x%08x\n", selected_options);
1372   fprintf (stderr, "The sound driver is now configured.\n");
1373 
1374 #if defined(SCO) || defined(ISC) || defined(SYSV)
1375   fprintf (stderr, "Remember to update the System file\n");
1376 #endif
1377 
1378   if (!old_config_used)
1379     {
1380       fprintf (stderr, "Save copy of this configuration to %s (y/n)", oldconf);
1381       if (think_positively (1))
1382         {
1383           char            cmd[200];
1384 
1385           sprintf (cmd, "cp local.h %s", oldconf);
1386 
1387           fclose (stdout);
1388           if (system (cmd) != 0)
1389             perror (cmd);
1390         }
1391     }
1392   exit (0);
1393 }
1394 
1395 int
1396 bin2hex (char *path, char *target, char *varname)
     /* [previous][next][first][last][top][bottom][index][help] */
1397 {
1398   int             fd;
1399   int             count;
1400   char            c;
1401   int             i = 0;
1402 
1403   if ((fd = open (path, 0)) > 0)
1404     {
1405       FILE           *sf = fopen (target, "w");
1406 
1407       fprintf (sf, "/* automaticaly generated by configure */\n");
1408       fprintf (sf, "static unsigned char %s[] = {\n", varname);
1409       while (1)
1410         {
1411           count = read (fd, &c, 1);
1412           if (count == 0)
1413             break;
1414           if (i != 0 && (i % 10) == 0)
1415             fprintf (sf, "\n");
1416           fprintf (sf, "0x%02x,", c & 0xFFL);
1417           i++;
1418         }
1419       fprintf (sf, "};\n"
1420                "#define %sLen %d\n", varname, i);
1421       fclose (sf);
1422       close (fd);
1423       return 1;
1424     }
1425 
1426   return 0;
1427 }

/* [previous][next][first][last][top][bottom][index][help] */