.key InstallDir
.bra {
.ket }

; This script will copy all existing executables and needed files to
; origami:amiga/bin.
; All files from origami:amiga/bin into the directory specified.

; Makeing amiga/bin directory
cd origami:
if not exists amiga/bin
  makedir amiga/bin
endif

; Coping existing executables
if exists origami/origami
  copy origami/origami amiga/bin/origami
  delete origami/origami
endif
if exists origami/.origamimsg
  copy origami/.origamimsg amiga/bin/.origamimsg
  delete origami/.origamimsg
endif

if exists keybind/keybind
  copy keybind/keybind amiga/bin/keybind
  delete keybind/keybind
endif

if exists viewrc/viewrc
  copy viewrc/viewrc amiga/bin/viewrc
  delete viewrc/viewrc
endif

if exists pager/oripager
  copy pager/oripager amiga/bin/oripager
  delete pager/oripager
endif

if exists dirfold/dirfold
  copy dirfold/dirfold amiga/bin/dirfold
  delete dirfold/dirfold
endif

if exists amiga/MakeDiffs
  copy amiga/MakeDiffs amiga/bin/MakeDiffs
  delete amiga/MakeDiffs
endif

if exists amiga/GetKeyCode
  copy amiga/GetKeyCode amiga/bin/GetKeyCode
  delete amiga/GetKeyCode
endif

if exists amiga/refer
  copy amiga/refer amiga/bin/refer
  delete amiga/refer
endif

if exists amiga/mkref
  copy amiga/mkref amiga/bin/mkref
  delete amiga/mkref
endif

if exists amiga/.origamimenu
  copy amiga/.origamimenu
endif

; Makeing emacs-keybind
if exists amiga/bin/keybind
  if exists origami:/
    cd origami:/
    if exists bindings
      cd bindings
      if exists termalias
        rename termalias termalias.old
      endif
      if not exists ami.termalias
        if exists origami:amiga/ami.termalias
          copy origami:amiga/ami.termalias /bindings/ami.termalias
        endif
      endif
      if exists ami.termalias
        copy ami.termalias termalias
        stack 50000
        origami:amiga/bin/keybind -o .origami amiga.keys
        if exists .origamirc
          copy .origamirc origami:amiga/bin/.origamirc
          delete .origamirc
        endif
        origami:amiga/bin/keybind -s -U c-mode -o .c- amiga.keys
        if exists .c-rc
          copy .c-rc origami:amiga/bin/.c-rc
          delete .c-rc
          copy origami:amiga/bin/.origamimsg origami:amiga/bin/.c-msg
        endif
        delete termalias
      endif
      if exists termalias.old
        rename termalias.old termalias
      endif
    endif
  endif
endif

; Install in $(INSTALLDIR)
if not "X{InstallDir}" eq "X"
  if exists {InstallDir}
    copy origami:amiga/bin/#? {InstallDir}
  endif
endif

cd origami:amiga
