There are two things that have to be considered here.
One is telling the code what board you are using, so it can compile in the right optional parts, and the other is getting the right pin mappings.
The first can be covered simply with a compilation flag:
-DARDUINO_MEGA2560
That defines the macro ARDUINO_MEGA2560 which is used in some places to know which board you are using.
Second is the pin mappings. These are stored in the file pins_arduino.h and each board variant has its own copy. You need to ensure that this file (and be sure to get the right one) is included in your code in the right places to ensure that the pins can be mapped right. If you are including the whole Arduino core (which it sounds like you must be in order for things to even have a hope of working) then you just need to ensure that you have the compiler set up to include the right copy of the pins_arduino.h file.
That means making sure you have an include path in your compile command line which points to where the pins_arduino.h file is before anything else Arduino core related.
-IC:\Path\to\arduino\mega2560\variant
or
-I/path/to/arduino/mega2560/variant