#
# MSDOS Make utility
# (compile with Wizard C version 2.0)
#

CC =		cc

#DBUG =		-DDBUG
#LIBS =		-ldbug

CFLAGS =	-O $(DBUG)

H =		make.h

FILES =		$H make.c macro.c token.c parsedir.c file.c osdate.c execute.c

#  This version of make currently does not grok continuation lines with
#  escaped newlines.  To avoid extra long lines, we define some intermediate
#  macros.

OBJS1 =		make.o macro.o token.o parsedir.o file.o osdate.o
OBJS2 =		getdir.o lwtol.o execute.o sys.o
OBJS =		$(OBJS1) $(OBJS2)

LSRC1 =		make.c macro.c token.c parsedir.c file.c osdate.c
LSRC2 =		getdir.c lwtol.c execute.c sys.c
LSRC =		$(LSRC1) $(LSRC2)

DOCUMENTATION = readme make.man makefile

all :		pdmake

pdmake :	$(OBJS)
		$(CC) -o pdmake $(OBJS) $(LIBS)

make.o :	make.c $H
		$(CC) $(CFLAGS) -c make.c

macro.o :	macro.c $H
		$(CC) $(CFLAGS) -c macro.c

token.o :	token.c $H
		$(CC) $(CFLAGS) -c token.c

parsedir.o :	parsedir.c $H
		$(CC) $(CFLAGS) -c parsedir.c

file.o :	file.c $H
		$(CC) $(CFLAGS) -c file.c

execute.o :	execute.c $H
		$(CC) $(CFLAGS) -c execute.c

osdate.o :	osdate.c $H lar.h
		$(CC) $(CFLAGS) -c osdate.c

sys.o :		sys.c $H
		$(CC) $(CFLAGS) -c sys.c

#
#	Makefile for lar.
#

lar.exe : lwtol.o getdir.o lar.o 
	link lar+lwtol+getdir,lar,lar/map

lar.o : lar.lar ( lar.c lar.h )
	cc -c lar.c

#
# Files shared by lar and make.
#

getdir.o :	getdir.c lar.h
		$(CC) $(CFLAGS) -c getdir.c

lwtol.o :	lwtol.c lar.h
		$(CC) $(CFLAGS) -c lwtol.c

#
# Print files associated with MAKE
#

print :
	print make.man $(FILES) makefile

#
# collect source and documentation files
#

collect :
	lar uv make.lar $(FILES) $(DOCUMENTATION)
	lar uv lar.lar lar.c lar.h lwtol.c getdir.c
	lar rv make.lar
	lar rv lar.lar

#
# copy to distribution disk (on A:)
#
distribution :
	copy readme a:
	copy make.man a:
	copy makefile a:
	copy make.c a:
	copy macro.c a:
	copy token.c a:
	copy parsedir.c a:
	copy file.c a:
	copy osdate.c a:
	copy execute.c a:
	copy lar.h a:
	copy lar.c a:
	copy getdir.c a:
	copy lwtol.c a:
	copy makemake.exe a:



lint:
	lint $(LSRC) >lint.out
