#"make all" is performed on the pc using Watcom wmake
#"make dist" and "make clean" are performed on a unix system

CC= wcc386
CCLD= wcl386
CFLAGS=-zp4 -w0 -fpc -ei -DWATCOM=1 -DMSDOS -I..\mcoffinc
LDFLAGS= -k524288 -zp4 -w0 -fpc 

# Host name
H	=wpc

# Object and executable directory
O	=obj\$(H)

# The dist make should be done on the sun4
INSTALL		= \bin\mv
#CLASDIR=clas56
#CLASDIR=clas96
CLASDIR=clas16

DROOT=..\..
#DROOT=\usr1\dsp\software
DIST=dist
DISTDIR=$(DROOT)\$(DIST)\$(H)\$(CLASDIR)
DISTSRC=cldinfo.c cldlod.c cofdmp.c srec.c strip.c tiohist.c cofdmp.h srec.h strip.h makefile
DISTBIN=$(O)\cldinfo.exe $(O)\cldlod.exe $(O)\cofdmp.exe $(O)\srec.exe $(O)\strip.exe $(O)\tiohist.exe
DISTOBJ=$(O)\cldinfo.obj $(O)\cldlod.obj $(O)\cofdmp.obj $(O)\srec.obj $(O)\strip.obj $(O)\tiohist.obj
DBIN=$(DISTDIR)\bin
DTOOL=$(DISTDIR)\cldtools

.c: .
.obj: $(O)
.exe: $(O)

.c.obj:
	$(CC) $(CFLAGS) -fo=$@ $<

.obj.exe:
	echo OPTION stub=wstubq >resp.pc
	$(CCLD) $< $(LDFLAGS) -fe=$@ @resp.pc
	del resp.pc


# use Watcom wmake to make all executables in .\obj\wpc
all: $(DISTOBJ) $(DISTBIN) .SYMBOLIC
	%null


# unix to dos source file conversion 
ud: ud.c
	cc -o ud ud.c

# copy distribution files to $(DROOT)\$(DIST)\clasnn\bin and $(DROOT)\$(DIST)\clasnn\wpc
$(DIST): ud
	test -d $(DROOT)\$(DIST) || mkdir $(DROOT)\$(DIST)
	test -d $(DROOT)\$(DIST)\$(H) || mkdir $(DROOT)\$(DIST)\$(H)
	test -d $(DISTDIR) || mkdir $(DISTDIR)
	test -d $(DBIN) || mkdir $(DBIN)
	test -d $(DTOOL) || mkdir $(DTOOL)
	for i in ${DISTBIN} ; do cp $$i $(DBIN)\. ; done
	for i in ${DISTSRC} ; do .\ud $$i $(DTOOL)\. ; done

# use unix make to remove obj\wpc
clean: obdir
	rm -f obj\$(H)\*

obdir: 
	test -d obj || mkdir obj
	test -d obj\$(H) || mkdir obj\$(H)










