Skip to content

Commit

Permalink
Merge pull request #39 from Exiv2/autotoolsMacLink
Browse files Browse the repository at this point in the history
./configure --with-adobe[=2016|2014|2013] for MacOSX
  • Loading branch information
clanmills authored Aug 23, 2017
2 parents 9263860 + fcaf2be commit b5cac37
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 76 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ config:

xmpsdk: config/config.mk
if test "x$(ENABLE_XMP)" = "x1"; then cd xmpsdk/src && $(MAKE) $@; fi;
if test "x$(ENABLE_XMP)" = "x2016" -o "x$(ENABLE_XMP)" = "x2014"; then xmpsdk/buildXMPsdk.sh $(ENABLE_XMP) $(MAKECMDGOALS); fi;
if test "x$(ENABLE_XMP)" = "x2016" -o "x$(ENABLE_XMP)" = "x2014" -o "x$(ENABLE_XMP)" = "x2013"; then xmpsdk/buildXMPsdk.sh $(ENABLE_XMP) $(MAKECMDGOALS); fi;

mostlyclean clean: config/config.mk
cd src && $(MAKE) $(MAKECMDGOALS)
Expand All @@ -156,6 +156,7 @@ distclean: clean
rm -f *~ *.bak
if [ -e bin ]; then rm -rf bin ; fi
if [ -e xmpsdk/Adobe ]; then rm -rf xmpsdk/Adobe ; fi
if [ -e /usr/local/include/exiv2 ]; then rm -rf /usr/local/include/exiv2 ; fi

# This removes almost everything, including the configure script!
maintainer-clean: distclean
Expand Down
3 changes: 2 additions & 1 deletion config/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ config:

xmpsdk: config/config.mk
if test "x$(ENABLE_XMP)" = "x1"; then cd xmpsdk/src && $(MAKE) $@; fi;
if test "x$(ENABLE_XMP)" = "x2016" -o "x$(ENABLE_XMP)" = "x2014"; then xmpsdk/buildXMPsdk.sh $(ENABLE_XMP) $(MAKECMDGOALS); fi;
if test "x$(ENABLE_XMP)" = "x2016" -o "x$(ENABLE_XMP)" = "x2014" -o "x$(ENABLE_XMP)" = "x2013"; then xmpsdk/buildXMPsdk.sh $(ENABLE_XMP) $(MAKECMDGOALS); fi;

mostlyclean clean: config/config.mk
cd src && $(MAKE) $(MAKECMDGOALS)
Expand All @@ -156,6 +156,7 @@ distclean: clean
rm -f *~ *.bak
if [ -e bin ]; then rm -rf bin ; fi
if [ -e xmpsdk/Adobe ]; then rm -rf xmpsdk/Adobe ; fi
if [ -e /usr/local/include/exiv2 ]; then rm -rf /usr/local/include/exiv2 ; fi

# This removes almost everything, including the configure script!
maintainer-clean: distclean
Expand Down
12 changes: 12 additions & 0 deletions config/config.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ LIBTOOL_DEPS = $(top_srcdir)/@LIBTOOL_DEPS@
# C++ Compiler and precompiler
CXX = @CXX@
GXX = @GXX@
PREFIX = @PREFIX@

# Common compiler flags (warnings, symbols [-ggdb], optimization [-O2], etc)
CXXFLAGS = @CXXFLAGS@
Expand Down Expand Up @@ -123,6 +124,17 @@ ifeq ($(ENABLE_XMP),2014)
CPPFLAGS_MORE = X
endif

ifeq ($(ENABLE_XMP),2013)
XMPSDK_LIBRARY = xmpsdk
XMPSDK_DIR = $(top_srcdir)/xmpsdk
XMPSDK_CPPFLAGS = -I$(XMPSDK_DIR)/Adobe/XMP-Toolkit-SDK-CC201306 \
-I$(XMPSDK_DIR)/Adobe/XMP-Toolkit-SDK-CC201306/public/include \
-DEXV_ADOBE_XMPSDK=2013
XMPSDK_LDFLAGS = -L$(XMPSDK_DIR)/Adobe/XMP-Toolkit-SDK-CC201306
XMPSDK_LIBS = -lXMPCore
CPPFLAGS_MORE = X
endif

