GNU   davin.50webs.com/research
Bringing to you notes for the ages

       Main Menu          Research Projects         Photo Album            Curriculum Vitae      The Greatest Artists
    Email Address       Computer Games          Web Design          Java Training Wheels      The Fly (A Story)   
  Political Activism   Scruff the Cat       My Life Story          Smoking Cessation          Other Links      
Debugging Macros     String Class I     Linked List System I Java for C Programmers Naming Convention
    String Class II         How I use m4              Strings III                 Symmetrical I/O             Linked Lists II     
Run-Time Type Info   Virtual Methods      An Array System        Science & Religion            Submodes       
  Nested Packages      Memory Leaks    Garbage Collection      Internet & Poverty      What is Knowledge?
Limits of Evolution   Emacs Additions      Function Plotter           Romantic Love        The Next Big Thing
    Science Fiction     Faster Compilation Theory of Morality         Elisp Scoping               Elisp Advice      
  S.O.G.M. Pattern       Safe Properties         School Bullying          Charisma Control          Life and Death    
     Splitting Java          Multiple Ctors       Religious Beliefs         Conversation 1           Conversation 2    
   J.T.W. language    Emacs Additions II      Build Counter             Relation Plotter          Lisp++ Language  
  Memory Leaks II   Super Constructors CRUD Implementation Order a Website Form There Is An Afterlife
More Occam's Razor C to Java Translator Theory of Morality II


A build counter system for Makefiles Free Stuff

1. How the system works

The build counter system presented in this article can be used to keep track of how many times your linker is invoked when you build your executables. The system is comprised of two pieces of code, one m4 source file and some code that goes into your Makefile after the linker is invoked. Suppose your executable is called 2010/tests/hello.exe. Then the name of the file that keeps track of how many times the linker is invoked is called 2010/tests/hello.num where the .num file extension stands for number. The system is robust enough to handle cases where the file 2010/tests/hello.num does not exist as will be the case when the linker is run for the first time with the extra linker code. The reason that the number of linker invocations is counted is that linking is always done once at the end of a series of compilations.

2. How to install the system

The following m4 code can be used to keep track to the build counts of your linker:

m4_define(COUNTER,m4_eval(m4_sinclude(FILE) + 1))m4_dnl
m4_esyscmd(echo >FILE COUNTER)m4_dnl
*** Updated build count to new value: COUNTER

Place the above code into a file called build-counter.txt and add the following code to your Makefile's linker call:

m4 -P -DFILE=$*.num build-counter.txt

so that the command to invoke the linker looks something like what follows:

%.exe: %.o $(LINK_WITH)
        @printf "** Linking %s %s\n" $*.exe $(INFO_OPTION)
        g++ $^ -o $*.exe $(LDFLAGS)
        m4 -P -DFILE=$*.num build-counter.txt

3. How to use the system

If /path/to/X.num is the name of your *.num file, then you can use m4 to include it in other documents using the command m4_include(/path/to/X.num), or you can issue the command cat /path/to/X.num to print out the value of the number stored in the file like so in your Makefile:

@echo "The current value for build count is: " $$(cat /path/to/X.num)

4. How to customise GNU Emacs to hide *.num files

By altering the variable dired-omit-extensions and completion-ignored-extensions you can hide the *.num files from being visible in Emacs' directory editor, dired and from showing up using TAB file completion. Here are the values for dired-omit-extensions and completion-ignored-extensions that work for my version of Emacs:

(setq dired-omit-extensions
   (append
      (list
         ".num")
         dired-omit-extensions))

(setq completion-ignored-extensions
   (append
      (list
         ".num")
         completion-ignored-extensions))


Back to Research Projects
This page has the following hit count:
| Main Menu | Research Projects | Photo Album | Curriculum Vitae | The Greatest Artists |
| Email Address | Computer Games | Web Design | Java Training Wheels | The Fly (A Story) |
| Political Activism | Scruff the Cat | My Life Story | Smoking Cessation | Other Links |
| Debugging Macros | String Class I | Linked List System I | Java for C Programmers | Naming Convention |
| String Class II | How I use m4 | Strings III | Symmetrical I/O | Linked Lists II |
| Run-Time Type Info | Virtual Methods | An Array System | Science & Religion | Submodes |
| Nested Packages | Memory Leaks | Garbage Collection | Internet & Poverty | What is Knowledge? |
| Limits of Evolution | Emacs Additions | Function Plotter | Romantic Love | The Next Big Thing |
| Science Fiction | Faster Compilation | Theory of Morality | Elisp Scoping | Elisp Advice |
| S.O.G.M. Pattern | Safe Properties | School Bullying | Charisma Control | Life and Death |
| Splitting Java | Multiple Ctors | Religious Beliefs | Conversation 1 | Conversation 2 |
| J.T.W. language | Emacs Additions II | Build Counter | Relation Plotter | Lisp++ Language |
| Memory Leaks II | Super Constructors | CRUD Implementation | Order a Website Form | There Is An Afterlife |
| More Occam's Razor | C to Java Translator | Theory of Morality II
Last modified: Sun Jul 14 03:34:53 NZST 2019
Best viewed at 800x600 or above resolution.
© Copyright 1999-2019 Davin Pearson.
Please report any broken links to