buildcounter / buildcounter.1

.\" Manpage for buildcounter.
.\" Contact to correct errors or typos.
.\" Original repository:
.TH buildcounter 1 "03 Oct 2012" "1.0" "buildcounter man page"
buildcounter \- build counter tool for C/C++ projects
\fBbuildcounter\fR <-s> [filename]
\fBbuildcounter\fR is a small automatic tool that helps keeping track of different builds for projects in C/C++. It works by creating and modifying a header file with a single define \fBBUILDNO\fR that counts with each invocation starting with 1.
.IP "\fB-s\fR" 4
Silent mode: Without this parameter, \fBbuildcounter\fR will not only write the define to the given filename, but also to stdout. 
To use \fBbuildcounter\fR for your project, do this:
.IP "\fB1\fR" 4
In your source folder, call \fBbuildcounter buildno.h\fR manually. As this creates an internal header file, it should not go into a special include folder.
.IP "\fB2\fR" 4
Create a target called "buildno.h" in your makefile. 
If you do not have a default target containing only dependencies yet, create one. Make it dependend to all necessary build steps and add the "buildno.h" to the end.

.IP "" 8 
all: withoutcounting buildno.h

withoutcounting: a.out

a.out: test.c
    gcc test.c

buildno.h: test.c
    buildcounter -s buildno.h

.IP "\fB3\fR" 4
In your code, include "buildno.h" and use \fBBUILDNO\fR.
Build your code normally using the default target (or explicitly call "make all"). If you do not want to increase the counter after a specific build, call "make withoutcounting".

Finding the right place to call \fBbuildcounter\fR allows some easy mistakes.
It should only be called once for each successful build. That means that you should call it after the real building.
If you forget to make it dependend of any of your source files, \fBbuildcounter\fR will be called even if there where no changes at all. If you only add some but not all source files, changes of other files will not change the counter.

No known bugs. 
If you find one, please use \fB\fR to create a ticket.
b.w (a) gmx (.) tm