Pass external dependencies to submodule Makefiles

Part of the fix for #2137.