You might take a look at the Transandalus website. It won't help with Portugal, but it will give you a choice of two great BTT routes through the provinces of Sevilla and Huelva to reach Portugal. The tracks for the entire 2500 km route are free online as are the accompanying route guides. It's a great ride through the mountains and National Parks of southern Spain.
Website:
https://www.transandalus.org/#!/
The tracks are also on Wikiloc:
https://es.wikiloc.com/rutas-mountain-bike/transandalus-vuelta-a-andalucia-en-btt-366563https://es.wikiloc.com/wikiloc/user.do?id=430319Here are some leads to BTT routes in Portugal:
https://biketestreviews.com/bikepacking-in-portugal/