Handle --disable-foo properly

Fixes #1253
Merge pull request #1540 from rubenk/#1253

Handle --disable-foo properly