1# Makefile for Zip, ZipNote, ZipCloak and ZipSplit
2
3# what you can make ...
4all: zip
5
6#MAKE = make -f unix/Makefile
7SHELL = /bin/sh
8
9# (to use the Gnu compiler, change cc to gcc in CC and BIND)
10CC = cc
11BIND = $(CC)
12AS = $(CC) -c
13E =
14CPP = /lib/cpp
15
16# probably can change this to 'install' if you have it
17INSTALL = cp
18
19# target directories - where to install executables and man pages to
20prefix = /usr/local
21BINDIR = $(prefix)/bin
22manext=1
23MANDIR = $(prefix)/man/man$(manext)
24ZIPMANUAL = MANUAL
25
26# flags
27#   CFLAGS    flags for C compile
28#   LFLAGS1   flags after output file spec, before obj file list
29#   LFLAGS2   flags after obj file list (libraries, etc)
30CFLAGS = -O2 -fno-strength-reduce -I. -DUNIX -DQLZIP -DASM_CRC
31LFLAGS1 =
32LFLAGS2 = -s
33
34# object file lists
35OBJZ = zip.o zipfile.o zipup.o fileio.o util.o globals.o crypt.o ttyio.o \
36       unix.o crc_gcc.o crc32.o qdos.o
37OBJI = deflate.o trees.o
38OBJA =
39OBJU = zipfile_.o fileio_.o util_.o globals.o unix_.o
40OBJN = zipnote.o  $(OBJU)
41OBJC = zipcloak.o $(OBJU) crc32_.o crypt_.o ttyio.o
42OBJS = zipsplit.o $(OBJU)
43
44ZIP_H = zip.h ziperr.h tailor.h unix/osdep.h
45
46# suffix rules
47.SUFFIXES:
48.SUFFIXES: _.o .o .c .doc .1
49.c_.o:
50	rm -f $*_.c; ln $< $*_.c
51	$(CC) -c $(CFLAGS) -DUTIL $*_.c
52	rm -f $*_.c
53.c.o:
54	$(CC) -c $(CFLAGS) $<
55
56.1.doc:
57	nroff -man $< | col -b | uniq > $@
58
59# rules for zip, zipnote, zipcloak, zipsplit, and the Zip MANUAL.
60$(OBJZ): $(ZIP_H)
61$(OBJI): $(ZIP_H)
62$(OBJN): $(ZIP_H)
63$(OBJS): $(ZIP_H)
64$(OBJC): $(ZIP_H)
65zip.o zipup.o crypt.o fileio.o zipfile.o: crc32.h
66zipcloak.o crc32_.o crypt_.o fileio_.o zipfile_.o: crc32.h
67zip.o zipup.o crypt.o ttyio.o zipcloak.o crypt_.o: crypt.h
68zip.o zipup.o zipnote.o zipcloak.o zipsplit.o: revision.h
69zip.o crypt.o ttyio.o zipcloak.o crypt_.o: ttyio.h
70zipup.o: unix/zipup.h
71
72match.o: match.S
73	$(CPP) match.S > _match.s
74	$(AS) _match.s
75	mv _match.o match.o
76	rm -f _match.s
77
78unix.o: unix/unix.c
79	$(CC) -c $(CFLAGS) unix/unix.c
80
81unix_.o: unix/unix.c
82	rm -f $*_.c; ln unix/unix.c $*_.c
83	$(CC) -c $(CFLAGS) -DUTIL $*_.c
84	rm -f $*_.c
85
86qdos.o: qdos/qdos.c
87	$(CC) -c $(CFLAGS) qdos/qdos.c
88
89crc_gcc.o: crc_i386.S			# 32bit, GNU AS
90	gcc -O3 -I. -DASM_CRC -Di386 -x assembler-with-cpp -c -o $@ crc_i386.S
91
92ZIPS = zip$E zipnote$E zipsplit$E zipcloak$E
93
94zips: $(ZIPS)
95zipsman: $(ZIPS) $(ZIPMANUAL)
96
97zip$E: $(OBJZ) $(OBJI) $(OBJA)
98	$(BIND) -o qlzip$E $(LFLAGS1) $(OBJZ) $(OBJI) $(OBJA) $(LFLAGS2)
99zipnote$E: $(OBJN)
100	$(BIND) -o zipnote$E $(LFLAGS1) $(OBJN) $(LFLAGS2)
101zipcloak$E: $(OBJC)
102	$(BIND) -o zipcloak$E $(LFLAGS1) $(OBJC) $(LFLAGS2)
103zipsplit$E: $(OBJS)
104	$(BIND) -o zipsplit$E $(LFLAGS1) $(OBJS) $(LFLAGS2)
105
106$(ZIPMANUAL): man/zip.1
107	nroff -man man/zip.1 | col -b | uniq > $(ZIPMANUAL)
108
109# install
110install:        $(ZIPS)
111	$(INSTALL) $(ZIPS) $(BINDIR)
112	$(INSTALL) man/zip.1 $(MANDIR)/zip.$(manext)
113
114uninstall:
115	-cd $(BINDIR); rm -f $(ZIPS)
116	-cd $(MANDIR); rm -f zip.$(manext)
117
118dist:
119	zip -u9T zip`sed -e '/VERSION/!d' -e 's/.*"\(.*\)".*/\1/' \
120			  -e s/[.]//g -e q revision.h` \
121	  `awk '/^Makefile/,/vms_zip.rnh/ {print $$1}' < contents`
122
123flags:  unix/configure
124	sh unix/configure "${CC}" "${CFLAGS}"
125
126# These symbols, when #defined using -D have these effects on compilation:
127# ZMEM                  - includes C language versions of memset(), memcpy(),
128#                         and memcmp() (util.c).
129# HAVE_DIRENT_H         - use <dirent.h> instead of <sys/dir.h>
130# NODIR                 - for 3B1, which has neither getdents() nor opendir().
131# HAVE_NDIR_H           - use <ndir.h> (unix/unix.c).
132# HAVE_SYS_DIR_H        - use <sys/dir.h>
133# HAVE_SYS_NDIR_H       - use <sys/ndir.h>
134# UTIL                  - select routines for utilities (note, cloak, split)
135# NO_RMDIR              - remove directories using a system("rmdir ...") call.
136# NO_PROTO              - cannot handle ANSI prototypes
137# NO_CONST              - cannot handle ANSI const
138
139#               Generic targets:
140
141# end of Makefile
142