# Makefile for Zip, ZipNote, ZipCloak and ZipSplit

# SMAKY version

all:
	@echo ''
	@echo 'Make what?  You must say what system to make Zip for--e.g.'
	@echo '"make bsd".  Choices: 3b1, aix, att6300, aux, bsd, bsdold,'
	@echo 'convex, cray, cray3, dec_osf1, dnix, hpux, isc, linux,'
	@echo 'minix, next, next10, scodos, sun, sun_gcc, sysv, sysv_386,'
	@echo 'sysv_old, ultrix, xenix, xos, zilog.'
	@echo 'See the files install.doc and zip.doc for more information.'
	@echo ''

CC = gcc
CRYPTO =
CLOAK =
CRFLAG =
MAKE = make
BIND = gcc
E = .code
DEBUG = 

#  **********************************************************************
#  *** For encryption version, remove the # at the front of next line ***
# MAKE = make CRYPTO="crypt.o" CLOAK="zipcloak" CRFLAG="-DCRYPT"


# probably can change this to 'install' if you have it
INSTALL = cp

# target directories - where to install executables and man pages to
BINDIR = /usr/local/bin
MANDIR = /usr/man/manl

# flags
#   CFLAGS    flags for C compile
#   LFLAGS1   flags after output file spec, before obj file list
#   LFLAGS2   flags after obj file list (libraries, etc)
CFLAGS = $(DEBUG) -O2
LFLAGS1 = $(DEBUG)
LFLAGS2 = -lxp -lsmaky

# object file lists
OBJZ = zip.o zipfile.o zipup.o fileio.o util.o globals.o $(CRYPTO)

OBJI = deflate.o trees.o bits.o
OBJA =
OBJU = zipfile_.o zipup_.o fileio_.o util_.o globals.o
OBJN = zipnote.o  $(OBJU)
OBJC = zipcloak.o $(OBJU) crypt_.o
OBJS = zipsplit.o $(OBJU)

# suffix rules
.SUFFIXES:
.SUFFIXES: _.o .o .c .doc .1
.c_.o:
	$(CC) $(CFLAGS) -DUTIL $(CRFLAG) -c $*.c -o $*_.o
.c.o:
	$(CC) $(CFLAGS) $(CRFLAG) -c $<

.1.doc:
	nroff -man $< | col -b | uniq > $@

# rules for zip, zipnote, zipcloak, zipsplit, and zip.doc.
$(OBJZ): zip.h ziperr.h tailor.h
$(OBJI): zip.h ziperr.h tailor.h
$(OBJN): zip.h ziperr.h tailor.h
$(OBJS): zip.h ziperr.h tailor.h
$(OBJC): zip.h ziperr.h tailor.h

ZIPS = zip$E zipnote$E zipsplit$E
# add $(CLOAK)$E for crypt version

zip.o zipup.o zipnote.o zipcloak.o zipsplit.o: revision.h
zips: $(ZIPS)
zipsman: zip zipnote zipsplit $(CLOAK) zip.doc

zip$E: $(OBJZ) $(OBJI) $(OBJA)
	$(BIND) -o zip$E $(LFLAGS1) $(OBJZ) $(OBJI) $(OBJA) $(LFLAGS2)
zipnote$E: $(OBJN)
	$(BIND) -o zipnote$E $(LFLAGS1) $(OBJN) $(LFLAGS2)
zipcloak$E: $(OBJC)
	$(BIND) -o zipcloak$E $(LFLAGS1) $(OBJC) $(LFLAGS2)
zipsplit$E: $(OBJS)
	$(BIND) -o zipsplit$E $(LFLAGS1) $(OBJS) $(LFLAGS2)

# install
install:	$(ZIPS)
	$(INSTALL) $(ZIPS) $(BINDIR)
	$(INSTALL) zip.1 $(MANDIR)


# These symbols, when #defined using -D have these effects on compilation:
# ZMEM		- includes C language versions of memset(), memcpy(), and
#		  memcmp() (util.c).
# DIRENT	- use <sys/dirent.h> and getdents() instead of <sys/dir.h>
#		  and opendir(), etc. (fileio.c).
# NODIR		- used for 3B1, which has neither getdents() nor opendir().
# NDIR		- use "ndir.h" instead of <sys/dir.h> (fileio.c).
# UTIL		- select routines for utilities (note, cloak, and split).
# PROTO		- enable function prototypes.
# RMDIR		- remove directories using a system("rmdir ...") call.
# CONVEX	- for Convex make target.
# AIX		- for AIX make target.
# CRYPT 	- include the encryption code.
# LINUX		- for linux make target.

# BSD 4.3 (also Unisys 7000--AT&T System V with heavy BSD 4.2)
bsd:
	$(MAKE) zips CFLAGS="-O"


# clean up after making stuff and installing it
clean:
	rm -f *.o
	rm -f $(ZIPS)

	LFLAGS2="-s -object" VPATH="${HOME}/Unix/bin"

# and this one for Jean-loup:
gcc_d:
	$(MAKE) zip CFLAGS="-g -DDEBUG -DDIRENT" CC=gcc BIND=gcc LFLAGS2="-g"
	mv zip zipd

# end of Makefile
