Add functional makefile and fix some bugs
add functional makefila and fix bugs