# Unix Makefile for CheapGlk library

# This generates two files. One, of course, is libcheapglk.a -- the library
# itself. The other is Make.cheapglk; this is a snippet of Makefile code
# which locates the cheapglk library.
#
# When you install cheapglk, you must put libcheapglk.a in the lib directory,
# and glk.h, glkstart.h, and Make.cheapglk in the include directory.
#
# The file cgunigen.c was generated by the casemap.py script, but
# that step isn't in the Makefile -- you don't have to re-generate it.
# It's based on Unicode character data, which is not platform-dependent.

# Pick a C compiler.
CC = gcc -ansi

OPTIONS = -O

CFLAGS = $(OPTIONS) $(INCLUDEDIRS)

GLKLIB = libcheapglk.a

CHEAPGLK_OBJS =  \
  cgfref.o cggestal.o cgmisc.o cgstream.o cgstyle.o cgwindow.o cgschan.o \
  cgunicod.o main.o gi_dispa.o gi_blorb.o cgblorb.o

CHEAPGLK_HEADERS = cheapglk.h gi_dispa.h

all: $(GLKLIB) Make.cheapglk

cgunicod.o: cgunigen.c

$(GLKLIB): $(CHEAPGLK_OBJS)
	ar r $(GLKLIB) $(CHEAPGLK_OBJS)
	ranlib $(GLKLIB)

Make.cheapglk:
	echo LINKLIBS = $(LIBDIRS) $(LIBS) > Make.cheapglk
	echo GLKLIB = -lcheapglk >> Make.cheapglk

$(CHEAPGLK_OBJS): glk.h $(CHEAPGLK_HEADERS)

clean:
	rm -f *~ *.o $(GLKLIB) Make.cheapglk
