From 45ff354dd802a9994d676eafff14499fd91d1946 Mon Sep 17 00:00:00 2001
From: Rolf Ahrenberg <Rolf.Ahrenberg@sci.fi>
Date: Mon, 21 Feb 2011 23:06:57 +0200
Subject: Added support for HAVE_LIBPCRECPP.

---
 Makefile              | 19 +++++++++++++------
 README                |  9 ++++++++-
 css/Makefile          |  2 +-
 javascript/Makefile   |  2 +-
 pages/Makefile        |  4 ++--
 pages/recordings.ecpp | 11 ++++++++++-
 6 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/Makefile b/Makefile
index 1cb7c6c..258cc62 100644
--- a/Makefile
+++ b/Makefile
@@ -25,6 +25,9 @@ ECPPC	 ?= ecppc
 CXXFLAGS ?= -fPIC -O2 -Wall
 LDFLAGS	 ?= -fPIC -g
 
+### Check for libpcre c++ wrapper
+HAVE_LIBPCRECPP = $(shell pcre-config --libs-cpp)
+
 ### The directory environment:
 
 VDRDIR	 ?= ../../..
@@ -48,8 +51,12 @@ TNTVERS7   = $(shell ver=$(TNTVERSION); if [ $$ver -ge "1606" ]; then echo "yes"
 
 CXXFLAGS  += $(shell tntnet-config --cxxflags)
 LIBS      += $(shell tntnet-config --libs)
-CXXFLAGS  += $(shell pcre-config --cflags)
-LIBS      += $(shell pcre-config --libs) -lpcrecpp
+
+ifneq ($(HAVE_LIBPCRECPP),)
+	FEATURES  += -DHAVE_LIBPCRECPP
+	CXXFLAGS  += $(shell pcre-config --cflags)
+	LIBS      += $(HAVE_LIBPCRECPP)
+endif
 
 ### The name of the distribution archive:
 
@@ -91,14 +98,14 @@ all: libvdr-$(PLUGIN).so $(I18NTARG)
 ### Implicit rules:
 
 %.o: %.cpp
-	$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
+	$(CXX) $(CXXFLAGS) -c $(DEFINES) $(FEATURES) $(INCLUDES) $<
 
 # Dependencies:
 
 MAKEDEP = $(CXX) -MM -MG
 DEPFILE = .dependencies
 $(DEPFILE): Makefile
-	@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(PLUGINOBJS:%.o=%.cpp) > $@
+	@$(MAKEDEP) $(DEFINES) $(FEATURES) $(INCLUDES) $(PLUGINOBJS:%.o=%.cpp) > $@
 
 ifneq ($(MAKECMDGOALS),clean)
 -include $(DEPFILE)
@@ -141,10 +148,10 @@ generate-i18n: i18n-template.h $(I18Npot) $(I18Npo) buildutil/pot2i18n.pl
 subdirs: $(SUBDIRS)
 
 $(SUBDIRS):
-	$(MAKE) -C $@ $(MAKECMDGOALS)
+	@$(MAKE) -C $@ $(MAKECMDGOALS) FEATURES="$(FEATURES)"
 
 PAGES:
-	$(MAKE) -C pages .dependencies
+	@$(MAKE) -C pages FEATURES="$(FEATURES)" .dependencies
 
 $(VERSIONSUFFIX): FORCE
 	./buildutil/version-util $(VERSIONSUFFIX) || ./buildutil/version-util -F $(VERSIONSUFFIX)
diff --git a/README b/README
index 4b6ead7..6b22ee6 100644
--- a/README
+++ b/README
@@ -55,7 +55,7 @@ VDR >= 1.4.0-2
 gcc >= 3.1
 if gcc < 4.0:
 boost >= 1.32.0		- http://www.boost.org
-PCRE >= 8.0     	- http://www.pcre.org/
+PCRE >= 8.0.2     	- http://www.pcre.org/
 Tntnet >= 1.5.3		- http://www.tntnet.org/download.hms
 Cxxtools >= 1.4.3	- http://www.tntnet.org/download.hms
 
@@ -63,6 +63,13 @@ Tntnet provides basic webserver functions for live and needs cxxtools.
 Boost provides some data structures we need. While currently relying on the
 full blown package we might provide a stripped down version in the future.
 
+PCRE provides filtering for recordings. Some older versions pcre-config tool
+doesn't contain C++ wrapper option, but filtering support can be forced via
+commandline:
+
+make HAVE_LIBPCRECPP="-lpcrecpp -lpcre"
+
+
 If you optionaly want to regenerate the i18n-generated.h header file
 for backward compatible i18n (VDR version prior to 1.5.7) you also
 need: (See also the Internationalization section below)
diff --git a/css/Makefile b/css/Makefile
index a138774..9fb16ff 100644
--- a/css/Makefile
+++ b/css/Makefile
@@ -44,7 +44,7 @@ all: libcss.a
 ### Implicit rules:
 
 %.o: %.cpp
-	$(CXX) $(CXXFLAGS) $(TNTFLAGS) -c $(DEFINES) $(INCLUDES) $<
+	$(CXX) $(CXXFLAGS) $(TNTFLAGS) -c $(DEFINES) $(FEATURES) $(INCLUDES) $<
 
 %.cpp: %.css
 	$(ECPPC) $(ECPPFLAGS) $(ECPPFLAGS_CSS) -b -m "text/css" $<
diff --git a/javascript/Makefile b/javascript/Makefile
index 44ef3c0..8f5ef13 100644
--- a/javascript/Makefile
+++ b/javascript/Makefile
@@ -44,7 +44,7 @@ all: libjavascript.a
 ### Implicit rules:
 
 %.o: %.cpp
-	$(CXX) $(CXXFLAGS) $(TNTFLAGS) -c $(DEFINES) $(INCLUDES) $<
+	$(CXX) $(CXXFLAGS) $(TNTFLAGS) -c $(DEFINES) $(FEATURES) $(INCLUDES) $<
 
 %.cpp: %.js
 	$(ECPPC) $(ECPPFLAGS) $(ECPPFLAGS_JS) -b -m "text/javascript" $<
diff --git a/pages/Makefile b/pages/Makefile
index 8ce12db..db9436a 100644
--- a/pages/Makefile
+++ b/pages/Makefile
@@ -51,7 +51,7 @@ all: libpages.a
 ### Implicit rules:
 
 %.o: %.cpp
-	$(CXX) $(CXXFLAGS) $(TNTFLAGS) -c $(DEFINES) $(INCLUDES) $<
+	$(CXX) $(CXXFLAGS) $(TNTFLAGS) -c $(DEFINES) $(FEATURES) $(INCLUDES) $<
 
 %.cpp: %.ecpp
 	$(ECPPC) $(ECPPFLAGS) $(ECPPFLAGS_CPP) $<
@@ -61,7 +61,7 @@ all: libpages.a
 MAKEDEP = $(CXX) -MM -MG
 DEPFILE = .dependencies
 $(DEPFILE): Makefile $(OBJS:%.o=%.cpp) $(OBJS:%.o=%.ecpp)
-	@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.cpp) > $@
+	@$(MAKEDEP) $(DEFINES) $(FEATURES) $(INCLUDES) $(OBJS:%.o=%.cpp) > $@
 
 ifneq ($(MAKECMDGOALS),clean)
 -include $(DEPFILE)