# Enable additional warnings. XMP Toolkit doesn't compile with these.
ifeq ($(GXX),yes)
ifneq ($(CPPFLAGS_MORE),X)
Expand Down
18 changes: 11 additions & 7 deletions config/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ if test "$enable_webready" = "yes"; then
AC_DEFINE(ENABLE_WEBREADY)
fi

echo "CPPFLAGS = $CPPFLAGS"

if test "$enable_webready" = "yes"; then
# libcurl option might change flags, so we save them initially
_cppflags="${CPPFLAGS}"
Expand Down Expand Up @@ -388,22 +390,24 @@ else
fi

AC_ARG_WITH(adobe,
[ --with-adobe[[=OPT]] use --with-adobe for Adobe XMPsdk. OPT: 2016|2014 default/--without-adobe is xmpsdk/src],
[ --with-adobe[[=OPT]] use --with-adobe for Adobe XMPsdk. OPT: 2016|2014|2013 default/--without-adobe is xmpsdk/src],
ADOBE=$withval,
ADOBE=xmpsdk/src)
if test "$ADOBE" == "yes"; then ADOBE=2016; fi

if test "$ADOBE" = "2016" -o "$ADOBE" = "2014" ; then
if test "$ADOBE" = "2016" -o "$ADOBE" = "2014" -o "$ADOBE" = "2013" ; then
ADOBE_SDK=XMP-Toolkit-SDK-CC201607
if test "$ADOBE" == "2014" ; then ADOBE_SDK=XMP-Toolkit-SDK-CC201412; fi
if test "$ADOBE" == "2013" ; then ADOBE_SDK=XMP-Toolkit-SDK-CC201306; fi
ENABLE_XMP=$ADOBE
XMPSDK_CPPFLAGS="-Ixmpsdk/Adobe/$ADOBE_SDK/public/include"
XMPSDK_LDFLAGS="-Lxmpsdk/Adobe/$ADOBE_SDK"
case "$host_os" in
*arwin*)
CPPFLAGS="${CPPFLAGS} -stdlib=libstdc++ -Wno-deprecated -fvisibility=hidden -fvisibility-inlines-hidden"
LDFLAGS="${LDFLAGS} -stdlib=libstdc++ -Wno-deprecated"
EXV_LIB_STATIC="-stdlib=libstdc++ -Wno-deprecated"
EXV_DARWIN_FLAGS="-stdlib=libstdc++ -Wno-deprecated"
CPPFLAGS="${CPPFLAGS} -fvisibility=hidden -fvisibility-inlines-hidden ${EXV_DARWIN_FLAGS} "
LDFLAGS="${LDFLAGS} ${EXV_DARWIN_FLAGS}"
AC_SUBST(EXV_DARWIN_FLAGS)
;;
esac
fi
Expand Down Expand Up @@ -509,8 +513,8 @@ esac
fi

echo "CPPFLAGS =" "$CPPFLAGS $SSH_CPPFLAGS $CURL_CPPFLAGS $XMPSDK_CPPFLAGS"
echo "LDFLAGS =" "$LDFLAGS $SSH_LDFLAGS $CURL_LDFLAGS $EXPAT_LDFLAGS $XMPSDK_LDFLAGS"
echo "LIBS =" "$LIBS $SSH_LIBS $CURL_LIBS $EXPAT_LIBS $XMPSDK_LIBS"
echo "LDFLAGS =" "$LDFLAGS $SSH_LDFLAGS $CURL_LDFLAGS $XMPSDK_LDFLAGS"
echo "LIBS =" "$LIBS $SSH_LIBS $CURL_LIBS $XMPSDK_LIBS"
echo "CXX =" "$CXX"
echo "------------------------------------------------------------------"
echo ""
Expand Down
4 changes: 2 additions & 2 deletions config/exiv2.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ includedir=@includedir@
Name: exiv2
Description: Image metadata library and tools
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lexiv2 @EXV_LIB_STATIC@
Libs: -L${libdir} -lexiv2 @EXV_LIB_STATIC@ @EXV_DARWIN_FLAGS@
Libs.private: @EXPAT_LDFLAGS@ @SSH_LDFLAGS@ @CURL_LDFLAGS@ @LTLIBINTL@ @LTLIBICONV@ @LIBS@ @EXPAT_LIBS@ @SSH_LIBS@ @CURL_LIBS@
Cflags: -I${includedir}
Cflags: -I${includedir} @EXV_DARWIN_FLAGS@
16 changes: 3 additions & 13 deletions samples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
# History: 08-Oct-07, ahu: created
#
# Description:
# Simple Makefile to build sample programs. Requires installed exiv2 library
# and headers. Adapted from the main Exiv2 src/Makefile.
# Makefile to build sample programs.
# Requires installed exiv2 library
#
# Restrictions:
# Requires GNU make.
Expand All @@ -46,10 +46,6 @@
# Default make target
all: samples

