Index: RRDTool-OO-0.36/Makefile.PL
--- RRDTool-OO-0.36/Makefile.PL.orig	2014-05-07 08:37:16.000000000 +0200
+++ RRDTool-OO-0.36/Makefile.PL	2017-05-16 20:42:09.905009000 +0200
@@ -10,52 +10,12 @@
     }
 };
 
-# Check if RRDs is installed
-
-eval "use RRDs 1.2011";
-
-    # (1) libcgi is missing on most Linux/FreeBSD systems, and we
-    #     don't need it anyway.
-    # (2) as of rrdtool-1.2.11, tcl libs didn't compile, so let's
-    #     leave them out.
-my $CONFIGURE_OPTS = "--enable-perl-site-install --prefix=/usr --disable-tcl --disable-rrdcgi";
-
-my $DIST_URL = 
-"http://oss.oetiker.ch/rrdtool/pub/rrdtool.tar.gz";
-
-if($@) {
-    print <<EOT;
-This module requires rrdtool 1.2.x and the RRDs module to be 
-installed. They are available in the rrdtool distribution:
- $DIST_URL
-EOT
-
-    $| = 1;
-    my $in = prompt ("Do you want me to install it for you right now (y/n)?","n");
-    chomp $in;
-    if($in =~ /^\s*$/ or $in =~ /y/i) {
-        if($> != 0) {
-            die "\nYou need to be root to do this.\n";
-        }
-        eval { install_RRDs() };
-        if($@) {
-            print $@;
-            note();
-            exit 0;
-        }
-    } else {
-        note();
-        exit 0;
-    }
-}
-
 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
 # the contents of the Makefile that is written.
 WriteMakefile(
     NAME              => 'RRDTool::OO',
     VERSION_FROM      => 'lib/RRDTool/OO.pm', # finds $VERSION
     PREREQ_PM         => {
-                         Log::Log4perl => '0.40',
                          RRDs          => 0,
                          Storable      => 0,
                          }, # e.g., Module::Name => 1.1
Index: RRDTool-OO-0.36/lib/RRDTool/OO.pm
--- RRDTool-OO-0.36/lib/RRDTool/OO.pm.orig	2015-05-13 08:21:50.000000000 +0200
+++ RRDTool-OO-0.36/lib/RRDTool/OO.pm	2017-05-16 20:42:09.905517000 +0200
@@ -7,7 +7,6 @@
 use RRDs;
 use Storable;
 use Data::Dumper;
-use Log::Log4perl qw(:easy);
 
 our $VERSION = '0.36';
 
@@ -209,7 +208,7 @@
         # Check if we got all mandatory parameters
     for(@{$ref->{mandatory}}) {
         if(! exists $options_hash{$_}) {
-            Log::Log4perl->get_logger("")->logcroak(
+            croak(
                 "Mandatory parameter '$_' not set " .
                 "in $method() (@{[%mandatory]}) (@$options)");
         }
@@ -221,7 +220,7 @@
         for(keys %options_hash) {
             if(! exists $optional{$_} and
                ! exists $mandatory{$_}) {
-                Log::Log4perl->get_logger("")->logcroak(
+               croak(
                     "Illegal parameter '$_' in $method()");
             }
         }
Index: bindings/perl-shared/Makefile.PL
--- bindings/perl-shared/Makefile.PL.orig	2016-05-23 17:58:55.000000000 +0200
+++ bindings/perl-shared/Makefile.PL	2017-05-16 20:42:09.905710000 +0200
@@ -3,71 +3,18 @@
 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
 # the contents of the Makefile that is written.
 
-if (($Config{'osname'} eq 'MSWin32' && $ENV{'OSTYPE'} eq '')) {
-	my ($perlver) = ($] =~ /(\d+\.\d{3})/);
-	$perlver =~ s/[.0]//g;
-
-	my $perl_core_dir = "$Config{privlib}/CORE";
-	my $vc_dir = $ENV{'VSINSTALLDIR'} || 'C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC';
-	my $sdk_dir = $ENV{'WindowsSdkDir'} || 'C:/Program Files/Microsoft SDKs/Windows/v6.0A';
-
-	WriteMakefile(
-		'NAME'         => 'RRDs',
-		'VERSION_FROM' => 'RRDs.pm',
-		'DEFINE'       => "-DPERLPATCHLEVEL=$Config{PATCHLEVEL} -D_CRT_SECURE_NO_WARNINGS -DWIN32",
-		'INC'          => '-I../../src -I../../win32 "-I$perl_core_dir" -I"$vc_dir/include" -I"$sdk_dir/Include"',
-		'LDDLFLAGS'    => '-dll -nologo -opt:ref,icf -ltcg -libpath:"$perl_core_dir" -machine:X86',
-		'LDFLAGS'      => '-nologo -opt:ref,icf -ltcg -libpath:"$perl_core_dir" -machine:X86',
-		'OPTIMIZE'     => '-O2 -MD',
-		'LIBS'         => qq{"../../win32/librrd-4.lib" "perl$perlver.lib" -L../../contrib/lib -L../../win32 -L"$sdk_dir/lib" -L"$vc_dir/lib" -L"$perl_core_dir"},
-		'realclean'    => {FILES => 't/demo?.rrd t/demo?.png' },
-		($] ge '5.005') ? (
-			'AUTHOR'   => 'Tobias Oetiker (tobi@oetiker.ch)',
-			'ABSTRACT' => 'Round Robin Database Tool',
-		) : ()
-	);
-}else{
-	my $TOP_SRCDIR = $ENV{'ABS_TOP_SRCDIR'} || '../..';
-	my $TOP_BUILDDIR = $ENV{'ABS_TOP_BUILDDIR'} || '../..';
-	my $SRCDIR = $ENV{'ABS_SRCDIR'} || '.';
-	# if the last argument when calling Makefile.PL is RPATH=/... and ... is the
-	# path to librrd.so then the Makefile will be written such that RRDs.so knows
-	# where to find librrd.so later on ... 
-	my $R="";
-	if ($ARGV[-1] =~ /RPATH=(\S+)/){
-		pop @ARGV;
-		my $rp = $1;
-		for ($^O){
-			/linux/   && do{ $R = "-Wl,--rpath -Wl,$rp"};
-			/hpux/    && do{ $R = "+b$rp"};
-			/solaris/ && do{ $R = "-R$rp"};
-			/bsd/     && do{ $R = "-Wl,--rpath -Wl,$rp"};
-			/aix/     && do{ $R = "-blibpath:$rp"};
-		}
-	}
-
-	# darwin works without this because librrd contains its
-	# install_name which will includes the final location of the
-	# library after it is installed. This install_name gets transferred
-	# to the perl shared object.
-	my $librrd;
-	if ($^O eq 'darwin'){
-        $librrd = '-lrrd';
-	} else {
-		$librrd = "-L${TOP_BUILDDIR}/src/.libs/ $R -lrrd";
-	}
+    my $librrd = "-L../../src/.libs/ -lrrd -L$Config{prefix}/lib -lcairo -lpangocairo -lpixman-1 -lpango -lpangoft2 -lfreetype -lpng -lgobject -lgio -lgmodule -lglib -lfontconfig -lfreetype -lxml2 -lexpat -lpcre -lz -liconv -lintl";
 
 	WriteMakefile(
 		'NAME'         => 'RRDs',
 		'VERSION_FROM' => 'RRDs.pm', # finds $VERSION
 		'DEFINE'	   => "-DPERLPATCHLEVEL=$Config{PATCHLEVEL}",
-		'INC'          => "-I${TOP_BUILDDIR}/src -I${TOP_SRCDIR}/src",
+		'INC'          => "-I$ENV{TOP_BUILDDIR}/src -I$ENV{TOP_SRCDIR}/src",
 		# Perl will figure out which one is valid
 		#'dynamic_lib'  => {'OTHERLDFLAGS' => "$librrd -lm"},
-		'depend'       => {'RRDs.c' => "${TOP_BUILDDIR}/src/librrd.la"},
+		'depend'       => {'RRDs.c' => "$ENV{TOP_BUILDDIR}/src/librrd.la"},
 		'LDFROM'       => '$(OBJECT) '.$librrd, 
 		'realclean'    => {FILES => 't/demo?.rrd t/demo?.png' },
-		($^O eq 'darwin') ? ( 'LDDLFLAGS'    => "-L${TOP_BUILDDIR}/src/.libs/ $Config{lddlflags}" ) : ()
+		($^O eq 'darwin') ? ( 'LDDLFLAGS'    => "-L$ENV{TOP_BUILDDIR}/src/.libs/ $Config{lddlflags}" ) : ()
 	);
-}
 
Index: bindings/python/setup.py
--- bindings/python/setup.py.orig	2017-05-16 20:42:09.905913000 +0200
+++ bindings/python/setup.py	2017-05-16 20:43:52.377401000 +0200
@@ -19,7 +19,7 @@
                        library_dirs=[os.path.join(TOP_BUILDDIR, 'src', '.libs')],
                        include_dirs=[os.path.join(TOP_BUILDDIR, 'src'),
                                      os.path.join(TOP_SRCDIR, 'src')],
-                       libraries=['rrd'])
+                       libraries=['rrd', 'freetype', 'art_lgpl', 'png', 'z'])
 
     kwargs = dict(
         name='rrdtool',
Index: configure
--- configure.orig	2017-05-16 13:55:23.000000000 +0200
+++ configure	2017-05-16 20:44:28.847924000 +0200
@@ -19952,7 +19952,7 @@
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lglib-2.0  $LIBS"
+LIBS="-lglib  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -19986,7 +19986,7 @@
 
     ac_fn_c_check_header_mongrel "$LINENO" "glib.h" "ac_cv_header_glib_h" "$ac_includes_default"
 if test "x$ac_cv_header_glib_h" = xyes; then :
-  LIBS="-lglib-2.0 ${LIBS}";EX_CHECK_STATE=YES
+  LIBS="-lglib ${LIBS}";EX_CHECK_STATE=YES
 fi
 
 
@@ -20049,7 +20049,7 @@
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lglib-2.0  $LIBS"
+LIBS="-lglib  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -20690,7 +20690,7 @@
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpangocairo-1.0  $LIBS"
+LIBS="-lpangocairo $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -20724,7 +20724,7 @@
 
     ac_fn_c_check_header_mongrel "$LINENO" "pango/pango.h" "ac_cv_header_pango_pango_h" "$ac_includes_default"
 if test "x$ac_cv_header_pango_pango_h" = xyes; then :
-  LIBS="-lpangocairo-1.0 ${LIBS}";EX_CHECK_STATE=YES
+  LIBS="-lpangocairo ${LIBS}";EX_CHECK_STATE=YES
 fi
 
 
@@ -20787,7 +20787,7 @@
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpangocairo-1.0  $LIBS"
+LIBS="-lpangocairo  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -22422,9 +22422,9 @@
 $as_echo_n "checking for headers required to compile python extensions... " >&6; }
 py_prefix=`$PYTHON -c "import sys; print(sys.prefix)"`
 py_exec_prefix=`$PYTHON -c "import sys; print(sys.exec_prefix)"`
-PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
+PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION} -I${py_prefix}/include/python"
 if test "$py_prefix" != "$py_exec_prefix"; then
-  PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
+  PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION} -I${py_exec_prefix}/include/python"
 fi
 
 save_CPPFLAGS="$CPPFLAGS"
Index: src/rrd_open.c
--- src/rrd_open.c.orig	2017-05-16 14:26:46.000000000 +0200
+++ src/rrd_open.c	2017-05-16 20:42:09.910984000 +0200
@@ -376,7 +376,7 @@
 #endif
     if (rdwr & RRD_CREAT)
         goto out_done;
-#ifdef USE_MADVISE
+#if defined(USE_MADVISE) && defined(MADV_WILLNEED) && defined(MADV_SEQUENTIAL) && defined(MADV_RANDOM)
     if (rdwr & RRD_COPY) {
         /* We will read everything in a moment (copying) */
         madvise(data, rrd_file->file_len, MADV_SEQUENTIAL );
@@ -650,7 +650,7 @@
     }
 
     if (dontneed_start < rrd_file->file_len) {
-#ifdef USE_MADVISE
+#if defined(USE_MADVISE) && defined(MADV_DONTNEED)
 	    madvise(rrd_simple_file->file_start + dontneed_start,
 		    rrd_file->file_len - dontneed_start, MADV_DONTNEED);
 #else
