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

     SUNOS_GCC
     HPUX_ANSI
     HPUX_GCC
     LINUX
   Set the variables for unproto to your version of it.
     SUNOS_UNPROTO_CC
     HPUX_UNPROTO
   The following defines are not tested. This version must be compiled with
   ANSI-cc or with uncompile!
     MINIX_BCCi386  (untested)
     MINIX_GCCi386  (untested)
     MIPS           (untested)

   The following CFLAGS are supported:

   MOUSY        use code for mouse preparation (see doc/MOUSY!)
   alias_count  -Dalias_count=xx sets number of aliases (default 128)
   macro_lg     -Dmacro_lg=xx sets length of OCL macros (default 2048 tokens)
   var_count    -Dvar_count=xx sets number of OCL variables (default 256)
   tag_count    -Dtag_count=xx sets number of OCL @use tags (default alias_count+128)
   op_count     -Dop_count=xx sets number of OCL macros (default 256)
   f_s_depth    -Df_s_depth=xx sets the stackdepth for filed-folds (default 4)
   termmax      -Dtermmax=xx sets the maximum number of available terminals (default 8)
   NO_OPTI      -DNO_OPTI replaces the optimizer by a dummy function
   DEFAULT_MOUSE
                -DDEFAULT_MOUSE=xxx sets the mouse-support, wich  is  activated
                in keybind without any -M.. option. The  default  is:
                      xterm, if possible
                 else mgr,   if possible
                 else ""
   XTERM_MOUSE_CODE
                -DXTERM_MOUSE_CODE=xx  sets  the  answering  header,  which  is
                followed by button,x and y-position, default is "\033[M".
   XTERM_MOUSE_LG
                -DXTERM_MOUSE_LG=xx  sets  the  length   of   XTERM_MOUSE_CODE,
                default is 3.
   OLD_OCL     -DOLD_OCL allows the usage of the old fashioned OCL-commands
               like sum-counter
*/
/*}}}  */
/*{{{  SUNOS*/
/*{{{  UNPROTO_CC*/
#ifdef SUNOS_UNPROTO_CC
AWK=            awk
CPP=            unproto
CC=             cc
CPPFLAGS=	-I.. -D_POSIX_SOURCE -DMICE
CFLAGS=		-O
LDFLAGS=
LIBS=           -ltermcap
O=              o
#ifndef BIN_PATH
BIN_PATH=   $(HOME)/bin$(ARCHITECTURE)
#endif
.c.o:
		$(CPP) $(CPPFLAGS) <$< >$*.kr.c
		$(CC) $(CFLAGS) -c -o $@ $*.kr.c
		rm $*.kr.c
#endif
/*}}}  */
/*{{{  GCC*/
#ifdef SUNOS_GCC
AWK=            awk
CC=             gcc
CFLAGS=         -O -ansi -pedantic -Wall -I.. -D_POSIX_SOURCE -DMICE
LDFLAGS=
LIBS=           -ltermcap
O=              o
#ifndef BIN_PATH
BIN_PATH=   $(HOME)/bin$(ARCHITECTURE)
#endif
#endif
/*}}}  */
/*}}}  */
/*{{{  HPUX*/
/*{{{  HPUX_UNPROTO*/
#ifdef HPUX_UNPROTO
AWK=            awk
CPP=            unproto
CC=             cc
CPPFLAGS=       -I.. -D_POSIX_SOURCE -DMICE
CFLAGS=         -O
LDFLAGS=
LIBS=           -ltermcap
O=              o
.c.o:
		$(CPP) $(CPPFLAGS) <$< >$*.kr.c
		$(CC) $(CFLAGS) -c -o $@ $*.kr.c
		rm $*.kr.c
