#!/bin/sh

#############################################################################
# FixMakefile script for TAU
#   based on the Sage/pC++ FixMakefiles

# An IMPROVED, FASTER script.  It now builds sed.cmd, and applies it ONCE!
#
# This script recursively finds Makefiles, and modifies them according
# to the keyword provided
#
# Kurt Windisch 12/10/96
# Pete Beckman 9/6/93
#############################################################################

# Record all the arguments
arguments=$*

# debug:
#echo $arguments

sedout=./utils/FixMakefile.sed

# Clear any old data
grep "^#" $sedout > $sedout.~~0
/bin/mv $sedout.~~0 $sedout

# Silly GOOFY Stupid /bin/sh on decstations gobble up the "\2" and make
# it an ASCII 002.  That breaks the echo commands below, since I REALLY
# want \2 to be output, not 002.  How in the world can DEC mess up /bin/sh?
# BSD-derived ash does the same.
bs=""

if test `echo "\2" | wc -c` = 2
  then
    bs="\\"
fi

# Default makefile sed commands.  Returns things to normal
echo "s/\(.*\)#ENDIF#\(.*\)/$bs\2$bs\1#ENDIF#/g" >> $sedout

###############################################################
# PARSE AN ARGUMENT
###############################################################
while [ x$1 != x ]
do

#echo Parsing $1
case $1 in

###############################################################
# Restore Makefiles to their original beauty
###############################################################
     arch=default)
        echo Restoring all files to original distribution
        config_arch=`echo $1 | sed 's/^arch=//'`
	echo "s/^CONFIG_ARCH=\(.*\)/CONFIG_ARCH=$config_arch/g" >> $sedout
	echo "s/^TAU_ARCH=\(.*\)/TAU_ARCH=$config_arch/g" >> $sedout
if [ -d target ]
  then
        pvm_arch=default
	pvm_homedir=default

        echo "s/#PVM_INSTALLED#\(.*\)/$bs\1#PVM_INSTALLED#/g" >> $sedout
	echo "s/^PVM_ARCH=\(.*\)/PVM_ARCH=$pvm_arch/g" >> $sedout
	echo "s@^PVM_DIR=\(.*\)@PVM_DIR=$pvm_homedir@g" >> $sedout

# make dir if it does not exist
	if [ ! -d target/pvm/lib ] 
	  then
		mkdir target/pvm/lib
	fi
 
# make dir if it does not exist
	if [ ! -d target/pvm/lib/$pvm_arch ] 
	  then
		mkdir target/pvm/lib/$pvm_arch
	fi
