# This file is part of the CJK package Version 4.1.3 (20-Jun-1997)

# GNU Makefile for ttflib

.PHONY: default all debug documentation clean depend \
        ttflib ttflib-doc


default:
	@echo " say                                     "
	@echo ".                                        "
	@echo "     make TARGET OS=SYSTEM               "
	@echo ".                                        "
	@echo " SYSTEM can be one of the following:     "
	@echo ".                                        "
	@echo "     unix (gcc)                          "
	@echo "     os2 bound (emx)                     "
	@echo "     dos (djgpp)                         "
	@echo ".                                        "
	@echo " TARGET can be one of the following:     "
	@echo ".                                        "
	@echo "     all debug depend                    "
	@echo "     documentation (needs c2cweb package)"
	@echo "     clean                               "


ifdef OS

  # default values
  FS = UNIX
  CC = gcc -Wall -O
  O = .o
  RM = rm -f
  AR = ar
  LIBO = .a

  ifeq ($(OS),os2)
    FS = MSDOS
    CC = gcc -Wall -Zomf -Zmtd -O
    O = .obj
    RM = del
    AR = emxomfar
    LIBO = .lib
  endif

  ifeq ($(OS),dos)
    FS = MSDOS
    CC = gcc -Wall -O
    O = .o
    RM = del
    AR = ar
    LIBO = .a
  endif

  ifeq ($(OS),bound)
    FS = MSDOS
    CC = gcc -Wall -O
    O = .o
    RM = del
    AR = ar
    LIBO = .a
  endif


  SRC = basic.h bitmap.h error.h loadtabl.h ttf.h ttf2bmp.h \
        basic.c bitmap.c error.c findex.c loadtabl.c render.c ttf2bmp.c
  OBJ = basic$O bitmap$O error$O findex$O loadtabl$O render$O ttf2bmp$O


  %$O: %.c
	$(CC) $(CFLAGS) -c -D$(FS) -o $@ $<

  %.dvi: %.tex
	$(TEX) $*


  all:
	$(MAKE) ttflib CFLAGS=-s

  debug:
	$(MAKE) ttflib CFLAGS="-Wstrict-prototypes -g -DDEBUG"

  # this builds a .dvi-file using the c2cweb package
  documentation ttflib-doc: ttflib.dvi

  # remove the unnecessary files.
  clean:
	-$(RM) *$O
	-$(RM) *.cw
	-$(RM) *.hw
	-$(RM) *.tex
	-$(RM) *.scn
	-$(RM) *.toc
	-$(RM) *.idx
	-$(RM) *.log

  # Dependencies.
  depend:
	gcc -E -M *.c > dep.end


  ttflib: ttflib$(LIBO)

  ttflib$(LIBO): $(OBJ)
	$(AR) rc $@ $^

  ttf2bmp.cw: $(SRC) ttflib.fmt
	c2cweb -b "The ttflib library" -l -v -f ttflib.fmt $(SRC)

  ttflib.tex: ttf2bmp.cw
	$(CWEAVE) +ai $< - $@
	

  ifeq (dep.end,$(wildcard dep.end))
    include dep.end
  endif

else # ifdef OS

  all debug depend documentation clean: default

endif
