I would just leave this if I haven't actually experienced the problem trying to build someone else's code, and wasn't myself building something using traditional, complex build tools, so with that in mind...
Ref to my github build tools
scripts. Creates a super simple GNU Autotools project in the directory of your choosing. I'll be adding more cool things as I think of them.
One of the buildsystem features that I forgot to mention in the
other thread, is reliably building the same code under a variety of different platforms with one command. The stability and complexity of your build tools is also proportional to the diversity of platforms under which you expect your code to build. The learning curve of something like GNU Autotools is soon rewarded by the ease with which you can add compiler flags, search paths, and feature checks for 3rd party libraries
and expect it to build on the most systems possible, out of the box.
For the non-educational version of a project like Handmade Hero, where the expectation is to ship a game in binary form to players, the developer doesn't expect to distribute code that will ever be built by users. This is extremely different from code that is distributed with the express intent that it must be built by the users, or by package maintainers for the users. Even on very predictable platforms there will be variations, as seen early on in the HMH series with versions of XInput, and linker flag differences for WinXP.
The specific problem that spurred me to write this, was in a handwritten build that determined the word size of the build platform based on semantics, without directly testing the hardware. The system distribution I use is sufficiently different from the developer's that the check would always fail. Probably on
any other distribution, too.
The easiest thing to do, of course, is ask the kernel what its architecture is. But that, too, is semantic. It turns out this was the solution I suggested and ultimately taken by upstream, but a better way to do it is to test the architecture for features. Eg.,
| $ gcc -xc - -include stdio.h << '...'
int main(){
#if __x86_64__
printf("64\n");
#else
printf("32\n");
#endif
}
...
$ if test $? -eq 0; then ./a.out && rm a.out; else echo failed; fi
|
I'm sure there are even better ways that that. Feel free to reply with your method in the comments :D
Granted, any of these problems can be solved without big, hairy build tools. If you are just planning to distribute binaries to users, then you probably don't have much to worry about apart from ensuring those binaries will work. But, if your intent is to bring the Handmade Philosophy into the Free Software world, and I know a lot of projects here speak about exactly that, then this observation is of much greater value to you than anyone following HMH just to learn how to write good low-level code. Write good, portable builds, too.