[sane-devel] Usage of LIBOBJS/ALLOCA in Makefiles

Chris Bagwell chris at cnpbagwell.com
Tue Jan 27 04:25:52 UTC 2009


Hi all,

I notice that sane-backend's has the pretty common setup where it looks 
for functions that are commonly missing from some platforms and compiles 
its own internal version and they are all located in lib/ directory.  I 
also see that it creates a library named liblib.a but no one usages it. 
Instead it uses LIBOBJS and ALLOCA in backend/Makefile.in.

I can't really test the existing logic easy right now because all my 
platforms have external versions of all these utils.  When I try to 
simulate it, the backend/Makefile.in fails.  Not sure why.

First question is if anyone on this list works on a platform that needs 
to link in the items from lib/ directory into the backends.  I'd like 
confirmation that existing logic even works.

Second question is this:  I don't think its a good idea to link internal 
versions of standard functions into the backends.  As I mentioned 
earlier, its super common for all projects to do this.  If we link in, 
for example, snprintf into libsane and then if someone else links in 
libsane along with their own internal snprintf then we will get symbol 
collisions and failed compiles.

In the past, I've worked around this issue by using preprocessor magic.  
When we detect internal version will be used then add a "#define 
snprintf sanei_snprintf" to some global header file.  Then normal code 
keeps referring to just snprintf() but it sometimes get remapped to 
internal version without library knowing it.  Exported symbol table will 
be proper sanei_ prefix as well.

Anyone have issues with me making this change?

Chris



More information about the sane-devel mailing list