#ifndef BIN_PATH
BIN_PATH=   $(HOME)/bin$(ARCHITECTURE)
#endif
#endif
/*}}}  */
/*{{{  HPUX_ANSI*/
#ifdef HPUX_ANSI
AWK=            awk
CC=             cc
CFLAGS=         +O3 -Aa -I.. -D_POSIX_SOURCE -DMICE
LDFLAGS=
LIBS=           -ltermcap
O=              o
#ifndef BIN_PATH
BIN_PATH=   $(HOME)/bin$(ARCHITECTURE)
#endif
#endif
/*}}}  */
/*{{{  HPUX_GCC*/
#ifdef HPUX_GCC
AWK=            awk
CC=             gcc
CFLAGS=         -O3 -ansi -pedantic -Wall -I.. -D_POSIX_SOURCE -DMICE
LDFLAGS=
LIBS=           -ltermcap
O=              o
#ifndef BIN_PATH
BIN_PATH=   $(HOME)/bin$(ARCHITECTURE)
#endif
#endif
/*}}}  */
/*}}}  */
/*{{{  LINUX*/
#ifdef LINUX
AWK=            gawk
CC=             gcc
CFLAGS=         -Wall -I.. -D_POSIX_SOURCE -DMICE
LDFLAGS=
LIBS=
O=              o
#ifndef BIN_PATH
BIN_PATH=	/usr/local/bin
#endif
#endif
/*}}}  */
/*{{{  MINIX*/
/*{{{  BCCI386*/
#ifdef MINIX_BCCi386
AWK=            bawk
CC=             bcc -3
CFLAGS=         -O -DMICE -D_MINIX -D_POSIX_SOURCE
LDFLAGS=
LIBS=
O=              o
#ifndef BIN_PATH
BIN_PATH=   /usr/local/bin
#endif
#endif
/*}}}  */
/*{{{  GCCi386*/
#ifdef MINIX_GCCi386
AWK=            bawk
CC=             gcc
CFLAGS=         -Wall -O -ansi -pedantic -DMICE -D_MINIX -D_POSIX_SOURCE
LDFLAGS=
LIBS=
O=              o
#ifndef BIN_PATH
BIN_PATH=       /usr/local/bin
#endif
#endif
/*}}}  */
/*}}}  */
/*{{{  MIPS*/
#ifdef MIPS
AWK=            awk
CC=             /posix/bin/cc
CFLAGS=         -I.. -O -D_POSIX_SOURCE -DMICE
LDFLAGS=
LIBS=           /usr/posix/usr/lib/libc.a -L/usr/lib -ltermcap
O=              o
#ifndef BIN_PATH
BIN_PATH=   $(HOME)/bin
#endif
#endif
/*}}}  */

HDRS=           ../h/keys.h ../h/os.h keybind.h ../h/token.h ../h/envvar_str.h

SRCS=           codehelp.c keybind.c keytab.c messages.c misc.c msg.c \
		name.c optmac.c parsecond.c parsemac.c parser.c scanner.c \
		set.c fileio.c

OBJS=           codehelp.$O keybind.$O keytab.$O messages.$O misc.$O msg.$O \
		name.$O optmac.$O parsecond.$O parsemac.$O parser.$O \
		scanner.$O set.$O $(MIPSADD)

keybind:        $(OBJS)
		$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)

msg.c:          msg2c.awk ../origami/msg
		$(AWK) -f msg2c.awk ../origami/msg >msg.c

optmac.$O:	codelg.h

codelg.h:	../h/tokens tok2lg.awk
		$(AWK) -f tok2lg.awk ../h/tokens >codelg.h

../h/token.h:   ../h/tokens ../h/tok2h.awk
		$(AWK) -f ../h/tok2h.awk ../h/tokens >../h/token.h

$(OBJS):        $(HDRS)

keybind.$O:	../h/rcformat.h

keytab.$O:	../h/rcformat.h

parser.$O:	../h/rcformat.h

set.$O:		../h/rcformat.h

install:        keybind
		install -d $(BIN_PATH)
		install -s keybind $(BIN_PATH)

deinstall:
		rm -f $(BIN_PATH)/keybind

clean:
		rm -f core symbol.out err.out $(OBJS) msg.c codelg.h *.kr.c

clobber:        clean
		rm -f keybind Makefile ../h/token.h