fi
	;;

     awedir=*)
        awedir=`echo $1 | sed -e 's/^awedir=//'`
	echo "s,^AWEDIR=.*$,AWEDIR=$awedir,g" >> $sedout
	;;

     ptdir=*)
        ptdir=`echo $1 | sed -e 's/^ptdir=//'`
	echo "s,^PTDIR=.*$,PTDIR=$ptdir,g" >> $sedout
	;;

     charmdir=*)
        charmdir=`echo $1 | sed -e 's/^charmdir=//'`
	echo "s,^CHARMDIR=.*$,CHARMDIR=$charmdir,g" >> $sedout
	;;

     pcldir=*)
        pcldir=`echo $1 | sed -e 's/^pcldir=//'`
	echo "s,^PCLDIR=.*$,PCLDIR=$pcldir,g" >> $sedout
	;;

     papidir=*)
        papidir=`echo $1 | sed -e 's/^papidir=//'`
	echo "s,^PAPIDIR=.*$,PAPIDIR=$papidir,g" >> $sedout
	;;

     taugcclibdir=*)
        taugcclibdir=`echo $1 | sed -e 's/^taugcclibdir=//'`
        echo "s,^TAUGCCLIBDIR=.*$,TAUGCCLIBDIR=$taugcclibdir,g" >> $sedout
        ;;

     taugfortranlibdir=*)
        taugfortranlibdir=`echo $1 | sed -e 's/^taugfortranlibdir=//'`
        echo "s,^TAUGFORTRANLIBDIR=.*$,TAUGFORTRANLIBDIR=$taugfortranlibdir,g" >> $sedout
        ;;

     taugcclibopts=*)
        taugcclibopts=`echo $1 | sed -e 's/^taugcclibopts=//'`
        echo "s,^TAUGCCLIBOPTS=.*$,TAUGCCLIBOPTS=$taugcclibopts,g" >> $sedout
        ;;

     papisubdir=*)
        papisubdir=`echo $1 | sed -e 's/^papisubdir=//'`
	echo "s,^PAPISUBDIR=.*$,PAPISUBDIR=$papisubdir,g" >> $sedout
	;;

     oparidir=*)
        oparidir=`echo $1 | sed -e 's/^oparidir=//'`
	echo "s,^OPARIDIR=.*$,OPARIDIR=$oparidir,g" >> $sedout
	;;

     vampirtracedir=*)
        vampirtracedir=`echo $1 | sed -e 's/^vampirtracedir=//'`
	echo "s,^VAMPIRTRACEDIR=.*$,VAMPIRTRACEDIR=$vampirtracedir,g" >> $sedout
	;;

     sicortexlink=*)
        sicortexlink=`echo $1 | sed -e 's/^sicortexlink=//' -e 's/#/ /g'`
	echo "s@^SICORTEXLINK=.*\$@SICORTEXLINK=$sicortexlink@g" >> $sedout
	;;

     epilogdir=*)
        epilogdir=`echo $1 | sed -e 's/^epilogdir=//'`
	echo "s,^EPILOGDIR=.*$,EPILOGDIR=$epilogdir,g" >> $sedout
	;;

     epilogbindir=*)
        epilogbindir=`echo $1 | sed -e 's/^epilogbindir=//'`
	echo "s,^EPILOGBINDIR=.*$,EPILOGBINDIR=$epilogbindir,g" >> $sedout
	;;

     epiloglibdir=*)
        epiloglibdir=`echo $1 | sed -e 's/^epiloglibdir=//'`
	echo "s,^EPILOGLIBDIR=.*$,EPILOGLIBDIR=$epiloglibdir,g" >> $sedout
	;;

     epilogextralinkcmd=*)
        epilogextralinkcmd=`echo $1 | sed -e 's/^epilogextralinkcmd=//' -e 's/#/ /g'`
	echo "s@^EPILOGEXTRALINKCMD=.*\$@EPILOGEXTRALINKCMD=$epilogextralinkcmd@g" >> $sedout
	;;

     epilogincdir=*)
        epilogincdir=`echo $1 | sed -e 's/^epilogincdir=//'`
	echo "s,^EPILOGINCDIR=.*$,EPILOGINCDIR=$epilogincdir,g" >> $sedout
	;;

     perfincdir=*)
        perfincdir=`echo $1 | sed -e 's/^perfincdir=//'`
	echo "s,^PERFINCDIR=.*$,PERFINCDIR=$perfincdir,g" >> $sedout
	;;

     perflibdir=*)
        perflibdir=`echo $1 | sed -e 's/^perflibdir=//'`
	echo "s,^PERFLIBDIR=.*$,PERFLIBDIR=$perflibdir,g" >> $sedout
	;;

     perflibrary=*)
        perflibrary=`echo $1 | sed -e 's/^perflibrary=//' -e 's/#/ /g'`
	echo "s,^PERFLIBRARY=.*$,PERFLIBRARY=$perflibrary,g" >> $sedout
	;;

     pdtdir=*)
        pdtdir=`echo $1 | sed -e 's/^pdtdir=//'`
	echo "s,^PDTDIR=.*$,PDTDIR=$pdtdir,g" >> $sedout
	;;

     vtfdir=*)
        vtfdir=`echo $1 | sed -e 's/^vtfdir=//'`
	echo "s,^VTFDIR=.*$,VTFDIR=$vtfdir,g" >> $sedout
	;;

     otfdir=*)
        otfdir=`echo $1 | sed -e 's/^otfdir=//'`
	echo "s,^OTFDIR=.*$,OTFDIR=$otfdir,g" >> $sedout
	;;

     slog2dir=*)
        slog2dir=`echo $1 | sed -e 's/^slog2dir=//'`
	echo "s,^SLOG2DIR=.*$,SLOG2DIR=$slog2dir,g" >> $sedout
	;;

     pdtcompdir=*)
        pdtcompdir=`echo $1 | sed -e 's/^pdtcompdir=//'`
	echo "s,^PDTCOMPDIR=.*$,PDTCOMPDIR=$pdtcompdir,g" >> $sedout
	;;

     pdtarchdir=*)
        pdtarchdir=`echo $1 | sed -e 's/^pdtarchdir=//'`
	echo "s,^PDTARCHITECTURE=.*$,PDTARCHITECTURE=$pdtarchdir,g" >> $sedout
	;;

     pdtcxx=*)
        pdtcxx=`echo $1 | sed -e 's/^pdtcxx=//'`
	echo "s,^PDT_CXX=.*$,PDT_CXX=$pdtcxx,g" >> $sedout
	;;

     fullcxx=*)
        fullcxx=`echo $1 | sed -e 's/^fullcxx=//'`
	echo "s,^FULL_CXX=.*$,FULL_CXX=$fullcxx,g" >> $sedout
	;;

     fullcc=*)
        fullcc=`echo $1 | sed -e 's/^fullcc=//'`
	echo "s,^FULL_CC=.*$,FULL_CC=$fullcc,g" >> $sedout
	;;

     dyninstdir=*)
        dyninstdir=`echo $1 | sed -e 's/^dyninstdir=//'`
	echo "s,^DYNINSTDIR=.*$,DYNINSTDIR=$dyninstdir,g" >> $sedout
	;;

     jdkdir=*)
        jdkdir=`echo $1 | sed -e 's/^jdkdir=//'`
	echo "s,^JDKDIR=.*$,JDKDIR=$jdkdir,g" >> $sedout
	;;

     pythoninc=*)
        pythoninc=`echo $1 | sed -e 's/^pythoninc=//'`
	echo "s,^PYTHON_INCDIR=.*$,PYTHON_INCDIR=$pythoninc,g" >> $sedout
	#echo "Using PYTHON INCLUDE DIR =" $pythoninc
	;;

     pythonlib=*)
        pythonlib=`echo $1 | sed -e 's/^pythonlib=//'`
	echo "s,^PYTHON_LIBDIR=.*$,PYTHON_LIBDIR=$pythonlib,g" >> $sedout
	#echo "Using PYTHON LIB DIR =" $pythonlib
	;;

     stffdir=*)
	stffdir=`echo $1 | sed -e 's/^stffdir=//'`
	echo "s,^STFF_DIR=.*$,STFF_DIR=$stffdir,g" >> $sedout
	;;

     sddfdir=*)
	sddfdir=`echo $1 | sed -e 's/^sddfdir=//'`
	echo "s,^SDDF_DIR=.*$,SDDF_DIR=$sddfdir,g" >> $sedout
	;;

     tulipdir=*)
        tulipdir=`echo $1 | sed -e 's/^tulipdir=//'`
	echo "s,^TULIPDIR=.*$,TULIPDIR=$tulipdir,g" >> $sedout
	;;

     ktauinc=*)
        ktauinc=`echo $1 | sed -e 's/^ktauinc=//'`
	echo "s,^KTAU_INCDIR=.*$,KTAU_INCDIR=$ktauinc,g" >> $sedout
	;;

     ktauincuser=*)
        ktauincuser=`echo $1 | sed -e 's/^ktauincuser=//'`
	echo "s,^KTAU_INCUSERDIR=.*$,KTAU_INCUSERDIR=$ktauincuser,g" >> $sedout
	;;

     ktaulib=*)
        ktaulib=`echo $1 | sed -e 's/^ktaulib=//'`
	echo "s,^KTAU_LIB=.*$,KTAU_LIB=$ktaulib,g" >> $sedout
	;;

     ktausym=*)
        ktausym=`echo $1 | sed -e 's/^ktausym=//'`
      echo "s,^KTAU_KALLSYMS_PATH=.*$,KTAU_KALLSYMS_PATH=$ktausym,g" >> $sedout
      ;;

