Improve Makefile for better binary compilation

User can change the compiler and the optimization level.
Also more generalized rules are used here.