Restore M4 scripts for autotools compatibility

Other DUNE modules that include opm-core include scripts from this
directory; if we delete them then these modules no longer work. They
are not necessary for building with CMake.
Only install .debug files when building shared object

Static libraries usually holds the debug information together with the
library because they are not loaded directly (but linked together to an
executable, which can be stripped)
Put static libraries in the same directory as shared
Only write source path line once

If more than one match is written, then DUNE_CHECK_MODULES will return
several matches, which becomes a syntax error on the resulting command-
line. Thus, check if there is a match before writing anything.