###############################################################
# Set the default optimization flags for compiling pcxx und user programs
###############################################################
     pcxxopt=*)
        pcxxopt=`echo $1 | sed -e 's/^pcxxopt=//' -e 's/_/ /'`
	echo "s@^PCXX_OPT=\(.*\)@PCXX_OPT=$pcxxopt@g" >> $sedout
        ;;
     useropt=*)
        useropt=`echo $1 | sed -e 's/^useropt=//' -e 's/#/ /g'`
	echo "s@^USER_OPT=\(.*\)@USER_OPT=$useropt@g" >> $sedout
        ;;
     extrashlibopts=*)
        extrashlibopts=`echo $1 | sed -e 's/^extrashlibopts=//' -e 's/#/ /g'`
	echo "s@^TAUEXTRASHLIBOPTS=\(.*\)@TAUEXTRASHLIBOPTS=$extrashlibopts@g" >> $sedout
        ;;

     extradir=*)
        extradir=`echo $1 | sed -e 's/^extradir=//' `
	echo "s@^EXTRADIR=\(.*\)@EXTRADIR=$extradir@g" >> $sedout
        ;;
     extradircxx=*)
        extradircxx=`echo $1 | sed -e 's/^extradircxx=//' `
	echo "s@^EXTRADIRCXX=\(.*\)@EXTRADIRCXX=$extradircxx@g" >> $sedout
        ;;
###############################################################
# Set the TAUROOT variable
###############################################################
     tauroot=*)
        tauroot=`echo $1 | sed -e 's/^tauroot=//' `
	echo "s@^TAUROOT=\(.*\)@TAUROOT=$tauroot@g" >> $sedout
        ;;

###############################################################
# Set the TAU_PREFIX_INSTALL_DIR variable
###############################################################
     tauprefix=*)
        tauprefix=`echo $1 | sed -e 's/^tauprefix=//' `
        echo "s@^TAU_PREFIX_INSTALL_DIR=\(.*\)@TAU_PREFIX_INSTALL_DIR=$tauprefix@g" >> $sedout
        ;;
###############################################################
# Set the CONFIG_ARCH variable using execprefix
###############################################################
     execprefix=*)
        execprefix=`echo $1 | sed -e 's/^execprefix=//' `
        echo "s@^CONFIG_ARCH=\(.*\)@CONFIG_ARCH=$execprefix@g" >> $sedout
        ;;

###############################################################
# Set the TAU_CONFIG variable
###############################################################
     tauoptions=*)
        tauoptions=`echo $1 | sed -e 's/^tauoptions=//' `
        echo "s@^TAU_CONFIG=\(.*\)@TAU_CONFIG=$tauoptions@g" >> $sedout
        ;;

###############################################################
# Set the default compilers
###############################################################
     c_compiler=*)
        c_compiler=`echo $1 | sed -e 's/^c_compiler=//' `
	echo "s@^CONFIG_CC=\(.*\)@CONFIG_CC=$c_compiler@g" >> $sedout
        ;;
     cxx_compiler=*)
        cxx_compiler=`echo $1 | sed -e 's/^cxx_compiler=//'`
	echo "s@^CONFIG_CXX=\(.*\)@CONFIG_CXX=$cxx_compiler@g" >> $sedout
        ;;





     TAU_LARGEFILE)
        echo NOTE: Using the O_LARGEFILE flag to open 
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     TAU_BFD)
        echo NOTE: Using BFD support
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;


