# 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 = pcc
#CC = gcc -ansi

#OPTIONS = -g -Wall
OPTIONS = -D_POSIX_SOURCE

CFLAGS = $(OPTIONS) $(INCLUDEDIRS)

GLKLIB = libcheapglk.a

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

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 *~ *.8 $(GLKLIB) Make.cheapglk