So I’ve been playing a bit with clump a very cool tiny build tool for C.
Clump analyzes the .c files for #include directives and main() functions. Then builds executables for each file containing a main, linking in the required libraries based on the included headers.
So in otherwords you never have to maintain Makefiles again. Dont expect it to work for complex projects (yet), but if you have a bunch of .c files in a directory all you need to build it is to type: clump
One caveat is that this will only work if you are using a few standard libraries. However it is very easy to add support for just about any type of library using a optional file called clump.ini
This file contains a few simple directives you can use to customize the build that clump performs:
objdir ../obj
bindir ../bin
compile "gcc -c -Wall -Werror -I/usr/include/libxml2 -ansi -O2 $(cfile) -o $(ofile)"
link "gcc $(objects) -o $(efile)"
syshdr libxml/tree.h -lxml
syshdr libxslt/xslt.h -lxslt
This example file is all you need for writing c applications using libxml2. The objdir, bindir and link lines are really optional and I’m only including them here to show their use.
In the compile directive I am telling clump to use this commandline for compiling each file. Thus I can include special include paths here, like the one for libxml2.
The syshdr directive is probably the meat of the intelligence. You basically use it to mark various header files to library flags. So, in this is example any .c file that includes libxml/tree.h should be linked with libxml.
It’s really very simple to configure.
Patrick Chkoreff the author of clump tells me about the following shortcomings:
- Unix only at the moment. He is planning a windows version
- Currently only builds executables. He is working on adding support for libraries. He says it should be fairly simple to add.
- Only deals with code files immediately contained in the current directory.
- He wants to implement a -m flag for outputting a Makefile.
All in all very cool. Particular for us occasional c programmers, who arent working on major ground breaking open source programs.
After using it for a few days, I was struck at how the basic philosophy is similar to Maven in the way that it kind of just figures out what to do, if you put it in the right structure.
This entry was posted in the following Categories: Open Source