Bug 691111

Summary: ghostscript-8.71 fails to compile against >=libpng-1.4.0
Product: Ghostscript Reporter: Timo Gurr <timo.gurr>
Component: Build ProcessAssignee: Hin-Tak Leung <htl10>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P4    
Version: 0.00   
Hardware: PC   
OS: Linux   
URL: http://bugs.gentoo.org/show_bug.cgi?id=305111
Customer: Word Size: ---
Attachments: ghostscript-gpl-8.71-libpng-1.4.0-compile-fix.patch
ghostscript-gpl-8.71-libpng-1.4.0-compile-fix-v2.patch

Description Timo Gurr 2010-02-15 13:40:46 UTC
On Gentoo Linux we don't use any bundled libraries and try to link as much as 
possible against system-wide libs. I'm aware that the ghostscript bundled 
version is libpng 1.2.42, which works quite fine.

Error when compiling against libpng-1.4.0:

./obj/../soobj/echogs -e .dev -w- -l-dev2 -b -s -l-include
-l./obj/../soobj/page -l-obj ./obj/../soobj/pksmraw ./obj/../soobj/gdevpbm.o
./obj/../soobj/gdevppla.o ./obj/../soobj/gdevmpla.o                             
./obj/../soobj/echogs -e .dev -w- -l-dev2 -b -s -l-include
-l./obj/../soobj/page -l-obj ./obj/../soobj/plan9bm ./obj/../soobj/gdevpbm.o
./obj/../soobj/gdevppla.o ./obj/../soobj/gdevmpla.o
make[1]: *** No rule to make target `src/png.c', needed by
`obj/../soobj/png.o'.  Stop.
make[1]: Leaving directory
`/var/tmp/portage/app-text/ghostscript-gpl-8.70-r1/work/ghostscript-8.70'
make: *** [so] Error 2

Attached is a patch which works around the problem, author of the patch is Lars 
Wendler (Polynomial-C) <polynomial-c@gentoo.org>, added the original bugreport 
on our Gentoo bugtracker in URL.
Comment 1 Timo Gurr 2010-02-15 13:42:20 UTC
Created attachment 5955 [details]
ghostscript-gpl-8.71-libpng-1.4.0-compile-fix.patch
Comment 2 Timo Gurr 2010-03-08 11:38:30 UTC
Created attachment 6041 [details]
ghostscript-gpl-8.71-libpng-1.4.0-compile-fix-v2.patch
Comment 3 Hin-Tak Leung 2010-05-02 03:12:47 UTC
Grabbing a Ralph's bugs.
Comment 4 Hin-Tak Leung 2010-06-28 03:16:48 UTC
(In reply to comment #2)
> Created an attachment (id=6041) [details]
> ghostscript-gpl-8.71-libpng-1.4.0-compile-fix-v2.patch

Sorry, the patch is wrong - in 1.4.0, png_check_sig() is removed and replaced by    png_sig_cmp() so applying it would break building against linpng 1.2.x .

It would be far better to modify configure to check for a function which is common to both 1.2.x and 1.4.x, rather than switching between the two. e.g. check if png_struct is defined or png_create_write_struct() is defined. (these are actually used by the png device so rather more appropriate than either png_check_sig() or png_sig_cmp()).
Comment 5 Hin-Tak Leung 2010-06-29 04:44:22 UTC
r11449 switches the png test away from png_sig_cmp() (obsolete/removed in libpng 1.4) to png_create_write_struct() which is actually used by the png device, and common to both libpng 1.2.x and 1.4.x , to allow building against either versions.

As explained, the submitted patch was wrong. Also, configure.ac is usually sym-link to "base/configure.ac", so only two files needed to be modified, rather than three.