There are conventions governing the configure
switch to enable your extension. If your extension does not rely on
any external components, use --enable-foo. If it does have some
nonbundled dependencies, such as a library, use --with-foo.
Optionally, you can specify a base path using --with-foo=/some/path,
which helps configure find the dependencies.
PHP uses the grand unifying scheme of autoconf,
automake, and libtool to
build extensions. These three tools, used together, can be extremely
powerful, but they can also be extremely frustrating. Getting this
stuff right is a bit of a black art. When an extension is part of the
PHP source tree and you run the buildconf script in the top directory
of the tree, it scans through all its subdirectories looking for
config.m4 files. It grabs all the config.m4 files and creates a
single configure script that contains all the
configure switches. This means that each extension
needs to implement its own configure checks to check for whatever
dependencies and system-level features might be needed to build the
extension.
These checks are done through autoconf macros
and general m4 scripting in the config.m4 file.
Your best bet is probably to look at some of the existing config.m4
files in the various PHP extensions to see how different types of
checks are done.