Thanks for that
paulsm4. I thought I must have misunderstood the question. Just to expand on my earlier post, I will add some of the details. Regretably, my first example did not use optimal CVS keywords, and do not match the ones I use routinely.
Code:
static char[] filename_c = "\nfilename.c: $Revision$ $Date$\n";
The variable named 'filename_c' is the C source file name, with the '.' replaced with an underscore. When I commit the source code to CVS, the macros/tokens "$Revision$" and "$Date$" are expanded by CVS into strings that identify the respective information about the file:
Code:
static char[] filename_c = "\nfilename.c: $Revision: 1.2 $ $Date: 2009/08/20 23:45:03 $\n";
When this source module is then compiled and linked into the runtime binary, it will have the above string embedded into it. As I said before, running the
strings command against that binary will display the embedded string. If you want to, your program can provide a command of some sort, such as a '--version' option that will
printf() the string(s), or display them in some other manner. If the C module is used to build a library, the contents of the library can be examined with the
nm command, and when filtered with
grep:
Code:
nm libMyLibrary.so | grep "_c"
will display all of the filenames that are similarly massaged within the library.
Hope this clarifies my original post.
--- rod.
EDIT: You can put a rule in your Makefile to commit all sources to CVS (or whatever versioning tool you use), thus satisfying your build-time requirement.