Single frame profiler

This PR extracts the profiler parts from #2541 and then better integrates them:

* On autotools, use `--enable-profiler` to build. On other platforms, define `PIONEER_PROFILER` at the project level (not done, MSVC users please help)

* Bugfix, don't emit profiling output every frame, only on the frame asked for.

* Store profiler output in `[userdir]/profiler`.

* Fix profiler macros to properly make internal variables unique.

The last two items are changes to the profiler code itself, which I will attempt to send upstream. The project looks dead, but I will try.