From 20e09dd14acae22f868dbc9e99bbedfb19d1352a Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Mon, 10 Jan 2011 18:40:35 +0000 Subject: [PATCH] build: changes to README for Cygwin and MacOSX. Added buildForMac and change eol-style on config files. --- CMakeLists.txt | 100 +++++++++++++++++++++++------- README | 116 +++++++++++++++++++++++++++++++++-- buildForMac | 48 +++++++++++++++ config/ConfigureChecks.cmake | 8 ++- msvc64/buildall.bat | 5 +- src/CMakeLists.txt | 37 ++++++----- 6 files changed, 267 insertions(+), 47 deletions(-) create mode 100755 buildForMac diff --git a/CMakeLists.txt b/CMakeLists.txt index 83121920..4bbe9e01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,7 +44,7 @@ SET( PACKAGE_URL "http://www.exiv2.org" ) SET( GENERIC_LIB_VERSION "10.0.0" ) SET( GENERIC_LIB_SOVERSION "10" ) -# options and there default values +# options and their default values OPTION( EXIV2_ENABLE_SHARED "Build exiv2 as a shared library (dll)" ON ) OPTION( EXIV2_ENABLE_XMP "Build with XMP metadata support" ON ) OPTION( EXIV2_ENABLE_LIBXMP "Build a static convenience Library for XMP" OFF ) @@ -67,12 +67,62 @@ IF( MINGW OR UNIX ) ) ENDIF( MINGW OR UNIX ) -IF( EXIV2_ENABLE_XMP ) - SET( HAVE_XMP_TOOLKIT ON ) - SET( XMPLIB "do" ) -ENDIF( EXIV2_ENABLE_XMP ) +if( MSVC ) -INCLUDE( config/ConfigureChecks.cmake ) + # add_library("../zlib-1.2.5" SHARED IMPORTED) + + include_directories( "../zlib-1.2.5" "../expat-2.0.1/lib" ) + set(EXPAT_INCLUDE_DIR "../expat-2.0.1/lib" ) + set(ZLIB_INCLUDE_DIR "../zlib-1.2.5" ) + + set(EXPAT_LIBRARY "../expat-2.0.1") + set(ZLIB_LIBRARY "../zlib-1.2.5" ) + + # target_link_libraries("zlibd.lib") + # add_subdirectory("../zlib-1.2.5" "../zlib-1.2.5" ) + # set_target_properties(exiv2 PROPERTIES LINK_FLAGS "/LIBPATH:../zlib-1.2.5/$(ConfigurationName)") + # target_link_libraries(A B) + # set_property(TARGET PROPERTY LINK_FLAGS "/LIBPATH:../zlib-1.2.5/$(ConfigurationName)") + + # cmake CMakeLists.txt -G "Visual Studio 9 2008" (Win64) + # cm.bat 2008 64 "-DEXIV2_ENABLE_SHARED=OFF" (32/ON) for 4 builds + # for %p in (Debug,Release) do devenv exiv2.sln /build %p for 2 builds + set( P_DIR Win32 ) + set( T_DIR Static) + + # 64 bit + if( CMAKE_SIZEOF_VOID_P MATCHES 8 ) + SET( P_DIR x64) + endif( CMAKE_SIZEOF_VOID_P MATCHES 8 ) + + # DLL/static build + if( EXIV2_ENABLE_SHARED ) + set( T_DIR Dynamic ) + endif( EXIV2_ENABLE_SHARED ) + + set(B_DIR ${PROJECT_BINARY_DIR}/bin/${P_DIR}/${T_DIR}) + set(CMAKE_CURRENT_BINARY_DIR ${B_DIR}) + set(EXECUTABLE_OUTPUT_PATH ${B_DIR}) + set(LIBRARY_OUTPUT_PATH ${B_DIR}) + + #if ( EXIV2_ENABLE_XMP ) + # ..\expat\Win32\Debug\libexpat.lib + # ..\xmpsdk\Win32\Debug\xmpsdk.lib + # ..\zlib\Win32\Debug\zlib1d.lib + #endif( EXIV2_ENABLE_XMP ) + +endif( MSVC ) + +IF( MINGW OR UNIX ) + IF( EXIV2_ENABLE_XMP ) + SET( HAVE_XMP_TOOLKIT ON ) + SET( XMPLIB "do" ) + ENDIF( EXIV2_ENABLE_XMP ) +ENDIF( MINGW OR UNIX ) + +#IF( MINGW OR UNIX ) + INCLUDE( config/ConfigureChecks.cmake ) +#ENDIF( MINGW OR UNIX ) SET( INSTALL_TARGET_STANDARD_ARGS RUNTIME DESTINATION bin @@ -81,23 +131,25 @@ SET( INSTALL_TARGET_STANDARD_ARGS ) # add sources from XMPSDK directory - this needs to be done here -SET( XMPSRC ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/ExpatAdapter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/MD5.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/ParseRDF.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/UnicodeConversions.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/WXMPIterator.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/WXMPMeta.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/WXMPUtils.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XML_Node.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPCore_Impl.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPIterator.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPMeta-GetSet.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPMeta-Parse.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPMeta-Serialize.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPMeta.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPUtils-FileInfo.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPUtils.cpp - ) +IF( MINGW OR UNIX ) + SET( XMPSRC ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/ExpatAdapter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/MD5.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/ParseRDF.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/UnicodeConversions.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/WXMPIterator.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/WXMPMeta.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/WXMPUtils.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XML_Node.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPCore_Impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPIterator.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPMeta-GetSet.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPMeta-Parse.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPMeta-Serialize.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPMeta.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPUtils-FileInfo.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/xmpsdk/src/XMPUtils.cpp + ) +ENDIF( MINGW OR UNIX ) # the following lines need to be added to circumvent the error in xmpsdk\src\MD5.h IF( ${EXV_HAVE_STDINT_H} ) @@ -114,3 +166,5 @@ ENDIF( EXIV2_ENABLE_BUILD_SAMPLES ) IF( EXIV2_ENABLE_BUILD_PO ) ADD_SUBDIRECTORY( po ) ENDIF( EXIV2_ENABLE_BUILD_PO ) + +# include(logger.txt) diff --git a/README b/README index 7a69c5ba..c6e51685 100644 --- a/README +++ b/README @@ -17,8 +17,18 @@ For more information on XMP support in Exiv2, see doc/README-XMP. Building and Installing ======================= -To build Exiv2 with MSVC 7.1 or later on Windows, use the solution file -msvc\exiv2.sln. See msvc\README-MSVC.txt for details. +You can build the libraries in the following ways: + +1 Linux, Mac, Cygwin, Msys (autoconf tools) + - general notes follow + - see notes below concerning Cygwin/MSYS and MacOSX + +2 Microsoft Visual C++ + - see msvc/README-MSVC.txt (32bit build VC7.1/2003 and up) + - see msvc64/ReadMe.txt (32bit and 64 bit build VC8/2005 and up) + +3 CMake (experimental support for cmake on all platforms) + - see README-CMAKE for more information On UNIX-like systems (including GNU/Linux, Mac OS X, MinGW), use the GNU configure script. Run the following commands from the top directory @@ -27,11 +37,17 @@ utility: $ ./configure $ make - $ make install + $ sudo make install If you downloaded the source code from the subversion repository, you won't have a configure script. Run 'make config' to generate it and see -the section "Hacking" below. +the section "Hacking" below. You may need to run autoconf in the config directory: + + $ cd exiv2/config + $ autoconf + $ mv configure .. + $ cd .. + $ ./configure etc....... The default install locations are /usr/local/lib for the library, /usr/local/bin for the exiv2 utility and /usr/local/include/exiv2 for the @@ -168,3 +184,95 @@ To do this on Windows, compile the library with the preprocessor symbol EXV_COMMERCIAL_VERSION defined in msvc\include\exv_msvc.h. On UNIX-like systems, run the configure script with the options --enable-commercial --disable-nls --disable-lensdata + + +To build Exiv2 with MSVC 7.1 or later on Windows, use the solution file +msvc\exiv2.sln. See msvc\README-MSVC.txt for details. + + +Cygwin/MSYS +=========== + +You can build on Cygwin using autoconf. The process is similar to Linux. This will generate a 32bit shared library (DLL) version of exiv2.exe and its libraries. + +Please observe the following additional steps: + +1) You may need to run dos2unix on all the files in the config directory. + This is only necessary if your exiv2 directory is SVN:2426 or earlier (2011-01-10) + cd exiv2/config + dos2unix * + cd .. + +2) You may make need to generate the configure script. + cd exiv2/config + autoconf + mv configure .. + +3) You should disable compiler visibility: + cd exiv2 + ./configure --disable-visibility + +4) If you wish to build the sample programs, here are the steps: + cd exiv2 + make + .... build time about 7 minutes (on a 2.2MHz Duo Core Intel Processor) + make install + export "PKG_CONFIG_PATH=${PWD}/config" + make samples + .... build time about 4 minutes + +5) Cygwin builds have dependancies on other cygwin dlls. + You can use depends32.exe (in the msvc64 tree) to determine the dependancies. + + 540 /c/gnu/exiv2/src/.libs> ../../msvc64/tools/bin/depends32.exe -q exiv2.exe + cygz.dll + cygintl-8.dll + cygiconv-2.dll + cygexpat-1.dll + cygstdc++-6.dll + CRYPTBASE.dll + SspiCli.dll + RPCRT4.dll + KERNEL32.dll + ntdll.dll + KERNELBASE.dll + ADVAPI32.DLL + cygwin1.dll + cyggcc_s-1.dll + cygexiv2-10.dll + exiv2.exe + + It's possible to run cygwin builds on "vanilla" windows machines (cygwin not installed) + provided you ensure that all the dependant cyg*.dll files are available + on the path or in the same directory as exiv2.exe. + (cryptbase.dll ... advapi32.dll are standard Windows dlls and should not be redistributed). + +MacOSX +====== + +By default the Mac will perform a "native" build of exiv2. On Leopard this is a 32 bit intel/ppc build. On Snow Leopard, this is a 64 bit intel build (x64). These correspond to arch={i386 | ppc | x86_64} The libraries are linked against the run-time libraries of the build machine. + +However there are three additional things you may wish to respect. + +1 Building and linking xmpsdk + + There is an additional complication that xmpsdk is very strong willed. You will have to pass OBJCFLAGS (and OBJCXXFLAGS) to the build environment for xmpsdk. + + arch=i386 + ./configure CFLAGS="$arch" CXXFLAGS="$arch" CPPFLAGS="$arch" LDFLAGS="$arch -L${PWD}/xmpsdk/src" OBJCFLAGS="$arch" OBJCXXFLAGS="$arch" + env CFLAGS="$arch" CXXFLAGS="$arch" CPPFLAGS="$arch" LDFLAGS="$arch" OBJCFLAGS="$arch" OBJCXXFLAGS="$arch" make + +2 Using the appropriate run-time libraries. + You should set the environment string TARGET to modify the + TARGET="MACOSX_DEPLOYMENT_TARGET=10.4" (or 5 or 6) + +3 Building "universal" binaries (library/executables which contain code for more than one architecture). + If you wish to build a "universal" library, you should build each of the architectures independantly and combine them with the lipo utility. + + lipo -arch i386 lib.i386 -arch x86_64 lib.x86_64 -arch ppc lib.ppc -create -output exiv2.20.dylib + +The bash script buildForMac embodies all three of these concepts and builds a universal exiv2 on Snow Leopard and Leopard. + + +That's all Folks! +================= diff --git a/buildForMac b/buildForMac new file mode 100755 index 00000000..18b42b70 --- /dev/null +++ b/buildForMac @@ -0,0 +1,48 @@ +#!/bin/bash + +lib=libexiv2.10.dylib +app=exiv2 +TARGET="MACOSX_DEPLOYMENT_TARGET=10.4" + +LIB=./src/.libs/$lib +APP=./src/.libs/$app + +props() { + ls -alt $* + lipo -info $* + otool -L $* + echo ---------------------- +} + +build() { + make clean + ./configure CFLAGS="$arch" CXXFLAGS="$arch" CPPFLAGS="$arch" LDFLAGS="$arch -L${PWD}/xmpsdk/src" OBJCFLAGS="$arch" OBJCXXFLAGS="$arch" $TARGET + env CFLAGS="$arch" CXXFLAGS="$arch" CPPFLAGS="$arch" LDFLAGS="$arch -L${PWD}/xmpsdk/src" OBJCFLAGS="$arch" OBJCXXFLAGS="$arch" $TARGET make $TARGET + props $APP + props $LIB +} + +for arch in '-arch i386' '-arch x86_64' '-arch ppc'; do + if [ "$arch" = "-arch i386" ]; then + build + rm -rf app.i386 lib.i386 + cp $APP app.i386 + cp $LIB lib.i386 + elif [ "$arch" = "-arch x86_64" ]; then + build + rm -rf app.x86_64 lib.x86_64 + cp $APP app.x86_64 + cp $LIB lib.x86_64 + elif [ "$arch" = "-arch ppc" ]; then + build + rm -rf app.ppc lib.ppc + cp $APP app.ppc + cp $LIB lib.ppc + fi +done + +env $TARGET lipo -arch i386 lib.i386 -arch x86_64 lib.x86_64 -arch ppc lib.ppc -create -output $lib +env $TARGET lipo -arch i386 app.i386 -arch x86_64 app.x86_64 -arch ppc app.ppc -create -output $app + +props $lib +props $app diff --git a/config/ConfigureChecks.cmake b/config/ConfigureChecks.cmake index 79bbe2d1..c9609a44 100644 --- a/config/ConfigureChecks.cmake +++ b/config/ConfigureChecks.cmake @@ -59,9 +59,11 @@ IF (EXIV2_ENABLE_XMP) FIND_PACKAGE(EXPAT) INCLUDE_DIRECTORIES(${EXPAT_INCLUDE_DIR}) # FindEXPAT.cmake doesn't check for REQUIRED flags - so we need to check ourselves - IF (NOT EXPAT_FOUND) - MESSAGE(FATAL_ERROR "missing library expat required for XMP") - ENDIF( NOT EXPAT_FOUND ) + IF( MINGW OR UNIX ) + IF (NOT EXPAT_FOUND) + MESSAGE(FATAL_ERROR "missing library expat required for XMP") + ENDIF( NOT EXPAT_FOUND ) + ENDIF( MINGW OR UNIX ) ENDIF (EXIV2_ENABLE_XMP) IF( EXIV2_ENABLE_SHARED ) diff --git a/msvc64/buildall.bat b/msvc64/buildall.bat index b92bac96..57ccdb3e 100644 --- a/msvc64/buildall.bat +++ b/msvc64/buildall.bat @@ -1,4 +1,4 @@ -@echo off +@echo of rem ## rem buildall - wee script for building from the command line @@ -28,7 +28,8 @@ if %ACTION%==/rebuild set DELBIN=1 if %ACTION%==/clean set DELBIN=1 if %DELBIN%==1 ( if EXIST bin rmdir/s/q bin - del/s *.pdb *.ild *.ncb *.bsc *.idb *.ilk *.pch *.tlog + del/s *.pdb *.ild *.ncb *.bsc *.idb *.ilk *.pch *.tlog > NUL + rmdir/s/q exiv2lib\win32 rmdir/s/q exiv2lib\x64 rmdir/s/q zlib\win32 zlib\x64 > NUL ) rem ## diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 15a440e5..dcdea985 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -186,27 +186,34 @@ ADD_LIBRARY( exiv2 ${STATIC_FLAG} ${LIBEXIV2_SRC} ) SET_TARGET_PROPERTIES( exiv2 PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} DEFINE_SYMBOL EXV_BUILDING_LIB + LINK_FLAGS "/LIBPATH:../zlib-1.2.5/$(ConfigurationName)" ) -TARGET_LINK_LIBRARIES( exiv2 ${EXPAT_LIBRARIES} ) +TARGET_LINK_LIBRARIES( exiv2 ) # ${EXPAT_LIBRARIES} ) -if( EXIV2_ENABLE_LIBXMP ) - TARGET_LINK_LIBRARIES( exiv2 ${XMPLIB} ) -ENDIF( EXIV2_ENABLE_LIBXMP ) +# IF( MINGW OR UNIX ) + if( EXIV2_ENABLE_LIBXMP ) + TARGET_LINK_LIBRARIES( exiv2 ${XMPLIB} ) + ENDIF( EXIV2_ENABLE_LIBXMP ) -IF( EXIV2_ENABLE_PNG ) - IF( ZLIB_FOUND ) - TARGET_LINK_LIBRARIES( exiv2 ${ZLIB_LIBRARIES} ) - ENDIF( ZLIB_FOUND ) -ENDIF( EXIV2_ENABLE_PNG ) + IF( EXIV2_ENABLE_PNG ) + IF( ZLIB_FOUND ) + IF ( MINGW OR UNIX ) + TARGET_LINK_LIBRARIES( exiv2 ${ZLIB_LIBRARIES} ) + ELSE ( MSVC ) + TARGET_LINK_LIBRARIES( exiv2 zlibd ) + ENDIF( MING OR UNIX) + ENDIF( ZLIB_FOUND ) + ENDIF( EXIV2_ENABLE_PNG ) -IF( EXIV2_ENABLE_NLS ) - TARGET_LINK_LIBRARIES( exiv2 ${LIBINTL_LIBRARIES} ) -ENDIF( EXIV2_ENABLE_NLS ) + IF( EXIV2_ENABLE_NLS ) + TARGET_LINK_LIBRARIES( exiv2 ${LIBINTL_LIBRARIES} ) + ENDIF( EXIV2_ENABLE_NLS ) -IF( ICONV_FOUND ) - TARGET_LINK_LIBRARIES( exiv2 ${ICONV_LIBRARIES} ) -ENDIF( ICONV_FOUND ) + IF( ICONV_FOUND ) + TARGET_LINK_LIBRARIES( exiv2 ${ICONV_LIBRARIES} ) + ENDIF( ICONV_FOUND ) +# ENDIF( MINGW OR UNIX ) INSTALL( TARGETS exiv2 ${INSTALL_TARGET_STANDARD_ARGS} )