---
 texk/web2c/ac/web2c.ac              |    7 +++++
 texk/web2c/aclocal.m4               |    1 
 texk/web2c/configure.ac             |    8 ++++++
 texk/web2c/synctexdir/am/synctex.am |   44 +++++++++++++++++++++++++++++++-----
 texk/web2c/synctexdir/synctex.pc.in |   12 +++++++++
 5 files changed, 66 insertions(+), 6 deletions(-)

--- texlive-bin.orig/texk/web2c/ac/web2c.ac
+++ texlive-bin/texk/web2c/ac/web2c.ac
@@ -79,3 +79,10 @@
               AS_HELP_STRING([--disable-web-progs],
                              [do not build WEB programs bibtex ... weave],
                              kpse_indent_26))[]dnl
+
+## configure option for the SyncTeX tool
+AC_ARG_ENABLE([synctex],
+              AS_HELP_STRING([--disable-synctex],
+                             [do not build the SyncTeX tool],
+                             kpse_indent_26))[]dnl
+
--- texlive-bin.orig/texk/web2c/aclocal.m4
+++ texlive-bin/texk/web2c/aclocal.m4
@@ -1233,6 +1233,7 @@
 m4_include([../../m4/kpse-icu-flags.m4])
 m4_include([../../m4/kpse-kpathsea-flags.m4])
 m4_include([../../m4/kpse-lex.m4])
+m4_include([../../m4/kpse-lib-version.m4])
 m4_include([../../m4/kpse-libpng-flags.m4])
 m4_include([../../m4/kpse-lt-hack.m4])
 m4_include([../../m4/kpse-lua52-flags.m4])
--- texlive-bin.orig/texk/web2c/configure.ac
+++ texlive-bin/texk/web2c/configure.ac
@@ -211,6 +211,8 @@
 
 AM_CONDITIONAL([WEB], [test "x$enable_web_progs" != xno])
 
+AM_CONDITIONAL([SYNCTEX], [test "x$enable_synctex" != xno])
+
 AS_IF([test "x$enable_ptex:$enable_eptex" = xno:no],
       [enable_pweb_progs=no],
       [enable_pweb_progs=$enable_web_progs])
@@ -393,6 +395,12 @@
 AC_CONFIG_FILES([ctangleboot-sh], [chmod +x ctangleboot-sh])
 AC_CONFIG_FILES([silent-sh], [chmod +x silent-sh])
 
+m4_define([synctex_version], m4_chomp(m4_include([synctexdir/synctex_parser_version.txt]))[.0])
+AC_SUBST([SYNCTEXVERSION], [synctex_version])
+KPSE_LT_VERSION([synctex])
+
+AC_CONFIG_FILES([synctexdir/synctex.pc])
+
 dnl The subdirectory web2c must be configured for the build system.
 dnl When cross compiling, can not share the cache file with the subdirectory!
 AC_CONFIG_COMMANDS_POST([AS_IF([test "x$cross_compiling" = xyes],
--- texlive-bin.orig/texk/web2c/synctexdir/am/synctex.am
+++ texlive-bin/texk/web2c/synctexdir/am/synctex.am
@@ -5,21 +5,53 @@
 
 ## The SyncTeX tool
 
+if SYNCTEX
 bin_PROGRAMS += synctex
+endif SYNCTEX
+EXTRA_PROGRAMS += synctex
 
 synctex_SOURCES = \
-	synctexdir/synctex_main.c \
+	synctexdir/synctex_main.c
+
+synctex_CPPFLAGS = -I$(srcdir)/synctexdir
+
+synctex_LDADD =  libsynctex.la $(ZLIB_LIBS)
+
+$(synctex_OBJECTS): libsynctex.la
+
+## The SyncTeX parser library
+
+EXTRA_LTLIBRARIES = libsynctex.la
+
+libsynctex_la_CPPFLAGS = -I$(srcdir)/synctexdir $(ZLIB_INCLUDES) -DSYNCTEX_USE_LOCAL_HEADER
+
+libsynctex_la_LDFLAGS = -rpath @libdir@ -bindir @bindir@ -no-undefined -version-info $(SYNCTEX_LT_VERSINFO)
+
+libsynctex_la_SOURCES = \
 	synctexdir/synctex_parser.c \
-	synctexdir/synctex_parser.h \
 	synctexdir/synctex_parser_local.h \
-	synctexdir/synctex_parser_utils.h \
 	synctexdir/synctex_parser_utils.c
 
-synctex_CPPFLAGS = -I$(srcdir)/synctexdir $(ZLIB_INCLUDES) -DSYNCTEX_USE_LOCAL_HEADER
+libsynctex_la_LIBADD = $(ZLIB_LIBS)
+
+$(libsynctex_la_OBJECTS): $(ZLIB_DEPEND)
+
+if SYNCTEX
+install-exec-local: libsynctex.la
+	$(MKDIR_P) "$(DESTDIR)$(libdir)"
+	$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) \
+	  libsynctex.la "$(DESTDIR)$(libdir)"
+
+nobase_include_HEADERS = \
+	synctexdir/synctex_parser.h \
+	synctexdir/synctex_parser_utils.h
+endif SYNCTEX
 
-synctex_LDADD = $(ZLIB_LIBS)
+pkgconfigdir = ${libdir}/pkgconfig
 
-$(synctex_OBJECTS): $(ZLIB_DEPEND)
+if SYNCTEX
+pkgconfig_DATA = synctexdir/synctex.pc
+endif SYNCTEX
 
 dist_man_MANS += synctexdir/man1/synctex.1 synctexdir/man5/synctex.5
 
--- /dev/null
+++ texlive-bin/texk/web2c/synctexdir/synctex.pc.in
@@ -0,0 +1,12 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: synctex
+Description: SyncTeX parser library
+Version: @SYNCTEXVERSION@
+Requires.private: zlib
+Libs: -L${libdir} -lsynctex
+Cflags: -I${includedir}
+
