# Copyright 2006 Deutsches Forschungszentrum fuer Kuenstliche Intelligenz 
# or its licensors, as applicable.
# 
# You may not use this file except under the terms of the accompanying license.
# 
# Licensed under the Apache License, Version 2.0 (the "License"); you
# may not use this file except in compliance with the License. You may
# obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 
# Project: ocroscript
# File: Jamfile
# Purpose:
# Responsible: tmb
# Reviewer: 
# Primary Repository: 
# Web Sites: www.iupr.org, www.dfki.de

SubDir TOP ocroscript ;

ImportDir TOP ext tolua++ ;
ImportDir TOP ext lua ;
ImportDir TOP colib ;
ImportDir TOP imgio ;
ImportDir TOP imglib ;
ImportDir TOP imgbits ;
ImportDir TOP ocr-utils ;
ImportDir TOP ocr-binarize ;
ImportDir TOP ocr-layout-rast ;
ImportDir TOP ocr-deskew-rast ;
ImportDir TOP ocr-doc-clean ;
ImportDir TOP ocr-pageseg ;
ImportDir TOP ocr-tesseract ;
# ImportDir TOP ocr-engine ;
ImportDir TOP ocr-bpnet ;
ImportDir TOP ocr-samples ;
ImportDir TOP langmods ;


# FIXME this doesn't seem to be working

ObjectC++Flags <$(SOURCE_GRIST)>ocroscript.cc : -DOCROSCRIPTS=\"$(OCROSCRIPTS)\" ;

if $(nofst) = ""  {
	C++Flags += -DHAVE_FST ;
	FST_PACKAGES = fst.pkg ;
} else {
	FST_PACKAGES = fst-stub.cc ;
}

PACKAGES =
    sysutil.pkg
    narray.pkg
    nustring.pkg
    image.pkg
    imgbitscmds.pkg
    imgrlecmds.pkg
    ocr.pkg
    # ocr-util.pkg
    # loggers_pkg.pkg
    $(FST_PACKAGES)
    # fst.pkg
;

if $(nolept) = "" {
PACKAGES += lepton.pkg ;
LINKLIBS += -llept ;
C++FLAGS += -DWITH_LEPT ;
}

if $(notesseract) = "" {
        PACKAGES += tess.pkg ;
} else {
        PACKAGES += tess-stub.cc ;
}


if $(nosdl) = "" {
	C++Flags += -DHAVE_SDL ;
	PACKAGES += graphics.pkg ;
	LINKLIBS += -lSDL_gfx -lSDL ;
} else {
	PACKAGES += graphics.pkg ;
}

if $(noeditline) = "" {
    LINKLIBS += -ledit ;
    SUBDIRC++FLAGS += -DLUA_USE_EDITLINE ;
}

# provide path to tesseract headers for lua binding
AddC++Flags tess : -I$(TESSHEADERS) ;

Lib libocroscript : $(PACKAGES) ocrotoplevel.cc ; # loggers.cc ;

Depends <$(SOURCE_GRIST)>$(PACKAGES:S=.cc) : tolua++ ;

ALWAYS <$(SOURCE_GRIST)>version.cc ;
GenerateVersion <$(SOURCE_GRIST)>version.cc ;

MakeLocate <$(SOURCE_GRIST)>version.cc : $(SUBDIR) ;
Exe ocroscript-simple : ocroscript-simple.cc <$(SOURCE_GRIST)>version.cc ;

if $(noeditline) = "" {
    Exe ocroscript : ocroscript.cc <$(SOURCE_GRIST)>version.cc ;
} else {
    Exe ocroscript : ocroscript.cc <$(SOURCE_GRIST)>version.cc <$(SOURCE_GRIST)>editline-stub.cc ;
}


