PROGRAM = glkzip

# 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 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 Glk lib and include directories are.
# The following are defaults that might work.

# for XGlk
#GLKDIR = ../xglk
#GLKINCLUDE = -I$(GLKDIR)
#GLKLIBDIR = -L$(GLKDIR)
#GLKMAKEFILE = $(GLKDIR)/Make.xglk
#GLKEXTOBJS = glkstart.o

# for GlkTerm
#GLKDIR = ../glkterm
#GLKINCLUDE = -I$(GLKDIR)
#GLKLIBDIR = -L$(GLKDIR)
#GLKMAKEFILE = $(GLKDIR)/Make.glkterm
#GLKEXTOBJS = glkstart.o

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

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

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

include $(GLKMAKEFILE)

CFLAGS = -g $(SYSTEMFLAGS) $(GLKINCLUDE)
LDFLAGS = -g
#LIBS = -L$(XLIB) -lX11 $(SYSTEMLIBS)
LIBS = $(LINKLIBS) $(GLKLIBDIR) $(GLKLIB)

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

GLKOBJS = glkio.o $(GLKEXTOBJS)

$(PROGRAM) : $(OBJS) $(GLKOBJS)
	$(CC) -o $@ $(LDFLAGS) $(OBJS) $(GLKOBJS) $(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
