Maybe comm is an outlier, but it uses the MKOCTFILE variable exported by "pkg install" which makes sure it's linking with the right Octave version, path, flags, etc. I have done some searching and found uses of both "mkoctfile" and "MKOCTFILE" throughout the repo. Maybe some packages do and some don't.
This change added environment variables to the "pkg install" function:
Are all packages that have autogen.sh/configure/Makeconf.in roughly the same?
I think it would be good practice for packages that have simple Makefiles to declare
MKOCTFILE = mkoctfile
and build using that variable, no ifndef required, minimal change, but this at least allows it to be overridden instead of requiring it to be the default mkoctfile in PATH. Then maybe I'd suggest pkg should be patched to pass MKOCTFILE as a make command argument instead of in the environment as it does now, i.e.
make OCTAVE=... MKOCTFILE=...
instead of (as it is today)
OCTAVE=... MKOCTFILE=... make
because I'm not sure what good that does since make variables always override environment variables.