What is the preferred way to debug?

I have added a printf statement in my program, to see what a variable looks like. Then I manually retyped the compile command from the Makefile manually interpolating the env vars, and finally run my compiled program manually at the CLI.

Is there a better way to either compile the code, or debug it without printf statements?

You can walk through the code and examine variables using a debugger like gdb. You should be able to compile your code but running the make command, which reads the Makefile.