home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1999 February / PCO_0299.ISO / filesbbs / linux / mikmod-3.000 / mikmod-3 / mikmod-3.1.2 / configure.cmd < prev    next >
Encoding:
Text File  |  1998-12-07  |  6.0 KB  |  272 lines

  1. /* REXX */
  2.  
  3. /*===============================================================================
  4. *
  5. *  $Id: configure.cmd,v 1.13 1998/12/07 06:01:54 miod Exp $
  6. *
  7. *  Configuration script for MikMod under OS/2
  8. *
  9. *=============================================================================*/
  10. ECHO OFF
  11. CALL main
  12. ECHO ON
  13. EXIT
  14.  
  15. /*
  16. *========== Helper functions
  17. */
  18.  
  19. yesno:
  20.     ans=''
  21.     DO WHILE ans=''
  22.         SAY message" [y/n] "
  23.         PULL ans
  24.         ans=SUBSTR(ans,1,1)
  25.         IF \((ans='N')|(ans='Y')) THEN
  26.         DO
  27.             SAY "Invalid answer. Please answer Y or N"
  28.             ans=''
  29.         END
  30.     END
  31.     RETURN ans
  32.     EXIT
  33.  
  34. sed:
  35.     IF LINES(fileout) THEN
  36.     DO
  37.         CALL LINEOUT fileout
  38.         ERASE fileout
  39.     END
  40.     CALL LINEOUT fileout,,1
  41.     linecount=0
  42.     DO WHILE LINES(filein)
  43.         line=LINEIN(filein)
  44.         IF linecount\=0 THEN
  45.         DO
  46.             arro1=LASTPOS('@',line)
  47.             arro2=0
  48.             IF (arro1\=0) THEN arro2=LASTPOS('@',line,arro1-1)
  49.             IF (arro2\=0) THEN
  50.             DO
  51.                 keyword=SUBSTR(line,arro2+1,arro1-arro2-1)
  52.                 SELECT
  53.                     WHEN keyword='CC' THEN keyword=cc
  54.                     WHEN keyword='CFLAGS' THEN keyword=cflags
  55.                     WHEN keyword='LDFLAGS' THEN keyword=ldflags
  56.                     WHEN keyword='AR' THEN keyword=ar
  57.                     WHEN keyword='ARFLAGS' THEN keyword=arflags
  58.                     WHEN keyword='RANLIB' THEN keyword=ranlib
  59.                     WHEN keyword='ORULE' THEN keyword=orule
  60.                     WHEN keyword='LINK' THEN keyword=link
  61.  
  62.                     WHEN keyword='DRIVER_OBJ' THEN keyword=driver_obj
  63.                     WHEN keyword='VIRTCH' THEN keyword=virtch
  64.                     WHEN keyword='EXTRA_OBJ' THEN keyword=extra_obj
  65.                     
  66.                     WHEN keyword='MAKE' THEN keyword=make
  67.                     OTHERWISE NOP
  68.                 END
  69.                 line=SUBSTR(line,1,arro2-1)""keyword""SUBSTR(line,arro1+1,LENGTH(line)-arro1)
  70.             END
  71.             /* convert forward slashes to backslashes for Watcom */
  72.             IF cc="wcc386" THEN DO
  73.                 arro1=1
  74.                 DO WHILE arro1\=0
  75.                     arro1=LASTPOS('/',line)
  76.                     IF (arro1\=0) THEN
  77.                         line=SUBSTR(line,1,arro1-1)"\"SUBSTR(line,arro1+1,LENGTH(line)-arro1)
  78.                 END
  79.             END
  80.         END
  81.         linecount=1
  82.         CALL LINEOUT fileout, line
  83.     END
  84.     CALL LINEOUT fileout
  85.     RETURN
  86.  
  87. main:
  88.  
  89. /*
  90.  *========== 1. Check the system and the compiler
  91.  */
  92.  
  93.     SAY "MikMod/2 version 3.1.2 configuration"
  94.     SAY
  95.  
  96. /* OS/2
  97.  * - MMPM/2 and DART drivers are available
  98.  * - no GNU getopt
  99.  * - usleep is not used
  100.  * - emx has fnmatch(3), watcom doesn't
  101.  */
  102.  
  103. /* Don't check for fnmatch() and usleep() */
  104.  
  105.     SAY
  106.     SAY "Compiler..."
  107.     SAY "You can compile MikMod either with emx or with Watcom C. However, due to"
  108.     SAY "the Unix nature of the program, emx is recommended."
  109.     message="Do you want to use the emx compiler (recommended) ?"
  110.     CALL yesno
  111.     IF RESULT='Y' THEN
  112.     DO
  113.         SAY "Configuring for emx..."
  114.         cc="gcc"
  115.         cflags="-O1 -Zmt -Zbin-files -funroll-loops -ffast-math -fno-strength-reduce -Wall"
  116.         ldflags=""
  117.         ar="ar"
  118.         arflags="cr"
  119.         ranlib="ar s"
  120.         make="make"
  121.         orule="-o $@ -c"
  122.         link="$(CC) $(LDFLAGS) -o $(AOUT) $(OBJ) $(EXTRA_OBJ) $(LIB) -Zmt -Zexe -Zcrtdll -lmmpm2"
  123.     END
  124.     ELSE
  125.     DO
  126.         SAY "Configuring for Watcom C..."
  127.         cc="wcc386"
  128.         cflags="-5r -bt=os2 -fp5 -fpi87 -mf -oeatxh -w4 -zp8"
  129.         ldflags=""
  130.         ar="wlib"
  131.         arflags="-b -c -n"
  132.         ranlib="rem"
  133.         make="wmake -ms"
  134.         orule="-fo=$^@"
  135.         link="wlink N $(AOUT) SYS OS2V2 LIBP $(LIBPATH) LIBF MMPM2.LIB F $(LINKOBJ) F $(LINKEXTRA_OBJ) F $(LIB)"
  136.     END
  137.  
  138. /* "Checking" for fnmatch() */
  139.  
  140.     cflags=cflags" -DHAVE_FCNTL_H -DHAVE_LIMITS_H -DHAVE_UNISTD_H -DHAVE_SYS_IOCTL_H -DHAVE_SYS_TIME_H"
  141.     IF cc="gcc" THEN
  142.     DO
  143.         cflags=cflags" -DHAVE_FNMATCH_H -DHAVE_FNMATCH"
  144.         extra_obj="getopt.o getopt1.o"
  145.     END
  146.     ELSE IF cc="wcc386" THEN
  147.     DO
  148.         extra_obj="getopt.o getopt1.o fnmatch.o"
  149.     END
  150.  
  151. /*
  152.  *========== 2. Ask the user for his/her choices
  153.  */
  154.  
  155. /* Debug version */
  156.     SAY
  157.     SAY "Debugging..."
  158.     message="Do you want a debug version ?"
  159.     CALL yesno
  160.     IF RESULT='Y' THEN
  161.     DO
  162.         cflags=cflags" -DMIKMOD_DEBUG"
  163.         IF cc="gcc" THEN
  164.         DO
  165.             cflags=cflags" -g"
  166.             ldflags=ldflags" -g"
  167.         END
  168.         ELSE IF cc="wcc386" THEN
  169.             cflags=cflags" -d2"
  170.     END
  171.     ELSE
  172.     DO
  173.         IF cc="gcc" THEN
  174.         DO
  175.             cflags=cflags" -finline-functions -fomit-frame-pointer"
  176.             ldflags=ldflags" -s"
  177.         END
  178.         ELSE IF cc="wcc386" THEN
  179.             cflags=cflags" -d1"
  180.     END
  181.  
  182. /* Drivers */
  183.     SAY
  184.     SAY "Drivers..."
  185.  
  186.     driver_obj=""
  187.  
  188. /* MMPM/2 driver */
  189.     SAY "The MMPM/2 drivers will work with any OS/2 version starting from 2.1."
  190.     SAY "If you're not running Warp 4, these drivers are recommended."
  191.     message="Do you want the MMPM/2 drivers ?"
  192.     CALL yesno
  193.     IF RESULT='Y' THEN
  194.     DO
  195.         cflags=cflags" -DDRV_OS2"
  196.         driver_obj=driver_obj" drv_os2s.o drv_os2l.o"
  197.     END
  198.  
  199. /* Dart driver */
  200.     SAY "The DART (Direct Audio Real Time) driver will use less CPU time than the"
  201.     SAY "standard MMPM/2 drivers, but will not work on OS/2 2.1 or 3.0."
  202.     SAY "If you use Warp 4, this driver is recommended."
  203.     message="Do you want the DART driver ?"
  204.     CALL yesno
  205.     IF RESULT='Y' THEN
  206.     DO
  207.         cflags=cflags" -DDRV_DART"
  208.         driver_obj=driver_obj" drv_dart.o"
  209.     END
  210.  
  211. /* Interface */
  212. /*    SAY
  213.     SAY "Interface..."*/
  214.  
  215. /* Options */
  216.     SAY
  217.     SAY "Options..."
  218.  
  219.     virtch=""
  220.  
  221. /* Time snagger */
  222.     cflags=cflags" -DCPUTIME_SNAGGER"
  223.  
  224. /* High quality mixer */
  225.     SAY "The High quality mixer will improve the quality of your sounds, but requires"
  226.     SAY "a huge amount of power ! That's why it is not recommended."
  227.     message="Do you want the high quality mixer ?"
  228.     CALL yesno
  229.     IF RESULT='Y' THEN
  230.     DO
  231.         virtch="virtch2.o"
  232.         cflags=cflags" -DVIRTCH2"
  233.     END
  234.     ELSE
  235.         virtch="virtch.o"
  236.  
  237. /*
  238.  *========== 3. Generate Makefiles
  239.  */
  240.  
  241.     SAY
  242.  
  243.     filein ="libmikmod\Makefile.tmpl"
  244.     fileout="libmikmod\Makefile"
  245.     CALL sed
  246.  
  247.     filein ="mikmod\Makefile.tmpl"
  248.     fileout="mikmod\Makefile"
  249.     CALL sed
  250.  
  251.     filein="Makefile.os2"
  252.     fileout="Make.cmd"
  253.     CALL sed
  254.  
  255. /*
  256.  *========== 4. Last notes
  257.  */
  258.  
  259.     SAY
  260.     SAY "Configuration is complete. MikMod is ready to compile."
  261.     IF cc="wcc386" THEN
  262.     DO
  263.         SAY "If you choose to compile with Watcom C, you may have to edit"
  264.         SAY "mikmod\Makefile to adjust path to Watcom runtime libraries."
  265.         SAY "Then, just enter 'make' at the command prompt..."
  266.     END
  267.     ELSE
  268.         SAY "Just enter 'make' at the command prompt..."
  269.     SAY
  270.  
  271.     RETURN
  272.