Replace R/makefile.R with functional makefile