PROGRAM = xzip

# You MUST define either BIG_END_MODE or LITTLE_END_MODE, by
#   uncommenting one of the lines below. If you don't know
#   which is right, try one and see if the program runs right.
#   The error messages are nice and obvious. Some Unixes
#   have a BYTE_ORDER definition; if you define AUTO_END_MODE,
#   the source code will check for that and work "automatically".
#   If Murphy's Law strikes, go back to BIG_END_MODE or 
#   LITTLE_END_MODE.

# If you get errors in xio.c about fd_set or FD_SET being 
#   undefined, put "-DNEEDS_SELECT_H" in the SYSTEMFLAGS line,
#   as has been done for the RS6000.

# If you get errors about bcopy being undefined, put
#   "-DNO_BCOPY" in the SYSTEMFLAGS line.

# If you get errors about random or srandom being undefined,
#   put "-DLOUSY_RANDOM" in the SYSTEMFLAGS line.

# --------------------

# definitions for RS6000 / AIX
#   If AUTO doesn't work, use BIG
#SYSTEMFLAGS = -DNEEDS_SELECT_H -DAUTO_END_MODE

# definitions for HP / HPUX
#SYSTEMFLAGS = -Ae -DBIG_END_MODE

# definitions for HP / HPUX 9.0 
#    (Dunno; this was contributed to me)
#SYSTEMFLAGS = -Aa -D_HPUX_SOURCE -DBIG_END_MODE

# definitions for SparcStation / SunOS
#SYSTEMFLAGS = -DBIG_END_MODE

# definitions for SparcStation / Solaris 
#    (Solaris 2.5, don't know about other versions)
#SYSTEMFLAGS = -DBIG_END_MODE
#SYSTEMLIBS = -R$(XLIB)  -lsocket

# definitions for DECstation / Ultrix
#SYSTEMFLAGS = -DLITTLE_END_MODE

# definitions for SGI / Irix
#SYSTEMFLAGS = -DBIG_END_MODE

# definitions for Linux
# Note! Old versions of Linux (pre 2.0?) may not have the magic
#   BYTE_ORDER definitions installed. If AUTO_END_MODE doesn't
#   work, use LITTLE_END_MODE on an x86, BIG_END_MODE on a
#   680x0 or PPC machine.
#SYSTEMFLAGS = -DAUTO_END_MODE

# definitions for BSDI 4
#SYSTEMFLAGS = -DAUTO_END_MODE

# definitions for some arbitrary big-endian system
#SYSTEMFLAGS = -DBIG_END_MODE

# definitions for some arbitrary little-endian system
#SYSTEMFLAGS = -DLITTLE_END_MODE

# --------------------

# definitions for where the X lib and include directories are.
# The following are defaults that might work.

XINCLUDE = /usr/include/X11
XLIB = /usr/lib/X11

# If your compiler can't find these things, try commenting out the
# above, and uncommenting various versions below. Also look around
# your hard drive for the appropriate files. (The XINCLUDE directory
# should contain the file "Xlib.h", and the XLIB dir should contain 
# "libX11.so" or "libX11.a".)
# The problem is, depending on how things are installed, the
# directories could be just about anywhere. Sigh.

# for Debian or SuSE Linux
#XINCLUDE = /usr/X11R6/include/X11
#XLIB = /usr/X11R6/lib

# for Red Hat Linux
#XINCLUDE = /usr/include/X11
#XLIB = /usr/X11/lib

# for SparcStation / Solaris 
#XINCLUDE = /usr/openwin/include
#XLIB = /usr/openwin/lib

# for BSDI 4
#XINCLUDE = /usr/X11R6/include
#XLIB = /usr/X11/lib

# --------------------

# definition for where to install xzip executable and man page
DESTDIR = /usr/local

# --------------------

CFLAGS = -O $(SYSTEMFLAGS) -I$(XINCLUDE)
LDFLAGS =
LIBS = -L$(XLIB) -lX11 $(SYSTEMLIBS)

# definitions for the default fonts. Users can override these with X resources.
FONTDEF_PLAIN=\
"-adobe-times-medium-r-normal--14-*-*-*-*-*-iso8859-1"
FONTDEF_BOLD=\
"-adobe-times-bold-r-normal--14-*-*-*-*-*-iso8859-1"
FONTDEF_ITALIC=\
"-adobe-times-medium-i-normal--14-*-*-*-*-*-iso8859-1"
FONTDEF_BOLDITALIC=\
"-adobe-times-bold-i-normal--14-*-*-*-*-*-iso8859-1"
FONTDEF_FIXED=\
"-adobe-courier-medium-r-normal--12-*-*-*-*-*-iso8859-1"
FONTDEF_BOLDFIXED=\
"-adobe-courier-bold-r-normal--12-*-*-*-*-*-iso8859-1"
FONTDEF_ITALICFIXED=\
"-adobe-courier-medium-o-normal--12-*-*-*-*-*-iso8859-1"
FONTDEF_BOLDITALICFIXED=\
"-adobe-courier-bold-o-normal--12-*-*-*-*-*-iso8859-1"

FONTDEFAULTLIST = \
-DFND0='$(FONTDEF_PLAIN)' \
-DFND1='$(FONTDEF_BOLD)' \
-DFND2='$(FONTDEF_ITALIC)' \
-DFND3='$(FONTDEF_BOLDITALIC)' \
-DFND4='$(FONTDEF_FIXED)' \
-DFND5='$(FONTDEF_BOLDFIXED)' \
-DFND6='$(FONTDEF_ITALICFIXED)' \
-DFND7='$(FONTDEF_BOLDITALICFIXED)'

INC = ztypes.h
OBJS = zip.o control.o extern.o fileio.o input.o interpre.o math.o memory.o \
	object.o operand.o osdepend.o property.o screen.o text.o variable.o \
	pickle.o quetzal.o

XOBJS = xio.o xinit.o xtext.o xkey.o xmess.o xstat.o

$(PROGRAM) : $(OBJS) $(XOBJS)
	$(CC) -o $@ $(LDFLAGS) $(OBJS) $(XOBJS) $(LIBS)

test: $(XOBJS)
	$(CC) -o $@ $(LDFLAGS) $(XOBJS) $(LIBS)

$(OBJS) : $(INC) extern.c version.h

pickle.o : pickle.h

$(XOBJS) : $(INC) xio.h version.h

xio.o: xio.c xio.h greypm.bm
	$(CC) $(CFLAGS) -c xio.c

xinit.o: xinit.c xio.h
	$(CC) $(CFLAGS) $(FONTDEFAULTLIST) -c xinit.c

install: $(PROGRAM)
	install -s $(PROGRAM) $(DESTDIR)/bin
	install $(PROGRAM).1 $(DESTDIR)/man/man1

clean :
	-rm -f *~ *.o $(PROGRAM) test
