--- a/Makefile	2014-08-23 13:33:34.000000000 +0400
+++ b/Makefile	2014-12-25 06:10:10.903404927 +0300
@@ -18,18 +18,12 @@
 ### The directory environment:
 
 # Use package data if installed...otherwise assume we're under the VDR source directory:
-PKGCFG = $(if $(VDRDIR),$(shell pkg-config --variable=$(1) $(VDRDIR)/vdr.pc),$(shell pkg-config --variable=$(1) vdr || pkg-config --variable=$(1) ../../../vdr.pc))
-CFGDIR = $(call PKGCFG,configdir)
-LIBDIR = $(call PKGCFG,libdir)
-LOCDIR = $(call PKGCFG,locdir)
-PLGCFG = $(call PKGCFG,plgcfg)
 #
 TMPDIR ?= /tmp
 
 ### The compiler options:
 
-export CFLAGS   = $(call PKGCFG,cflags)
-export CXXFLAGS = $(call PKGCFG,cxxflags)
+include $(VDRDIR)/Make.global
 
 ### Regexp
 ifeq (exists, $(shell pkg-config libpcre && echo exists))
@@ -40,7 +34,7 @@
 
 ### The version number of VDR's plugin API:
 
-APIVERSION = $(call PKGCFG,apiversion)
+APIVERSION = $(shell sed -ne '/define APIVERSION/s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/config.h)
 
 ### Allow user defined options to overwrite defaults:
 
@@ -57,7 +51,7 @@
 
 ### Includes and Defines (add further entries here):
 
-INCLUDES +=
+INCLUDES += -I$(VDRDIR)/include
 
 DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
 
@@ -70,8 +64,8 @@
 OBJS = $(PLUGIN).o blacklist.o charset.o config.o epgclone.o epghandler.o regexp.o setup_menu.o tools.o
 
 ifeq ($(REGEXLIB), pcre)
-LIBS += $(shell pcre-config --libs-posix)
-INCLUDES += $(shell pcre-config --cflags)
+LIBS += $(shell pkg-config --libs libpcreposix libpcre)
+INCLUDES += $(shell pkg-config --cflags libpcre)
 DEFINES += -DHAVE_PCREPOSIX
 endif
 
@@ -123,6 +117,7 @@
 
 $(SOFILE): $(OBJS)
 	$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) -o $@ $(LIBS)
+	@cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
 
 install-lib: $(SOFILE)
 	install -D $^ $(DESTDIR)$(LIBDIR)/$^.$(APIVERSION)
