From d00bbb29b8a84511c04aff2081c86022c24f89ec Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Sun, 14 Mar 2010 09:15:49 -0500 Subject: [PATCH] [devel] Made PNG_BUILD_DLL safe: it can be set whenever a DLL is being built. Removed the include of sys/types.h - apparently unnecessary now on the platforms on which it happened (all but Mac OS and RISC OS). Moved the Mac OS test into pngpriv.h (the only place it is used.) --- ANNOUNCE | 4 ++ CHANGES | 4 ++ CMakeLists.txt | 8 +-- pngconf.h | 111 +++++++++++++++---------------- pngpriv.h | 3 +- projects/visualc6/libpng.dsp | 22 +++--- projects/visualc6/pngtest.dsp | 16 ++--- projects/visualc71/libpng.vcproj | 54 +++++---------- projects/xcode/README.txt | 2 +- 9 files changed, 102 insertions(+), 122 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 90d2c476c..da6e9015b 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -119,6 +119,10 @@ version 1.5.0beta14 [March 14, 2010] to join tokens in the output and rewrite *.dfn to use this. Eliminated scripts/*.def in favor of libpng.def; updated projects/visualc71 and removed scripts/makefile.cygwin. + Made PNG_BUILD_DLL safe: it can be set whenever a DLL is being built. + Removed the include of sys/types.h - apparently unnecessary now on the + platforms on which it happened (all but Mac OS and RISC OS). + Moved the Mac OS test into pngpriv.h (the only place it is used.) Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index dd52393ea..f252744ce 100644 --- a/CHANGES +++ b/CHANGES @@ -2596,6 +2596,10 @@ version 1.5.0beta14 [March 14, 2010] to join tokens in the output and rewrite *.dfn to use this. Eliminated scripts/*.def in favor of libpng.def; updated projects/visualc71 and removed scripts/makefile.cygwin. + Made PNG_BUILD_DLL safe: it can be set whenever a DLL is being built. + Removed the include of sys/types.h - apparently unnecessary now on the + platforms on which it happened (all but Mac OS and RISC OS). + Moved the Mac OS test into pngpriv.h (the only place it is used.) Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CMakeLists.txt b/CMakeLists.txt index 2879c6837..43c37f6c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,7 +101,7 @@ set(CMAKE_DEBUG_POSTFIX "d") set(libpng_sources png.h pngconf.h - pngpriv.h + pngpriv.h png.c pngerror.c pngget.c @@ -123,10 +123,8 @@ set(pngtest_sources ) # SOME NEEDED DEFINITIONS -add_definitions(-DPNG_CONFIGURE_LIBPNG) - if(MSVC) - add_definitions(-DPNG_NO_MODULEDEF -D_CRT_SECURE_NO_DEPRECATE) + add_definitions(-D_CRT_SECURE_NO_DEPRECATE) endif(MSVC) if(PNG_SHARED OR NOT MSVC) @@ -148,7 +146,7 @@ if(PNG_NO_STDIO) endif() if(PNG_DEBUG) - add_definitions(-DPNG_DEBUG) + add_definitions(-DPNG_DEBUG=1) endif() if(NOT M_LIBRARY AND NOT WIN32) diff --git a/pngconf.h b/pngconf.h index 75a10025b..37efe7553 100644 --- a/pngconf.h +++ b/pngconf.h @@ -246,7 +246,7 @@ * the magic flag PNG_USE_DLL to turn on the special processing before * it includes png.h. * - * Two additional macros are used to make this happen: + * Four additional macros are used to make this happen: * * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from * the build or imported if PNG_USE_DLL is set - compiler @@ -254,6 +254,13 @@ * * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to * 'type', compiler specific. + * + * PNG_DLL_EXPORT Set to the magic to use during a libpng build to + * make a symbol exported from the DLL. + * + * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come + * from a DLL - used to define PNG_IMPEXP when + * PNG_USE_DLL is set. */ /* System specific discovery. @@ -272,17 +279,14 @@ # define PNGCAPI __cdecl # endif - /* Use dllexport and give the option of forcing DLL linking. */ -# ifdef DLL_EXPORT /* set by libtool */ -# ifndef PNG_IMPEXP -# define PNG_IMPEXP __declspec(dllexport) -# endif + /* Provide the appropriate defaults for exporting a symbol from + * the DLL and forcing import. Always set these - the choice to + * use them is made below. + */ +# ifndef PNG_DLL_EXPORT +# define PNG_DLL_EXPORT __declspec(dllexport) # endif - # ifndef PNG_DLL_IMPORT - /* Always set this because we don't know what will happen when - * the application is compiled. - */ # define PNG_DLL_IMPORT __declspec(dllimport) # endif @@ -312,30 +316,22 @@ # endif /* compiler/api */ /* NOTE: PNGCBAPI always defaults to PNGCAPI. */ -# if defined(DLL_EXPORT) || defined(_WINDLL) || defined(_DLL) ||\ - defined(__DLL__) - /* Building a DLL; check the compiler. */ -# if (defined(_MSC_VER) && _MSC_VER < 800) ||\ - (defined(__BORLANDC__) && __BORLANDC__ < 0x500) - /* older Borland and MSC - * compilers used '__export' and required this to be after - * the type. - */ -# ifndef PNG_EXPORT_TYPE -# define PNG_EXPORT_TYPE(type) type PNG_IMPEXP -# endif -# ifndef PNG_IMPEXP -# define PNG_IMPEXP __export -# endif -# else /* newer compiler */ -# ifndef PNG_IMPEXP -# define PNG_IMPEXP __declspec(dllexport) -# endif -# ifndef PNG_DLL_IMPORT -# define PNG_DLL_IMPORT __declspec(dllimport) -# endif -# endif /* compiler */ -# endif /* building DLL */ +# if (defined(_MSC_VER) && _MSC_VER < 800) ||\ + (defined(__BORLANDC__) && __BORLANDC__ < 0x500) + /* older Borland and MSC + * compilers used '__export' and required this to be after + * the type. + */ +# ifndef PNG_EXPORT_TYPE +# define PNG_EXPORT_TYPE(type) type PNG_IMPEXP +# endif +# define PNG_DLL_EXPORT __export +# else /* newer compiler */ +# define PNG_DLL_EXPORT __declspec(dllexport) +# ifndef PNG_DLL_IMPORT +# define PNG_DLL_IMPORT __declspec(dllimport) +# endif +# endif /* compiler */ # else /* !Cygwin && !Windows/x86 */ # if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) @@ -359,9 +355,31 @@ # define PNGAPI PNGCAPI #endif +/* The default for PNG_IMPEXP depends on whether the library is + * being built or used. + */ #ifndef PNG_IMPEXP -# define PNG_IMPEXP +# ifdef PNGLIB_BUILD + /* Building the library */ +# if (defined(DLL_EXPORT)/*from libtool*/ ||\ + defined(_WINDLL) || defined(_DLL) || defined(__DLL__) ||\ + defined(PNG_BUILD_DLL)) && defined(PNG_DLL_EXPORT) + /* Building a DLL. */ +# define PNG_IMPEXP PNG_DLL_EXPORT +# endif /* DLL */ +# else + /* Using the library */ +# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT) + /* This forces use of a DLL, disallowing static linking */ +# define PNG_IMPEXP PNG_DLL_IMPORT +# endif +# endif + +# ifndef PNG_IMPEXP +# define PNG_IMPEXP +# endif #endif + #ifndef PNG_EXPORT_TYPE # define PNG_EXPORT_TYPE(type) PNG_IMPEXP type #endif @@ -470,13 +488,6 @@ # define PNG_STDIO_SUPPORTED #endif - -#ifdef PNG_BUILD_DLL -# if !defined(PNG_CONSOLE_IO_SUPPORTED) && !defined(PNG_NO_CONSOLE_IO) -# define PNG_NO_CONSOLE_IO -# endif -#endif - #ifdef PNG_NO_STDIO # ifndef PNG_NO_CONSOLE_IO # define PNG_NO_CONSOLE_IO @@ -494,22 +505,6 @@ # define PNG_CONSOLE_IO_SUPPORTED #endif -/* Try to determine if we are compiling on a Mac. Note that testing for - * just __MWERKS__ is not good enough, because the Codewarrior is now used - * on non-Mac platforms. - */ -#ifndef MACOS -# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ - defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) -# define MACOS -# endif -#endif - -/* Enough people need this for various reasons to include it here */ -#if !defined(MACOS) && !defined(RISCOS) -#include -#endif - /* PNG_SETJMP_NOT_SUPPORTED and PNG_NO_SETJMP_SUPPORTED are deprecated. */ #if !defined(PNG_NO_SETJMP) && \ !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED) diff --git a/pngpriv.h b/pngpriv.h index e12a1507b..5c3dc0225 100644 --- a/pngpriv.h +++ b/pngpriv.h @@ -57,7 +57,8 @@ */ #ifdef PNG_FLOATING_POINT_SUPPORTED -# ifdef MACOS +# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ + defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) /* We need to check that hasn't already been included earlier * as it seems it doesn't agree with , yet we should really use * if possible. diff --git a/projects/visualc6/libpng.dsp b/projects/visualc6/libpng.dsp index bf0e140e9..4b125fba0 100644 --- a/projects/visualc6/libpng.dsp +++ b/projects/visualc6/libpng.dsp @@ -44,9 +44,9 @@ CFG=libpng - Win32 DLL Release # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" CPP=cl.exe -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c +# ADD BASE CPP /nologo /MD /W3 /O2 /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /FD /c +# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "NDEBUG" /D "ZLIB_DLL" /FD /c # SUBTRACT CPP /YX /Yc /Yu MTL=midl.exe # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -75,9 +75,9 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" CPP=cl.exe -# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c +# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "_DEBUG" /FD /GZ /c # SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /D "ZLIB_DLL" /FD /GZ /c # SUBTRACT CPP /YX /Yc /Yu MTL=midl.exe # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 @@ -106,9 +106,9 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" CPP=cl.exe -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c +# ADD BASE CPP /nologo /MD /W3 /O2 /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /D PNGAPI=__stdcall /D "PNG_NO_MODULEDEF" /D "PNG_LIBPNG_SPECIALBUILD" /FD /c +# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "NDEBUG" /D "ZLIB_DLL" /D PNGAPI=__stdcall /D "PNG_NO_MODULEDEF" /D "PNG_LIBPNG_SPECIALBUILD" /FD /c # SUBTRACT CPP /YX /Yc /Yu MTL=midl.exe # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -142,9 +142,9 @@ PostBuild_Cmds=echo Deleting $(targetname) import library and export file (No # PROP Intermediate_Dir "Win32_LIB_Release" # PROP Target_Dir "" CPP=cl.exe -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c +# ADD BASE CPP /nologo /MD /W3 /O2 /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /FD /c +# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "NDEBUG" /FD /c # SUBTRACT CPP /YX /Yc /Yu RSC=rc.exe # ADD BASE RSC /l 0x409 /d "PNG_NO_PEDANTIC_WARNINGS" /d "NDEBUG" @@ -169,9 +169,9 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "Win32_LIB_Debug" # PROP Target_Dir "" CPP=cl.exe -# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c +# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "_DEBUG" /FD /GZ /c # SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /FD /GZ /c # SUBTRACT CPP /YX /Yc /Yu RSC=rc.exe # ADD BASE RSC /l 0x409 /d "PNG_NO_PEDANTIC_WARNINGS" /d "_DEBUG" @@ -241,7 +241,7 @@ SOURCE=..\..\pngtrans.c # End Source File # Begin Source File -SOURCE=..\..\scripts\pngwin.def +SOURCE=..\..\libpng.def !IF "$(CFG)" == "libpng - Win32 DLL Release" diff --git a/projects/visualc6/pngtest.dsp b/projects/visualc6/pngtest.dsp index 0f5ca50d2..149f02ac8 100644 --- a/projects/visualc6/pngtest.dsp +++ b/projects/visualc6/pngtest.dsp @@ -43,9 +43,9 @@ RSC=rc.exe # PROP Intermediate_Dir "Win32_DLL_Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c +# ADD BASE CPP /nologo /W3 /O2 /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_DLL" /D "PNG_NO_STDIO" /FD /c +# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\zlib" /D "NDEBUG" /D "PNG_NO_STDIO" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" @@ -75,9 +75,9 @@ PostBuild_Cmds=set path=$(outdir);..\..\..\zlib\projects\visualc6\Win32_DLL_Rele # PROP Intermediate_Dir "Win32_DLL_Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c +# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "_DEBUG" /FD /GZ /c # SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "PNG_DLL" /D "PNG_NO_STDIO" /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\zlib" /D "_DEBUG" /D "PNG_NO_STDIO" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" @@ -107,9 +107,9 @@ PostBuild_Cmds=set path=$(outdir);..\..\..\zlib\projects\visualc6\Win32_DLL_Debu # PROP Intermediate_Dir "Win32_LIB_Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c +# ADD BASE CPP /nologo /W3 /O2 /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /FD /c +# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\zlib" /D "NDEBUG" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" @@ -139,9 +139,9 @@ PostBuild_Cmds=$(outdir)\pngtest.exe ..\..\pngtest.png # PROP Intermediate_Dir "Win32_LIB_Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c +# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "_DEBUG" /FD /GZ /c # SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\zlib" /D "_DEBUG" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" diff --git a/projects/visualc71/libpng.vcproj b/projects/visualc71/libpng.vcproj index 9c4b70536..3ecda6f15 100644 --- a/projects/visualc71/libpng.vcproj +++ b/projects/visualc71/libpng.vcproj @@ -58,18 +58,18 @@ @@ -89,7 +89,7 @@ Name="VCPreLinkEventTool"/> @@ -153,26 +152,26 @@ + OutputFile="$(OutDir)\libpng.lib"/> @@ -213,7 +212,7 @@ Name="VCCustomBuildTool"/> + OutputFile="$(OutDir)\libpngd.lib"/> - - - - - - - - - - - @@ -400,7 +378,7 @@ + RelativePath="PRJ0041.mak">