######################################################################
#
#	Makefile for dgrep and test programs
#
######################################################################

dgrep:	dgrep.exe
try:	try.exe
asm:	bm.asm dfaregex.asm

!if $d(DEBUG)
DBG	= -v -O-
LDBG	= -lv
!endif

!if $d(TEST)
TST	= -DTEST
!endif

!if $d(FAST)
FAST	= -DFAST
!endif

MDL	= s

WILDARG	= \usr\lib\$(MDL)setargv.obj

CC	= tcc
CFLAGS	= -w -Z -O -G -K -d -c -m$(MDL) -DECTYPE $(DBG) $(TST) $(FAST)

LINK	= tcc
LFLAGS	= $(LDBG)
LIBS	= c$(MDL)jr.lib		# for getopt

ASMF	= -S

ASM	= tasm
ASMFLAGS= /ml

DFAOBJ	= dfaregex.obj dfa.obj calcpos.obj dfatree.obj regmust.obj set.obj clib.obj
	  
DGREPOBJ = dgrep.obj bm.obj $(DFAOBJ)

dgrep.exe: $(DGREPOBJ)
	$(LINK) $(LFLAGS) $(DGREPOBJ) $(WILDARG) $(LIBS)

TRYOBJ = try.obj $(DFAOBJ)

try.exe: $(TRYOBJ)
	$(LINK) $(LFLAGS) $(TRYOBJ) $(LIBS)

.c.obj:
	$(CC) $(CFLAGS) $<

.c.asm:
	$(CC) $(ASMF) $(CFLAGS) $<

dfa.h:		set.h

dgrep.obj:	dgrep.c dfaregex.h dfa.h bm.h system.h
bm.obj:		bm.c bm.h dfa.h system.h
dfaregex.obj:	dfaregex.c dfaregex.h dfa.h system.h
dfa.obj:	dfa.c dfa.h system.h
calcpos.obj:	calcpos.c dfa.h system.h
dfatree.obj:	dfatree.c dfa.h system.h
regmust.obj:	regmust.c dfa.h system.h
set.obj:	set.c set.h system.h
clib.obj:	clib.c system.h
try.obj:	try.c dfaregex.h

bm.asm:		bm.c bm.h dfa.h system.h
dfaregex.asm:	dfaregex.c dfaregex.h dfa.h system.h
