From 562f1736b725167d0b87ce803fe3816f1396504f Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Fri, 27 Jun 2014 22:15:55 +0200 Subject: [PATCH] Take advantage of shared SyncTeX parser library As of revision 34449 texlive builds SyncTeX parser as library. We continue to include the code until this patch is deployed on most major distributions. Signed-off-by: Sebastian Ramacher --- Makefile | 25 +++++++++++++++++-------- config.mk | 13 +++++++++++-- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index cb2ccd8..995c8f0 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ include config.mk include colors.mk include common.mk -OSOURCE = $(filter-out css-definitions.c, $(filter-out dbus-interface-definitions.c, $(wildcard *.c))) $(wildcard synctex/*.c) +OSOURCE = $(filter-out css-definitions.c, $(filter-out dbus-interface-definitions.c, $(wildcard *.c))) HEADER = $(wildcard *.h) $(wildcard synctex/*.h) HEADERINST = version.h document.h macros.h page.h types.h plugin-api.h links.h @@ -23,6 +23,22 @@ LIBS += $(MAGIC_LIB) CPPFLAGS += -DWITH_MAGIC endif +ifneq ($(WITH_SYSTEM_SYNCTEX),0) +INCS += $(SYNCTEX_INC) +LIBS += $(SYNCTEX_LIB) +else +INCS += $(ZLIB_INC) +LIBS += $(ZLIB_LIB) +SOURCE += $(wildcard synctex/*.c) + +ifeq (,$(findstring -Isynctex,${CPPFLAGS})) +CPPFLAGS += -Isynctex +endif +ifeq (,$(findstring -DSYNCTEX_VERBOSE=0,${CPPFLAGS})) +CPPFLAGS += -DSYNCTEX_VERBOSE=0 +endif +endif + ifneq ($(wildcard ${VALGRIND_SUPPRESSION_FILE}),) VALGRIND_ARGUMENTS += --suppressions=${VALGRIND_SUPPRESSION_FILE} endif @@ -36,13 +52,6 @@ endif ifeq (,$(findstring -DLOCALEDIR,${CPPFLAGS})) CPPFLAGS += -DLOCALEDIR=\"${LOCALEDIR}\" endif -ifeq (,$(findstring -Isynctex,${CPPFLAGS})) -CPPFLAGS += -Isynctex -endif -ifeq (,$(findstring -DSYNCTEX_VERBOSE=0,${CPPFLAGS})) -CPPFLAGS += -DSYNCTEX_VERBOSE=0 -endif - OBJECTS = $(patsubst %.c, %.o, $(SOURCE)) dbus-interface-definitions.o css-definitions.o DOBJECTS = $(patsubst %.o, %.do, $(OBJECTS)) diff --git a/config.mk b/config.mk index df37cfd..947a98c 100644 --- a/config.mk +++ b/config.mk @@ -33,6 +33,10 @@ GTK_PKG_CONFIG_NAME = gtk+-3.0 # To disable support for the sqlite backend set WITH_SQLITE to 0. WITH_SQLITE ?= $(shell (pkg-config --atleast-version=3.5.9 sqlite3 && echo 1) || echo 0) +# synctex +# To use the embedded copy of the syntex parser set WITH_SYSTEM_SYNCTEX to 0. +WITH_SYSTEM_SYNCTEX ?= $(shell (pkg-config synctex && echo 1) || echo 0) + # mimetype detection # To disable support for mimetype detction with libmagic set WITH_MAGIC to 0. WITH_MAGIC ?= 1 @@ -77,11 +81,16 @@ MAGIC_INC ?= MAGIC_LIB ?= -lmagic endif +ifneq ($(WITH_SYSTEM_SYNCTEX),0) +SYNCTEX_INC ?= $(shell pkg-config --cflags synctex) +SYNCTEX_LIB ?= $(shell pkg-config --libs synctex) +else ZLIB_INC ?= $(shell pkg-config --cflags zlib) ZLIB_LIB ?= $(shell pkg-config --libs zlib) +endif -INCS = ${GIRARA_INC} ${GTK_INC} ${GTHREAD_INC} ${GMODULE_INC} ${GLIB_INC} $(ZLIB_INC) -LIBS = ${GIRARA_LIB} ${GTK_LIB} ${GTHREAD_LIB} ${GMODULE_LIB} ${GLIB_LIB} $(ZLIB_LIB) -lpthread -lm +INCS = ${GIRARA_INC} ${GTK_INC} ${GTHREAD_INC} ${GMODULE_INC} ${GLIB_INC} +LIBS = ${GIRARA_LIB} ${GTK_LIB} ${GTHREAD_LIB} ${GMODULE_LIB} ${GLIB_LIB} -lpthread -lm # flags CFLAGS += -std=c99 -pedantic -Wall -Wno-format-zero-length -Wextra $(INCS)