# $Id: Makefile,v 1.9 1996/07/15 23:20:03 venkat Exp $
# $Log: Makefile,v $
# Revision 1.9  1996/07/15 23:20:03  venkat
# Added -D$(MACHINE) to CFLAGS macro for dealing with the order of
# include of lex.yy.c in script.y.
#
# Revision 1.8  1995/12/13  23:45:41  dhb
# Changed explict cc to use the CC macro.
#
# Revision 1.7  1995/05/08  21:44:17  dhb
# Now removes y.tab.[ch] and lex.yy.c on make clean.
#
# Revision 1.6  1995/04/29  01:14:15  dhb
# Added use of YACC, LEX and LEXLIB macros to control processing of
# yacc and lex files and what lex library to use.
#
# Revision 1.5  1995/04/01  19:11:59  dhb
# Added installation of convert.doc and convert.man to install target.
#
# Revision 1.4  1995/03/27  18:51:30  dhb
# - Changed to use top level CFLAGS
# - Added a chmod in the install target to make sure installed X1compat
#   scripts are writable
#
# Revision 1.3  1995/02/13  21:36:16  dhb
# Removed checkout of RCSRELEASE versions.
# Added convert to things removed in clean target.
#
# Revision 1.2  1995/01/25  02:10:09  dhb
# Modified install target to install convert program and X1compat
# scripts.
#
# Revision 1.1  1995/01/13  01:09:48  dhb
# Initial revision
#

CFLAGS = $(COPT) -D$(MACHINE)
INSTALL_DIR =	$(INSTALL)
X1COMPAT_DIR =	$(INSTALL_DIR)/Scripts/X1compat
OBJ = \
      convert.o \
      output.o \
      mapcommand.o \
      script.o \
      strsave.o \
      symtab.o \
      ../sys/getopt.o

default: convert


convert: $(OBJ)
	$(CC) $(OBJ) $(LEXLIB) -o convert

script.o: y.tab.c lex.yy.c
	$(CC) -c $(CFLAGS) y.tab.c
	mv y.tab.o script.o

lex.yy.c: script.l
	$(LEX) script.l

y.tab.h y.tab.c: script.y
	$(YACC) -dv script.y

realclean:
	-(rm -rf *.o y.tab.h y.tab.c lex.yy.c convert)

install:
	-(cp convert $(INSTALL_DIR))
	-if test ! -d $(X1COMPAT_DIR); then mkdir $(X1COMPAT_DIR); fi
	-cp X1compat/*.g $(X1COMPAT_DIR)
	-chmod +w $(X1COMPAT_DIR)/*.g
	-if test ! -d $(INSTALL_DIR)/man; then mkdir $(INSTALL_DIR)/man $(INSTALL_DIR)/man/man1; fi
	-if test ! -d $(INSTALL_DIR)/man/man1; then mkdir $(INSTALL_DIR)/man/man1; fi
	-cp convert.man $(INSTALL_DIR)/man/man1/convert.1
	-cp convert.doc $(INSTALL_DIR)/Doc

clean:
	-(rm -rf *.o y.tab.h y.tab.c lex.yy.c convert)


# mds3
# New line needed to prevent getting default rule if using cross compilers
.c.o:
	$(CC) $(CFLAGS) $(SIMINCLUDE) $< -c
