#CC=cc -DHPDAT -O2
# if you have an dds2-device, uncomment the following line :
CC=cc -DHPDAT -DHPDAT4 -O2
TAR=tar
V=2.0.0
ARCHIVE=\
dds2tar-$(V)/Makefile \
dds2tar-$(V)/Changes \
dds2tar-$(V)/README \
dds2tar-$(V)/dds2tar.1 \
dds2tar-$(V)/dds2index.1 \
dds2tar-$(V)/mt-dds.1 \
dds2tar-$(V)/dds2tar.h \
dds2tar-$(V)/dds2tar.c \
dds2tar-$(V)/open_device.c \
dds2tar-$(V)/open_file.c \
dds2tar-$(V)/dds_extract.c \
dds2tar-$(V)/dds_index.c \
dds2tar-$(V)/dds_tapepos.c \
dds2tar-$(V)/dat.c \
dds2tar-$(V)/COPYING \


OBJ= open_device.o dds_index.o dds_extract.o dds_tapepos.o \
	open_file.o dat.o

all: dds2tar

dds2tar: dds2tar.o $(OBJ)
	$(CC) dds2tar.o $(OBJ)  -o dds2tar
	strip dds2tar

dds2index: dds2index.o $(OBJ)
	$(CC) dds2index.o $(OBJ)  -o dds2index
	strip dds2index

mt-dds: mt-dds.o $(OBJ)
	$(CC) mt-dds.o $(OBJ)  -o mt-dds
	strip mt-dds

install: dds2tar
	install -c -s dds2tar /usr/bin
	install dds2tar.1 /usr/man/man1
	install dds2index.1 /usr/man/man1
	install mt-dds.1 /usr/man/man1
	rm /usr/bin/dds2index /usr/bin/mt-dds
	ln /usr/bin/dds2tar /usr/bin/dds2index
	ln /usr/bin/dds2tar /usr/bin/mt-dds

tar: 
	cd .. ; echo ' ' ; $(TAR) -R -c -f dds2tar-$(V).tar -v $(ARCHIVE) ; echo ' '
	gzip -9 -f ../dds2tar-$(V).tar
	cp dds2tar.lsm ../dds2tar-$(V).lsm
	ls -l ../dds2tar*z ../dds2tar*.lsm

.c.o:
	$(CC) -c $< 

clean:
	rm $(OBJ) dds2tar.o dds2index.o mt-dds.o *.BAK
	rm dds2tar

doc:
	                a2ps -p -nP    [A-Z]* *.h *.c *.lsm > a.ps
	man dds2tar   | a2ps -p -nP -m -Hdds2tar            > b.ps
	man dds2index | a2ps -p -nP -m -Hdds2index          > c.ps
	man mt-dds    | a2ps -p -nP -m -Hmt-dds.1.ps        > d.ps

dds2tar.o:dds2tar.c dds2tar.h
	$(CC) -c dds2tar.c -DPROGRAM=DDS2TAR -o dds2tar.o
dds2index.o:dds2tar.c dds2tar.h
	$(CC) -c dds2tar.c -DPROGRAM=DDS2INDEX -o dds2index.o
mt-dds.o:dds2tar.c dds2tar.h
	$(CC) -c dds2tar.c -DPROGRAM=MTDDS -o mt-dds.o
dds_index.o:dds_index.c dds2tar.h
dds_extract.o:dds_extract.c dds2tar.h
dds_tapepos.o:dds_tapepos.c dds2tar.h
open_device.o:open_device.c dds2tar.h
open_file.o:open_file.c dds2tar.h