###############################################################
# Set up MPI stuff if possible
###############################################################
     MPI)
        echo NOTE: Using the TAU MPI Profiling Interface 
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;

     MPI2)
        echo "NOTE: Using TAU's MPI-2 extensions"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;

     LAMPI)
        echo "NOTE: Using LA-MPI MPI_Request_c2f workaround"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;

     IBMMPI)
        echo "NOTE: Using TAU's IBM MPI extensions"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;

     WEAKMPIINIT)
        echo "NOTE: Not defining TAU's mpi_init wrapper for Fortran"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;

     MPICH_IGNORE_CXX_SEEK)
	echo "NOTE: Using the -DMPICH_IGNORE_CXX_SEEK to compile C++ programs"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;

     MPICH2_MPI_INPLACE)
	echo "NOTE: Using the -DMPICH2_MPI_INPLACE flag"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;

     MPIGREQUEST)
        echo "NOTE: Using TAU's MPI-2 Grequest extensions"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;

     MPIDATAREP)
        echo "NOTE: Using TAU's MPI-2 Datarep_conversion extensions"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;

     MPIOREQUEST)
        echo "NOTE: Using TAU's MPI-2 MPIO_Request extensions"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;

     MPIERRHANDLER)
        echo "NOTE: Using TAU's MPI-2 Error handler extensions"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;

     MPICONSTCHAR)
        echo "NOTE: Using TAU's MPI-2 MPI_Info_set const char * interface"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;

    MPIATTR)
        echo "NOTE: Using TAU's MPI-2 Attr extensions"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;

    MPITYPEEX)
        echo "NOTE: Using TAU's MPI-2 Type and Exscan extensions"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;

    MPIADDERROR)
        echo "NOTE: Using TAU's MPI-2 Add_error extensions"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;

    MPINEEDSTATUSCONV)
        echo "NOTE: Using TAU's MPI_Status_c2f/f2c routines"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;

     MPI_THREADED)
        echo NOTE: Using the TAU MPI_Init_thread Profiling Interface Wrapper
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;

     MPI_R_SUFFIX)
        echo NOTE: Using thread-safe MPI library with _r suffix
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;

     mpiincargs=*)
        mpiinc=`echo $1 | sed -e 's/^mpiincargs=//' -e 's/#/ /g'`
	echo "s@^TAU_MPI_INC=\(.*\)@TAU_MPI_INC=$mpiinc@g" >> $sedout
        #echo "MPIINC=$mpiinc"
        ;;

     mpilibargs=*)
        mpilib=`echo $1 | sed -e 's/^mpilibargs=//' -e 's/#/ /g'`
	echo "s@^TAU_MPI_LIB=\(.*\)@TAU_MPI_LIB=$mpilib@g" >> $sedout
        #echo "MPILIB=$mpilib" 
        ;;

     mpiflibargs=*)
        mpiflib=`echo $1 | sed -e 's/^mpiflibargs=//' -e 's/#/ /g'`
	echo "s@^TAU_MPI_FLIB=\(.*\)@TAU_MPI_FLIB=$mpiflib@g" >> $sedout
        #echo "MPIFLIB=$mpiflib" 
        ;;

     mpinowraplibargs=*)
        mpilib=`echo $1 | sed -e 's/^mpinowraplibargs=//' -e 's/#/ /g'`
	echo "s@^TAU_MPI_NOWRAP_LIB=\(.*\)@TAU_MPI_NOWRAP_LIB=$mpilib@g" >> $sedout
        ;;

     mpinowrapflibargs=*)
        mpiflib=`echo $1 | sed -e 's/^mpinowrapflibargs=//' -e 's/#/ /g'`
	echo "s@^TAU_MPI_NOWRAP_FLIB=\(.*\)@TAU_MPI_NOWRAP_FLIB=$mpiflib@g" >> $sedout
        ;;

     mpilib=*)
        mpilibdir=`echo $1 | sed -e 's/^mpilib=//'`
	echo "s@^TAU_MPILIB_DIR=\(.*\)@TAU_MPILIB_DIR=$mpilibdir@g" >> $sedout
        #echo "TAU_MPILIB_DIR=$mpilibdir" 
        ;;

###############################################################
# Set up SHMEM stuff if possible
###############################################################
     SHMEM)
        echo NOTE: Using the TAU SHMEM Profiling Interface 
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;

     GPSHMEM)
        echo NOTE: Using the TAU GPSHMEM/PGPSHMEM Profiling Interface 
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;

     shmemincargs=*)
        shmeminc=`echo $1 | sed -e 's/^shmemincargs=//' -e 's/#/ /g'`
	echo "s@^TAU_SHMEM_INC=\(.*\)@TAU_SHMEM_INC=$shmeminc@g" >> $sedout
        #echo "SHMEMINC=$shmeminc"
        ;;

     shmemlibargs=*)
        shmemlib=`echo $1 | sed -e 's/^shmemlibargs=//' -e 's/#/ /g'`
	echo "s@^TAU_SHMEM_LIB=\(.*\)@TAU_SHMEM_LIB=$shmemlib@g" >> $sedout
        #echo "SHMEMLIB=$shmemlib" 
        ;;
     

###############################################################
# Set the CONFIG_ARCH=<machine-name> in the Makefiles.
###############################################################
     arch=*)
        config_arch=`echo $1 | sed 's/^arch=//'`
	echo "s/^CONFIG_ARCH=\(.*\)/CONFIG_ARCH=$config_arch/g" >> $sedout
	echo "s/^TAU_ARCH=\(.*\)/TAU_ARCH=$config_arch/g" >> $sedout

###############################################################
# Set up PVM stuff if possible
###############################################################

#Only do the PVM stuff if this is a pC++ distribution
if [ -d target ]
  then
        xdev_arch=`utils/archfind -x`
        pvm_arch=`grep "^$config_arch" utils/pvm_arches | awk '{print $2;}'`
        pvm_parch=`grep "^$xdev_arch" utils/pvm_arches | awk '{print $2;}'`

	pvm_homedir=`utils/checkPVM`
	if [ $pvm_homedir = no ]
	  then
            echo PVM:  Could not find a PVM installation, PVM run-time will not be compiled
	  else
	    echo PVM:  Found PVM installation at $pvm_homedir
	    echo PVM:  PVM run-time module will be installed
            echo "s/#PVM_INSTALLED#\(.*\)/$bs\1#PVM_INSTALLED#/g" >> $sedout
	fi

# used to be "xnone"
        if [ x$pvm_parch = x$pvm_parch ]
          then
            if [ x$pvm_arch = x ]
              then
                echo PVM:  No matching PVM architecture name in utils/pvm_arches for $config_arch
                echo PVM:  Configuring pC++ PVM runtime module for UNKNOWN
	        pvm_arch=UNKNOWN
            else
              echo PVM:  Matching PVM-style architecture name is $pvm_arch
            fi
          else
            echo PVM:  Found Parallel PVM machine $pvm_parch
            pvm_arch=$pvm_parch
	fi

	echo "s/^PVM_ARCH=\(.*\)/PVM_ARCH=$pvm_arch/g" >> $sedout
	echo "s@^PVM_DIR=\(.*\)@PVM_DIR=$pvm_homedir@g" >> $sedout

# make dir if it does not exist
	if [ ! -d target/pvm/lib ] 
	  then
		mkdir target/pvm/lib
	fi
 
