/*{{{  possible switches*/
/*
   Use the following configuration symbols to generate a makefile for
   your system with "/usr/lib/cpp -DCONFIG Makefile.cpp >Makefile"

   SUNOS_UNPROTO_CC
   SUNOS_GCC
   HPUX_UNPROTO
   HPUX_ANSI
   LINUX
   MINIX_BCCi386  (untested)
   MINIX_GCCi386  (untested)
   MIPS           (untested)

   If you call keybind with option -r<file>, it will generate a reference
   card when compiling the keybinding.  Since we never used reference cards,
   this option is not set anywhere in the rules.

*/
/*}}}  */
/*{{{  SUNOS*/
#if (defined(SUNOS_UNPROTO_CC) || defined(SUNOS_GCC))
#ifndef ORIGAMI_PATH
ORIGAMI_PATH=   $(HOME)/origami
#endif
#ifndef RC_PATH
RC_PATH=        $(HOME)/origami
#endif
#ifndef DOC_PATH
DOC_PATH=       $(HOME)/origami/doc
#endif
TERMINALS=      xterm s\un mgr
MODEORIFLAG=    -M xterm
#endif
/*}}}  */
/*{{{  HPUX*/
#if (defined(HPUX_UNPROTO) || defined(HPUX_ANSI) || defined(HPUX_GCC))
#ifndef ORIGAMI_PATH
ORIGAMI_PATH=   $(HOME)/origami
#endif
#ifndef RC_PATH
RC_PATH=        $(HOME)/origami
#endif
#ifndef DOC_PATH
DOC_PATH=       $(HOME)/origami/doc
#endif
TERMINALS=      vt100 xterm
MODEORIFLAG=    -M xterm
#endif
/*}}}  */
/*{{{  MINIX, LINUX*/
#if (defined(MINIX_BCCi386) || defined(MINIX_GCCi386) || defined(LINUX))
#ifndef ORIGAMI_PATH
ORIGAMI_PATH=   /usr/local/origami
#endif
#ifndef RC_PATH
RC_PATH=        /usr/local/origami
#endif
#ifndef DOC_PATH
DOC_PATH=       /usr/local/origami/doc
#endif
TERMINALS=	$(TERM)
MODEORIFLAG=    -U BASE
#endif
/*}}}  */
/*{{{  MIPS*/
#if defined(MIPS)
#ifndef ORIGAMI_PATH
ORIGAMI_PATH=   $(HOME)/origami
#endif
RC_PATH=        $(HOME)/origami
#ifndef DOC_PATH
DOC_PATH=       $(HOME)/origami/doc
#endif
TERMINALS=      vt100 xterm
MODEORIFLAG=    -M xterm
#endif
/*}}}  */

install:	oclinstall bindinstall

$(DOC_PATH):
		install -d $(DOC_PATH)

$(RC_PATH):
		install -d $(RC_PATH)

oclinstall:     $(RC_PATH) $(DOC_PATH) deinstall term
		install -d $(ORIGAMI_PATH)/bindings/fun
		install -d $(ORIGAMI_PATH)/bindings/modeori-fun
		install -d $(ORIGAMI_PATH)/bindings/emacs-fun
		install *.keys $(ORIGAMI_PATH)/bindings
		install fun/?* $(ORIGAMI_PATH)/bindings/fun
		install modeori-fun/?* $(ORIGAMI_PATH)/bindings/modeori-fun
		install termalias termlist $(ORIGAMI_PATH)/bindings

bindinstall:	eminstall moinstall mtinstall


term:		Makefile
		echo "; This file is generated by autoalias(1)" >termalias
		for i in $(TERMINALS); do autoalias -t $$i >>termalias; done
		echo "; This file is generated by autoalias(1)" >termlist
		echo "(" >termlist
		echo $(TERMINALS) >>termlist
		echo ")" >>termlist

emacs:		term
		keybind -sOR -U TERM -o .origami emacs.keys

eminstall:	emacs
		install -d $(RC_PATH)
		install .origamirc $(RC_PATH)

modeori:        .modeorirc .modeorihelp

.modeorihelp .modeorirc:	modeori.keys modeori-fun/?* fun/?*
		keybind -sO -r .modeorihelp $(MODEORIFLAG) -o .modeori modeori.keys

moinstall:	morcinstall $(DOC_PATH)/modeori.ref

$(DOC_PATH)/modeori.ref:	morcinstall
		ln $(RC_PATH)/.modeorihelp $(DOC_PATH)/modeori.ref


morcinstall:	modeori $(RC_PATH)
		install -d $(RC_PATH)
		install .modeorirc $(RC_PATH)
		install .modeorihelp $(RC_PATH)

mtorigami:
		keybind -s -o .mtorigami mtool.keys

mtinstall:	mtorigami
		install -d $(RC_PATH)
		install .mtorigamirc $(RC_PATH)

deinstall:
		rm -rf $(ORIGAMI_PATH)/bindings
		rm -f $(RC_PATH)/.origamirc
		rm -f $(RC_PATH)/.modeorirc
		rm -f $(RC_PATH)/.modeorihelp
		rm -f $(RC_PATH)/.mtorigamirc
		rm -f $(DOC_PATH)/modeori.ref

clobber:
		rm -f Makefile termalias termlist .*rc .*help
