I have always wondered how does GRUB 2 work. While reading it's source code, I saw that there are some #include directives which include seemingly nonexistent "grub/machine/...", for example in grub-core/boot/i386/pc/boot.S bootloader file there is
#include <grub/machine/boot.h>
As it seems, it provides some architecture-specific macros, and my current guess is that it is created from sort of a mixin of files and macros from include/grub when compiling for a specific architecture (e.g. #include <grub/machine/boot.h>
might be directly copied from include/grub/i386/pc/boot.h, which I can assume by looking at macro references in boot.S and corresponding definitions in i386/pc/boot.h), but I am very unsure about my assumption as I have failed to find any documentation or article about that. Also I'm failing to understand, in case my assumptions are at least somewhat correct, why are some directories in include/grub not just not similar to eachother (with, for example, having some files in common, like arm/ having it's own boot.h), but, in some cases, completely different, which seems counterintuitive from my perspective.
I would be glad to get some explanation on what is really going on behind those curtains as I'm trying to learn kernel development myself.
In ./configure.ac, there is this line
AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
That line creates a symlink to the right CPU architecture ../../include/grub/i386/pc
after I ran ./autogen.sh && ./configure && make
on my machine. Inside of that directory will be the architecture dependent boot.h file.
I find it easier to understand repos like this running some of the build commands locally.