#/*====================================================================*
# -  Copyright (C) 2001 Leptonica.  All rights reserved.
# -
# -  Redistribution and use in source and binary forms, with or without
# -  modification, are permitted provided that the following conditions
# -  are met:
# -  1. Redistributions of source code must retain the above copyright
# -     notice, this list of conditions and the following disclaimer.
# -  2. Redistributions in binary form must reproduce the above
# -     copyright notice, this list of conditions and the following
# -     disclaimer in the documentation and/or other materials
# -     provided with the distribution.
# -
# -  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# -  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# -  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# -  A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL ANY
# -  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# -  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# -  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# -  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# -  OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# -  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# -  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# *====================================================================*/

#   Makefile.mingw  (cross-compiled for windows)
#
#   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#   NOTE: This file may not be up to date on the source files that
#   are listed here.  For the current set of source files, see:
#        makefile
#   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#
#   For a nodebug version:             make
#   For a debug version:               make DEBUG=yes
#   For a shared library version:      make SHARED=yes
#   With nonstandard library directories:
#                    make EXTRALIBS="-L<nonstandard-lib-dir>"
#   With nonstandard header directories
#                    make EXTRAINCLUDES="-I<nonstandard-incl-dir>"
#
#   To remove all executables:  make clean
#
#   This is EXPERIMENTAL.  It compiles and links, but is not very neat,
#   because I haven't built executables for windows in any environment
#   except cygwin.  It makes optimized executables with static
#   libraries; ignore the 'SHARED' lines.  This should eventually
#   be fixed up, but for now, SHARED doesn't work.  Also, if
#   you make with DEBUG=yes, you will get very large .o files.
#
#   To build .exe windows programs, you need 4 libraries:
#     jpeg, png, zlib, tiff
#   You can get them from the gnuwin32 site on sourceforge:
#     http://gnuwin32.sourceforge.net/packages/netpbm.htm
#   Download the 4 libraries as 'developer' packages, which give
#   you the library binaries with the header files.
#   The header files go in:
#      /usr/local/include/mingw/
#   and the four libraries go in
#      /usr/local/lib/mingw/
#   The four libraries you need are specified in the ALL_LIBS definition.
#   It seems that you also need to download dll files to get
#   the programs to run (e.g., jpeg2b.dll).
#


# Libraries are built into a binary tree with its root in the
# parent directory
ROOT_DIR = ..

LIB_NODEBUG_DIR =	$(ROOT_DIR)/lib/nodebug
LIB_DEBUG_DIR =		$(ROOT_DIR)/lib/debug
LIB_SHARED_DIR =	$(ROOT_DIR)/lib/shared

# Include files are found within the same tree
IMAGELIB_INCL =	$(ROOT_DIR)/src


CC =	i586-mingw32msvc-gcc -ansi -Werror -D_BSD_SOURCE -DANSI
#CC =	i586-mingw32msvc-g++ -Werror -D_BSD_SOURCE


ifdef  SHARED
    LIB_DIR =	$(LIB_SHARED_DIR)
    OPTIMIZE =	-O2
else
    ifdef  DEBUG
	LIB_DIR =	$(LIB_DEBUG_DIR)
	OPTIMIZE =	-g
    else
	LIB_DIR =	$(LIB_NODEBUG_DIR)
	OPTIMIZE =	-O2
    endif
endif

OPTIONS =

INCLUDES =	-I$(IMAGELIB_INCL) -I/usr/local/include/mingw

CFLAGS =	$(OPTIMIZE) $(OPTIONS)
CPPFLAGS =      $(INCLUDES) -DL_LITTLE_ENDIAN
#CPPFLAGS =      $(INCLUDES) -DL_BIG_ENDIAN

LDFLAGS +=	-L$(LIB_DIR) -L/usr/local/lib/mingw -L/usr/lib $(EXTRALIBS)
#LDFLAGS +=	-L$(LIB_DIR) -L/usr/X11R6/lib -L/usr/local/lib -L/usr/lib $(EXTRALIBS)

ifdef  SHARED
    LEPTLIB =		$(LIB_DIR)/liblept.so
else
    LEPTLIB =		$(LIB_DIR)/liblept.a
endif

ALL_LIBS =	$(LEPTLIB) /usr/local/lib/mingw/libpng.a /usr/local/lib/mingw/libz.a /usr/local/lib/mingw/libtiff.dll.a /usr/local/lib/mingw/libjpeg.dll.a -lm

#########################################################################

