reorganize makefile. it will need simplifying though