# Include system configuration
top_srcdir = ..
include $(top_srcdir)/config/config.mk

# ******************************************************************************
# Source files

Expand Down Expand Up @@ -120,12 +116,6 @@ endif
PREFIX = /usr/local/lib
LINK.cc += -rpath $(PREFIX) -L$(PREFIX)

# TODO: This should really not be here. We should use the installed headers
# to build the samples. Some errors only show up in this scenario, e.g., errors
# due to missing headers which are not installed (depending on compile-time
# settings) but may be wrongly included from other headers.
COMPILE.cc += -I$(top_srcdir)/include -I$(top_srcdir)/include/exiv2 # -std=gnu++98

# ******************************************************************************
# Rules
samples: $(BINARY) $(OTHERBIN)
Expand Down Expand Up @@ -167,7 +157,7 @@ geotag: %: %.cpp
@$(POSTDEPEND)
$(LIBTOOL) --mode=link $(LINK.cc) -lexpat $@.o -o ../bin/$@

# link applications which require utils.cpp support
# link applications which require src/utils.cpp support
metacopy path-test toexv: %: %.cpp ../src/utils.o
$(COMPILE.cc) -I../src -o $@.o $<
@$(MAKEDEPEND)
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ include $(top_srcdir)/config/config.mk
CCHDR = exiv2.hpp \
config.h \
exv_conf.h \
exv_msvc.h \
xmp_exiv2.hpp \
version.hpp

# Add library C++ source files to this list
Expand Down
6 changes: 3 additions & 3 deletions src/convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ EXIV2_RCSID("@(#) $Id$")
// Adobe XMP Toolkit
#ifdef EXV_HAVE_XMP_TOOLKIT
# define TXMP_STRING_TYPE std::string
# if EXV_ADOBE_XMPSDK
# include <XMP.hpp>
# ifdef EXV_ADOBE_XMPSDK
# include <XMP.hpp>
# else
# include <XMPSDK.hpp>
# include <XMPSDK.hpp>
# endif
# include <MD5.h>
#endif // EXV_HAVE_XMP_TOOLKIT
Expand Down
1 change: 0 additions & 1 deletion src/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

// *********************************************************************
// included header files
#include "futils.hpp"

// + standard includes
#include <string>
Expand Down
101 changes: 54 additions & 47 deletions xmpsdk/buildXMPsdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
##
# buildXMPsdk.sh
# TODO:
# 1) Command-line parser for options such as:
# version of xmpsdk (2014, 2016)
# build options (64/32 static/dynamic debug/release)
# help
# 2) Cygwin support (in progress)
# 3) Write buildXMPsdk.cmd (for MSVC)
# 1) Cygwin support (in progress)
# 2) Write buildXMPsdk.cmd (for MSVC)
##

syntaxError() {
echo "usage: $0 [--help|-?|--2013|--2014|--2016|--32|--64]"
exit 1
}

uname=$(uname -a | cut -d' ' -f 1 | cut -d_ -f 1)
case "$uname" in
Darwin|Linux|CYGWIN) ;;
Expand All @@ -19,28 +20,50 @@ case "$uname" in
;;
esac

cd $(dirname "$0") # always run this script in exiv2-dir/xmpsdk
SDK=XMP-Toolkit-SDK-CC201607
if [ "$1" == "2014" ]; then
SDK=XMP-Toolkit-SDK-CC201412
fi
##
# always run this script in <exiv2dir>/xmpsdk
cd $(dirname "$0")

##
# parse command-line
bits=64
SDK=2016

while [ $# -ne 0 ]; do
case "$1" in
-h|--help|-\?) syntaxError; exit 0;;
--64|64) bits=64 ; shift ;;
--32|32) bits=32 ; shift ;;
--2013|2013) SDK=2013 ; shift ;;
--2014|2014) SDK=2014 ; shift ;;
--2016|2016) SDK=2016 ; shift ;;
install) exit 0 ;; # argument passed by make

*) syntaxError; exit 1;;
esac
done

