Makefile improvement

* generate the dependency file (.d)
* move main makefile to root of directory
* clean some variable