# 68000 Compiler buildtemplate

VPATH	= ../mi
MI	= $(VPATH)

SPECINCLUDES = -I$(MI)

#ifdef UNIX
OPTS = -O -I/usr/sun/include -DBOOTSTRAP -DFLEXNAMES -DStanford
#else
OPTS = -DBOOTSTRAP -DFLEXNAMES -DStanford
#endif

SRCS =		xdefs.c scan.c pftn.c trees.c optim.c code.c local.c \
		reader.c local2.c order.c match.c allo.c comm1.c table.c \
		stab.c
ALLSRCS =	cgram.c $(SRCS)

O    =		$(OBJSUFFIX)
OBJS =		cgram.$O xdefs.$O scan.$O pftn.$O trees.$O optim.$O code.$O \
		local.$O reader.$O local2.$O order.$O match.$O allo.$O \
		comm1.$O table.$O stab.$O

all: ccom68.$(MACHINE)

ccom68.$(MACHINE): $(OBJS)
	$(CC) $(MIFLAGS) $< -o $@ $(MDFLAGS) $(LIBRARIES)

.c.$O:
	$(CC) $(OPTS) $(MIFLAGS) $(SPECINCLUDES) $(INCLUDES) -c $*.c
# ^ What we really want is to tack $(OPTS) onto the normal rule in
#   /xV/cmds/{m68k,vax,unix,...}/buildtemplate.  Is there a way?


install: ccom68.$(MACHINE)
#ifdef UNIX
	rcp $< $(UNIXDESTDIR)/ccom68
#else
	$(NETINSTALL) -p $< $(VSYS)/bin
#endif

depend: $(SRCS)
	makedep -N $(INCLUDES) $(SPECINCLUDES) -t $(MACHINE) -e $O $<
# We make "depend" dependent on $(SRCS) so we can the use $<, which generates
#	paths to the source files - which helps a lot.
# Note how we pick up the include files.  Dunno whether this always does what
#	we want; maybe we need a -$(Xx)V as well - but not if UNIX?  What we
#	really want is the same bunch of includes that are given to the compiler
#	(including any generated by the compiler front end).
#	Haven't really got this right - should also match OPTS declaration
#	above.
 
cgram.c: cgram.y
	yacc $<
	mv y.tab.c cgram.c
# ^ Does this dependency actually get used, or are we misleading build into
#   thinking that cgram.c exists in its own right?
# ^ And, will this end up putting a copy of cgram.c in each machine directory?
#   Does this bear any relation to what we really want?

clean:
	rm -f cgram.c *.$O *BAK *CKP ccom68.$(MACHINE)

relink:
	rm -f ccom68.$(MACHINE)
