Code Search for Developers
 
 
  

fix.sh from Allegro game programming library at Krugle


Show fix.sh syntax highlighted

#!/bin/sh
#
# Sets up the Allegro package for building with the specified compiler,
# and if possible converting text files to the desired target format.

proc_help()
{
   echo
   echo "Usage: ./fix.sh <platform> [--quick|--dtou|--utod|--utom|--mtou]"
   echo
   echo "Where platform is one of: bcc32, beos, djgpp, mingw32, msvc, qnx, unix"
   echo "mac and watcom."
   echo "The --quick parameter turns of text file conversion, --dtou converts from"
   echo "DOS/Win32 format to Unix, --utod converts from Unix to DOS/Win32 format,"
   echo "--utom converts from Unix to Macintosh format and --mtou converts from"
   echo "Macintosh to Unix format. If no parameter is specified --dtou is assumed."
   echo

   AL_NOCONV="1"
}

proc_fix()
{
   echo "Configuring Allegro for $1..."

   if [ "$2" != "none" ]; then
      echo "# generated by fix.sh" > makefile
      echo "MAKEFILE_INC = $2" >> makefile
      echo "include makefile.all" >> makefile
   fi

   echo "/* generated by fix.sh */" > include/allegro/platform/alplatf.h
   echo "#define $3" >> include/allegro/platform/alplatf.h
}

proc_filelist()
{
   # common files.
   AL_FILELIST=`find . -type f "(" \
      -name "*.c" -o -name "*.cfg" -o -name "*.cpp" -o -name "*.def" -o \
      -name "*.h" -o -name "*.hin" -o -name "*.in" -o -name "*.inc" -o \
      -name "*.m4" -o -name "*.mft" -o -name "*.s" -o -name "*.rc" -o \
      -name "*.spec" -o -name "*.pl" -o -name "*.txt" -o -name "*._tx" -o \
      -name "makefile*" -o -name "*.inl" -o -name "configure" -o \
      -name "CHANGES" -o -name "AUTHORS" -o -name "THANKS" \
   ")"`

   # touch unix shell scripts?
   if [ "$1" != "omit_sh" ]; then
      AL_FILELIST="$AL_FILELIST `find . -type f -name '*.sh'`"
   fi
}

proc_utod()
{
   echo "Converting files from Unix to DOS/Win32..."
   proc_filelist "omit_sh"
   for file in $AL_FILELIST; do
      echo "$file"
      cp $file _tmpfile
      perl -p -i -e "s/([^\r]|^)\n/\1\r\n/" _tmpfile
      touch -r $file _tmpfile
      mv _tmpfile $file
   done
}

