From 3afbe205d8346f7558b363005351ce95e17bf5f4 Mon Sep 17 00:00:00 2001
From: Hugh McMaster <hugh.mcmaster@outlook.com>
Date: Wed, 26 Feb 2020 23:44:23 +1100
Subject: [PATCH] Use PKG_CHECK_MODULES to detect the libxml2 library

---
 configure.ac    | 8 +++-----
 src/Makefile.am | 8 ++++----
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1194059..9dd069f 100644
--- configure.ac
+++ configure.ac
@@ -8,6 +8,8 @@
 
 AC_PROG_INSTALL
 
+PKG_PROG_PKG_CONFIG
+
 AC_SYS_LARGEFILE
 
 AC_HEADER_STDBOOL
@@ -100,6 +102,7 @@
     AC_MSG_ERROR([freetype not found])
 fi
 
+PKG_CHECK_MODULES([XML2], [libxml-2.0 >= 2.6.0])
 
 AC_ARG_ENABLE([default-video-format],
 AS_HELP_STRING([--enable-default-video-format=format], [specify a default video format, either NTSC or PAL, to be used if no configuration or input setting is given]),
@@ -135,11 +138,6 @@
 
 AM_ICONV
 
-ifdef([AM_PATH_XML2],
-    [AM_PATH_XML2(2.6.0, , AC_MSG_ERROR([You must have libxml2 >= 2.6.0 installed]))],
-    [errprint([You must have libxml2 (>= 2.6.0) installed
-])m4_exit(1)AC_MSG_ERROR([You must have libxml2 (>= 2.6.0) installed])])
-
 AC_CHECK_DECLS(O_BINARY, , , [ #include <fcntl.h> ] )
 
 AC_OUTPUT(Makefile doc/Makefile src/Makefile)
diff --git a/src/Makefile.am b/src/Makefile.am
index 5ef90c3..5504b8e 100644
--- src/Makefile.am
+++ src/Makefile.am
diff -u src/Makefile.am.orig src/Makefile.am
--- src/Makefile.am.orig	2016-10-24 17:26:59.000000000 -0700
+++ src/Makefile.am	2020-08-26 17:39:32.000000000 -0700
@@ -8,7 +8,7 @@
 nodist_bin_SCRIPTS = dvddirdel
 
 AM_CPPFLAGS = -DSYSCONFDIR="\"$(sysconfdir)\"" \
-    @XML_CPPFLAGS@ @MAGICK_CPPFLAGS@ @FREETYPE_CPPFLAGS@ @FRIBIDI_CFLAGS@ @FONTCONFIG_CFLAGS@
+    @XML2_CFLAGS@ @MAGICK_CPPFLAGS@ @FREETYPE_CPPFLAGS@ @FRIBIDI_CFLAGS@ @FONTCONFIG_CFLAGS@
 AM_CFLAGS = -Wall
 
 dvdauthor_SOURCES = dvdauthor.c common.h dvdauthor.h da-internal.h \
@@ -16,17 +16,17 @@
     dvdifo.c dvdvob.c dvdpgc.c \
     dvdcli.c readxml.c readxml.h \
     conffile.c conffile.h compat.c compat.h rgb.h
-dvdauthor_LDADD = $(LIBICONV) $(XML_LIBS)
+dvdauthor_LDADD = $(LIBICONV) $(XML2_LIBS)
 
 dvdunauthor_SOURCES = dvdunauthor.c dvduncompile.c common.h dvduncompile.h compat.c compat.h
-dvdunauthor_LDADD = $(XML_LIBS) $(LIBICONV) -ldvdread
+dvdunauthor_LDADD = $(XML2_LIBS) $(LIBICONV) -ldvdread
 
 spumux_SOURCES = subgen.c subgen.h rgb.h \
     subgen-parse-xml.c readxml.c readxml.h \
     subgen-encode.c subgen-image.c subglobals.h \
     conffile.c conffile.h compat.c compat.h common.h \
     subrender.c subrender.h subreader.c subreader.h subfont.c subfont.h
-spumux_LDADD = $(XML_LIBS) $(MAGICK_LIBS) $(FREETYPE_LIBS) \
+spumux_LDADD = $(XML2_LIBS) $(MAGICK_LIBS) $(FREETYPE_LIBS) \
     $(FRIBIDI_LIBS) $(FONTCONFIG_LIBS) $(LIBICONV) -lm
 
 spuunmux_SOURCES = spuunmux.c rgb.h compat.c compat.h common.h conffile.h conffile.c
