# Makefile for public domain tar program.
# @(#)Makefile 1.21	87/07/31

# Berserkeley version
DEFS = -DBSD42
LIBS = 
LINTFLAGS = -abchx
DEF_AR_FILE = \"/dev/rmt8\"
DEFBLOCKING = 20

# USG version
#DEFS = -DUSG
#LIBS = -lndir
#LINTFLAGS = -bx
#DEF_AR_FILE = \"/dev/rmt8\"
#DEFBLOCKING = 20

# UniSoft's Uniplus SVR2 with NFS
#DEFS = -DUSG -DUNIPLUS -DNFS -DSVR2
#LIBS = -lndir
#LINTFLAGS = -bx
#DEF_AR_FILE = \"/dev/rmt8\"
#DEFBLOCKING = 20

# MASSCOMP version
#CC = ucb cc
#DEFS = -DBSD42
#LIBS = 
#LINTFLAGS = -bx
#DEF_AR_FILE = \"/dev/rmt0\"
#DEFBLOCKING = 20

# V7 version
# Pick open3 emulation or nonexistence.  See open3.h, port.c.
##DEFS = -DV7 -DEMUL_OPEN3 -Dvoid=int
##DEFS = -DV7 -DNO_OPEN3 -Dvoid=int
#LIBS = -lndir
#LINTFLAGS = -abchx
#DEF_AR_FILE = \"/dev/rmt8\"
#DEFBLOCKING = 20

# Minix version
# No lint, so no lintflags.  Default file is stdin/out.  (Minix "tar"
# doesn't even take an "f" flag, it assumes argv[2] is the archive name!)
# Minix "make" doesn't expand macros right, so Minix users will have
# to expand CFLAGS, SRCS, etc by hand, or fix your make.  Not my problem!
# You'll also need to come up with getopt() and ctime(), the directory
# library, and a fixed doprintf() that handles %*s.  Put this stuff in
# the "SUBSRC/SUBOBJ" macro below if you didn't put it in your C library.
#
# Pick open3 emulation or nonexistence.  See open3.h, port.c.
##DEFS = -DV7 -DMINIX -DEMUL_OPEN3
##DEFS = -DV7 -DMINIX -DNO_OPEN3
#LIBS =
#DEF_AR_FILE = \"-\"
#DEFBLOCKING = 8	/* No good reason for this, change at will */

CFLAGS = $(COPTS) $(ALLDEFS)
ALLDEFS = $(DEFS) \
	-DDEF_AR_FILE=$(DEF_AR_FILE) \
	-DDEFBLOCKING=$(DEFBLOCKING)
# next line for Debugging
COPTS = -g
# next line for Production
#COPTS = -O

# Add things here like getopt, readdir, etc that aren't in your
# standard libraries.
SUBSRC=	
SUBOBJ=	

# Destination directory and installation program for make install
DESTDIR = /usr/pd
INSTALL = cp

SRC1 =	tar.c create.c extract.c buffer.c getoldopt.c list.c
SRC2 =	names.c diffarch.c port.c $(SUBSRC)
SRCS =	$(SRC1) $(SRC2)
OBJS = 	tar.o create.o extract.o buffer.o getoldopt.o list.o names.o \
	diffarch.o port.o $(SUBOBJ)
AUX =	README PORTING Makefile TODO tar.1 tar.5 tar.h port.h open3.h

all:	tar

tar:	$(OBJS)
	$(CC) -o tar $(COPTS) $(OBJS) $(LIBS)

install: all
	rm -f $(DESTDIR)/tar $(DESTDIR)/.man/tar.[15]
	$(INSTALL) tar   $(DESTDIR)/tar
	$(INSTALL) tar.1 $(DESTDIR)/.man/tar.1
	$(INSTALL) tar.5 $(DESTDIR)/.man/tar.5

lint:	$(SRCS)
	lint $(LINTFLAGS) $(ALLDEFS) $(SRCS)

clean:
	rm -f errs *.o tar

tar.shar: $(SRCS) $(AUX)
	shar >tar.shar1 $(SRC1)
	shar >tar.shar2 $(AUX) $(SRC2)

tar.tar.Z: $(SRCS) $(AUX)
	/bin/tar cf - $(AUX) $(SRCS) | compress -v >tar.tar.Z

$(OBJS): tar.h port.h
