I never recall having any issues with installation of easy-to-install packages such as samtools and BEDTools. One of the reasons may be because the system admin was taking care of several system level library installations that were a pre-requisite. While compiling BEDTools, it complained about "undefined reference to `gzopen64'". Searching the forums, I figured out that it is complaining about not finding zlib. I checked installation several times and zlib was right there and was there on path. Checking the stdout of make commands I found that it searches zlib at the right place yet comes back in the end complaining about it. However, finally changing the LIBS path in makefile solved the problem.
export LIBS = YOUR_PATH/libz.so.
It should compile fine.
With Samtools, the problem lasted for a very long time. It always exited with error
"samtools error bam_import.c:76: undefined reference to gzopen64"
I tried re-installing zlib, added zlib path to LD_LIBRARY_PATH, installed latest version zlib, nothing worked.
Finally changing CFLAGS in makefile did the trick :
CFLAGS= -g -Wall -O2
CFLAGS= -g -Wall -O2 -L /usr/local/lib (This is where my zlib libraries are located)
.... It finally worked.
NOTE: Install as regular user. May be later you can copy the binary files to the system