Respect LDFLAGS and explicitly link to math library

This makes the build process respect the environment's LDFLAGS and explicitly links to the math library fixing linking errors that can arise such as the following:

tree.c:(.text+0x1a5): undefined reference to `log'