# sample Makefile for TET applications
#
# tested with gmake, so if your make does not work properly try to use gmake

RM      = rm -f

CXX = g++
SAMPLE_CFLAGS = 
SAMPLE_CXXFLAGS = 
SAMPLE_LDFLAGS = 
SAMPLE_LDLIBS = -framework ApplicationServices -framework SystemConfiguration
SAMPLE_DLLDLIBS = 

CFLAGS  = -I../c/include $(SAMPLE_CFLAGS)
CXXFLAGS= -I../c/include $(SAMPLE_CXXFLAGS)
LDFLAGS = -L../c/lib $(SAMPLE_LDFLAGS)
LDLIBS	= -ltet -lm $(SAMPLE_LDLIBS) $(SAMPLE_DLLDLIBS)

PROGS	= \
	dumper \
	extractor \
	extractor_string \
	extractor_u16string \
	extractor_u32string \
	fontfilter \
	glyphinfo \
	get_attachments \
	images_per_page \
	image_resources \
	tetml

all: $(PROGS)

test: all
	./dumper TET-datasheet.pdf
	./extractor TET-datasheet.pdf TET-datasheet.txt
	./extractor_string TET-datasheet.pdf TET-datasheet.txt
	./extractor_u16string TET-datasheet.pdf TET-datasheet.txt
	./extractor_u32string TET-datasheet.pdf TET-datasheet.txt
	./fontfilter TET-datasheet.pdf
	./glyphinfo TET-datasheet.pdf TET-datasheet.info.txt
	./get_attachments Portfolio_sample.pdf attachments.txt
	./images_per_page TET-datasheet.pdf
	./image_resources TET-datasheet.pdf
	./tetml TET-datasheet.pdf TET-datasheet.tetml

# Load the TET DLL dynamically in the C++ binding by compiling with -DTETCPP_DL=1.
# The program must be linked with tetlibdl.o, but not against the TET library.
extractordl: extractor.cpp ../c/tetlibdl.c
	$(CXX) -c -o extractordl.o $(CXXFLAGS) -DTETCPP_DL=1 extractor.cpp
	$(CC) -c $(CFLAGS) ../c/tetlibdl.c
	$(CXX) $(LDFLAGS) -o $@ extractordl.o tetlibdl.o $(SAMPLE_DLLDLIBS)
        
clean:
	$(RM) $(PROGS) TET-datasheet.tetml TET-datasheet.txt attachments.txt
	$(RM) TET-datasheet.info.txt TET-datasheet_*.tif TET-datasheet_*.jpg

#  As we need a C++ linker change the default rules how to create executables
.SUFFIXES:
.SUFFIXES: .c .cpp

.c:
	$(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $< $(LDLIBS)

.cpp:
	$(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $< $(LDLIBS)

