Improve makefiles

I just fixed a little bug on the master Makefile and made some improvements in the device specific ones, because I was not able to compile the software.

If you want you can merge this in your repo.