proc_dtou()
{
   echo "Converting files from DOS/Win32 to Unix..."
   proc_filelist
   for file in $AL_FILELIST; do
      echo "$file"
      mv $file _tmpfile
      tr -d '\015' < _tmpfile > $file
      touch -r _tmpfile $file
      rm _tmpfile
   done
   chmod +x *.sh misc/*.sh misc/*.pl
   if [ -e configure ]; then
      chmod +x configure
   fi
}

proc_utom()
{
   echo "Converting files from Unix to Macintosh..."
   proc_filelist "omit_sh"
   for file in $AL_FILELIST; do
      echo "$file"
      mv $file _tmpfile
      tr '\012' '\015' < _tmpfile > $file
      touch -r _tmpfile $file
      rm _tmpfile
   done
}

proc_mtou()
{
   echo "Converting files from Macintosh to Unix..."
   proc_filelist
   for file in $AL_FILELIST; do
      echo "$file"
      mv $file _tmpfile
      tr '\015' '\012' < _tmpfile > $file
      touch -r _tmpfile $file
      rm _tmpfile
   done
}

# prepare allegro for the given platform.

case "$1" in
   "bcc32"   ) proc_fix "Windows (BCC32)"   "makefile.bcc" "ALLEGRO_BCC32";;
   "beos"    ) proc_fix "BeOS"              "makefile.be"  "ALLEGRO_BEOS";;
   "djgpp"   ) proc_fix "DOS (djgpp)"       "makefile.dj"  "ALLEGRO_DJGPP";;
   "mingw32" ) proc_fix "Windows (Mingw32)" "makefile.mgw" "ALLEGRO_MINGW32";;
   "msvc"    ) proc_fix "Windows (MSVC)"    "makefile.vc"  "ALLEGRO_MSVC";;
   "qnx"     ) proc_fix "QNX"               "makefile.qnx" "ALLEGRO_QNX";;
   "unix"    ) proc_fix "Unix"              "none"         "ALLEGRO_UNIX";;
   "mac"     ) proc_fix "Mac"               "none"         "ALLEGRO_MPW";;
   "watcom"  ) proc_fix "DOS (Watcom)"      "makefile.wat" "ALLEGRO_WATCOM";;
   "help"    ) proc_help;;
   *         ) proc_help;;
esac

# convert all text-file line endings.

if [ "$AL_NOCONV" != "1" ]; then
   case "$2" in
      "--utod"  ) proc_utod;;
      "--dtou"  ) proc_dtou;;
      "--utom"  ) proc_utom;;
      "--mtou"  ) proc_mtou;;
      "--quick" ) echo "No text file conversion...";;
      *         ) proc_dtou;;
   esac
fi

echo "Done!"




See more files for this project here

Allegro game programming library

Allegro is a cross-platform library intended for use in computer games and other types of multimedia programming.

Project homepage: http://sourceforge.net/projects/alleg
Programming language(s): Assembly,C,Shell Script
License: other

  demo/
    demo.c
    demo.h
    music.txt
  docs/
    build/
      bcc32.txt
      beos.txt
      djgpp.txt
      linux.txt
      macos.txt
      mingw32.txt
      msvc.txt
      qnx.txt
      unix.txt
      watcom.txt
    html/
      tmpfile.txt
    info/
      tmpfile.txt
    man/
      tmpfile.txt
    rtf/
      tmpfile.txt
    src/
      abi._tx
      ahack._tx
      allegro._tx
      changes._tx
      const._tx
      faq._tx
      help._tx
      thanks._tx
    texi/
      tmpfile.txt
    txt/
    makedoc.c
  examples/
    allegro.pcx
    ex12bit.c
    ex3buf.c
    ex3d.c
    exaccel.c
    exalpha.c
    example.dat
    example.h
    examples.txt
    exbitmap.c
    exblend.c
    excamera.c
    excolmap.c
    excustom.c
    exdata.c
    exdbuf.c
    exdodgy.c
    exexedat.c
    exfixed.c
    exflame.c
    exflip.c
    exgui.c
    exhello.c
    exjoy.c
    exkeys.c
    exlights.c
    exmem.c
    exmidi.c
    exmouse.c
    expal.c
    expat.c
    exquat.c
    exrgbhsv.c
    exsample.c
    exscale.c
    exscn3d.c
    exscroll.c
    exshade.c
    exspline.c
    exsprite.c
    exstars.c
    exstream.c
    exswitch.c
    extimer.c
    extrans.c
    extruec.c
    exunicod.c
    exupdate.c
    exxfade.c
    exzbuf.c
    mysha.pcx
    planet.pcx
    running.dat
    running.h
    unifont.dat
  include/
    allegro/
    allegro.h
    bealleg.h
    linalleg.h
    macalleg.h
    qnxalleg.h
    winalleg.h
    xalleg.h
  lib/
    bcc32/
    beos/
    djgpp/
    mingw32/
    msvc/
    qnx/
    unix/
    watcom/
  misc/
    alex.xpm
    allegro-config-qnx.sh
    allegro-config.in
    allegro.spec
    askq.c
  obj/
  resource/
  setup/
  src/
  tests/
  tools/
  acconfig.h
  aclocal.m4
  allegro.cfg
  configure.in
  fix.bat
  fix.sh
  fixmpw.sh
  indent.pro
  makefile.all
  makefile.bcc
  makefile.be
  makefile.dj
  makefile.in
  makefile.lst
  makefile.mgw
  makefile.mpw
  makefile.qnx
  makefile.tst
  makefile.vc
  makefile.ver
  makefile.wat
  modules.lst
  readme.txt
  stamp-h.in
  todo.txt
  xmake.sh