Melt the butter in a large saucepan over low heat and sauté the onions, uncovered, stirring constantly for 15 and 30 minutes, or until they start to colour. Add 2 tablespoons of cold water, cover and cook 15 minutes more.
Add the flour and stir to coat the onions. Cook for another 5 minutes uncovered, stirring constantly. Add the stock, wine, salt and pepper, and bring to the boil. Reduce heat and simmer gently for 20 minutes. Adjust seasoning if necessary.
Meanwhile, toast the bread till very crisp (so they don't break down once in the soup). Place one slice in each soup bowl, then ladle the soup over the toast. The bread will rise to the surface. Sprinkle each bowl with grated cheese.
Place under the grill for 3 to 5 minutes, or until the cheese is melted and bubbly. Serve straightaway.