#############################################################################
#			  Motorola Time Processor Unit microcode assembler 				#
#############################################################################
#																			#
#	Copyright 1998, (c) Bendor Research Pty. Ltd.							#
#																			#
#	This file is under the GNU General Public License.						#
#	See LICENSE for details.												#
#																			#
#############################################################################
#																			#
#	This file is the makefile (surprise :-) for	the TPU assembler			#
#																			#
#############################################################################
#																			#
#	Changelog:																#
#																			#
#	30/04/98	Zoltan Kocsi	Alpha version								#
#	19/05/98	Joern Tietjen	Modified to work on HP-UX					#
#	20/05/98	Zoltan Kocsi	Added NetBSD 1.1							#
#	25/06/98	Zoltan Kocsi	Added more Joern and Josef changes :-)		#
#																			#
#############################################################################

#
#	Tools may depend on your OS !
#
#	To compile you need:
#
#	-	an ANSI C compiler (gcc is fine but there's nothing
#		gcc specific in the source.
#
#	-	flex. You need flex because the include & macro mechanism uses
#		flex's buffer notion.
#
#	-	bison or yacc
#
#	-	make (in theory, it should work with any make)
#
#	Try to find a suitable definition below or create your own.
#

#
#	You can set the language used in error messages and usage text.
#	Currently ENGLISH, HUNGARIAN and GERMAN can be specified.
#

LANGUAGE = ENGLISH

#
#	This works for DOS with GNUWIN32-b18 on Intel boxes with W95 and NT
#

#CC       = gcc
#YACC     = byacc
#LEX      = flex
#CFLAGS   = -O2 -Wall -g
#YFLAGS   = -d
#LFLAGS   = -i
#LIBS     = -lfl
#PREFIX   = c:/bin
#TPU      = tas.exe

#
#	This works for Linux (RH4.2) on Intel boxes
#	Also works for FreeBSD-stable on Intel boxes
#

CC       = gcc
YACC     = bison
LEX      = flex
CFLAGS   = -O2 -g -ansi -Wall --strict-prototypes --pedantic
YFLAGS   = -d -y
LFLAGS   = -i
LIBS     = -lfl
PREFIX   = /usr/local
TPU      = tas

#
#	This works for NetBSD 1.1 on Amiga (old gcc, BSD yacc)
#

#CC       = gcc
#YACC     = yacc
#LEX      = flex
#CFLAGS   = -O2 -g -D__DONT_USHORT__
#YFLAGS   = -d
#LFLAGS   = -i
#LIBS     = -lfl
#PREFIX   = /usr/local
#TPU      = tas

#
#	This works for HP-UX 9.0x, no GNU tools
#	Note that you *need* flex !!!
#   To compile make distclean ; touch parse.y ; make
#

#CC       = c89
#YACC     = yacc
#LEX      = flex
#CFLAGS   = -Aa
#YFLAGS   =
#LFLAGS   = -i
#LIBS     =
#PREFIX   = /usr/local
#TPU      = tas

#
#	This works for Solaris if you have gcc, bison and flex
#	

#CC       = gcc
#YACC     = bison
#LEX      = flex
#CFLAGS   = -O2 -g -ansi -Wall --strict-prototypes --pedantic
#YFLAGS   = -d -y
#LFLAGS   = -i
#LIBS     =
#PREFIX   = /usr/local
#TPU      = tas


#
#       Hopefully no need to touch anything below this
#

OBJECTS = tokens.o parser.o main.o insn.o direct.o label.o list.o srec.o cinc.o
HEADERS = insn.h tpuasm.h errors.h usage.h cinc.h
YTABH   = y.tab.h
YTABC   = y.tab.c
LEXYYC  = lex.yy.c

$(TPU): $(OBJECTS)
	$(CC) $(CFLAGS) -o $(TPU) $(OBJECTS) $(LIBS)

$(YTABC) $(YTABH):	parser.y
	$(YACC) $(YFLAGS) parser.y

parser.o:	$(YTABC)
	$(CC) $(CFLAGS) -D$(LANGUAGE) -c -o $@ $(YTABC)

$(LEXYYC):	tokens.lex
	$(LEX) $(LFLAGS) tokens.lex

tokens.o:	$(LEXYYC) $(YTABH)
	$(CC) $(CFLAGS) -D$(LANGUAGE) -c -o $@ $(LEXYYC)

#
#	This target removes the lex-generated stuff
#

cleanlex:
	-rm -f $(LEXYYC)

#
#	This target removes the yacc-generated stuff
#

cleanyacc:
	-rm -f $(YTABC) $(YTABH)

#
#	This target removes the core stuff
#

cleancore:
	-rm -f $(TPU) $(OBJECTS) core *~

#
#	This is the usual clean target
#

clean: cleancore cleanyacc cleanlex

#
#	This is a target that cleans but the C and H files generated by
#	yacc & lex are retained.
#

distclean: cleancore
	
$(YTABC):       insn.h tpuasm.h

tokens.o:       parser.o tpuasm.h

$(YTABC) $(LEXYYC) $(OBJECTS):  $(HEADERS)

.c.o:
	$(CC) $(CFLAGS) -D$(LANGUAGE) -c -o $*.o $*.c

print:
	a2ps -l90 -t4 *.*

install: $(TPU)
	cp $(TPU)   $(PREFIX)/bin
	cp $(TPU).1 $(PREFIX)/man/man1
