Firefighters are racing to contain wildfires tearing through France and Spain as hundreds of thousands evacuate.