SRC =		adaptnorm_reg.c affine_reg.c alphaclean_reg.c \
		bilinear_reg.c binarize_reg.c \
		binmorph1_reg.c binmorph2_reg.c \
		binmorph3_reg.c binmorph4_reg.c binmorph5_reg.c \
		blend_reg.c blend2_reg.c \
		ccthin1_reg.c ccthin2_reg.c \
		cmapquant_reg.c colorquant_reg.c \
		colorseg_reg.c compfilter_reg.c \
		conncomp_reg.c conversion_reg.c \
		distance_reg.c dwamorph1_reg.c \
		dwamorph2_reg.c enhance_reg.c \
		equal_reg.c expand_reg.c extrema_reg.c \
		fhmtauto_reg.c flipdetect_reg.c \
		fmorphauto_reg.c fpix_reg.c gifio_reg.c \
		grayfill_reg.c graymorph_reg.c grayquant_reg.c \
		hardlight_reg.c heap_reg.c ioformats_reg.c \
		kernel_reg.c locminmax_reg.c \
		logicops_reg.c lowaccess_reg.c \
		maze_reg.c morphseq_reg.c numa_reg.c \
		paint_reg.c paintmask_reg.c \
		pixa1_reg.c pixa2_reg.c \
		pixadisp_reg.c pixalloc_reg.c \
		pixcomp_reg.c pixmem_reg.c \
		pixserial_reg.c pixtile_reg.c \
		projective_reg.c psioseg_reg.c \
		pta_reg.c ptra1_reg.c \
		ptra2_reg.c rank_reg.c \
		rasterop_reg.c rasteropip_reg.c \
		rotate1_reg.c rotate2_reg.c rotateorth_reg.c \
		scale_reg.c selio_reg.c \
		shear_reg.c  skew_reg.c \
		smallpix_reg.c smoothedge_reg.c splitcomp_reg.c \
		string_reg.c subpixel_reg.c threshnorm_reg.c \
		warper_reg.c writetext_reg.c xformbox_reg.c \
		adaptmaptest.c \
		arithtest.c barcodetest.c \
		baselinetest.c \
		bincompare.c blendcmaptest.c \
		blendtest1.c buffertest.c \
		ccbordtest.c cctest1.c \
		colormorphtest.c colorsegtest.c \
		colorspacetest.c comparepages.c \
		comparetest.c contrasttest.c \
		convertfilestops.c convertformat.c \
		convertsegfilestops.c converttogray.c \
		converttops.c convolvetest.c cornertest.c \
		croptext.c digitprep1.c dithertest.c \
		dwalineargen.c edgetest.c falsecolortest.c \
		fcombautogen.c fhmtautogen.c fileinfo.c \
		findpattern1.c findpattern2.c findpattern3.c \
		flipselgen.c \
		fmorphautogen.c gammatest.c \
		genfonts.c graphicstest.c graymorphtest.c \
		histotest.c iotest.c inserttest.c \
		jbcorrelation.c jbrankhaus.c jbwords.c \
		lineremoval.c listtest.c \
		maketile.c misctest1.c \
		modifyhuesat.c morphtest1.c mtifftest.c \
		numaranktest.c otsutest.c \
		pagesegtest1.c pagesegtest2.c pagesegtest3.c \
		partitiontest.c pixaatest.c \
		plottest.c \
		printimage.c printsplitimage.c printtiff.c \
		ranktest.c reducetest.c \
		removecmap.c renderfonts.c \
		rotatefastalt.c rotateorthtest1.c \
		rotatetest1.c runlengthtest.c \
		scaletest1.c scaletest2.c \
		seedfilltest.c sharptest.c \
		sheartest.c showedges.c \
		skewtest.c snapcolortest.c \
		sorttest.c splitimage2pdf.c \
		trctest.c \
		viewertest.c watershedtest.c \
		wordsinorder.c xtractprotos.c xvdisp.c

#  Remove the .o files from these on clean
SRC2 =		dwalinear.3.c dwalinearlow.3.c

######################################################################

all:	$(SRC:%.c=%)

debian:	binarize_reg \
	binmorph1_reg binmorph2_reg binmorph3_reg \
	binmorph4_reg binmorph5_reg \
	blend_reg blend2_reg buffertest comparetest \
	cctest1 ccthin1_reg \
	colormorphtest colorquant_reg colorspacetest \
	conncomp_reg conversion_reg \
	convertfilestops convertformat \
	convertsegfilestops converttops distance_reg \
	dithertest edgetest enhance_reg \
	equal_reg expand_reg extrema_reg \
	fhmtauto_reg fhmtautogen fileinfo \
	flipdetect_reg flipselgen fmorphauto_reg fmorphautogen \
	fpix_reg gammatest graphicstest grayfill_reg \
	graymorph_reg \
	grayquant_reg hardlight_reg heap_reg histotest ioformats_reg \
	jbcorrelation jbrankhaus jbwords \
	kernel_reg lineremoval locminmax_reg \
	lowaccess_reg maze_reg numaranktest numa_reg pagesegtest1 \
	pagesegtest2 pagesegtest3 paint_reg paintmask_reg \
	partitiontest pixalloc_reg pixmem_reg plottest \
	printimage printsplitimage printtiff \
	ranktest rank_reg removecmap rotate1_reg rotate2_reg \
	scale_reg selio_reg \
	sharptest shear_reg smallpix_reg \
	splitcomp_reg splitimage2pdf \
	viewertest warper_reg writetext_reg xtractprotos

######################################################################

adaptnorm_reg:	adaptnorm_reg.o $(LEPTLIB)
	$(CC) -o adaptnorm_reg adaptnorm_reg.o $(ALL_LIBS) $(EXTRALIBS)

affine_reg:	affine_reg.o $(LEPTLIB)
	$(CC) -o affine_reg affine_reg.o $(ALL_LIBS) $(EXTRALIBS)

