Autodetect main programs