if [ "$SDK" == "2013" ] ; then SDK=XMP-Toolkit-SDK-CC201306 ; ZIP=XMP-Toolkit-SDK-CC-201306 ;fi
if [ "$SDK" == "2014" ] ; then SDK=XMP-Toolkit-SDK-CC201412 ; ZIP=$SDK; fi
if [ "$SDK" == "2016" ] ; then SDK=XMP-Toolkit-SDK-CC201607 ; ZIP=$SDK; fi

##
# if it's already built, we're done
if [ -e Adobe/$SDK/libXMPCore.a ]; then exit 0 ; fi
if [ -e Adobe/$SDK/libXMPCore.a ]; then ls -alt Adobe/$SDK/libXMPCore.a ; exit 0 ; fi

##
# Download the code from Adobe
if [ ! -e Adobe/$SDK ]; then (
mkdir Adobe
cd Adobe
if curl -O http://download.macromedia.com/pub/developer/xmp/sdk/$SDK.zip ; then
unzip $SDK.zip
if curl -O http://download.macromedia.com/pub/developer/xmp/sdk/$ZIP.zip ; then
unzip $ZIP.zip
fi
) fi

if [ ! -d Adobe/$SDK ]; then
echo "*** ERROR SDK = Adobe/$SDK not found" >2
exit 1
echo "*** ERROR SDK = Adobe/$SDK not found" >2
exit 1
fi

##
Expand All @@ -53,25 +76,12 @@ fi
# generate Makefile and build libraries
( cd Adobe/$SDK/build
##
# Tweak the code (depends on platform)
# Tweak the code (depends on platform) and build using adobe tools
case "$uname" in
Linux)
# modify ProductConfig.cmake (don't link libssp.a)
f=ProductConfig.cmake
if [ -e $f.orig ]; then mv $f.orig $f ; fi ; cp $f $f.orig
sed -E -e 's? \$\{XMP_GCC_LIBPATH\}/libssp.a??g' $f.orig > $f

# copy resources
for f in XMPFiles XMPCore; do
cp ../$f/resource/linux/* ../$f/resource
done

cmake . -G "Unix Makefiles" \
-DXMP_ENABLE_SECURE_SETTINGS=OFF \
-DXMP_BUILD_STATIC=1 \
-DCMAKE_CL_64=ON \
-DCMAKE_BUILD_TYPE=Release
make
target=StaticRelease64
if [ "$BITS" == "32" ]; then target=StaticRelease32 ; fi
make "$target"
result=$?
;;

Expand All @@ -85,17 +95,17 @@ fi

Darwin)
if [ ! -e ../../$SDK/public/libraries/macintosh/intel_64/release/libXMPCoreStatic.a ]; then
cmake . -G "Unix Makefiles" \
-DXMP_ENABLE_SECURE_SETTINGS=OFF \
-DXMP_BUILD_STATIC=1 \
-DCMAKE_CL_64=ON \
-DCMAKE_BUILD_TYPE=Release
make
result=$?
target=5 # (5=64 bit build for 2013 and 2014, 3 = 64 bit build for 2016)
if [ "$SDK" == "XMP-Toolkit-SDK-CC201607" ]; then target=3; fi
echo $target | ./GenerateXMPToolkitSDK_mac.sh

project=XMPToolkitSDK64.xcodeproj
find . -name "$project" -execdir xcodebuild -project {} -target XMPCoreStatic -configuration Release \;
result=$?
fi
;;
*)
result=1 # build failed
result=1 # build failed
;;
esac
)
Expand All @@ -108,21 +118,18 @@ if [ -z "$result" ]; then (

# report archives we can see
cd Adobe/$SDK
rm -rf *.a *.ar
rm -rf *.a *.ar # clean up from previous build
find public -name "*.a" -o -name "*.ar" | xargs ls -alt

# move the library/archives into xmpsdk
# move the library/archives into xmpsdk/Adobe/$SDK
case "$uname" in
Linux)
find public -name "*.ar" -exec cp {} . ';'
mv staticXMPCore.ar libXMPCore.a
mv staticXMPFiles.ar libXMPFiles.a
;;

Darwin)
find public -name "*.a" -exec cp {} . ';'
mv libXMPCoreStatic.a libXMPCore.a
mv libXMPFilesStatic.a libXMPFiles.a
find public -name "libXMPCoreStatic.a" -exec cp {} libXMPCore.a ';'
;;
esac
ls -alt *.a
Expand Down

0 comments on commit b5cac37

Please sign in to comment.