A few different sources of tests and command-line parsing code exist.
Many common tests are packaged with autoconf.
Some tests become common enough that they are distributed in third-party macro libraries (*.m4 files).
Once-off tests can be coded directly into the configure.in file.
Collecting together the macros that come autoconf and third-party packages is done by aclocal.