Automatically detect libpng.
authorJason Rumney <jasonr@gnu.org>
Sat, 25 Jan 2003 20:50:48 +0000 (20:50 +0000)
committerJason Rumney <jasonr@gnu.org>
Sat, 25 Jan 2003 20:50:48 +0000 (20:50 +0000)
nt/configure.bat

index 0525b53..2aa477c 100755 (executable)
@@ -85,6 +85,7 @@ if "%1" == "--no-opt" goto noopt
 if "%1" == "--no-cygwin" goto nocygwin\r
 if "%1" == "--cflags" goto usercflags\r
 if "%1" == "--ldflags" goto userldflags\r
+if "%1" == "--without-png" goto withoutpng\r
 if "%1" == "" goto checkutils\r
 :usage\r
 echo Usage: configure [options]\r
@@ -97,6 +98,7 @@ echo.   --no-opt                disable optimization
 echo.   --no-cygwin             use -mno-cygwin option with GCC\r
 echo.   --cflags FLAG           pass FLAG to compiler\r
 echo.   --ldflags FLAG          pass FLAG to compiler when linking\r
+echo.   --without-png                  do not use libpng even if it is installed \r
 goto end\r
 rem ----------------------------------------------------------------------\r
 :setprefix\r
@@ -143,6 +145,12 @@ set userldflags=%userldflags%%sep2%%1
 set sep2= %nothing%\r
 shift\r
 goto again\r
+rem ----------------------------------------------------------------------\r
+\r
+:withoutpng\r
+set pngsupport=N\r
+set HAVE_PNG=\r
+goto again\r
 \r
 rem ----------------------------------------------------------------------\r
 rem    Check that necessary utilities (cp and rm) are present.\r
@@ -165,7 +173,7 @@ goto end
 rem ----------------------------------------------------------------------\r
 rem   Auto-detect compiler if not specified, and validate GCC if chosen.\r
 :checkcompiler\r
-if (%COMPILER%)==(cl) goto genmakefiles\r
+if (%COMPILER%)==(cl) goto compilercheckdone\r
 if (%COMPILER%)==(gcc) goto checkgcc\r
 \r
 echo Checking whether 'cl' is available...\r
@@ -231,13 +239,39 @@ goto end
 set COMPILER=gcc\r
 rm -f junk.c junk.o\r
 echo Using 'gcc'\r
-goto genmakefiles\r
+goto compilercheckdone\r
 \r
 :clOk\r
 set COMPILER=cl\r
 rm -f junk.c junk.obj\r
 echo Using 'MSVC'\r
-goto genmakefiles\r
+\r
+:compilercheckdone\r
+\r
+rem ----------------------------------------------------------------------\r
+rem   Check for external image libraries. Since they are loaded\r
+rem   dynamically, the libraries themselves do not need to be present\r
+rem   at compile time, but the header files are required.\r
+\r
+if (%pngsupport%) == (N) goto pngDone\r
+\r
+echo Checking for libpng...\r
+echo #include "png.h" >junk.c\r
+echo main (){} >>junk.c\r
+rem   -o option is ignored with cl, but allows result to be consistent.\r
+%COMPILER% %usercflags% -c junk.c -o junk.obj\r
+if exist junk.obj goto havePng\r
+\r
+echo ...building without PNG support.\r
+set HAVE_PNG=\r
+goto :pngDone\r
+\r
+:havePng\r
+echo ...PNG header available, building with PNG support.\r
+set HAVE_PNG=1\r
+\r
+:pngDone\r
+rm -f junk.c junk.obj\r
 \r
 rem ----------------------------------------------------------------------\r
 :genmakefiles\r
@@ -261,8 +295,13 @@ echo # End of settings from configure.bat>>config.settings
 echo. >>config.settings\r
 \r
 copy config.nt ..\src\config.h\r
+echo. >>..\src\config.h\r
+echo /* Start of settings from configure.bat.  */ >>..\src\config.h\r
 if not "(%usercflags%)" == "()" echo #define USER_CFLAGS " %usercflags%">>..\src\config.h\r
 if not "(%userldflags%)" == "()" echo #define USER_LDFLAGS " %userldflags%">>..\src\config.h\r
+if not "(%HAVE_PNG%)" == "()" echo #define HAVE_PNG 1 >>..\src\config.h\r
+echo /* End of settings from configure.bat.  */ >>..\src\config.h\r
+\r
 copy paths.h ..\src\epaths.h\r
 \r
 copy /b config.settings+%MAKECMD%.defs+..\nt\makefile.w32-in ..\nt\makefile\r