# Generated automatically from Makefile.in by configure.
#
#  type "make help" for help
#
# TODO: examples
#       rpm package, man page
#

prefix = /usr/local
bindir = $(prefix)/bin

SHELL = /bin/sh
# this does not work on SuSE 6.0, why? (autoconf 2.12 do not set /bin/sh ?)
#SHELL = bash #
INSTALL = /usr/bin/install -c
CC = gcc
CFLAGS = -g -O2
# following DEFs are not used, but I play with it for training
CPPFLAGS = -I/usr/X11R6/include
DEFS = -DHAVE_CONFIG_H
includedir = ${prefix}/include
#
# -pedantic -ansi -Wall
LDFLAGS = -L/usr/X11R6/lib -L/usr/local/netpbm/lib
LIBS = -lpnm 

RANLIB = ranlib
AR = ar


FILES = \
 AUTHORS Makefile.in bin/ doc/ lib/ BUGS README examples/ make.bat\
 CREDITS READMEde.txt frontend/ man/ REMARK.txt src/\
 HISTORY REVIEW configure gpl.html INSTALL TODO configure.in include/\
 Makefile api/ create_db install-sh

# export all make-variables to submakes - said to be not working on IRIS

# default rule
default: all

.PHONY : src doc examples frontend help clean proper distclean dist tgz

# example file generation takes lot of memory and time, do it explicitely
# by make examples
all:	src Makefile
	@echo " --- for help do: make help ---"
	@echo " --- for documentation do: make doc ---"
	@echo " --- for examples do: make examples ---"

include/config.h: include/config.h.in configure
	configure

configure: configure.in
	autoconf

Makefile: Makefile.in configure
	configure

src:
	$(MAKE) -C src all

man:
	$(MAKE) -C man all

doc:
	$(MAKE) -C doc all

examples:
	$(MAKE) -C examples all

frontend:
	$(MAKE) -C frontend all

gocr.tar.Z: $(FILES)
	tar -cf - $(FILES) | compress -c >gocr.tar.Z

.PHONY : zip help database
zip:
	zip -k -q gocr.zip $(FILES)
	@ls -al gocr.zip

help:
	@printf "make          - compile all\n"
	@printf "make src      - build lib and gocr\n"
	@printf "make man      - build manual\n"
	@printf "make doc      - make documentation\n"
	@printf "make frontend - build frontend\n"
	@printf "make examples - create examples ./examples/\n"
	@printf "make database - create database\n"
	@printf "make clean    - erase temporary files\n"
	@printf "make proper   - erase all created files\n"
	@printf "make install  - Really? Its development version!\n"

database:
	$(SHELL) bin/create_db

.PHONY : install test examples
install:
	$(MAKE) -C src install
	$(MAKE) -C man install
	$(MAKE) -C doc install
	$(MAKE) -C examples install
	$(MAKE) -C frontend install

.PHONY : tgz dist
dist:
	echo gocr-`sed \
	 -e '/version_string/!d' \
	 -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \
	 -e q \
	 src/gocr.c` > .fname
	-rm -rf `cat .fname`
	mkdir `cat .fname`
	cp -r -d $(FILES) `cat .fname`
	$(MAKE) -C `cat .fname` proper
	tar chzf `cat .fname`.tgz `cat .fname`
	ls -l `cat .fname`.tgz
	-rm -rf `cat .fname` .fname


tgz: proper
	(cd ..;tar -czf gocr.tgz jocr)

# PHONY = don't look at file clean, -rm = start rm and ignore errors
.PHONY : clean proper
clean:
	-rm -f config.cache config.status config.log
	-rm -f *.aux *.log *.dvi *.ps *.lj *~ gocr.ini out.txt
	-rm -f convert.cc convert convert.o	# remove v0.2.4 rests
	$(MAKE) -C src clean
	$(MAKE) -C doc clean
	$(MAKE) -C examples/ clean


distclean: proper

proper: clean
	$(MAKE) -C src/ proper
	$(MAKE) -C doc proper
	$(MAKE) -C examples/ proper
	-rm -f gocr bin/gocr libPgm2asc.* out??.bmp


