Only add option for shared libraries once

The way the test was done previously, it was added for *every* option
after `--enable-shared`, not only that one.