Cut the aubergines into quarters lengthways, then each quarter in half lengthways. Cut the pieces into finger-sized lengths.
Heat 1 cm (½ inch) oil in a large frying pan over a high heat until the surface of the oil seems to shimmer. Add the aubergines, in batches, and fry until golden. With a slotted spoon, remove and drain on kitchen paper.
Heat 1 tablespoon oil in a large, heavy-based frying pan over a medium heat, add the garlic and cook, stirring, for 30 seconds. Stir in the aubergines and season, then stir in the tomatoes. Bring to the boil, then reduce the heat and simmer, uncovered, for 20 minutes until the sauce has thickened. Remove from the heat, stir in half the basil and adjust the seasoning.
When the sauce is almost ready, cook the pasta in a large saucepan of salted boiling water according to the packet instructions until al dente. Drain, reserving a ladleful of the cooking water. Add the pasta to the sauce and stir over a low heat. Pour in the reserved pasta cooking water and continue stirring until the pasta is well coated and looks silky. Serve immediately with a scattering of ricotta, pecorino and the remaining basil.