alphaclean_reg:	alphaclean_reg.o $(LEPTLIB)
	$(CC) -o alphaclean_reg alphaclean_reg.o $(ALL_LIBS) $(EXTRALIBS)

bilinear_reg:	bilinear_reg.o $(LEPTLIB)
	$(CC) -o bilinear_reg bilinear_reg.o $(ALL_LIBS) $(EXTRALIBS)

binarize_reg:	binarize_reg.o $(LEPTLIB)
	$(CC) -o binarize_reg binarize_reg.o $(ALL_LIBS) $(EXTRALIBS)

binmorph1_reg:	binmorph1_reg.o $(LEPTLIB)
	$(CC) -o binmorph1_reg binmorph1_reg.o $(ALL_LIBS) $(EXTRALIBS)

binmorph2_reg:	binmorph2_reg.o $(LEPTLIB)
	$(CC) -o binmorph2_reg binmorph2_reg.o $(ALL_LIBS) $(EXTRALIBS)

binmorph3_reg:	binmorph3_reg.o $(LEPTLIB)
	$(CC) -o binmorph3_reg binmorph3_reg.o $(ALL_LIBS) $(EXTRALIBS)

binmorph4_reg:	binmorph4_reg.o $(LEPTLIB)
	$(CC) -o binmorph4_reg binmorph4_reg.o $(ALL_LIBS) $(EXTRALIBS)

binmorph5_reg:	binmorph5_reg.o $(LEPTLIB)
	$(CC) -o binmorph5_reg binmorph5_reg.o $(ALL_LIBS) $(EXTRALIBS)

blend_reg:	blend_reg.o $(LEPTLIB)
	$(CC) -o blend_reg blend_reg.o $(ALL_LIBS) $(EXTRALIBS)

blend2_reg:	blend2_reg.o $(LEPTLIB)
	$(CC) -o blend2_reg blend2_reg.o $(ALL_LIBS) $(EXTRALIBS)

ccthin1_reg:	ccthin1_reg.o $(LEPTLIB)
	$(CC) -o ccthin1_reg ccthin1_reg.o $(ALL_LIBS) $(EXTRALIBS)

ccthin2_reg:	ccthin2_reg.o $(LEPTLIB)
	$(CC) -o ccthin2_reg ccthin2_reg.o $(ALL_LIBS) $(EXTRALIBS)

cmapquant_reg:	cmapquant_reg.o $(LEPTLIB)
	$(CC) -o cmapquant_reg cmapquant_reg.o $(ALL_LIBS) $(EXTRALIBS)

colorquant_reg:	colorquant_reg.o $(LEPTLIB)
	$(CC) -o colorquant_reg colorquant_reg.o $(ALL_LIBS) $(EXTRALIBS)

colorseg_reg:	colorseg_reg.o $(LEPTLIB)
	$(CC) -o colorseg_reg colorseg_reg.o $(ALL_LIBS) $(EXTRALIBS)

compfilter_reg: compfilter_reg.o $(LEPTLIB)
	$(CC) -o compfilter_reg compfilter_reg.o $(ALL_LIBS) $(EXTRALIBS)

conncomp_reg: conncomp_reg.o $(LEPTLIB)
	$(CC) -o conncomp_reg conncomp_reg.o $(ALL_LIBS) $(EXTRALIBS)

conversion_reg: conversion_reg.o $(LEPTLIB)
	$(CC) -o conversion_reg conversion_reg.o $(ALL_LIBS) $(EXTRALIBS)

distance_reg:	distance_reg.o $(LEPTLIB)
	$(CC) -o distance_reg distance_reg.o $(ALL_LIBS) $(EXTRALIBS)

dwamorph1_reg:  dwamorph1_reg.o dwalinear.3.o dwalinearlow.3.o $(LEPTLIB)
	$(CC) -o dwamorph1_reg dwamorph1_reg.o dwalinear.3.o dwalinearlow.3.o $(ALL_LIBS) $(EXTRALIBS)

dwamorph2_reg:  dwamorph2_reg.o dwalinear.3.o dwalinearlow.3.o $(LEPTLIB)
	$(CC) -o dwamorph2_reg dwamorph2_reg.o dwalinear.3.o dwalinearlow.3.o $(ALL_LIBS) $(EXTRALIBS)

enhance_reg:	enhance_reg.o $(LEPTLIB)
	$(CC) -o enhance_reg enhance_reg.o $(ALL_LIBS) $(EXTRALIBS)

equal_reg:	equal_reg.o $(LEPTLIB)
	$(CC) -o equal_reg equal_reg.o $(ALL_LIBS) $(EXTRALIBS)

expand_reg:	expand_reg.o $(LEPTLIB)
	$(CC) -o expand_reg expand_reg.o $(ALL_LIBS) $(EXTRALIBS)

extrema_reg:	extrema_reg.o $(LEPTLIB)
	$(CC) -o extrema_reg extrema_reg.o $(ALL_LIBS) $(EXTRALIBS)

fhmtauto_reg:	fhmtauto_reg.o $(LEPTLIB)
	$(CC) -o fhmtauto_reg fhmtauto_reg.o $(ALL_LIBS) $(EXTRALIBS)

