# ----------------------------------------------------------------------------
# Makefile for PDFlib, version for Watcom C/C++
# (C) Thomas Merz 1997
# ----------------------------------------------------------------------------

VERSION = 0.5b

# ---------------------- Configuration options -------------------------------
# Add the following defines for configuring several features:
# -DUSE_TIFF    use TIFF library for reading TIFF files (requires -DUSE_JPEG)
#               -DUSE_TIFF requires -ltiff and -ljpeg
#
# -DUSE_ZLIB    use zlib library for decompression (not yet implemented)
#               -DUSE_zlib requires -lgz (sometimes -lz)
#
# -DUSE_JPEG    use IJG JPEG library for decompressing non-baseline JPEGs
#               (currently not implemented)
#               This is only required for rare JPEGs, most are handled
#               internally in PDFlib. -DUSE_JPEG requires -ljpeg
#
# -DDEBUG       makes the PDF output more debug-friendly but may also
#               obscure the bugs you're investigating (as predicted by 
#               Heisenberg's law)

DEFINES = 
EXTRALIBS= 

# ------------------- Make variables for Linux/Gnu Compiler ----------------
# Additional include directories, e.g. for TIFF and ZLIB library headers
INCDIR  = 
CC      = wcc386
CCOPT   = -DDOS
LD      = wlink
LDOPT   = 
OBJ     = obj
EXE     = .exe
RM      = del
AR      = wlib
AROPTS  = -b
RANLIB  = rem
PDFLIB  = libpdf.lib
LIBS    = $(PDFLIB)

# ------------------- Nothing of interest below ---------------------------
DIRNAME = pdflib-$(VERSION)
TARFILE = pdflib-$(VERSION).tar

.c.$(OBJ) :
	$(CC) $(CCOPT) $(DEFINES) $<

# The following is only used with Watcom
.obj.exe :
	$(LD) $(LDOPT) NAME $* FILE $*.$(OBJ) LIBRARY $(LIBS) $(EXTRALIBS)

SRCS    = \
	p_basic.c \
	p_color.c \
	p_draw.c \
	p_filter.c \
	p_font.c \
	p_gif.c \
	p_gstate.c \
	p_hyper.c \
	p_image.c \
	p_jpeg.c \
	p_text.c \
	p_tiff.c \
	p_util.c \
	afmparse.c \
	getopt.c \
	hello.c \
	imagepdf.c \
	pdfclock.c \
	pdfgraph.c \
	pdfdemo.c \
	text2pdf.c

OBJS    = \
	p_basic.$(OBJ) \
	p_color.$(OBJ) \
	p_draw.$(OBJ) \
	p_filter.$(OBJ) \
	p_font.$(OBJ) \
	p_gif.$(OBJ) \
	p_gstate.$(OBJ) \
	p_hyper.$(OBJ) \
	p_image.$(OBJ) \
	p_jpeg.$(OBJ) \
	p_text.$(OBJ) \
	p_tiff.$(OBJ) \
	p_util.$(OBJ) \
	getopt.$(OBJ) \
	afmparse.$(OBJ)

HEADERS = \
	afmparse.h \
	pdf.h \
	p_intern.h \
	p_port.h \
	ansi_e.h \
	macrom_e.h \
	pdfdoc_e.h

PROGS   = \
	text2pdf$(EXE) \
	pdfclock$(EXE) \
	pdfgraph$(EXE) \
	pdfdemo$(EXE) \
	hello$(EXE) \
	imagepdf$(EXE)

SUPPORT = \
	makefile.gcc \
	makefile.wat \
	README \
	CHANGES \
	PDFlib.pdf \
	LICENSE

AFMS    = \
	fonts/cour1.afm \
	fonts/cour2.afm \
	fonts/cour3.afm \
	fonts/cour4.afm \
	fonts/helv1.afm \
	fonts/helv2.afm \
	fonts/helv3.afm \
	fonts/helv4.afm \
	fonts/symbol.afm \
	fonts/times1.afm \
	fonts/times2.afm \
	fonts/times3.afm \
	fonts/times4.afm \
	fonts/zapf.afm \
	fonts/afmlist \
	fonts/afmlist.unx