# make dir if it does not exist
	if [ ! -d target/pvm/lib/$pvm_arch ] 
	  then
		mkdir target/pvm/lib/$pvm_arch
	fi
fi
	;;

     sage1dir=*)
        sage1dir=`echo $1 | sed -e 's/^sage1dir=//' -e 's/_/ /'`
	echo "s@^SAGE1DIR=\(.*\)@SAGE1DIR=$sage1dir@g" >> $sedout
        ;;

     sage2dir=*)
        sage2dir=`echo $1 | sed -e 's/^sage2dir=//' -e 's/_/ /'`
	echo "s@^SAGE2DIR=\(.*\)@SAGE2DIR=$sage2dir@g" >> $sedout
        ;;

###############################################################
# Else, just do the standard modification based on the keyword
###############################################################
     NO_RANLIB)
	echo NOTE: ranlib not required for this architecture.
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     USE_DECCXX)
	echo NOTE: Using the Compaq cxx C++ compiler
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     COMPAQ_ALPHA)
	echo NOTE: Using configuration for Compaq Alpha      
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     USE_IBMXLC)
	echo NOTE: Using the IBM xlC C++ compiler
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     USE_NECCXX)
	echo NOTE: Using the NEC C++ compiler
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     USE_INTELCXX)
	echo NOTE: Using the Intel C++ compiler
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     USE_PATHCC)
	echo NOTE: Using the Pathscale C++ compiler
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     OPEN64ORC)
	echo NOTE: Using the Open64 C++ compiler
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     HITACHI)
	echo NOTE: Using the HITACHI SR8000 MPP options
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     HITACHI_FORTRAN)
	echo NOTE: Using the HITACHI Fortran 90 compiler options
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     OPEN64ORC_FORTRAN)
	echo NOTE: Using the Open64 ORC Fortran compiler options
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PATHSCALE_FORTRAN)
	echo NOTE: Using the Pathscale Fortran 90 compiler options
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     SC_PATHSCALE)
	echo NOTE: Using the SiCortex Pathscale Cross compiler options
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     HITACHI_OPENMP)
	echo NOTE: Using HITACHI OpenMP options
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     OPEN64_OPENMP)
	echo NOTE: Using Open64 ORC OpenMP options
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     IBMXLC_OPENMP)
	echo NOTE: Using the IBM xlC OpenMP options
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     COMPAQCXX_OPENMP)
	echo NOTE: Using the Compaq cxx OpenMP options
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     COMPAQCXX_PTHREAD)
	echo NOTE: Using the Compaq cxx -pthread option
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     COMPENSATE)
	echo NOTE: Using the TAU instrumentation perturbation compensation scheme
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     IOWRAPPER)
	echo NOTE: Building POSIX I/O wrapper
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     KTAU)
	echo NOTE: Using Kernel Profiling
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     KTAU_MERGE)
	echo NOTE: Using Kernel Profiling with merging user-space profile
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     KTAU_SHCTR)
	echo NOTE: Using Kernel Profiling with shared OS counter support
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     MUSE)
	echo NOTE: Using MAGNET/MUSE with TAU
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     MUSE_EVENT)
	echo NOTE: Using MAGNET/MUSE EVENT with TAU
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     MUSE_MULTIPLE)
	echo NOTE: Using MAGNET/MUSE MULTIPLE with TAU
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     USE_SGINCC)
	echo NOTE: Using the SGI NCC C++ compiler
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     SGICC)
	echo NOTE: Using SGI CC C++ compiler
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PDTSGICC)
	echo NOTE: Using -LANG:std option for tau_instrumentor
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PDTCXX)
	echo NOTE: Using a different compiler for tau_instrumentor
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PDTARCH)
	echo NOTE: Using a different compiler dir for PDT 
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PDTARCHITECTURE)
	echo NOTE: Using a different architecture dir for PDT 
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PDTNOFSTMTS)
	echo NOTE: Disabling loop level instrumentation for Fortran
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PDTALPHACXX)
	echo NOTE: Using -D__USE_STD_IOSTREAM option for tau_instrumentor
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PDTHPACC)
	echo NOTE: Using -AA option for tau_instrumentor
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     ENABLE32BIT)
	echo NOTE: Using -32 flag for the C++ compiler
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     ENABLEN32BIT)
	echo NOTE: Using -n32 flag for the C++ compiler
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     ENABLE64BIT)
	echo NOTE: Using -64 flag for the C++ compiler
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     SGIGNU)
	echo NOTE: Using GNU C++ compiler on SGI
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     CRAYCC)
	echo NOTE: Using The Cray T3E CC C++ compiler 
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     CRAYX1CC)
	echo NOTE: Using The Cray CC C++ compiler 
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     CRAYKAI)
	echo NOTE: Using The Cray T3E KAI C++ compiler 
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PGI) 
	echo NOTE: Using Portland Group Inc. pgCC C++ compiler
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PGI1.7) 
	echo NOTE: Using special switches for PGI 1.7 compiler
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PGICC) 
	echo NOTE: May use --prelink_objects for PGI 3.0-5.4 compiler
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PGINOPRELINK) 
	echo NOTE: Disabling the use of --prelink_objects for PGI 6.0+ compiler
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     FUJITSU) 
	echo NOTE: Using Fujitsu FCC C++ compiler
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     FREEBSD)
	echo NOTE: FreeBSD options will be used
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     FUJITSU_SOLARIS) 
	echo NOTE: Using Fujitsu f90 Fortran compiler
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     NEXT_CLIB)
	echo NOTE: The NeXTs do not have a libc.a
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     USE_CFRONT)
	echo "NOTE: Using the 'CC' C++ Compiler"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     HP-ALLOCA)
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     HPUX10)
	echo NOTE: HPUX Version 10 fixes will be used
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     HP)
	echo NOTE: HPUX fixes will be used
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     HPGNU)
	echo NOTE: HP GNU fixes will be used
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     ACC)
	echo NOTE: HP aCC compiler will be used
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     APPLECXX)
	echo NOTE: Apple c++ compiler will be used
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     USE_CC)
	echo "NOTE: Using default cc compiler."
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     HP_CFLAGS)
	echo NOTE: Using -AA flag and shared libraries for HP native compiler.
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     MIPS_CC)
	echo NOTE: Using -Wf,-XNg800 flags for MIPS native compiler.
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     MIPSR4K)
	echo NOTE: Using -mips2 optimization flag MIPS native compiler.
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     MIPSR8K)
	echo NOTE: Using -mips4 optimization flag MIPS native compiler.
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     USE_GCC)
	echo NOTE: Using the Gnu C Compiler, GCC
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     SICORTEX)
        echo NOTE: Using SiCortex build options
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     FORCEIA32)
        echo NOTE: Using 32 bit mode for x86_64 
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     CM5)
	echo "NOTE: *** CM5 development enviroment found ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PARAGON)
	echo "NOTE: *** Paragon development environment found. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     SP1)
	echo "NOTE: *** SP development environment found. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     IBM64)
	echo "NOTE: *** Using IBM 64 bit options.  ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PPC64)
	echo "NOTE: *** IBM pSeries Linux environment found. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     MIPS32)
	echo "NOTE: *** SiCortex MIPS32 environment found. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     MIPS32LINUX)
	echo "NOTE: *** SiCortex MIPS32 Linux environment found. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     MIPS32PAPI)
	echo "NOTE: *** SiCortex 32 bit PAPI options used. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     MIPS64)
	echo "NOTE: *** SiCortex MIPS64 environment found. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     MIPS64LINUX)
	echo "NOTE: *** SiCortex MIPS64 Linux environment found. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     MIPS64PAPI)
	echo "NOTE: *** SiCortex 64 bit PAPI options used. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     BGL)
	echo "NOTE: *** IBM BlueGene/L development environment found. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     BGP)
	echo "NOTE: *** IBM BlueGene/P development environment found. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     BGP_GFORTRAN)
	echo "NOTE: *** Using gfortran. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     BGPPAPI)
	echo "NOTE: *** IBM BlueGene/P PAPI found. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     T3D)
	echo "NOTE: *** CRAY T3D development environment found. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     T3E)
	echo "NOTE: *** CRAY T3E development environment found. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     CRAY-ALLOCA)
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     SGIMP)
	echo "NOTE: *** SGI Symmetric Multiprocessing Environment found. ***"
        numproc=`/bin/hinv | /bin/grep -v "PU" | /usr/bsd/head -1 | /bin/cut -d" " -f1 `
	echo NOTE: "*** There are $numproc processors in this system ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     SOL2)
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     SUN386I)
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     SUNX86_64)
	echo "NOTE: *** Using Solaris 64 bit options.  ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     CNXSPP)
	echo "NOTE: *** Convex SPP development environment found. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     CS2)
	echo "NOTE: *** Meiko CS2 development environment found. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     C90)
	echo "NOTE: *** Cray C90 development environment found. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     KSR)
	echo "NOTE: *** Kendall Square KSR-1 development environment found. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PTX)
	echo "NOTE: *** Symmetry PTX development environment found. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     TC2000)
        echo "Bernd, I dont know what to do here...."
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     SYMMETRY)
	echo "NOTE: *** Symmetry Dynix development environment found. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
    RENCI_STFF)
       echo "NOTE: Using RENCI STFF library. ***"
       echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
       ;;
     TCLTK)
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     AWE_AVAILABLE)
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     TAU_CHARM)
	echo "NOTE: Using charm++ (converse) threads"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PTHREAD_AVAILABLE)
        echo "NOTE: Using pthreads as the thread package. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     TAU_PAPI_THREADS)
        echo "NOTE: Using PAPI threads as the thread package. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     NOCOMM)
        echo "NOTE: Disabling tracking of communication messages in MPI ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     TAU_SPROC)
	echo "NOTE: Using SGI sproc as the thread package. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     TULIPTHREADS)
	echo "NOTE: Using Tulip Threads as the thread package. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     SMARTS)
	echo "NOTE: Using SMARTS interface for Tulip threads. ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PCL)
	echo "NOTE: Using PCL interface for Hardware Performance Counters ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PAPI)
	echo "NOTE: Using PAPI interface for Hardware Performance Counters ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PERFLIB)
	echo "NOTE: Using PERFLIB measurement library instead of TAU's"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PYTHON)
	echo "NOTE: Using TAU Python bindings ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     MULTIPLECOUNTERS)
	echo "NOTE: Using multiple counters for measurement ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PDT)
	echo "NOTE: Using PDT for TAU Source Code Instrumentation ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     MPITRACE)
	echo "NOTE: Using instrumentation of MPI and ancestor events ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     VTF)
	echo "NOTE: Using VTF3 library to build tau2vtf trace converter ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     OTF)
	echo "NOTE: Using OTF library to build tau2otf trace converter ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     OTFSRC)
	echo "NOTE: Using OTF source based distribution to build tau2otf trace converter ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     TAU2EPILOG)
	echo "NOTE: Using Kojak 2.1+ Epilog write interface to build tau2elg ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     SLOG2)
	echo "NOTE: Using SLOG2SDK library to build tau2slog2 trace converter ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     DYNINST)
	echo "NOTE: Using DYNINST for TAU Runtime Instrumentation ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     DYNINST41)
	echo "NOTE: Using newer version DYNINST 4.1+ "
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     DYNINST6)
	echo "NOTE: Using newer version DYNINST 5+ "
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     DYNINST5.2)
	echo "NOTE: Using newer version DYNINST 5.2 "
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     JAVA)
	echo "NOTE: Using Java Virtual Machine Instrumentation ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     OPENMP)
	echo "NOTE: Using OpenMP Threads ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     OPARI)
	echo "NOTE: Using Opari OpenMP directive rewriting tool ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     KOJAKOPARI)
	echo "NOTE: Using KOJAK's Opari implementation ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     OPARI_REGION)
	echo "NOTE: Using Opari tool with OpenMP region information ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     OPARI_CONSTRUCT)
	echo "NOTE: Using Opari tool with OpenMP construct information ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     VAMPIRTRACE)
	echo "NOTE: Using VAMPIRTRACE Tracing Package ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     VAMPIRTRACEINTS)
	echo "NOTE: Using -DTAU_64BITTYPES_NEEDED -DHAVE_INTTYPES_H for VampirTrace ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     VAMPIRTRACEMPI)
	echo "NOTE: Using VAMPIRTRACE's MPI Wrapper Library ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     VAMPIRTRACEOMPI)
	echo "NOTE: Using VAMPIRTRACE's OpenMP MPI Wrapper Library ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     VAMPIRTRACEOMP)
	echo "NOTE: Using VAMPIRTRACE's OpenMP Trace Library ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     EPILOG)
	echo "NOTE: Using EPILOG Tracing Package ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     SCALASCA)
	echo "NOTE: Detected SCALASCA Package ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     EPILOGMPI)
	echo "NOTE: Using EPILOG's MPI Wrapper Library ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     EPILOGOMPI)
	echo "NOTE: Using EPILOG's OpenMP MPI Wrapper Library ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     EPILOGOMP)
	echo "NOTE: Using EPILOG's OpenMP Trace Library ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PGIOPENMP)
	echo "NOTE: Using PGI's OpenMP options ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     INTELOPENMP)
	echo "NOTE: Using Intel's OpenMP options ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     GNUOPENMP)
	echo "NOTE: Using GNU's OpenMP options ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     GUIDE)
	echo "NOTE: Using KAI's Guide OpenMP ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     COMPAQ_GUIDEF90)
	echo "NOTE: Using Compaq f90 options with Guide ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PCLPTHREAD)
	echo "NOTE: Using multi-threaded access to H/W Performance Counters ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PAPIPTHREAD)
	echo "NOTE: Using multi-threaded access to H/W Performance Counters ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     LWP_AVAILABLE)
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     TASK_AVAILABLE)
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PCXX)
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     HPCXX)
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     ANSIC)
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
# PROFILING OPTIONS
     PROFILE)
	echo "NOTE: Enabled Profiling. Compiling with -DPROFILING_ON"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