flipdetect_reg:	flipdetect_reg.o $(LEPTLIB)
	$(CC) -o flipdetect_reg flipdetect_reg.o $(ALL_LIBS) $(EXTRALIBS)

fmorphauto_reg:	fmorphauto_reg.o $(LEPTLIB)
	$(CC) -o fmorphauto_reg fmorphauto_reg.o $(ALL_LIBS) $(EXTRALIBS)

fpix_reg:	fpix_reg.o $(LEPTLIB)
	$(CC) -o fpix_reg fpix_reg.o $(ALL_LIBS) $(EXTRALIBS)

gifio_reg:	gifio_reg.o $(LEPTLIB)
	$(CC) -o gifio_reg gifio_reg.o $(ALL_LIBS) $(EXTRALIBS)

grayfill_reg:	grayfill_reg.o $(LEPTLIB)
	$(CC) -o grayfill_reg grayfill_reg.o $(ALL_LIBS) $(EXTRALIBS)

graymorph_reg:	graymorph_reg.o $(LEPTLIB)
	$(CC) -o graymorph_reg graymorph_reg.o $(ALL_LIBS) $(EXTRALIBS)

grayquant_reg:	grayquant_reg.o $(LEPTLIB)
	$(CC) -o grayquant_reg grayquant_reg.o $(ALL_LIBS) $(EXTRALIBS)

hardlight_reg:	hardlight_reg.o $(LEPTLIB)
	$(CC) -o hardlight_reg hardlight_reg.o $(ALL_LIBS) $(EXTRALIBS)

heap_reg:	heap_reg.o $(LEPTLIB)
	$(CC) -o heap_reg heap_reg.o $(ALL_LIBS) $(EXTRALIBS)

ioformats_reg:	ioformats_reg.o $(LEPTLIB)
	$(CC) -o ioformats_reg ioformats_reg.o $(ALL_LIBS) $(EXTRALIBS)

kernel_reg:	kernel_reg.o $(LEPTLIB)
	$(CC) -o kernel_reg kernel_reg.o $(ALL_LIBS) $(EXTRALIBS)

locminmax_reg:	locminmax_reg.o $(LEPTLIB)
	$(CC) -o locminmax_reg locminmax_reg.o $(ALL_LIBS) $(EXTRALIBS)

logicops_reg:	logicops_reg.o $(LEPTLIB)
	$(CC) -o logicops_reg logicops_reg.o $(ALL_LIBS) $(EXTRALIBS)

lowaccess_reg:	lowaccess_reg.o $(LEPTLIB)
	$(CC) -o lowaccess_reg lowaccess_reg.o $(ALL_LIBS) $(EXTRALIBS)

maze_reg:	maze_reg.o $(LEPTLIB)
	$(CC) -o maze_reg maze_reg.o $(ALL_LIBS) $(EXTRALIBS)

morphseq_reg:	morphseq_reg.o $(LEPTLIB)
	$(CC) -o morphseq_reg morphseq_reg.o $(ALL_LIBS) $(EXTRALIBS)

numa_reg:	numa_reg.o $(LEPTLIB)
	$(CC) -o numa_reg numa_reg.o $(ALL_LIBS) $(EXTRALIBS)

paint_reg:	paint_reg.o $(LEPTLIB)
	$(CC) -o paint_reg paint_reg.o $(ALL_LIBS) $(EXTRALIBS)

paintmask_reg:	paintmask_reg.o $(LEPTLIB)
	$(CC) -o paintmask_reg paintmask_reg.o $(ALL_LIBS) $(EXTRALIBS)

pixa1_reg:	pixa1_reg.o $(LEPTLIB)
	$(CC) -o pixa1_reg pixa1_reg.o $(ALL_LIBS) $(EXTRALIBS)

pixa2_reg:	pixa2_reg.o $(LEPTLIB)
	$(CC) -o pixa2_reg pixa2_reg.o $(ALL_LIBS) $(EXTRALIBS)

pixadisp_reg:	pixadisp_reg.o $(LEPTLIB)
	$(CC) -o pixadisp_reg pixadisp_reg.o $(ALL_LIBS) $(EXTRALIBS)

pixalloc_reg:	pixalloc_reg.o $(LEPTLIB)
	$(CC) -o pixalloc_reg pixalloc_reg.o $(ALL_LIBS) $(EXTRALIBS)

pixcomp_reg:	pixcomp_reg.o $(LEPTLIB)
	$(CC) -o pixcomp_reg pixcomp_reg.o $(ALL_LIBS) $(EXTRALIBS)

pixmem_reg:	pixmem_reg.o $(LEPTLIB)
	$(CC) -o pixmem_reg pixmem_reg.o $(ALL_LIBS) $(EXTRALIBS)

pixserial_reg:	pixserial_reg.o $(LEPTLIB)
	$(CC) -o pixserial_reg pixserial_reg.o $(ALL_LIBS) $(EXTRALIBS)

pixtile_reg:	pixtile_reg.o $(LEPTLIB)
	$(CC) -o pixtile_reg pixtile_reg.o $(ALL_LIBS) $(EXTRALIBS)

