To make the sauce also called 'pesto alla trapanese': Put the tomatoes, garlic and basil in a large mortar. Add the extra-virgin olive oil, salt and use a pestle to crush the ingredients into a paste. If the pesto looks too dry, add more olive oil. Crush the ingredients until the pesto sauce is even in consistency. Alternatively, place the above ingredients in a food processor and puree.
Heat up extra-virgin olive oil in a saucepan and fry the eggplant until golden. Place the fried eggplant on an absorbent paper towel to drain the excess oil. Season the eggplant, while hot, with salt. Follow the same procedure to fry up the potatoes.
Place the spaghetti in a pot of boiling salted water. Stir initially to prevent the strands from sticking.
Drain the spaghetti when it is 'al dente'. Place the spaghetti in a large mixing bowl, add the pesto sauce, half the quantity of the fried eggplant, potatoes, Pecorino cheese, and mix thoroughly. Transfer to a large serving bowl and top with the remaining eggplant, potatoes and Pecorino cheese. Serve immediately.