Making Debian packages on an SMP machine

When you have an SMP machine (including dual core CPUs - but I'm sure everyone knows that by now), you quickly learn to use the -jN flag to GNU make(1). N is the number of CPUs you have and it lets make(1) run that many jobs in parallel whenever possible, thus using all your CPUs and giving you a nice speed benefit.

However when creating a Debian package you can't always specify this when you use a tool like dpkg-buildpackage(1), debuild(1) or svn-buildpackage(1). A simple trick is to just invoke these tools with the environment variable MAKE set to make -jN. Now whenever make(1) will invoke a sub-make, it will use the -jN parameter for it and since debian/rules is the first make invocation, all your actual compilation will always happen with multiple jobs in parallel.

This is not perfect however, all sub-makes will be called with -j too now, so you'll get more jobs then CPUs. I tried using MAKEFLAGS but that didn't quite work out, if someone knows of a better solution let me know. But this one works anyway.