Split SOURCE_REF into its own makefile function