Fix autotools configuration

I encountered some errors while trying to build with autotools, so I have modified configuration files.

* Add some headers to the list of installed files.
* Specify the "foreign" strictness so that automake does not complain about missing files.
* Specify a directory for m4 macros as suggested by libtoolize.
* Add autotools-generated files to gitignore.