The other day, I was working with an unfamiliar build and I needed to get familiar with it in a hurry. In this case, I was dealing with a makefile generated by the Perl utility h2xs, but the trick I’ll show you here works any time you need to find your way around a new build system, whether it’s something you just downloaded or an internal project you just transferred to.
What I wanted to do was add a few object files to the link command. Here’s the build log, with the link command highlighted:
gcc -c -I. -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -DVERSION=\"0.01\" -DXS_VERSION=\"0.01\" -fPIC "-I/usr/lib/perl/5.10/CORE" mylib.c rm -f blib/arch/auto/mylib/mylib.so gcc -shared -O2 -g -L/usr/local/lib mylib.o -o blib/arch/auto/mylib/mylib.so \ \ chmod 755 blib/arch/auto/mylib/mylib.so
Should be easy, right? I just needed to find that command in the makefile and make my changes. Wrong. Read on to see how annotation helped solve this problem.