#DEFINE precompile by custom GUI

I can write a code to manipulate all #define in on file so after I must call in sequence the compiler, the linker and the uploader... but how?

Enable verbose mode in the IDE. Compile, link, and upload code. You will see all the commands, arguments, and output that the IDE uses/sets/produces.

Then, do the same things from your application.