### this is the default makefile for DOS: default.mk
# MicroSoft C Makefile for ELVIS - a clone of `vi`
#
# Use `make` to compile all programs
# Use `make install` to copy the programs to the BIN directory
# Use `make clean` to remove all object files
# Use `make clobber` to remove everything except source & documentation
# Use `make tags` to build new "tags" and "refs" files
# Use `make sh` to produce shar archives of the source

.SUFFIXES : .exe .obj .c

#	C section

CC	 = cl

.c.exe	 :
	 $(CC) $(CFLAGS) -c -Fo$*.obj $<
	 $(CC) -Fe$@ $*.obj 
	 $(RM) $*.obj
.c.obj:
	$(CC) $(CFLAGS) -c $<

LINK.c	= link

MODEL	= s

WILD	= c:\LIB\setargv.obj

SHELL	= command /c

RM	= del

CP	= copy /u

BIN=c:\BIN

LIB=c:\C\TC\LIB

PROGS=	elvis.exe ctags.exe ref.exe virec.exe wildcard.exe refont.exe \
	ex.exe vi.exe view.exe 

OBJS=	blk.obj cmd1.obj cmd2.obj curses.obj cut.obj ex.obj input.obj \
	main.obj misc.obj modify.obj move1.obj move2.obj move3.obj \
	move4.obj move5.obj  opts.obj recycle.obj redraw.obj regexp.obj \
	regsub.obj tio.obj tmp.obj vars.obj vcmd.obj vi.obj \
	system.obj pc.obj sysdos.obj tinytcap.obj
#
# The utilities fit into 64K code + 64K data just fine.
#

CFLAGS_UTIL=	-AS -Olt

#
# Elvis has too much code for the SMALL model, but not much data.
#

CFLAGS=	-AM -Olt -DCS_IBMPC -DCS_SPECIAL -DSETARGV=1

all: $(PROGS) tags refs 

elvis.exe: $(OBJS)
	link @elvis.lnk

#
# This just says that a change to nomagic.c is effectively a change to regexp.c
#

regexp.obj: nomagic.c

ctags.exe: ctags.c config.h
	 $(CC) $(CFLAGS_UTIL) -c -Fo$*.obj $*.c
	 $(CC) -Fe$@ $*.obj 

ref.exe: ref.c
	 $(CC) $(CFLAGS_UTIL) -c -Fo$*.obj $*.c
	 $(CC) -Fe$@ $*.obj 

virec.exe: virec.c config.h vi.h
	 $(CC) $(CFLAGS_UTIL) -c -Fo$*.obj $*.c
	 $(CC) -Fe$@ $*.obj 

wildcard.exe: wildcard.c
	 $(CC) $(CFLAGS_UTIL) -c -Fo$*.obj $*.c
	 $(CC) -Fe$@ $*.obj 
	
refont.exe: refont.c
	 $(CC) $(CFLAGS_UTIL) -c -Fo$*.obj $*.c
	 $(LINK.c) /stack:0x4000 $*.obj, $@,,; 

ex.exe: alias.c
	 $(CC) $(CFLAGS_UTIL) -c -Foalias.obj alias.c
	 $(CC) -Feex.exe alias.obj 

vi.exe: ex.exe
	$(CP) ex.exe vi.exe

view.exe: ex.exe
	$(CP) ex.exe view.exe

install: $(PROGS)
	$(CP) $(PROGS) $(BIN)

clean:
	$(RM) *.obj

clobber: clean
	$(RM) tags refs $(PROGS)

which:
	@echo 'MicroSoft-C'

tags refs: ctags.exe
	ctags -r *.c *.h

