I can give you a couple hints to get you on your way:
cut the last line of the output of the tar xvzf process out and strip it down to everything before the /, change directory to that stored value and run ./configure && make && make install.
declare -r DIRECTORY=$(tar xvzf $1 | grep -m 1 Makefile | cut -d'/' -f1)
./configure && make && make install
Perhaps something like that will do the trick.
DIRECTORY will hold the output of what is in the paranthesis, which is taking (or piping) the output of the tar command to the grep, only allowing one line to match (in case you get multiple Makefiles), and then cutting that one line up by the slash (/) and stripping off anything after and including the first match (or in this case, the first slash). Then it changes the directory up and configures, makes, and make installs. Good luck!
Edit: A side note, you probably know, but I will describe it for clarity. $1 means the OPTION included after the script name, so, in this case, you will have to run a file at a time. If you named the script install_script, then you would have to type:
# install_script <filename>.tar.gz