# TRACING OPTIONS
     TRACE)
	echo "NOTE: Enabled Tracing. Compiling with -DTRACING_ON"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     MONITOR)
	echo "NOTE: Enabled Monitoring. Compiling with -DMONITORING_ON"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     KAI)
	echo "NOTE: Using KAI KCC options"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     SGICOUNTERS)
	echo "NOTE: Using SGI R10000 Hardware Counters for Profiling"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     BGLTIMERS)
	echo "NOTE: Using IBM BlueGene/L Fast Low-Overhead Timers for Profiling"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     BGPTIMERS)
	echo "NOTE: Using IBM BlueGene/P Fast Low-Overhead Timers for Profiling"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     SGITIMERS)
	echo "NOTE: Using SGI Fast Nanosecond Timers for Profiling"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     CRAYTIMERS)
	echo "NOTE: Using Cray X1/XT3 fast nanosecond timers for profiling"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     CATAMOUNT)
	echo "NOTE: Using Cray RS Catamount options"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     CRAYCNL)
	echo "NOTE: Using Cray Compute Node Linux options"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     LINUXTIMERS)
	echo "NOTE: Using Linux TSC Counters for low overhead wallclock time"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
ALPHATIMERS)
	echo "NOTE: Using Alpha clock_gettime for low overhead wallclock time"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     CPUTIME)
	echo "NOTE: Using usertime + system time for Profiling"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     JAVACPUTIME)
	echo "NOTE: Using JVMPI thread specific cpu time"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PAPIWALLCLOCK)
	echo "NOTE: Using PAPI's low overhead wall clock time"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PAPIVIRTUAL)
	echo "NOTE: Using PAPI's CPU Time (process virtual time)"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PROFILESTATS)
	echo "NOTE: Using Profile Statistics (Std. Dev. of Excl time/counts)"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PROFILEMEMORY)
	echo "NOTE: Using PROFILEMEMORY options"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PROFILEHEADROOM)
	echo "NOTE: Using PROFILEHEADROOM options"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PROFILECALLPATH)
	echo "NOTE: Using Call Path Profiles"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PROFILEPARAM)
	echo "NOTE: Using Parameter Mapped Profiles"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PROFILEPHASE)
	echo "NOTE: Using Phase Based Profiling Using Callpaths"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PROFILECALLS)
	echo "NOTE: Using PROFILECALLS for tracing timings for each function invocation "
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     DEPTHLIMIT)
	echo "NOTE: Disabling instrumentation beyond a certain callstack depth"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     CALLSTACK)
        echo "NOTE:  Using PROFILECALLSTACK for callstack tracing"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     INTELCXXLIBICC)
	echo "NOTE: Using INTEL's -cxxlib-icc compilation option"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     INTELTFLOP)
	echo "NOTE: Using INTEL TeraFlop Profiling Options -DPOOMA_TFLOP"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     DEBUGPROF)
	echo "NOTE: Using Debugging Mode for Profiling Library -DDEBUG_PROF"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     STDCXXLIB)
	echo "NOTE: Using Standard C++ Library"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     SOL2CC)
        echo "NOTE: Solaris2 CC doesn't support RTTI yet, using -DNO_RTTI"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     SUNCC)
        echo "NOTE: Using SUN's CC compiler"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     SOL2CC_OPENMP)
        echo "NOTE: Using Solaris CC's -xopenmp option"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     SUNCC_OPENMP)
        echo "NOTE: Using SUN CC's -xopenmp=parallel option under Linux"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     SOL2PAPI)
	echo "NOTE: Using PAPI on Solaris (static library) ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     SOLARIS64)
        echo "NOTE: Using 64 bit compiler options under Solaris"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     X86_64PAPI)
        echo "NOTE: Using PAPI with AMD Opteron x86_64 options"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
        ;;
     IBMPAPI)
	echo "NOTE: Using PAPI with PM Toolkit options ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     BGLPAPI)
	echo "NOTE: Using PAPI with BGL (libpapi.a) options ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     BGLPAPI_RTS)
	echo "NOTE: Using PAPI with BGL (libpapi.rts.a) options ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     ALPHAPAPI)
	echo "NOTE: Using PAPI with DADD options ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     IA64PAPI)
	echo "NOTE: Using PAPI with IA-64 options (-lpapi) ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PAPIPFM)
	echo "NOTE: Using PAPI with -lpfm option ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PPC64PAPI)
	echo "NOTE: Using PAPI with PPC64 options (-lpapi) ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     SGI64PAPI)
	echo "NOTE: Using PAPI with SGI64 options ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     IBM64PAPI)
	echo "NOTE: Using PAPI with IBM64 options ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     IBM64PAPILINUX)
	echo "NOTE: Using PAPI with IBM64 Linux options ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     IBM64LINUX)
	echo "NOTE: Using IBM64 Linux options ***"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     GNU)
	echo "NOTE: GNU g++ options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     RTTI)
	echo "NOTE: <typeinfo.h> available"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     NORTTI)
	echo "NOTE: No Runtime Type Information available"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     KAINOEX)
	echo "NOTE: Using KAI with no exceptions for compiling"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     SGICCNOEX)
	echo "NOTE: Using SGI CC with no exceptions for compiling"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     SETNODE0)
	echo "NOTE: Using default node no of 0 instead of -1"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     HP_FORTRAN)
	echo "NOTE: HP Fortran compiler specific options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     GNU_FORTRAN)
	echo "NOTE: GNU f77 Fortran compiler specific options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     SC_GFORTRAN)
	echo "NOTE: SiCortex scgfortran compiler specific options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     G95_FORTRAN)
	echo "NOTE: g95 compiler specific options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     GNU_GFORTRAN)
	echo "NOTE: GNU gfortran compiler specific options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     SGI_FORTRAN)
	echo "NOTE: SGI f90 compiler specific options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     IBM_FORTRAN)
	echo "NOTE: IBM xlf90 compiler specific options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     IBMXLFAPPLE)
	echo "NOTE: IBM XLF compiler for Apple Mac OS X options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     IBMXLCAPPLE)
	echo "NOTE: IBM xlC/xlc++ compiler for Apple Mac OS X options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     IBM64_FORTRAN)
	echo "NOTE: IBM 64 bit f90 compiler specific options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     THREADSAFE_COMPILERS)
	echo "NOTE: Using xlf90_r instead of xlf90 IBM compiler"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     CRAY_FORTRAN)
	echo "NOTE: Cray f90 compiler specific options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     CRAY_X1_FORTRAN)
	echo "NOTE: Cray ftn compiler specific options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PGI_FORTRAN)
	echo "NOTE: PGI pgf90 compiler specific options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     PGI_CATAMOUNT)
	echo "NOTE: Catamount PGI pgf90 compiler specific options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     ABSOFT_FORTRAN)
	echo "NOTE: Absoft f90 compiler specific options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     LAHEY_FORTRAN)
	echo "NOTE: Lahey lf95 compiler specific options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     LAHEY64_FORTRAN)
	echo "NOTE: Lahey lf95 64 bit compiler specific options used"
	echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     NAGWARE_FORTRAN)
	echo "NOTE: NAGWARE f95 compiler specific options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     FUJITSU_FORTRAN)
	echo "NOTE: Fujitsu F90 compiler specific options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     NEC_FORTRAN)
	echo "NOTE: NEC f90 compiler specific options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     SUN_FORTRAN)
	echo "NOTE: Sun f90 compiler specific options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     COMPAQ_FORTRAN)
	echo "NOTE: Compaq f90 compiler specific options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     KAI_FORTRAN)
	echo "NOTE: KAI guidef90 compiler specific options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     INTEL_FORTRAN)
	echo "NOTE: Intel efc compiler specific options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     INTEL32_FORTRAN)
	echo "NOTE: Intel ifc compiler specific options used"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     INTELIFORT)
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     INTEL32_ON_64)
	echo "NOTE: Using 32-bit Intel compilers on a 64-bit machine"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     INTEL81FIX)
	echo "NOTE: Using -cxxlib-gcc and gcc libraries to link with ifort"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     INTEL10FIX)
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     COMPINST_GNU)
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     COMPINST_PGI)
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     COMPINST_XL)
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     COMPINST_INTEL9)
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     FORCESHARED)
	echo "NOTE: Using Shared Libraries by default"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     NOSHARED)
	echo "NOTE: Disabling building of shared objects"
        echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
	;;
     *)
	echo "ERROR: Unknown argument directive \`$1' to FixMakefile"
	;;
    esac

shift
done

#############################################################################
# Ok, I have built up $sedout, now apply it to all the Makefile\* I can find!
#############################################################################

# OK, stop here, and let another script actually hack all the Makefiles
echo "Script to modify Makefiles created."