projective_reg:	projective_reg.o $(LEPTLIB)
	$(CC) -o projective_reg projective_reg.o $(ALL_LIBS) $(EXTRALIBS)

psioseg_reg:	psioseg_reg.o $(LEPTLIB)
	$(CC) -o psioseg_reg psioseg_reg.o $(ALL_LIBS) $(EXTRALIBS)

pta_reg:	pta_reg.o $(LEPTLIB)
	$(CC) -o pta_reg pta_reg.o $(ALL_LIBS) $(EXTRALIBS)

ptra1_reg:	ptra1_reg.o $(LEPTLIB)
	$(CC) -o ptra1_reg ptra1_reg.o $(ALL_LIBS) $(EXTRALIBS)

ptra2_reg:	ptra2_reg.o $(LEPTLIB)
	$(CC) -o ptra2_reg ptra2_reg.o $(ALL_LIBS) $(EXTRALIBS)

rank_reg:	rank_reg.o $(LEPTLIB)
	$(CC) -o rank_reg rank_reg.o $(ALL_LIBS) $(EXTRALIBS)

rasterop_reg:	rasterop_reg.o $(LEPTLIB)
	$(CC) -o rasterop_reg rasterop_reg.o $(ALL_LIBS) $(EXTRALIBS)

rasteropip_reg:	rasteropip_reg.o $(LEPTLIB)
	$(CC) -o rasteropip_reg rasteropip_reg.o $(ALL_LIBS) $(EXTRALIBS)

rotate1_reg:	rotate1_reg.o $(LEPTLIB)
	$(CC) -o rotate1_reg rotate1_reg.o $(ALL_LIBS) $(EXTRALIBS)

rotate2_reg:	rotate2_reg.o $(LEPTLIB)
	$(CC) -o rotate2_reg rotate2_reg.o $(ALL_LIBS) $(EXTRALIBS)

rotateorth_reg:	rotateorth_reg.o $(LEPTLIB)
	$(CC) -o rotateorth_reg rotateorth_reg.o $(ALL_LIBS) $(EXTRALIBS)

scale_reg:	scale_reg.o $(LEPTLIB)
	$(CC) -o scale_reg scale_reg.o $(ALL_LIBS) $(EXTRALIBS)

selio_reg:	selio_reg.o $(LEPTLIB)
	$(CC) -o selio_reg selio_reg.o $(ALL_LIBS) $(EXTRALIBS)

shear_reg:	shear_reg.o $(LEPTLIB)
	$(CC) -o shear_reg shear_reg.o $(ALL_LIBS) $(EXTRALIBS)

skew_reg:	skew_reg.o $(LEPTLIB)
	$(CC) -o skew_reg skew_reg.o $(ALL_LIBS) $(EXTRALIBS)

smallpix_reg:	smallpix_reg.o $(LEPTLIB)
	$(CC) -o smallpix_reg smallpix_reg.o $(ALL_LIBS) $(EXTRALIBS)

smoothedge_reg:	smoothedge_reg.o $(LEPTLIB)
	$(CC) -o smoothedge_reg smoothedge_reg.o $(ALL_LIBS) $(EXTRALIBS)

splitcomp_reg:	splitcomp_reg.o $(LEPTLIB)
	$(CC) -o splitcomp_reg splitcomp_reg.o $(ALL_LIBS) $(EXTRALIBS)

string_reg:	string_reg.o $(LEPTLIB)
	$(CC) -o string_reg string_reg.o $(ALL_LIBS) $(EXTRALIBS)

subpixel_reg:	subpixel_reg.o $(LEPTLIB)
	$(CC) -o subpixel_reg subpixel_reg.o $(ALL_LIBS) $(EXTRALIBS)

threshnorm_reg:	threshnorm_reg.o $(LEPTLIB)
	$(CC) -o threshnorm_reg threshnorm_reg.o $(ALL_LIBS) $(EXTRALIBS)

warper_reg:	warper_reg.o $(LEPTLIB)
	$(CC) -o warper_reg warper_reg.o $(ALL_LIBS) $(EXTRALIBS)

writetext_reg:	writetext_reg.o $(LEPTLIB)
	$(CC) -o writetext_reg writetext_reg.o $(ALL_LIBS) $(EXTRALIBS)

xformbox_reg:	xformbox_reg.o $(LEPTLIB)
	$(CC) -o xformbox_reg xformbox_reg.o $(ALL_LIBS) $(EXTRALIBS)

adaptmaptest:	adaptmaptest.o $(LEPTLIB)
	$(CC) -o adaptmaptest adaptmaptest.o $(ALL_LIBS) $(EXTRALIBS)

arithtest:	arithtest.o $(LEPTLIB)
	$(CC) -o arithtest arithtest.o $(ALL_LIBS) $(EXTRALIBS)

barcodetest:	barcodetest.o $(LEPTLIB)
	$(CC) -o barcodetest barcodetest.o $(ALL_LIBS) $(EXTRALIBS)

baselinetest:	baselinetest.o $(LEPTLIB)
	$(CC) -o baselinetest baselinetest.o $(ALL_LIBS) $(EXTRALIBS)

