In a 12- by 15-inch baking pan, mix eggplant with 2 tablespoons oil, 1 tablespoon garlic, 1/4 teaspoon salt, and 1/4 teaspoon pepper. Bake in a 400° regular or convection oven, stirring once, until eggplant is browned and soft when pierced, 30 to 35 minutes.
Pour remaining tablespoon oil into a 5- to 6-quart pan over medium heat. When hot, add onion and remaining 2 tablespoons garlic. Stir frequently until onion is very limp, 5 to 8 minutes.
Add tomatoes, basil, sugar, oregano, chili flakes, and roasted eggplant. Cover and simmer, stirring occasionally, until tomatoes have broken down slightly and mixture is thick, 35 to 40 minutes. Add salt and pepper to taste.