I had the same problem today, I couldn't get an SD card to work with the SD library on an atmega 1284P with the mighty1284P 16 MHz optiboot bootloader.
The solution turned out to be a missing definition of the correct chip.
one needs to add "|| defined(__AVR_ATmega1284P__)" to the atmega644 line so that it reads:
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)|| defined(__AVR_ATmega1284P__)
Then my code compiled and it now seems to run without a hitch.