bincompare:	bincompare.o $(LEPTLIB)
	$(CC) -o bincompare bincompare.o $(ALL_LIBS) $(EXTRALIBS)

blendcmaptest:	blendcmaptest.o $(LEPTLIB)
	$(CC) -o blendcmaptest blendcmaptest.o $(ALL_LIBS) $(EXTRALIBS)

blendtest1:	blendtest1.o $(LEPTLIB)
	$(CC) -o blendtest1 blendtest1.o $(ALL_LIBS) $(EXTRALIBS)

buffertest:	buffertest.o $(LEPTLIB)
	$(CC) -o buffertest buffertest.o $(ALL_LIBS) $(EXTRALIBS)

ccbordtest:	ccbordtest.o $(LEPTLIB)
	$(CC) -o ccbordtest ccbordtest.o $(ALL_LIBS) $(EXTRALIBS)

cctest1:	cctest1.o $(LEPTLIB)
	$(CC) -o cctest1 cctest1.o $(ALL_LIBS) $(EXTRALIBS)

colormorphtest:	colormorphtest.o $(LEPTLIB)
	$(CC) -o colormorphtest colormorphtest.o $(ALL_LIBS) $(EXTRALIBS)

colorsegtest:	colorsegtest.o $(LEPTLIB)
	$(CC) -o colorsegtest colorsegtest.o $(ALL_LIBS) $(EXTRALIBS)

colorspacetest:	colorspacetest.o $(LEPTLIB)
	$(CC) -o colorspacetest colorspacetest.o $(ALL_LIBS) $(EXTRALIBS)

comparepages:	comparepages.o $(LEPTLIB)
	$(CC) -o comparepages comparepages.o $(ALL_LIBS) $(EXTRALIBS)

comparetest:	comparetest.o $(LEPTLIB)
	$(CC) -o comparetest comparetest.o $(ALL_LIBS) $(EXTRALIBS)

contrasttest:	contrasttest.o $(LEPTLIB)
	$(CC) -o contrasttest contrasttest.o $(ALL_LIBS) $(EXTRALIBS)

convertfilestops:	convertfilestops.o $(LEPTLIB)
	$(CC) -o convertfilestops convertfilestops.o $(ALL_LIBS) $(EXTRALIBS)

convertformat:	convertformat.o $(LEPTLIB)
	$(CC) -o convertformat convertformat.o $(ALL_LIBS) $(EXTRALIBS)

convertsegfilestops:	convertsegfilestops.o $(LEPTLIB)
	$(CC) -o convertsegfilestops convertsegfilestops.o $(ALL_LIBS) $(EXTRALIBS)

converttogray:	converttogray.o $(LEPTLIB)
	$(CC) -o converttogray converttogray.o $(ALL_LIBS) $(EXTRALIBS)

converttops:	converttops.o $(LEPTLIB)
	$(CC) -o converttops converttops.o $(ALL_LIBS) $(EXTRALIBS)

convolvetest:	convolvetest.o $(LEPTLIB)
	$(CC) -o convolvetest convolvetest.o $(ALL_LIBS) $(EXTRALIBS)

cornertest:	cornertest.o $(LEPTLIB)
	$(CC) -o cornertest cornertest.o $(ALL_LIBS) $(EXTRALIBS)

croptext:	croptext.o $(LEPTLIB)
	$(CC) -o croptext croptext.o $(ALL_LIBS) $(EXTRALIBS)

digitprep1:	digitprep1.o $(LEPTLIB)
	$(CC) -o digitprep1 digitprep1.o $(ALL_LIBS) $(EXTRALIBS)

dithertest:	dithertest.o $(LEPTLIB)
	$(CC) -o dithertest dithertest.o $(ALL_LIBS) $(EXTRALIBS)

dwalineargen:	dwalineargen.o $(LEPTLIB)
	$(CC) -o dwalineargen dwalineargen.o $(ALL_LIBS) $(EXTRALIBS)

edgetest:	edgetest.o $(LEPTLIB)
	$(CC) -o edgetest edgetest.o $(ALL_LIBS) $(EXTRALIBS)

falsecolortest:	falsecolortest.o $(LEPTLIB)
	$(CC) -o falsecolortest falsecolortest.o $(ALL_LIBS) $(EXTRALIBS)

fhmtautogen:	fhmtautogen.o $(LEPTLIB)
	$(CC) -o fhmtautogen fhmtautogen.o $(ALL_LIBS) $(EXTRALIBS)

fileinfo:	fileinfo.o $(LEPTLIB)
	$(CC) -o fileinfo fileinfo.o $(ALL_LIBS) $(EXTRALIBS)

findpattern1:	findpattern1.o $(LEPTLIB)
	$(CC) -o findpattern1 findpattern1.o $(ALL_LIBS) $(EXTRALIBS)

findpattern2:	findpattern2.o $(LEPTLIB)
	$(CC) -o findpattern2 findpattern2.o $(ALL_LIBS) $(EXTRALIBS)

findpattern3:	findpattern3.o $(LEPTLIB)
	$(CC) -o findpattern3 findpattern3.o $(ALL_LIBS) $(EXTRALIBS)

