diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2006-10-01 20:27:01 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2006-10-01 20:27:01 +0000 |
commit | fb4d809cd1b40be077412759c53d8e938aabc436 (patch) | |
tree | 7fec20d1082fce5c63d28f2ebe132c4f9aca25a9 /buildtools | |
parent | fce04508ec7e63241fc52278a2b960d8a5e4608c (diff) | |
download | netpbm-mirror-fb4d809cd1b40be077412759c53d8e938aabc436.tar.gz netpbm-mirror-fb4d809cd1b40be077412759c53d8e938aabc436.tar.xz netpbm-mirror-fb4d809cd1b40be077412759c53d8e938aabc436.zip |
Configure does test compiles to detect broken libpng-config --ldflags
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@79 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'buildtools')
-rwxr-xr-x | buildtools/configure.pl | 65 |
1 files changed, 57 insertions, 8 deletions
diff --git a/buildtools/configure.pl b/buildtools/configure.pl index 3a44a0da..dea30b75 100755 --- a/buildtools/configure.pl +++ b/buildtools/configure.pl @@ -221,6 +221,33 @@ sub testCompile($$$) { +sub testCompileLink($$$) { + my ($flags, $cSourceCodeR, $successR) = @_; +#----------------------------------------------------------------------------- +# Do a test compile of the program in @{$cSourceCodeR}. +# +# Return $$successR == $TRUE iff the compile succeeds (exit code 0). +#----------------------------------------------------------------------------- + my ($cFile, $cFileName) = tempFile('.c'); + + print $cFile @{$cSourceCodeR}; + + my ($oFile, $oFileName) = tempFile(''); + + my $compileCommand = "$testCc -o $oFileName $flags $cFileName"; + print ("Doing test compile/link: $compileCommand\n"); + my $rc = system($compileCommand); + + unlink($oFileName); + close($oFile); + unlink($cFileName); + close($cFile); + + $$successR = ($rc == 0); +} + + + sub displayIntroduction() { print("This is the Netpbm configurator. It is an interactive dialog " . "that\n"); @@ -1464,6 +1491,34 @@ sub testPngHdr($$$) { +sub testLinkPnglib($$) { + my ($generalCflags, $pngCflags) = @_; + + my @cSourceCode = ( + "#include <png.h>\n", + "int main() {\n", + "png_create_write_struct(0, NULL, NULL, NULL);\n", + "}\n", + ); + + testCompile("$generalCflags $pngCflags", \@cSourceCode, \my $success); + if (!$success) { + # Since it won't compile, we can't test the link + } else { + my $pngLdflags = qx{libpng-config --ldflags}; + chomp($pngLdflags); + + testCompileLink("$generalCflags $pngCflags $pngLdflags", + \@cSourceCode, \my $success); + + if (!$success) { + printBadPngConfigLdflagsWarning($pngLdflags); + } + } +} + + + sub testLibpngConfig($) { my ($needLocal) = @_; #----------------------------------------------------------------------------- @@ -1478,15 +1533,9 @@ sub testLibpngConfig($) { testCompilePngH("$generalCflags $pngCflags", \my $success); if (!$success) { - print("\n"); - print("Unable to compile a test PNG program using the compiler " . - "flags that libpng-config says to use: '$pngCflags'.\n"); - print("This indicates that you have Libpng installed incorrectly.\n"); - print("libpng-config gets installed as part of the Libpng package.\n"); + printBadPngConfigCflagsWarning($pngCflags); } else { - - - + testLinkPnglib($generalCflags, $pngCflags); } } |