# Take EB provided SAMtools, and use the correct include path. Pick EB provided CC and CFLAGS as well.
# May 29th 2017 by B. Hajgato (Free University Brussles - VUB)
--- Bio-SamTools-1.43/Build.PL.orig	2016-02-12 20:31:32.000000000 +0100
+++ Bio-SamTools-1.43/Build.PL	2017-05-26 13:22:23.318323680 +0200
@@ -75,7 +75,7 @@
 	$sam_include = $samtools
 	    if -e "$samtools/$HeaderFile";
 	$sam_include = "$samtools/include"
-	    if -e "$samtools/include/$HeaderFile";
+	    if -e "$samtools/include/bam/$HeaderFile";
 	$sam_lib     = $samtools
 	    if -e "$samtools/$LibFile";
 	$sam_lib     = "$samtools/lib"
@@ -164,7 +164,7 @@
 }
 
 sub _samtools {
-    $ENV{SAMTOOLS} ||
+    $ENV{EBROOTSAMTOOLS} ||
     ( can_load(modules => {'Alien::SamTools' => undef, 'File::ShareDir' => undef}) &&
       File::ShareDir::dist_dir('Alien-SamTools'));
 }
--- Bio-SamTools-1.43/c_bin/makefile.orig	2016-02-12 20:31:32.000000000 +0100
+++ Bio-SamTools-1.43/c_bin/makefile	2017-05-26 13:44:43.770545813 +0200
@@ -1,5 +1,5 @@
-CC=		gcc
-CFLAGS=		-g -Wall -O2 -fPIC
+CC?=		gcc
+CFLAGS?=		-g -Wall -O2 -fPIC
 DFLAGS=		-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_USE_KNETFILE -D_CURSES_LIB=1
 INCLUDES=
 LIBPATH=
--- Bio-SamTools-1.43/c_bin/bam2bedgraph.c.orig	2016-02-12 20:31:32.000000000 +0100
+++ Bio-SamTools-1.43/c_bin/bam2bedgraph.c	2017-05-26 13:29:28.041584111 +0200
@@ -1,5 +1,5 @@
 #include <stdio.h>
-#include "sam.h"
+#include "bam/sam.h"
 
 typedef struct {
   uint32_t ltid;
--- Bio-SamTools-1.43/lib/Bio/DB/Sam.xs.orig	2016-02-12 20:31:32.000000000 +0100
+++ Bio-SamTools-1.43/lib/Bio/DB/Sam.xs	2017-05-29 11:56:51.145855185 +0200
@@ -25,9 +25,9 @@
 
 #include <unistd.h>
 #include <math.h>
-#include "bam.h"
-#include "khash.h"
-#include "faidx.h"
+#include "bam/bam.h"
+#include "bam/khash.h"
+#include "bam/faidx.h"
 
 /* stolen from bam_aux.c */
 #define MAX_REGION 1<<29
