nixpkgs/pkgs/applications/misc/k2pdfopt/k2pdfopt.patch
2017-10-03 20:26:54 -04:00

100 lines
3.0 KiB
Diff

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4a2378b..502c477 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,6 +52,7 @@ endif(JPEG_FOUND)
include(FindJasper)
if(JASPER_FOUND)
set(HAVE_JASPER_LIB 1)
+ set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${JASPER_LIBRARY})
endif(JASPER_FOUND)
# paths from willuslib/wgs.c
@@ -66,8 +67,12 @@ else()
message(STATUS "Could NOT find ghostscript executable")
endif(GHOSTSCRIPT_EXECUTABLE)
-# willus.h
-# HAVE_GSL_LIB
+pkg_check_modules(GSL gsl)
+if(GSL_FOUND)
+ set(HAVE_GSL_LIB 1)
+ include_directories(SYSTEM ${GSL_INCLUDEDIR})
+ set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${GSL_LDFLAGS})
+endif(GSL_FOUND)
# libfreetype6 (>= 2.3.9), libjbig2dec0, libjpeg8 (>= 8c), libx11-6, libxext6, zlib1g (>= 1:1.2.0)
@@ -80,7 +85,7 @@ if(MUPDF_FOUND)
include_directories(SYSTEM ${MUPDF_INCLUDEDIR})
message(STATUS "mupdf libraries: ${MUPDF_LDFLAGS}")
set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${MUPDF_LDFLAGS}
- -lmupdf-js-none -lopenjpeg -ljbig2dec -ljpeg -lfreetype
+
)
endif(MUPDF_FOUND)
@@ -91,9 +96,25 @@ if(DJVU_FOUND)
set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${DJVU_LDFLAGS})
endif(DJVU_FOUND)
-# HAVE_GOCR_LIB
-# HAVE_LEPTONICA_LIB
-# HAVE_TESSERACT_LIB
+find_library(GOCR_LIB NAMES Pgm2asc)
+if(GOCR_LIB)
+ set(HAVE_GOCR_LIB 1)
+ set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${GOCR_LIB})
+endif(GOCR_LIB)
+
+pkg_check_modules(LEPTONICA lept)
+if(LEPTONICA_FOUND)
+ set(HAVE_LEPTONICA_LIB 1)
+ include_directories(SYSTEM ${LEPTONICA_INCLUDEDIR})
+ set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${LEPTONICA_LDFLAGS})
+endif(LEPTONICA_FOUND)
+
+pkg_check_modules(TESSERACT tesseract)
+if(TESSERACT_FOUND)
+ set(HAVE_TESSERACT_LIB 1)
+ include_directories(SYSTEM ${TESSERACT_INCLUDEDIR})
+ set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${TESSERACT_LDFLAGS})
+endif(TESSERACT_FOUND)
# ---- Describe project
diff --git a/willuslib/CMakeLists.txt b/willuslib/CMakeLists.txt
index 463bbc9..8043db5 100644
--- a/willuslib/CMakeLists.txt
+++ b/willuslib/CMakeLists.txt
@@ -6,7 +6,7 @@ include_directories(..)
set(WILLUSLIB_SRC
ansi.c array.c bmp.c bmpdjvu.c bmpmupdf.c dtcompress.c filelist.c
fontdata.c fontrender.c gslpolyfit.c linux.c math.c mem.c ocr.c
- ocrjocr.c ocrtess.c pdfwrite.c point2d.c render.c strbuf.c string.c
+ ocrgocr.c ocrtess.c pdfwrite.c point2d.c render.c strbuf.c string.c
token.c wfile.c wgs.c wgui.c willusversion.c win.c winbmp.c
wincomdlg.c winmbox.c winshell.c wmupdf.c wmupdfinfo.c wpdf.c wsys.c
wzfile.c wleptonica.c
diff --git a/willuslib/ocrgocr.c b/willuslib/ocrgocr.c
index 6027e9a..fbe10f0 100644
--- a/willuslib/ocrgocr.c
+++ b/willuslib/ocrgocr.c
@@ -29,6 +29,8 @@
#ifdef HAVE_GOCR_LIB
#include <gocr.h>
+job_t *OCR_JOB;
+
/*
** bmp8 must be grayscale
** (x1,y1) and (x2,y2) from top left of bitmap
@@ -63,6 +65,7 @@ void gocr_single_word_from_bmp8(char *text,int maxlen,WILLUSBITMAP *bmp8,
h=y2-y1+1;
dh=h+bw*2;
job=&_job;
+ OCR_JOB=job;
job_init(job);
job_init_image(job);
// willus_mem_alloc_warn((void **)&job->src.p.p,w*h,funcname,10);