Skip to content

Commit

Permalink
1. Added targets to build libpng, libjpg, libtiff. Instead of scripts.
Browse files Browse the repository at this point in the history
2. Removed internal tesseract and leptonica headers from the project.
  • Loading branch information
ws233 committed Aug 16, 2015
1 parent 13eb4bf commit 0e12559
Show file tree
Hide file tree
Showing 278 changed files with 338 additions and 46,008 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ These are the current versions of the upstream bundled libraries within the fram
* Tesseract 3.03-rc1 ([homepage](https://code.google.com/p/tesseract-ocr/))
* Leptonica 1.72 ([homepage](http://leptonica.org/))
* Libtiff 4.0.4 ([homepage](http://www.remotesensing.org/libtiff/))
* Libpng 1.6.17 ([homepage](http://www.libpng.org/pub/png/libpng.html))
* Libpng 1.6.18 ([homepage](http://www.libpng.org/pub/png/libpng.html))
* Libjpeg 9a ([homepage](http://libjpeg.sourceforge.net/))

Getting Started
Expand Down
1,495 changes: 233 additions & 1,262 deletions Tesseract OCR iOS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

132 changes: 104 additions & 28 deletions TesseractOCR/Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
LEPTON_NAME = leptonica-1.72
PNG_NAME = libpng-1.6.18
JPEG_NAME = jpeg-9a
TIFF_NAME = tiff-4.0.4

SDK_IPHONEOS_PATH=$(shell xcrun --sdk iphoneos --show-sdk-path)
SDK_IPHONESIMULATOR_PATH=$(shell xcrun --sdk iphonesimulator --show-sdk-path)
XCODE_DEVELOPER_PATH=/Applications/Xcode.app/Contents/Developer
XCODETOOLCHAIN_PATH=$(XCODE_DEVELOPER_PATH)/Toolchains/XcodeDefault.xctoolchain
IOS_DEPLOY_TGT="7.0"

LEPTON_NAME = leptonica-1.72

TESSERACT_SRC = $(shell pwd)/tesseract-ocr
LEPTON_SRC = $(shell pwd)/$(LEPTON_NAME)
IMAGE_SRC = $(shell pwd)/libtiff-ios
PNG_SRC = $(IMAGE_SRC)/$(PNG_NAME)
JPEG_SRC = $(IMAGE_SRC)/$(JPEG_NAME)
TIFF_SRC = $(IMAGE_SRC)/$(TIFF_NAME)

IMAGE_LIB_DIR = $(IMAGE_SRC)/dependencies/lib/
IMAGE_INC_DIR = $(IMAGE_SRC)/dependencies/include/
LIB_FAT_DIR = $(shell pwd)/lib
LEPT_INC_DIR = $(shell pwd)/include
TESS_INC_DIR = $(shell pwd)/include
LIB_FAT_DIR = $(shell pwd)/lib

libtessallfiles = libtesseract_all.a
libtessfiles = ccmain/.libs/libtesseract_main.a ccstruct/.libs/libtesseract_ccstruct.a \
Expand All @@ -21,39 +29,50 @@ libtessfiles = ccmain/.libs/libtesseract_main.a ccstruct/.libs/libtesseract_ccst
textord/.libs/libtesseract_textord.a viewer/.libs/libtesseract_viewer.a wordrec/.libs/libtesseract_wordrec.a \
api/.libs/libtesseract.a api/.libs/libtesseract_api.a
libleptfiles = liblept.a
libpngfiles = libpng.a libpng16.a
libpngfiles = libpng.a
libjpegfiles = libjpeg.a
libtifffiles = libtiff.a libtiffxx.a
libtifffiles = libtiff.a

sdks = $(SDK_IPHONEOS_PATH) $(SDK_IPHONEOS_PATH) $(SDK_IPHONEOS_PATH) $(SDK_IPHONESIMULATOR_PATH) $(SDK_IPHONESIMULATOR_PATH)
archs = armv7 armv7s arm64 i386 x86_64
arch_names = arm-apple-darwin7 arm-apple-darwin7s arm-apple-darwin64 i386-apple-darwin x86_64-apple-darwin

libleptfolders = $(foreach arch, $(arch_names), $(LEPTON_SRC)/$(arch)/)
libleptmakefile = $(foreach folder, $(libleptfolders), $(addprefix $(folder), Makefile) )

libtessfolders = $(foreach arch, $(arch_names), $(TESSERACT_SRC)/$(arch)/)
libpngfolders = $(foreach arch, $(arch_names), $(PNG_SRC)/$(arch)/)
libjpegfolders = $(foreach arch, $(arch_names), $(JPEG_SRC)/$(arch)/)
libtifffolders = $(foreach arch, $(arch_names), $(TIFF_SRC)/$(arch)/)

libleptmakefile = $(foreach folder, $(libleptfolders), $(addprefix $(folder), Makefile) )
libtessmakefile = $(foreach folder, $(libtessfolders), $(addprefix $(folder), Makefile) )
libpngmakefile = $(foreach folder, $(libpngfolders), $(addprefix $(folder), Makefile) )
libjpegmakefile = $(foreach folder, $(libjpegfolders), $(addprefix $(folder), Makefile) )
libtiffmakefile = $(foreach folder, $(libtifffolders), $(addprefix $(folder), Makefile) )

libleptfat = $(LIB_FAT_DIR)/$(libleptfiles)
libtessfat = $(LIB_FAT_DIR)/$(libtessallfiles)
libpngfat = $(addprefix $(IMAGE_LIB_DIR), $(libpngfiles))
libjpegfat = $(addprefix $(IMAGE_LIB_DIR), $(libjpegfiles))
libtifffat = $(addprefix $(IMAGE_LIB_DIR), $(libtifffiles))

libtessall = $(foreach folder, $(libtessfolders), $(addprefix $(folder), $(libtessallfiles)) )
libtess = $(foreach folder, $(libtessfolders), $(addprefix $(folder), $(libtessfiles)) )
liblept = $(foreach folder, $(addsuffix src/.libs/, $(libleptfolders) ), $(addprefix $(folder), $(libleptfiles)) )
libpng = $(addprefix $(IMAGE_LIB_DIR), $(libpngfiles))
libjpeg = $(addprefix $(IMAGE_LIB_DIR), $(libjpegfiles))
libtiff = $(addprefix $(IMAGE_LIB_DIR), $(libtifffiles))
libpng = $(foreach folder, $(libpngfolders), $(addprefix $(folder)/lib/, $(libpngfiles)) )
libjpeg = $(foreach folder, $(libjpegfolders), $(addprefix $(folder)/lib/, $(libjpegfiles)) )
libtiff = $(foreach folder, $(libtifffolders), $(addprefix $(folder)/lib/, $(libtifffiles)) )

libtessautogen = $(TESSERACT_SRC)/autogen.sh
libtessconfig = $(TESSERACT_SRC)/configure
libleptconfig = $(LEPTON_SRC)/configure
libtiffconfig = $(IMAGE_SRC)
libpngconfig = $(PNG_SRC)/configure
libjpegconfig = $(JPEG_SRC)/configure
libtiffconfig = $(TIFF_SRC)/configure

index = $(words $(shell a="$(2)";echo $${a/$(1)*/$(1)} ))
swap = $(word $(call index,$(1),$(2)),$(3))

dependant_libs = $(libtessfat) $(libleptfat) $(libpng) $(libjpeg) $(libtiff)
dependant_libs = $(libtessfat) $(libleptfat) $(libpngfat) $(libjpegfat) $(libtifffat)

.PHONY : all
all : $(dependant_libs)
Expand All @@ -62,7 +81,10 @@ all : $(dependant_libs)
# TESSERACT-OCR
#######################
$(libtessfat) : $(libtessall)
mkdir -p $(LIB_FAT_DIR)
xcrun lipo $^ -create -output $@
mkdir -p $(TESS_INC_DIR)
cp -rvf $(firstword $(libtessfolders))/include/tesseract $(TESS_INC_DIR)

$(libtessall) : $(libtess)
cd $(@D) ; \
Expand All @@ -71,7 +93,7 @@ $(libtessall) : $(libtess)
$(libtess) : $(liblept) $(libtessmakefile)
echo $(libtessmakefile)
cd $(abspath $(@D)/..) ; \
$(MAKE)
$(MAKE) -j8 && $(MAKE) install

$(TESSERACT_SRC)/%/Makefile : $(libtessconfig)
export LIBS="-lz -lpng -ljpeg -ltiff" ; \
Expand All @@ -84,7 +106,7 @@ $(TESSERACT_SRC)/%/Makefile : $(libtessconfig)
mkdir -p $(@D) ; \
cd $(@D) ; \
ln -s $(LEPTON_SRC)/src/ leptonica ; \
../configure --host=$* --enable-shared=no --disable-graphics
../configure --host=$* --prefix=`pwd` --enable-shared=no --disable-graphics

$(libtessconfig) : $(libtessautogen)
cd $(@D) ; \
Expand All @@ -94,13 +116,16 @@ $(libtessconfig) : $(libtessautogen)
# LEPTONLIB
#######################
$(libleptfat) : $(liblept)
mkdir -p $(LIB_FAT_DIR)
xcrun lipo $^ -create -output $@
mkdir -p $(LEPT_INC_DIR)
cp -rvf $(firstword $(libleptfolders))/include/leptonica $(LEPT_INC_DIR)

$(liblept) : $(libtiff) $(libleptmakefile)
$(liblept) : $(libleptmakefile)
cd $(abspath $(@D)/../..) ; \
$(MAKE)
$(MAKE) -j8 && $(MAKE) install

$(LEPTON_SRC)/%/Makefile : $(libleptconfig)
$(LEPTON_SRC)/%/Makefile : $(libjpegfat) $(libpngfat) $(libtifffat) $(libleptconfig)
export LIBS="-lz -lpng -ljpeg -ltiff" ; \
export SDKROOT="$(call swap, $*, $(arch_names), $(sdks))" ; \
export CFLAGS="-I$(IMAGE_INC_DIR) -L$(IMAGE_LIB_DIR) -Qunused-arguments -arch $(call swap, $*, $(arch_names), $(archs)) -pipe -no-cpp-precomp -isysroot $$SDKROOT -miphoneos-version-min=$(IOS_DEPLOY_TGT) -O2" ; \
Expand All @@ -109,27 +134,72 @@ $(LEPTON_SRC)/%/Makefile : $(libleptconfig)
export LDFLAGS="-L$$SDKROOT/usr/lib/ -L$(IMAGE_LIB_DIR)" ; \
mkdir -p $(@D) ; \
cd $(@D) ; \
../configure --host=$* --enable-shared=no --disable-programs --with-zlib --with-libpng --with-jpeg --without-giflib --with-libtiff
../configure --host=$* --prefix=`pwd` --enable-shared=no --disable-programs --with-zlib --with-libpng --with-jpeg --without-giflib --with-libtiff

#######################
# Build libtiff and all of it's dependencies
#######################
$(libtiff) : $(libpng) $(libjpeg) $(libtiffconfig)
cd $(IMAGE_SRC) ; \
./build-tiff.sh
$(libtifffat) : $(libtiff)
mkdir -p $(@D)
xcrun lipo $(addsuffix lib/$(@F), $(libtifffolders)) -create -output $@
mkdir -p $(IMAGE_INC_DIR)
cp -rvf $(firstword $(libtifffolders))/include/*.h $(IMAGE_INC_DIR)

$(libtiff) : $(libtiffmakefile)
cd $(abspath $(@D)/..) ; \
$(MAKE) -j8 && $(MAKE) install

$(TIFF_SRC)/%/Makefile : $(libtiffconfig)
export SDKROOT="$(call swap, $*, $(arch_names), $(sdks))" ; \
export CFLAGS="-Qunused-arguments -arch $(call swap, $*, $(arch_names), $(archs)) -pipe -no-cpp-precomp -isysroot $$SDKROOT -miphoneos-version-min=$(IOS_DEPLOY_TGT) -O2" ; \
export CPPFLAGS=$$CFLAGS ; \
export CXXFLAGS="$$CFLAGS -Wno-deprecated-register"; \
mkdir -p $(@D) ; \
cd $(@D) ; \
../configure --host=$* --enable-fast-install --enable-shared=no --prefix=`pwd` --without-x --with-jpeg-include-dir=$(abspath $(@D)/../../$(JPEG_NAME)/$*/include) --with-jpeg-lib-dir=$(abspath $(@D)/../../$(JPEG_NAME)/$*/lib)

$(libpng) : $(libtiffconfig)
cd $(IMAGE_SRC); \
./build-png.sh
$(libpngfat) : $(libpng)
mkdir -p $(@D)
xcrun lipo $(addsuffix lib/$(@F), $(libpngfolders)) -create -output $@
mkdir -p $(IMAGE_INC_DIR)
cp -rvf $(firstword $(libpngfolders))/include/*.h $(IMAGE_INC_DIR)

$(libjpeg) : $(libtiffconfig)
cd $(IMAGE_SRC) ;\
./build-jpg.sh
$(libpng) : $(libpngmakefile)
cd $(abspath $(@D)/..) ; \
$(MAKE) -j8 && $(MAKE) install

$(PNG_SRC)/%/Makefile : $(libpngconfig)
export SDKROOT="$(call swap, $*, $(arch_names), $(sdks))" ; \
export CFLAGS="-Qunused-arguments -arch $(call swap, $*, $(arch_names), $(archs)) -pipe -no-cpp-precomp -isysroot $$SDKROOT -miphoneos-version-min=$(IOS_DEPLOY_TGT) -O2" ; \
export CPPFLAGS=$$CFLAGS ; \
export CXXFLAGS="$$CFLAGS -Wno-deprecated-register"; \
mkdir -p $(@D) ; \
cd $(@D) ; \
../configure --host=$* --enable-shared=no --prefix=`pwd`

$(libjpegfat) : $(libjpeg)
mkdir -p $(@D)
xcrun lipo $(addsuffix lib/$(@F), $(libjpegfolders)) -create -output $@
mkdir -p $(IMAGE_INC_DIR)
cp -rvf $(firstword $(libjpegfolders))/include/*.h $(IMAGE_INC_DIR)

$(libjpeg) : $(libjpegmakefile)
cd $(abspath $(@D)/..) ; \
$(MAKE) -j8 && $(MAKE) install

$(JPEG_SRC)/%/Makefile : $(libjpegconfig)
export SDKROOT="$(call swap, $*, $(arch_names), $(sdks))" ; \
export CFLAGS="-Qunused-arguments -arch $(call swap, $*, $(arch_names), $(archs)) -pipe -no-cpp-precomp -isysroot $$SDKROOT -miphoneos-version-min=$(IOS_DEPLOY_TGT) -O2" ; \
export CPPFLAGS=$$CFLAGS ; \
export CXXFLAGS="$$CFLAGS -Wno-deprecated-register"; \
mkdir -p $(@D) ; \
cd $(@D) ; \
../configure --host=$* --enable-shared=no --prefix=`pwd`

#######################
# Download dependencies
#######################
$(libtiffconfig) $(libtessautogen) :
$(libtiffconfig) $(libpngconfig) $(libjpegconfig) $(libtessautogen) :
git submodule init
git submodule update

Expand All @@ -150,12 +220,14 @@ mostlyclean : mostlycleanimage mostlycleanlept mostlycleantess

cleanimage :

.PHONY : cleanlept
cleanlept :
for folder in $(libleptfolders); do \
cd $$folder; \
$(MAKE) clean; \
done ; \

.PHONY : cleantess
cleantess :
for folder in $(libtessfolders); do \
cd $$folder; \
Expand All @@ -164,12 +236,14 @@ cleantess :

mostlycleanimage :

.PHONY : mostlycleanlept
mostlycleanlept :
for folder in $(libleptfolders); do \
cd $$folder; \
$(MAKE) mostlyclean; \
done ; \

.PHONY : mostlycleantess
mostlycleantess :
for folder in $(libtessfolders); do \
cd $$folder; \
Expand All @@ -182,11 +256,13 @@ distcleanimage :

PHONY : distcleanlept
distcleanlept :
-rm -rf $(LEPT_INC_DIR)/leptonica
-rm -rf $(libleptfat)
-rm -rf $(LEPTON_SRC)

.PHONY : distcleantess
distcleantess :
-rm -rf $(TESS_INC_DIR)/tesseract
-rm -rf $(libtessfat)
-rm -rf $(TESSERACT_SRC)

Loading

0 comments on commit 0e12559

Please sign in to comment.