Suppose there is a C program, which stores its version in a global char*
in main.c. Can the buildsystem (gnu make) somehow extract the value of this variable on build time, so that the executable built could have the exact version name as it appears in the program?
What I'd like to achieve is that given the source:
char g_version[] = "Superprogram 1.32 build 1142";
the buildsystem would generate an executable named Superprogram 1.32 build 1142.exe
The shell
function allows you to call external applications such as sed
that can be used to parse the source for the details required.
Define your version variable from a Macro:
char g_version[] = VERSION;
then make your makefile put a -D argument on the command line when compiling
gcc hack.c -DVERSION=\"Superprogram\ 1.99\"
And of course you should in your example use sed/grep/awk etc to generate your version string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With