flipselgen:	flipselgen.o $(LEPTLIB)
	$(CC) -o flipselgen flipselgen.o $(ALL_LIBS) $(EXTRALIBS)

fcombautogen:	fcombautogen.o $(LEPTLIB)
	$(CC) -o fcombautogen fcombautogen.o $(ALL_LIBS) $(EXTRALIBS)

fmorphautogen:	fmorphautogen.o $(LEPTLIB)
	$(CC) -o fmorphautogen fmorphautogen.o $(ALL_LIBS) $(EXTRALIBS)

gammatest:	gammatest.o $(LEPTLIB)
	$(CC) -o gammatest gammatest.o $(ALL_LIBS) $(EXTRALIBS)

genfonts:	genfonts.o $(LEPTLIB)
	$(CC) -o genfonts genfonts.o $(ALL_LIBS) $(EXTRALIBS)

graphicstest:	graphicstest.o $(LEPTLIB)
	$(CC) -o graphicstest graphicstest.o $(ALL_LIBS) $(EXTRALIBS)

graymorphtest:	graymorphtest.o $(LEPTLIB)
	$(CC) -o graymorphtest graymorphtest.o $(ALL_LIBS) $(EXTRALIBS)

histotest:	histotest.o $(LEPTLIB)
	$(CC) -o histotest histotest.o $(ALL_LIBS) $(EXTRALIBS)

iotest:		iotest.o $(LEPTLIB)
	$(CC) -o iotest iotest.o $(ALL_LIBS) $(EXTRALIBS)

inserttest:	inserttest.o $(LEPTLIB)
	$(CC) -o inserttest inserttest.o $(ALL_LIBS) $(EXTRALIBS)

jbcorrelation:	jbcorrelation.o $(LEPTLIB)
	$(CC) -o jbcorrelation jbcorrelation.o $(ALL_LIBS) $(EXTRALIBS)

jbrankhaus:	jbrankhaus.o $(LEPTLIB)
	$(CC) -o jbrankhaus jbrankhaus.o $(ALL_LIBS) $(EXTRALIBS)

jbwords:	jbwords.o $(LEPTLIB)
	$(CC) -o jbwords jbwords.o $(ALL_LIBS) $(EXTRALIBS)

lineremoval:	lineremoval.o $(LEPTLIB)
	$(CC) -o lineremoval lineremoval.o $(ALL_LIBS) $(EXTRALIBS)

listtest:	listtest.o $(LEPTLIB)
	$(CC) -o listtest listtest.o $(ALL_LIBS) $(EXTRALIBS)

maketile:	maketile.o $(LEPTLIB)
	$(CC) -o maketile maketile.o $(ALL_LIBS) $(EXTRALIBS)

misctest1:	misctest1.o $(LEPTLIB)
	$(CC) -o misctest1 misctest1.o $(ALL_LIBS) $(EXTRALIBS)

modifyhuesat:	modifyhuesat.o $(LEPTLIB)
	$(CC) -o modifyhuesat modifyhuesat.o $(ALL_LIBS) $(EXTRALIBS)

morphtest1:	morphtest1.o $(LEPTLIB)
	$(CC) -o morphtest1 morphtest1.o $(ALL_LIBS) $(EXTRALIBS)

mtifftest:	mtifftest.o $(LEPTLIB)
	$(CC) -o mtifftest mtifftest.o $(ALL_LIBS) $(EXTRALIBS)

numaranktest:	numaranktest.o $(LEPTLIB)
	$(CC) -o numaranktest numaranktest.o $(ALL_LIBS) $(EXTRALIBS)

otsutest:	otsutest.o $(LEPTLIB)
	$(CC) -o otsutest otsutest.o $(ALL_LIBS) $(EXTRALIBS)

pagesegtest1:	pagesegtest1.o $(LEPTLIB)
	$(CC) -o pagesegtest1 pagesegtest1.o $(ALL_LIBS) $(EXTRALIBS)

pagesegtest2:	pagesegtest2.o $(LEPTLIB)
	$(CC) -o pagesegtest2 pagesegtest2.o $(ALL_LIBS) $(EXTRALIBS)

pagesegtest3:	pagesegtest3.o $(LEPTLIB)
	$(CC) -o pagesegtest3 pagesegtest3.o $(ALL_LIBS) $(EXTRALIBS)

partitiontest:	partitiontest.o $(LEPTLIB)
	$(CC) -o partitiontest partitiontest.o $(ALL_LIBS) $(EXTRALIBS)

pixaatest:	pixaatest.o $(LEPTLIB)
	$(CC) -o pixaatest pixaatest.o $(ALL_LIBS) $(EXTRALIBS)

plottest:	plottest.o $(LEPTLIB)
	$(CC) -o plottest plottest.o $(ALL_LIBS) $(EXTRALIBS)

printimage:	printimage.o $(LEPTLIB)
	$(CC) -o printimage printimage.o $(ALL_LIBS) $(EXTRALIBS)

printsplitimage:	printsplitimage.o $(LEPTLIB)
	$(CC) -o printsplitimage printsplitimage.o $(ALL_LIBS) $(EXTRALIBS)

