#!/usr/bin/env perl # mikmod.wrapper - Wrapper for "mikmod" # License: BSD-style (for this file only) # Revision: 080925 #--------------------------------------------------------------------- # overview #--------------------------------------------------------------------- # This is a wrapper for "mikmod" (which must be renamed to "mikmod. # bin"). This wrapper operates as follows: # # a. It prevents multiple instances. # # b. If the environment variable AOSSMIKMOD is not set, or if it's # equal to "true", "yes", or a similar value, this wrapper runs # "mikmod.bin" via "aoss". Otherwise, it runs "mikmod.bin" dir- # ectly. #--------------------------------------------------------------------- # module setup #--------------------------------------------------------------------- require 5.6.1; use strict; use Carp; use warnings; # Trap warnings $SIG {__WARN__} = sub { die @_; }; #--------------------------------------------------------------------- # basic constants #--------------------------------------------------------------------- use constant ZERO => 0; # Zero use constant ONE => 1; # One use constant FALSE => 0; # Boolean FALSE use constant TRUE => 1; # Boolean TRUE #--------------------------------------------------------------------- # program parameters #--------------------------------------------------------------------- my $DEVDSP = '/dev/dsp'; # Absolute path for "dsp" device node #--------------------------------------------------------------------- # main routine #--------------------------------------------------------------------- sub Main { my $n; # Scratch (integer ) my $str; # Scratch (string ) #--------------------------------------------------------------------- # Initial setup. unshift (@ARGV, '__META_PREFIX__/bin/mikmod.bin'); #--------------------------------------------------------------------- # Prevent multiple instances. $str = `/bin/ps ax 2>&1`; $str = "" unless defined $str; exit ONE if $str =~ m@\bmikmod\.bin\b@; #--------------------------------------------------------------------- # Handle AOSSMIKMOD feature $str = $ENV {AOSSMIKMOD}; $str = "" unless defined $str; $str = 'yes' unless length $str; if ($str =~ m@^(1|one?|true|y|yes)\z@i) { # See notes near start of this file unshift (@ARGV, 'aoss'); } #--------------------------------------------------------------------- # Chain to target program (directly or indirectly). exec @ARGV; } #--------------------------------------------------------------------- # main program #--------------------------------------------------------------------- &Main(); # Call the main routine exit ZERO; # Normal exit