Files
mozjpeg/release/makemacpkg.in
DRC d681fa7626 Build: Set install dirs in a more GNU-friendly way
This builds upon the existing GNUInstallDirs module in CMake but adds
the following features to that module:

- The ability to override the defaults for each install directory
  through a new set of variables (`CMAKE_INSTALL_DEFAULT_*DIR`).

  Before operating system vendors began shipping libjpeg-turbo, it was
  meant to be a run-time drop-in replacement for the system's
  distribution of libjpeg, so it has traditionally installed itself
  under /opt/libjpeg-turbo on Un*x systems by default.  On Windows, it
  has traditionally installed itself under %SystemDrive%\libjpeg-turbo*,
  which is not uncommon behavior for open source libraries (open source
  SDKs tend to install outside of the Program Files directory so as to
  avoid spaces in the directory name.)  At least in the case of Un*x,
  the install directory behavior is based somewhat on the Solaris
  standard, which requires all non-O/S packages to install their files
  under /opt/{package_name}.  I adopted that standard for VirtualGL and
  TurboVNC while working at Sun, because it allowed those packages to be
  located under the same directory on all platforms.  I adopted it for
  libjpeg-turbo because it ensured that our files would never conflict
  with the system's version of libjpeg.  Even though many Un*x
  distributions ship libjpeg-turbo these days, not all of them ship the
  TurboJPEG API library or the Java classes or even the latest version
  of the libjpeg API library, so there are still many cases in which it
  is desirable to install a separate version of libjpeg-turbo than the
  one installed by the system.  Furthermore, installing the files under
  /opt mimics the directory structure of our official binary packages,
  and it makes it very easy to uninstall libjpeg-turbo.

  For these reasons, our build system needs to be able to use
  non-GNU-compliant defaults for each install directory if
  `CMAKE_INSTALL_PREFIX` is set to the default value.

- For each directory variable, the module now detects changes to
  `CMAKE_INSTALL_PREFIX` and changes the directory variable accordingly,
  if the variable has not been changed by the user.

  This makes it easy to switch between our "official" directory
  structure and the GNU-compliant directory structure "on the fly"
  simply by changing `CMAKE_INSTALL_PREFIX`.  Also, this new mechanism
  eliminated the need for the crufty mechanism that previously did the
  same thing just for the library directory variable.

  How it should work:
  - If a dir variable is unset, then the module will set an internal
    property indicating that the dir variable was initialized to its
    default value.
  - If the dir variable ever diverges from its default value, then the
    internal property is cleared, and it cannot be set again without
    unsetting the dir variable.
  - If the install prefix changes, and if the internal property
    indicates that the dir variable is still set to its default value,
    and if the dir variable's value is not being manually changed at the
    same time that the install prefix is being changed, then the dir
    variable's value is automatically changed to the new default value
    for that variable (as determined by the new install prefix.)

- The directory variables are now always cached, regardless of whether
  they were set on the command line or not.  This ensures that they can
  easily be examined and modified after being set, regardless of how they
  were set.

  This was made possible by the introduction of the aforementioned
  `CMAKE_INSTALL_DEFAULT_*DIR` variables.