printtiff:	printtiff.o $(LEPTLIB)
	$(CC) -o printtiff printtiff.o $(ALL_LIBS) $(EXTRALIBS)

ranktest:	ranktest.o $(LEPTLIB)
	$(CC) -o ranktest ranktest.o $(ALL_LIBS) $(EXTRALIBS)

reducetest:	reducetest.o $(LEPTLIB)
	$(CC) -o reducetest reducetest.o $(ALL_LIBS) $(EXTRALIBS)

removecmap:	removecmap.o $(LEPTLIB)
	$(CC) -o removecmap removecmap.o $(ALL_LIBS) $(EXTRALIBS)

renderfonts:	renderfonts.o $(LEPTLIB)
	$(CC) -o renderfonts renderfonts.o $(ALL_LIBS) $(EXTRALIBS)

rotatefastalt:	rotatefastalt.o $(LEPTLIB)
	$(CC) -o rotatefastalt rotatefastalt.o $(ALL_LIBS) $(EXTRALIBS)

rotateorthtest1:	rotateorthtest1.o $(LEPTLIB)
	$(CC) -o rotateorthtest1 rotateorthtest1.o $(ALL_LIBS) $(EXTRALIBS)

rotatetest1:	rotatetest1.o $(LEPTLIB)
	$(CC) -o rotatetest1 rotatetest1.o $(ALL_LIBS) $(EXTRALIBS)

runlengthtest:	runlengthtest.o $(LEPTLIB)
	$(CC) -o runlengthtest runlengthtest.o $(ALL_LIBS) $(EXTRALIBS)

scaletest1:	scaletest1.o $(LEPTLIB)
	$(CC) -o scaletest1 scaletest1.o $(ALL_LIBS) $(EXTRALIBS)

scaletest2:	scaletest2.o $(LEPTLIB)
	$(CC) -o scaletest2 scaletest2.o $(ALL_LIBS) $(EXTRALIBS)

seedfilltest:	seedfilltest.o $(LEPTLIB)
	$(CC) -o seedfilltest seedfilltest.o $(ALL_LIBS) $(EXTRALIBS)

sharptest:	sharptest.o $(LEPTLIB)
	$(CC) -o sharptest sharptest.o $(ALL_LIBS) $(EXTRALIBS)

sheartest:	sheartest.o $(LEPTLIB)
	$(CC) -o sheartest sheartest.o $(ALL_LIBS) $(EXTRALIBS)

showedges:	showedges.o $(LEPTLIB)
	$(CC) -o showedges showedges.o $(ALL_LIBS) $(EXTRALIBS)

skewtest:	skewtest.o $(LEPTLIB)
	$(CC) -o skewtest skewtest.o $(ALL_LIBS) $(EXTRALIBS)

snapcolortest:	snapcolortest.o $(LEPTLIB)
	$(CC) -o snapcolortest snapcolortest.o $(ALL_LIBS) $(EXTRALIBS)

sorttest:	sorttest.o $(LEPTLIB)
	$(CC) -o sorttest sorttest.o $(ALL_LIBS) $(EXTRALIBS)

splitimage2pdf:	splitimage2pdf.o $(LEPTLIB)
	$(CC) -o splitimage2pdf splitimage2pdf.o $(ALL_LIBS) $(EXTRALIBS)

trctest:	trctest.o $(LEPTLIB)
	$(CC) -o trctest trctest.o $(ALL_LIBS) $(EXTRALIBS)

viewertest:	viewertest.o $(LEPTLIB)
	$(CC) -o viewertest viewertest.o $(ALL_LIBS) $(EXTRALIBS)

watershedtest:	watershedtest.o $(LEPTLIB)
	$(CC) -o watershedtest watershedtest.o $(ALL_LIBS) $(EXTRALIBS)

wordsinorder:	wordsinorder.o $(LEPTLIB)
	$(CC) -o wordsinorder wordsinorder.o $(ALL_LIBS) $(EXTRALIBS)

xtractprotos:   xtractprotos.o $(LEPTLIB)
	$(CC) -o xtractprotos xtractprotos.o $(ALL_LIBS) $(EXTRALIBS)

xvdisp:		xvdisp.o $(LEPTLIB)
	$(CC) -o xvdisp xvdisp.o $(ALL_LIBS) $(EXTRALIBS)

###########################################################

clean:
	-@ for file in $(SRC:%.c=%) ; do \
		rm -f $$file; \
	done ;
	-@ for file in $(SRC:%.c=%.o) ; do \
		rm -f $$file; \
	done ;
	-@ for file in $(SRC2:%.c=%.o) ; do \
		rm -f $$file; \
	done ;

###########################################################
 
install:
	mkdir -p $(DESTDIR)/usr/bin/leptonica
	-@ for file in $(SRC:%.c=%) ; do \
		install $$file $(DESTDIR)/usr/bin/leptonica; \
	done ;

###########################################################

depend:
	$(BIN)/makedepend -DNO_PROTOS $(CPPFLAGS) $(SRC)

dependprotos:
	$(BIN)/makedepend $(CPPFLAGS) $(SRC)

# DO NOT DELETE THIS LINE -- make depend depends on it.
