build: factor out the .c and .S compile commands as a macro