Hacking Makefiles on OS X

A quarter past midnight on the morning, and i just got some recalcitrant software to build on my machine by hacking the makefile. Verily, now, i am teh propar haxx0r!!!

Just in case anyone else comes across this problem, the software in question is NetPBM, although it probably comes up with other stuff, and my machine is running OS X 10.3. The problem was down to quirkiness in Apple's ld. Well, difference to GNU ld, anyway. With GNU ld, the flag for adding a directory to the library search path is "-rpath,/path/to/dir"; with Apple's, it's "-L/path/to/dir". To get round this, after you've run ./configure, you need to change two things (well, you could just change one thing, but this is fractionally cleaner). Firstly, in Makefile.config, change the line "RPATHOPTNAME = -rpath" to "RPATHOPTNAME = -L" (with no trailing spaces!) - that will give you the right flag. Ignore the preceding remark about NEED_RUNTIME_PATH. Secondly, in Makefile.common, change the line "RPATH = -Wl,$(RPATHOPTNAME),$(NETPBMLIB_RUNTIME_PATH)" to "RPATH = -Wl,$(RPATHOPTNAME)$(NETPBMLIB_RUNTIME_PATH)" (spot the difference!) - that will get rid of the noisome comma. Unless i've forgotten something, that should do the trick.

I'm quite confused by all this, since it really looks to me like the makefile intends to use gcc to do its linking. Maybe gcc just punts to ld or something.

While you're there, you might want to fiddle with the CCFLAGS; i get the impression my run through ./configure didn't enable gcc-specific optimisation flags. SUCK.

Yes, i know Fink has NetPBM - but it doesn't have a version recent enough to have pamgauss, and i need pamgauss.

Update: turned out i didn't need pamgauss.