Merge branch 'hotfix-3.0.1'
Merge branch 'hotfix-3.0.1'
scripts/upstart: change start/stop dependencies

Reported by Robin Battey
(https://lists.launchpad.net/bumblebee/msg00181.html):

    The upstart script starts on runlevel 2345, and stops on runlevel 016.
    However, the hybrid-detect task that runs upon starting lightdm (from
    the nvidia-current package in x-updates) changes the graphics settings
    in a way that, at least on this system, causes the graphical
    environment to fail. (The VT changes but you see no video, however
    from the sounds of the system it's clear that the graphical
    environment is running in some framebuffer *somewhere* just not
    attached to the screen -- I expect it's running on the wrong GPU.)
    The solution is to have the bumblebeed service start when the
    login-session-start (for the usual graphical login) and
    desktop-session-start (for those running "startx") events occur, which
    is *after* the display manager is running.
optirun: split virtualgl off

Trivial change, move code to run_virtualgl, passing argc and argv. Add
declaration for variables "r" and "exitcode" and use that in run_app. This
prepares for supporting other backends.
Support multiple optirun bridges, validate

Add Bridge key to optirun section in bumblebee.conf, add CONF_BRIDGE configure
option, accept -b and --bridge options for optirun.
Todo: implement primus and auto-detection accel/display bridge.
optirun: move --{,no-}failsafe text to have --vgl-* below each other
optirun: support auto-detect accel/display bridge

auto-detection works by trying to locate available back-ends in order. Fail
early if a back-end cannot be loaded. The which(1) implementation is not
fool-proof, but that is not the intend. I assume a bit sanity.
optirun: add primus support, taking precedence over virtualgl
optirun: export BUMBLEBEE_SOCKET for primus
optirun: support OSS drivers with primus

primus hard-codes the proprietary nvidia drivers by default. To make it work for
non-proprietary nvidia drivers (nouveau, radeon, fglrx), set the PRIMUS_libGLa
and PRIMUS_libGLd settings explicitly. It is also assumed that the LibraryPath
setting is empty if open-source drivers are used.
bash_completion: add -b (--bridge) option
VirtualGL as default, primus as alternative

Since there are more unsolved issues and crash with primus, just let VirtualGL be the default setting for now, and make primus available as an alternative backend.
Removed --wait argument of rmmod

This argument was firstly deprecated by kernel, and is now not supported anymore. A udev rule to power on/off the nvidia card upon loading/unloading nvidia module via bbswitch should be added to replace this.
Fix build in a directory other than source directory.

This allows to build Bumblebee like this:

  mkdir /tmp/bb
  cd /tmp/bb
  /path/to/source/Bumblebee/configure
  make

The advantage is a clear separation of the source and build trees (which
allows for several build dirs with different compile flags for instance).
Merge pull request #316 from kroki/separate-build-dir

Fix builds outside of the source tree
Revert "VirtualGL as default, primus as alternative"

This reverts commit a22b602ebb345a9bba4684970a3487ffd2a45b45.

Since this branch will only be merged when primus will be ready for replacing VirtualGL as default, there is no need for this.
module: support module aliases

As reported on GH-330, bumblebeed bails out when the KernelDriver line is set to
"nvidia", even though an alias exist in /etc/modprobe.d/. Instead of using
`modinfo` to determine the existence of a module, use `modprobe --dry-run` to
determine whether a module is available.

This should also catch errors earlier when `nouveau` is aliased to `off` for
example in which case the module must be considered "unavailable".
module: wait three seconds before failing at rmmod (Closes GH-283)
Merge branch 'common-primus' (early part) into develop
File formatting for xorg.conf's