#!/bin/sh
 
 # mk_reply
 # ========
   
 # This file is part of Gerolf Markup Shredder,
 # written by G. D. Brettschneider(1999-2006). All rights reserved.
 # Send corrections to: MarkupShredder(at)Gerolf.de (www.Gerolf.de)
 
 GMSdateMK_REPLY=20061224
   
 # ============================================================================
  
 # This script just helps to compile 'reply.c' (expected to be placed in 
 # '$GMS_ROOT/doc/reply), to view error messages, and to move 'reply' to
 # the binary folder ('$GMS_ROOT/bin/linux'):
 
 # Start shell:
 if [ "$1" = "" ]; then   
    xterm -fg black -bg white -e "$0" -shell
    exit 1
 fi
 
 # Compile reply.c, if present: 
 replydir=$(dirname "$0")
 cd "$replydir"
 if [ -f "$replydir/reply.c" ]; then 
   echo; echo "Compiling 'reply'..."
   gcc -o reply reply.c -Lstring 2> reply.log   
 else
   echo; echo "Could not find '$replydir/reply.c'!"
   sleep 1
   exit 2
 fi
 
 # Check for success: 
 if [ -f "$replydir/reply" ]; then 
   echo; echo "Compilation successful."
 else
   echo; echo "Compilation failed."; echo
   less < "$replydir/reply.log"
   sleep 1
   exit 3
 fi
 
 # Move 'reply' to ../bin/linux, if that folder is present: 
 OLDDIR=$PWD
   if [ -d ../../bin/linux ]; then
     cd ../../bin/linux
     NEWDIR=$PWD
       cd "$OLDDIR"
       echo; echo "Moving 'reply' to $NEWDIR ..." 
       mv "$replydir/reply" "$NEWDIR"
       echo; echo "Done." 
     NEWDIR=
     sleep 1
   fi 
 OLDDIR=