SAMPLES = \
	test\nesrin.jpg  \
	test\acro_web.gif \
	test\bible.tif \
	test\graphdata

CGI = \
	cgi-bin/clock.cgi

DISTFILES= \
	$(SRCS) $(HEADERS) $(SUPPORT) $(AFMS) $(SAMPLES) $(CGI)

all:    $(PDFLIB) $(PROGS)

$(PDFLIB):      $(OBJS)
	$(RM) $(PDFLIB)
	$(AR) $(AROPTS) $(PDFLIB) $(OBJS)
	$(RANLIB) $(PDFLIB)

TESTFILES = \
	test\clock.pdf  \
	test\readme.pdf \
	test\images.pdf \
	test\hello.pdf  \
	test\demo.pdf

# library clients
text2pdf$(EXE): text2pdf.$(OBJ) $(PDFLIB) pdf.h p_port.h

pdfgraph$(EXE): pdfgraph.$(OBJ) $(PDFLIB) pdf.h p_port.h

pdfdemo$(EXE):  pdfdemo.$(OBJ) $(PDFLIB) pdf.h p_port.h

pdfclock$(EXE): pdfclock.$(OBJ) $(PDFLIB) pdf.h p_port.h

hello$(EXE):    hello.$(OBJ) $(PDFLIB) pdf.h p_port.h

imagepdf$(EXE): imagepdf.$(OBJ) $(PDFLIB) pdf.h p_port.h

dist:
	$(RM) -f $(TARFILE).gz;                         \
	ln -s . $(DIRNAME);                             \
	(for i in $(DISTFILES); do                      \
		echo $$i;                               \
	done) | sed "s;.*;$(DIRNAME)/&;" >distfiles;    \
	tar cvf  $(TARFILE) `cat distfiles`;            \
	gzip $(TARFILE);                                \
	rm -f $(DIRNAME) distfiles;

clean:  .SYMBOLIC
	$(RM) *.$(OBJ)
	$(RM) $(PROGS)
	$(RM) $(PDFLIB)
	$(RM) $(TESTFILES)

test/clock.pdf: pdfclock$(EXE)
	.\pdfclock -o test/clock.pdf
	
test/readme.pdf:        text2pdf$(EXE)
	.\text2pdf -o test/readme.pdf README
	
test/images.pdf:        imagepdf$(EXE)
	.\imagepdf -o test/images.pdf test/bible.tif test/acro_web.gif test/nesrin.jpg

test/hello.pdf: hello$(EXE)
	.\hello test/hello.pdf

test/demo.pdf:  pdfdemo$(EXE)
	.\pdfdemo test/demo.pdf

test:   $(PROGS) $(TESTFILES)

# PDFlib library modules
afmparse.$(OBJ):        afmparse.c afmparse.h

p_hyper.$(OBJ):         p_hyper.c pdf.h p_intern.h pdfdoc_e.h

p_color.$(OBJ):         p_color.c pdf.h p_intern.h

p_basic.$(OBJ):         p_basic.c pdf.h p_intern.h

p_draw.$(OBJ):          p_draw.c pdf.h p_intern.h

p_filter.$(OBJ):        p_filter.c pdf.h p_intern.h

p_font.$(OBJ):          p_font.c pdf.h p_intern.h ansi_e.h macrom_e.h

p_gif.$(OBJ):           p_gif.c pdf.h p_intern.h

p_gstate.$(OBJ):        p_gstate.c pdf.h p_intern.h

p_image.$(OBJ):         p_image.c pdf.h p_intern.h

p_jpeg.$(OBJ):          p_jpeg.c pdf.h p_intern.h

p_text.$(OBJ):          p_text.c pdf.h p_intern.h

p_tiff.$(OBJ):          p_tiff.c pdf.h p_intern.h

p_util.$(OBJ):          p_util.c pdf.h p_intern.h
