Merge remote-tracking branch 'origin/master' into unified-build-candidate-3

Conflicts:
	src/rtapi/sim_common.h
Merge remote-tracking branch 'origin/master' into unified-build-candidate-3
deb/rules: remove unused python_version
deb/rules: dont need to care about BUILD_SYS

The -X argument to dh_fixperms says to eXclude linuxcnc_module_helper
when it's fixing the permissions on all our files.  But dh_fixperm won't
complain or fail if it doesn't find linuxcnc_module_helper, so we don't
need to do this substitution trick to tell it what to expect.
deb: dont ignore package-dirs we no longer build
deb: new debian/configure and debian/control

This one's written in python instead of bash, and has a cleaner internal
structure.

This handles the flavored debs of the unified-build-candidate branch.

The new debian packaging produces linuxcnc.deb, linuxcnc-dev.deb,
and linuxcnc-doc-*.deb, just like before, and in addition produces
linuxcnc-$FLAVOR.deb for each flavor enabled by debian/configure.
The available flavors are:

    posix (what we used to call sim)

    rtai-kernel (what we used to call rt)

    rt-preempt

    xenomai

    xenomai-kernel

linuxcnc.deb depends on at least one of the flavor debs, and suggests
all of them (to make them easy to find in the package manager, mostly).
deb: fix the debian/{control/rules} remaking rules

The code in debian/rules.in for rebuilding debian/control has been broken
for a good long while.  This commit fixes that, and unifies it with the
rule for rebuilding debian/rules.  Also changes the name of the subst
variable to be more descriptive.
deb/conf: accept -a to mean -r

"debian/configure -r" is supposed to mean "configure for the running
realtime kernel", and "debian/configure -a" is supposed to mean "configure
for any realtime headers you can find on the system".

The buildbot ill-advisedly runs 'debian/configure -a', even though it
knows it's going to run runtests later (so the kernel it builds for must
be the one that's running).  So really -r would be more correct.

In practice it's fine because all the buildslave VMs only have one
realtime kernel installed, so there's no difference between -a and -r
on those hosts.

If someone cares strongly about the difference between the old "-a"
and the new "-a" we can reinstate it.

As an aside, it probably makes sense to add a "debian/configure --all"
option that examines the apt database and makes the dsc build-depend on
all *available* realtime kernel headers.
deb/control: get rid of ancient Provides in control

I think it's time to stop worrying about users upgrading from emc2.deb
packages.
deb/control: relax the Conflicts

The flavor packages should conflict with pre-ubc packages, but there's
no convenient way to specify that currently.

When we merge ubc into master we'll tag that point as 2.6.0-pre1,
and make the post-ubc debs conflict with linuxcnc < 2.6.0-pre1.
deb/rules: dont use cpio when cp will do

Debian Wheezy doesn't come with cpio by default, this commit lets us
not add a build-dependency on it.
install rsyslogd.conf file
give dlopen the path to the ulapi library

Normally dlopen() searches LD_LIBRARY_PATH and /lib and /usr/lib.  In rip
builds we set LD_LIBRARY_PATH and we could do the same in installed
scripts, but it seems simpler to teach ulapi where the files live.
put ulapi-$flavor.so straight into rtlib/, not lib, so the dlopen can look in EMC2_RTLIB_DIR
hm2-idrom test:  fix "too many arguments" error

Introduced by Y.T. in c6b87eec.  :P

From build log:

+ test -f realtime.log.0 realtime.log.1 realtime.log.10 realtime.log.11 [...]
test.sh: line 29: test: too many arguments

(Also, fix difficult-to-read test)
realtime.in:  recursively remove kmods and depending modules at unload

In kthreads flavors, when the realtime environment crashes badly
enough (e.g. linuxcncrsh starts during runtests but the test fails for
other reasons), 'trivkins', 'comp', and other modules that depend on
hal_lib and rtapi may be left loaded.  In this case, hal_lib and rtapi
cannot be unloaded without first removing those modules.

The RemoveModules function removes a list of modules recursively by
finding dependent modules in /proc/modules and removing them first.
runtests script:  run with 'bash -e'

Without '-e', runtests can exit 0 when tests didn't actually run.

This was observed when the /tmp filesystem became full, and
$TMPDIR/alltests couldn't be written.

When '$?' is checked, this is handling a possible non-success exit
from the previous command.  Modify each such command so that the exit
code is collected but the command doesn't result in the script
exiting.
mesa-hostmot2 driver:  Remove int->double conversions

Fixes 'Unknown symbol __fixunsdfdi' on 32-bit gcc-4.[34].x kthreads

For 64-bit arithmetic, gcc provides helpers on 32-bit architectures.
The __fixunsdfdi routine converts a double to u64.  For some versions
of gcc, this symbol is left for the linker to resolve from libgcc.a.
Kbuild does not link from libgcc.a, so these must be worked around.

The sserial.c example casts the double pin->fullscale to a float so
the expression is evaluated as a float, and then casts the float to
u32, avoiding double and u64 types in the conversion.

The watchdog.c example replaces the floating point calculation,
presumably meant to avoid loss of precision in an integer divide, by
doing the multiplication in 64-bit space first, then using the
kernel-supplied do_div() macro for the 64-bit integer division.

Also see these links for where these issues were addressed previously:

http://permalink.gmane.org/gmane.linux.distributions.emc.user/18718
http://permalink.gmane.org/gmane.linux.distributions.emc.devel/3663

(There are several more places in components/lcd.c parse_fmt() that
need these fixes; this patch at least the hostmot2 driver and unit
tests working.)
check-system-configuration.sh:  check for common problems

Instead of installing /etc/rsyslog.d/linuxcnc.conf,
/etc/security/limits.d/linuxcnc.conf and
/etc/udev/rules.d/50-LINUXCNC-shmdrv.rules from Makefile in RIP
builds, run check-system-configuration.sh after 'make setuid' to check
for these configuration problems and report to the user.

At the same time, add those missing files to non-RIP installs and to
Debian packaging.

check-system-configuration.sh is the former check-logging.sh, renamed
and extended.

(Installing the files with $(FILE) also ensures these files are
installed world-readable; installing with 'cp' under buildbot's funky
077 netmask nullifies their purpose.)
configure.in:  tweak libmodbus not found behavior

If libmodbus is not found:
  - Fail if --with-libmodbus specified (drop Debian-specific error)
  - Continue (with diagnostic) if not specified