Wednesday, 7 August 2013

Makefile.am commands to override library functions

Makefile.am commands to override library functions

I have an open source project that relies on another open source project
(let's call that other project X). Both are written in C. I've had to hack
pieces of X to get multi-threading to work. This causes some issues when
trying to package up the code for distribution. To make things easier,
I've just included the entirety of X within mine along with the few little
hacks I've made.
I'd like to do something more sophisticated now in order to keep the
improved functionality of X (it has frequent releases and mine does not)
without having to repackage the whole project (with my hacks) within my
project again each time that X has a release.
There are only 3 or 4 functions in that need to override. I can follow
what is going on in this IBM Tutorial, but how can I modify my Makefile.am
to generate the Makefile changes suggested in that article? To summarize,
the article suggests writing my own functions with the same signatures as
the ones I want to override (in a file called libfuncs.c) and then add the
following 'libs' target to the makefile:
all: libs setresgid-tester
libs: libfuncs.c
gcc -shared -Wl,-soname,libfuncs.so.1 -o libfuncs.so.1.0
libfuncs.c
ln -s libfuncs.so.1.0 libfuncs.so.1
ln -s libfuncs.so.1 libfuncs.so
setresgid-tester: setresgid-tester.c
gcc -o setresgid-tester setresgid-tester.c
All of that makes sense to me. What I need to do, however, is to have this
'libs' target created for me with the autotools. I have a Makefile.am
works well right now. How do I modify it to produce the desired results
above? It was difficult to find in the autotools documentation, but I may
just not have known exactly what to look for.
I'm happy to provide more details if helpful. Thanks in advance.

No comments:

Post a Comment