build: only do docclean when doc building enabled

this fixes an undefined variable warning

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
build: give EXTRAFLAGS an empty definition

.. so that it's not a warning to refer to it when
--warn-undefined-variables is specified as a make flag

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
build: Unconditionally enable -fno-strict-aliasing

This flag is supported in gcc 4.4, the oldest version we target
with linuxcnc 2.6.

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
build: compute EXTRA_CFLAGS just once

We were repeatedly invoking the compiler on trivial input files
via $(call cc-option).  Using := assignment, these compiler invocations
occur only once.

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
build: Warn about use of undefined variables

.. these usually indicate mistakes in the Makefiles.

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
build: correctly check for 'make -s' silent build

The documentation of GNU make is a bit confusing on this point, but
apparently -s is indicated when a word in MAKEFLAGS which *does not*
start with -- contains the letter s.  In testing, "make --silent" and
"make --quiet", two long-option synonyms for "make -s", both add the
lone letter "s" to the first word of MAKEFLAGS.

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
build: Honor silent mode when it comes to informing about dependency info

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
build: don't bother reading legacy (2.5)-style dependencies

If people switch from a 2.5-ish branch to a master branch, they may
encounter build errors.  In that case, it will be necessary to
'make clean'.

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
build: provide empty EXTRA_DEBUG by default, but allow overriding from make commandline

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
build: fix 'cannot stat tc.h' build error when switching branches

These rules interacted badly with the dummy header-regenerating rules
in .d files, causing the build process to try to copy tc.h from the wrong
location after switching branches.

Restrict each rule so that it can only be used in cases where the source
file actually exists.  (This is OK so long as we don't generate and then
copy any headers)

This commit fixes a build problem when switching from the 2.6 branch
(34a59fdb) to master (e8de7f59).

This script reproduces the problem:

    cd linuxcnc-dev/src
    git checkout 2.6
    git clean -fdx ..
    ./autogen.sh
    ./configure --enable-simulator --disable-build-documentation
    make
    git checkout master
    make   # this fails:
           # cp emc/kinematics/tc.h ../include/tc.h
           # cp: cannot stat `emc/kinematics/tc.h': No such file or directory
           # make: *** [../include/tc.h] Error 1
    make   # this succeeds

The problem:

    The 2.6 and master (e8de7f59 and older) src/Makefile include the
    .d dependency files, using "-include" so that it's not an error
    (or even a warning) if the dependency files are missing.

    Those Makefiles also don't have any rules for generating the .d
    files; they're generated as a byproduct of compiling the source into
    .o files.

    So in the repro script above, the 2.6 'make' fails to include any .d
    dependency files but runs to completion anyway.  Then the master 'make'
    includes the old 2.6 dependency files which are out-of-date, and the
    build fails.  But it fails after re-compiling the problematic sources
    files, thus re-generating the dependency files, so that the following
    'make' sees correct dependencies and succeeds.

Signed-off-by: Jeff Epler <jepler@unpythonic.net>