- Improved directory variable documentation (based on descriptions at
  https://www.gnu.org/prep/standards/html_node/Directory-Variables.html)

- The module now allows "<DATAROOTDIR>" to be used as a placeholder in
  relative directory variables.

  It is replaced "on the fly" with the actual path of
  `CMAKE_INSTALL_DATAROOTDIR`.

This should more closely mimic the behavior of the old autotools build
system while retaining our customizations to it, and it should retain
the behavior of the old CMake build system.

Closes #124
2016-12-07 16:55:38 -06:00

269 lines
7.1 KiB
Bash

#!/bin/sh
set -u
set -e
trap onexit INT
trap onexit TERM
trap onexit EXIT
TMPDIR=
onexit()
{
if [ ! "$TMPDIR" = "" ]; then
rm -rf $TMPDIR
fi
}
safedirmove ()
{
if [ "$1" = "$2" ]; then
return 0
fi
if [ "$1" = "" -o ! -d "$1" ]; then
echo safedirmove: source dir $1 is not valid
return 1
fi
if [ "$2" = "" -o -e "$2" ]; then
echo safedirmove: dest dir $2 is not valid
return 1
fi
if [ "$3" = "" -o -e "$3" ]; then
echo safedirmove: tmp dir $3 is not valid
return 1
fi
mkdir -p $3
mv $1/* $3/
rmdir $1
mkdir -p $2
mv $3/* $2/
rmdir $3
return 0
}
usage()
{
echo "$0 [universal] [-lipo [path to lipo]]"
exit 1
}
UNIVERSAL=0
PACKAGE_NAME=@PKGNAME@
VERSION=@VERSION@
BUILD=@BUILD@
SRCDIR=@CMAKE_CURRENT_SOURCE_DIR@
BUILDDIR32=@OSX_32BIT_BUILD@
BUILDDIRARMV7=@IOS_ARMV7_BUILD@
BUILDDIRARMV7S=@IOS_ARMV7S_BUILD@
BUILDDIRARMV8=@IOS_ARMV8_BUILD@
WITH_JAVA=@WITH_JAVA@
LIPO=lipo
PREFIX=@CMAKE_INSTALL_PREFIX@
BINDIR=@CMAKE_INSTALL_FULL_BINDIR@
DOCDIR=@CMAKE_INSTALL_FULL_DOCDIR@
LIBDIR=@CMAKE_INSTALL_FULL_LIBDIR@
LIBJPEG_DSO_NAME=libjpeg.@SO_MAJOR_VERSION@.@SO_AGE@.@SO_MINOR_VERSION@.dylib
TURBOJPEG_DSO_NAME=libturbojpeg.@TURBOJPEG_SO_VERSION@.dylib
while [ $# -gt 0 ]; do
case $1 in
-h*)
usage 0
;;
-lipo)
if [ $# -gt 1 ]; then
if [[ ! "$2" =~ -.* ]]; then
LIPO=$2; shift
fi
fi
;;
universal)
UNIVERSAL=1
;;
esac
shift
done
if [ -f $PACKAGE_NAME-$VERSION.dmg ]; then
rm -f $PACKAGE_NAME-$VERSION.dmg
fi
umask 022
TMPDIR=`mktemp -d /tmp/$PACKAGE_NAME-build.XXXXXX`
PKGROOT=$TMPDIR/pkg/Package_Root
mkdir -p $PKGROOT
make install DESTDIR=$PKGROOT
if [ "$PREFIX" = "@CMAKE_INSTALL_DEFAULT_PREFIX@" -a "$DOCDIR" = "@CMAKE_INSTALL_DEFAULT_PREFIX@/doc" ]; then
mkdir -p $PKGROOT/Library/Documentation
safedirmove $PKGROOT$DOCDIR $PKGROOT/Library/Documentation/@CMAKE_PROJECT_NAME@ $TMPDIR/__tmpdoc
ln -fs /Library/Documentation/@CMAKE_PROJECT_NAME@ $PKGROOT$DOCDIR
fi
if [ $UNIVERSAL = 1 -a "$BUILDDIR32" != "" ]; then
if [ ! -d $BUILDDIR32 ]; then
echo ERROR: 32-bit build directory $BUILDDIR32 does not exist
exit 1
fi
if [ ! -f $BUILDDIR32/Makefile ]; then
echo ERROR: 32-bit build directory $BUILDDIR32 is not configured
exit 1
fi
mkdir -p $TMPDIR/dist.x86
pushd $BUILDDIR32
make install DESTDIR=$TMPDIR/dist.x86
popd
$LIPO -create \
-arch i386 $TMPDIR/dist.x86/$LIBDIR/$LIBJPEG_DSO_NAME \
-arch x86_64 $PKGROOT/$LIBDIR/$LIBJPEG_DSO_NAME \
-output $PKGROOT/$LIBDIR/$LIBJPEG_DSO_NAME
$LIPO -create \
-arch i386 $TMPDIR/dist.x86/$LIBDIR/libjpeg.a \
-arch x86_64 $PKGROOT/$LIBDIR/libjpeg.a \
-output $PKGROOT/$LIBDIR/libjpeg.a
$LIPO -create \
-arch i386 $TMPDIR/dist.x86/$LIBDIR/$TURBOJPEG_DSO_NAME \
-arch x86_64 $PKGROOT/$LIBDIR/$TURBOJPEG_DSO_NAME \
-output $PKGROOT/$LIBDIR/$TURBOJPEG_DSO_NAME
$LIPO -create \
-arch i386 $TMPDIR/dist.x86/$LIBDIR/libturbojpeg.a \
-arch x86_64 $PKGROOT/$LIBDIR/libturbojpeg.a \
-output $PKGROOT/$LIBDIR/libturbojpeg.a
$LIPO -create \
-arch i386 $TMPDIR/dist.x86/$BINDIR/cjpeg \
-arch x86_64 $PKGROOT/$BINDIR/cjpeg \
-output $PKGROOT/$BINDIR/cjpeg
$LIPO -create \
-arch i386 $TMPDIR/dist.x86/$BINDIR/djpeg \
-arch x86_64 $PKGROOT/$BINDIR/djpeg \
-output $PKGROOT/$BINDIR/djpeg
$LIPO -create \
-arch i386 $TMPDIR/dist.x86/$BINDIR/jpegtran \
-arch x86_64 $PKGROOT/$BINDIR/jpegtran \
-output $PKGROOT/$BINDIR/jpegtran
$LIPO -create \
-arch i386 $TMPDIR/dist.x86/$BINDIR/tjbench \
-arch x86_64 $PKGROOT/$BINDIR/tjbench \
-output $PKGROOT/$BINDIR/tjbench
$LIPO -create \
-arch i386 $TMPDIR/dist.x86/$BINDIR/rdjpgcom \
-arch x86_64 $PKGROOT/$BINDIR/rdjpgcom \
-output $PKGROOT/$BINDIR/rdjpgcom
$LIPO -create \
-arch i386 $TMPDIR/dist.x86/$BINDIR/wrjpgcom \
-arch x86_64 $PKGROOT/$BINDIR/wrjpgcom \
-output $PKGROOT/$BINDIR/wrjpgcom
fi
install_ios()
{
BUILDDIR=$1
ARCHNAME=$2
DIRNAME=$3
LIPOARCH=$4
if [ ! -d $BUILDDIR ]; then
echo ERROR: $ARCHNAME build directory $BUILDDIR does not exist
exit 1
fi
if [ ! -f $BUILDDIR/Makefile ]; then
echo ERROR: $ARCHNAME build directory $BUILDDIR is not configured
exit 1
fi
mkdir -p $TMPDIR/dist.$DIRNAME
pushd $BUILDDIR
make install DESTDIR=$TMPDIR/dist.$DIRNAME
popd
$LIPO -create \
$PKGROOT/$LIBDIR/$LIBJPEG_DSO_NAME \
-arch $LIPOARCH $TMPDIR/dist.$DIRNAME/$LIBDIR/$LIBJPEG_DSO_NAME \
-output $PKGROOT/$LIBDIR/$LIBJPEG_DSO_NAME
$LIPO -create \
$PKGROOT/$LIBDIR/libjpeg.a \
-arch $LIPOARCH $TMPDIR/dist.$DIRNAME/$LIBDIR/libjpeg.a \
-output $PKGROOT/$LIBDIR/libjpeg.a
$LIPO -create \
$PKGROOT/$LIBDIR/$TURBOJPEG_DSO_NAME \
-arch $LIPOARCH $TMPDIR/dist.$DIRNAME/$LIBDIR/$TURBOJPEG_DSO_NAME \
-output $PKGROOT/$LIBDIR/$TURBOJPEG_DSO_NAME
$LIPO -create \
$PKGROOT/$LIBDIR/libturbojpeg.a \
-arch $LIPOARCH $TMPDIR/dist.$DIRNAME/$LIBDIR/libturbojpeg.a \
-output $PKGROOT/$LIBDIR/libturbojpeg.a
$LIPO -create \
$PKGROOT/$BINDIR/cjpeg \
-arch $LIPOARCH $TMPDIR/dist.$DIRNAME/$BINDIR/cjpeg \
-output $PKGROOT/$BINDIR/cjpeg
$LIPO -create \
$PKGROOT/$BINDIR/djpeg \
-arch $LIPOARCH $TMPDIR/dist.$DIRNAME/$BINDIR/djpeg \
-output $PKGROOT/$BINDIR/djpeg
$LIPO -create \
$PKGROOT/$BINDIR/jpegtran \
-arch $LIPOARCH $TMPDIR/dist.$DIRNAME/$BINDIR/jpegtran \
-output $PKGROOT/$BINDIR/jpegtran
$LIPO -create \
$PKGROOT/$BINDIR/tjbench \
-arch $LIPOARCH $TMPDIR/dist.$DIRNAME/$BINDIR/tjbench \
-output $PKGROOT/$BINDIR/tjbench
$LIPO -create \
$PKGROOT/$BINDIR/rdjpgcom \
-arch $LIPOARCH $TMPDIR/dist.$DIRNAME/$BINDIR/rdjpgcom \
-output $PKGROOT/$BINDIR/rdjpgcom
$LIPO -create \
$PKGROOT/$BINDIR/wrjpgcom \
-arch $LIPOARCH $TMPDIR/dist.$DIRNAME/$BINDIR/wrjpgcom \
-output $PKGROOT/$BINDIR/wrjpgcom
}
if [ $UNIVERSAL = 1 -a "$BUILDDIRARMV7" != "" ]; then
install_ios $BUILDDIRARMV7 ARMv7 armv7 arm
fi
if [ $UNIVERSAL = 1 -a "$BUILDDIRARMV7S" != "" ]; then
install_ios $BUILDDIRARMV7S ARMv7s armv7s arm
fi
if [ $UNIVERSAL = 1 -a "BUILDDIRARMV8" != "" ]; then
install_ios $BUILDDIRARMV8 ARMv8 armv8 arm64
fi
install_name_tool -id $LIBDIR/$LIBJPEG_DSO_NAME $PKGROOT/$LIBDIR/$LIBJPEG_DSO_NAME
install_name_tool -id $LIBDIR/$TURBOJPEG_DSO_NAME $PKGROOT/$LIBDIR/$TURBOJPEG_DSO_NAME
if [ $WITH_JAVA = 1 ]; then
ln -fs $TURBOJPEG_DSO_NAME $PKGROOT/$LIBDIR/libturbojpeg.jnilib
fi
if [ "$PREFIX" = "@CMAKE_INSTALL_DEFAULT_PREFIX@" -a "$LIBDIR" = "@CMAKE_INSTALL_DEFAULT_PREFIX@/lib" ]; then
if [ ! -h $PKGROOT/$PREFIX/lib32 ]; then
ln -fs lib $PKGROOT/$PREFIX/lib32
fi
if [ ! -h $PKGROOT/$PREFIX/lib64 ]; then
ln -fs lib $PKGROOT/$PREFIX/lib64
fi
fi
mkdir -p $TMPDIR/pkg
install -m 755 pkgscripts/uninstall $PKGROOT/$BINDIR/
find $PKGROOT -type f | while read file; do xattr -c $file; done
cp $SRCDIR/release/License.rtf $SRCDIR/release/Welcome.rtf $SRCDIR/release/ReadMe.txt $TMPDIR/pkg/
mkdir $TMPDIR/dmg
pkgbuild --root $PKGROOT --version $VERSION.$BUILD --identifier @PKGID@ \
$TMPDIR/pkg/$PACKAGE_NAME.pkg
productbuild --distribution pkgscripts/Distribution.xml \
--package-path $TMPDIR/pkg/ --resources $TMPDIR/pkg/ \
$TMPDIR/dmg/$PACKAGE_NAME.pkg
hdiutil create -fs HFS+ -volname $PACKAGE_NAME-$VERSION \
-srcfolder "$TMPDIR/dmg" $TMPDIR/$PACKAGE_NAME-$VERSION.dmg
cp $TMPDIR/$PACKAGE_NAME-$VERSION.dmg .
exit