diff --git a/pages/recordings.ecpp b/pages/recordings.ecpp
index d761bb4..cd12acd 100644
--- a/pages/recordings.ecpp
+++ b/pages/recordings.ecpp
@@ -203,7 +203,10 @@ for (recIter = recItems.begin(); recIter != recItems.end(); ++recIter) {
 		string duration(LiveSetup().GetShowRecDuration() ? FormatDuration(tr("(%d')"), recItem->Duration()) : "");
 		string shortDescr(recItem->RecInfo()->ShortText() ? recItem->RecInfo()->ShortText() : "");
 		string hint(tr("Click to view details.")); if (!shortDescr.empty()) hint = shortDescr + "<br />" + hint;
-		if (filter.empty() || pcrecpp::RE(filter.c_str(), pcrecpp::UTF8()).PartialMatch(recItem->Name()) || pcrecpp::RE(filter.c_str(), pcrecpp::UTF8()).PartialMatch(shortDescr)) {
+#ifdef HAVE_LIBPCRECPP
+		if (filter.empty() || pcrecpp::RE(filter.c_str(), pcrecpp::UTF8()).PartialMatch(recItem->Name()) || pcrecpp::RE(filter.c_str(), pcrecpp::UTF8()).PartialMatch(shortDescr))
+#endif
+		{
 </%cpp>
 	<li class="recording">
 	   <& rec_item_file name=(recItem->Name()) level=(level) id=(recItem->Id()) day=(day) dayLen=(dayLen) startTime=(recItem->StartTime()) duration=(duration) hint=(hint) shortDescr=(shortDescr) archived=(RecordingsManager::GetArchiveDescr(recItem->Recording())) &>
@@ -221,8 +224,14 @@ for (recIter = recItems.begin(); recIter != recItems.end(); ++recIter) {
 <a href="recordings.html?sort=name&filter=<? currentFilter != "" ? currentFilter ?>" alt="" /><$ tr("Sort by name") $></a>
 <span class="sep">|</span>
 <a href="recordings.html?sort=date&filter=<? currentFilter != "" ? currentFilter ?>" alt="" /><$ tr("Sort by date") $></a>
+<%cpp>
+#ifdef HAVE_LIBPCRECPP
+</%cpp>
 <span class="sep">|</span>
 <span class="label bold"><$ tr("Filter") $>:&nbsp;<input type="text" name="filter" value="<$ currentFilter $>" id="filter" onchange="filterRecordings(this)" />&nbsp;<& tooltip.help text=(tr("Look in recordings titles and subtitles for the given string and display only the matching ones. You may also use perl compatible regular expressions (PCRE).")) &></span>
+<%cpp>
+#endif
+</%cpp>
 <%cpp> } </%cpp>
 </%def>
 
-- 
cgit v1.2.3