]> granicus.if.org Git - libjpeg-turbo/commitdiff
Overhaul Linux/Unix packaging system, primarily to avoid conflicts with vendor-suppli...
authorDRC <dcommander@users.sourceforge.net>
Fri, 19 Apr 2013 04:25:14 +0000 (04:25 +0000)
committerDRC <dcommander@users.sourceforge.net>
Fri, 19 Apr 2013 04:25:14 +0000 (04:25 +0000)
If the default prefix (/opt/libjpeg-turbo) is used, then we now always install 32-bit libraries in /opt/libjpeg-turbo/lib32 and 64-bit libraries in /opt/libjpeg-turbo/lib64 instead of trying to conform to the Debian or Red Hat conventions.  The RPM and DEB packages will now be created with the directory structure defined by the configure variables "prefix", "bindir", "libdir", etc., with the exception that the docs are always installed under /usr/share/doc/{package_name}-{version}.

git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@944 632fc199-4ca6-4c93-a231-07263d6284db

ChangeLog.txt
Makefile.am
configure.ac
java/Makefile.am
release/libjpeg-turbo.spec.in
release/makedpkg.in

index 7bae7809702b42c7f1ca10cc46d209e89b1cbb7e..798377e3eda32f3410561e72b3c7c061fbfba954 100644 (file)
@@ -4,6 +4,19 @@
 [1] 'make test' now works properly on FreeBSD, and it no longer requires the
 md5sum executable to be present on other Un*x platforms.
 
+[2] Overhauled the Linux/Unix packaging system:
+-- To avoid conflict with vendor-supplied libjpeg-turbo packages, the
+official RPMs and DEBs for libjpeg-turbo have been renamed to
+"libjpeg-turbo-official", and the TurboJPEG libraries are now packaged under
+/opt/libjpeg-turbo in the official packages.
+-- DEB and RPM packages are now created properly whenever the prefix is set
+to a non-default value (such as /usr/local.)
+-- To avoid confusion, official libjpeg-turbo packages on Linux/Unix platforms
+(except for Mac) will always install the 32-bit libraries in
+/opt/libjpeg-turbo/lib32 and the 64-bit libraries in /opt/libjpeg-turbo/lib64.
+-- Fixed an issue whereby, in some cases, the libjpeg-turbo executables were
+not properly linking with the shared libraries installed by the same package.
+
 
 1.2.90 (1.3 beta1)
 ==================
index f9d8942e0773693e98e51def30271f460d160033..832b1727c3c538552f7d2ec62847afc13a5f9291 100644 (file)
@@ -320,79 +320,69 @@ if WITH_JAVA
 endif
 
 
-if X86_64
-
-install-exec-hook:
-       __PREFIX=`echo ${prefix} | sed -e 's@\/*$$@@'`;  \
-       if [ "$$__PREFIX" = "/opt/libjpeg-turbo" ]; then  \
-               cd $(DESTDIR)/${prefix};  \
-               if [ -d lib -a ! -d lib64 -a ! -h lib64 ]; then  \
-                       $(LN_S) lib lib64;  \
-               fi  \
-       fi
-
-else
-
-install-exec-hook:
-       __PREFIX=`echo ${prefix} | sed -e 's@\/*$$@@'`;  \
-       if [ "$$__PREFIX" = "/opt/libjpeg-turbo" ]; then  \
-               cd $(DESTDIR)/${prefix};  \
-               if [ -d lib -a ! -d lib32 -a ! -h lib32 ]; then  \
-                       $(LN_S) lib lib32;  \
-               fi  \
-       fi
-
-endif
-
-rpm: all
+pkgscripts/libjpeg-turbo.spec: pkgscripts/libjpeg-turbo.spec.tmpl
+       cat pkgscripts/libjpeg-turbo.spec.tmpl | sed s@%{__prefix}@$(prefix)@g | \
+               sed s@%{__bindir}@$(bindir)@g | sed s@%{__datadir}@$(datadir)@g | \
+               sed s@%{__docdir}@$(docdir)@g | sed s@%{__includedir}@$(includedir)@g | \
+               sed s@%{__libdir}@$(libdir)@g | sed s@%{__mandir}@$(mandir)@g \
+               > pkgscripts/libjpeg-turbo.spec
+
+rpm: all pkgscripts/libjpeg-turbo.spec
        TMPDIR=`mktemp -d /tmp/${PACKAGE_NAME}-build.XXXXXX`; \
        mkdir -p $$TMPDIR/RPMS; \
        ln -fs `pwd` $$TMPDIR/BUILD; \
-       rm -f ${PACKAGE_NAME}-${VERSION}.${RPMARCH}.rpm; \
+       rm -f ${PKGNAME}-${VERSION}.${RPMARCH}.rpm; \
        rpmbuild -bb --define "_blddir $$TMPDIR/buildroot"  \
                --define "_topdir $$TMPDIR" \
                --target ${RPMARCH} pkgscripts/libjpeg-turbo.spec; \
-       cp $$TMPDIR/RPMS/${RPMARCH}/${PACKAGE_NAME}-${VERSION}-${BUILD}.${RPMARCH}.rpm \
-               ${PACKAGE_NAME}-${VERSION}.${RPMARCH}.rpm; \
+       cp $$TMPDIR/RPMS/${RPMARCH}/${PKGNAME}-${VERSION}-${BUILD}.${RPMARCH}.rpm \
+               ${PKGNAME}-${VERSION}.${RPMARCH}.rpm; \
        rm -rf $$TMPDIR
 
-srpm: dist-gzip
+srpm: dist-gzip pkgscripts/libjpeg-turbo.spec
        TMPDIR=`mktemp -d /tmp/${PACKAGE_NAME}-build.XXXXXX`; \
        mkdir -p $$TMPDIR/RPMS; \
        mkdir -p $$TMPDIR/SRPMS; \
        mkdir -p $$TMPDIR/BUILD; \
        mkdir -p $$TMPDIR/SOURCES; \
        mkdir -p $$TMPDIR/SPECS; \
-       rm -f ${PACKAGE_NAME}-${VERSION}.src.rpm; \
+       rm -f ${PKGNAME}-${VERSION}.src.rpm; \
        cp ${PACKAGE_NAME}-${VERSION}.tar.gz $$TMPDIR/SOURCES; \
        cat pkgscripts/libjpeg-turbo.spec | sed s/%{_blddir}/%{_tmppath}/g \
                | sed s/#--\>//g \
                > $$TMPDIR/SPECS/libjpeg-turbo.spec; \
        rpmbuild -bs --define "_topdir $$TMPDIR" $$TMPDIR/SPECS/libjpeg-turbo.spec; \
-       cp $$TMPDIR/SRPMS/${PACKAGE_NAME}-${VERSION}-${BUILD}.src.rpm \
-               ${PACKAGE_NAME}-${VERSION}.src.rpm; \
+       cp $$TMPDIR/SRPMS/${PKGNAME}-${VERSION}-${BUILD}.src.rpm \
+               ${PKGNAME}-${VERSION}.src.rpm; \
        rm -rf $$TMPDIR
 
-deb: all
+pkgscripts/makedpkg: pkgscripts/makedpkg.tmpl
+       cat pkgscripts/makedpkg.tmpl | sed s@%{__prefix}@$(prefix)@g | \
+               sed s@%{__bindir}@$(bindir)@g | sed s@%{__datadir}@$(datadir)@g | \
+               sed s@%{__docdir}@$(docdir)@g | sed s@%{__includedir}@$(includedir)@g | \
+               sed s@%{__libdir}@$(libdir)@g | sed s@%{__mandir}@$(mandir)@g \
+               > pkgscripts/makedpkg
+
+deb: all pkgscripts/makedpkg
        sh pkgscripts/makedpkg
 
 if X86_64
 
-udmg: all
+udmg: all pkgscripts/makemacpkg
        sh pkgscripts/makemacpkg -build32 ${BUILDDIR32}
 
-iosdmg: all
+iosdmg: all pkgscripts/makemacpkg
        sh pkgscripts/makemacpkg -build32 ${BUILDDIR32} -buildarmv6 ${BUILDDIRARMV6} -buildarmv7 ${BUILDDIRARMV7} -buildarmv7s ${BUILDDIRARMV7S}
 
 else
 
-iosdmg: all
+iosdmg: all pkgscripts/makemacpkg
        sh pkgscripts/makemacpkg -buildarmv6 ${BUILDDIRARMV6} -buildarmv7 ${BUILDDIRARMV7} -buildarmv7s ${BUILDDIRARMV7S}
 
 endif
 
-dmg: all
+dmg: all pkgscripts/makemacpkg
        sh pkgscripts/makemacpkg
 
-cygwinpkg: all
+cygwinpkg: all pkgscripts/makecygwinpkg
        sh pkgscripts/makecygwinpkg
index 9404cac240bf991debec826a26a389fa6b746dbe..49d896a1006786ddb588f46aa4c33b2de303424e 100644 (file)
@@ -21,6 +21,47 @@ AC_PROG_INSTALL
 AC_PROG_LIBTOOL
 AC_PROG_LN_S
 
+# When the prefix is /opt/libjpeg-turbo, we assume that an "official" binary is
+# being created, and thus we install things into specific locations.
+
+old_prefix=${prefix}
+if test "x$prefix" = "xNONE" -a "x$ac_default_prefix" != "x"; then
+  prefix=$ac_default_prefix
+fi
+DATADIR=`eval echo ${datadir}`
+DATADIR=`eval echo $DATADIR`
+if test "$DATADIR" = "/opt/libjpeg-turbo/share"; then
+  datadir='${prefix}'
+fi
+
+old_exec_prefix=${exec_prefix}
+if test "x$exec_prefix" = "xNONE"; then
+  exec_prefix=${prefix}
+fi
+
+if test "x${libdir}" = 'x${exec_prefix}/lib' -o "x${libdir}" = 'x${prefix}/lib'; then
+  LIBDIR=`eval echo ${libdir}`
+  LIBDIR=`eval echo $LIBDIR`
+  if test "$LIBDIR" = "/opt/libjpeg-turbo/lib"; then
+    case $host_os in
+      darwin*)
+        ;;
+      *)
+        case "$host_cpu" in
+          x86_64 | amd64)
+            libdir='${exec_prefix}/lib64'
+            ;;
+          i*86 | x86 | ia32)
+            libdir='${exec_prefix}/lib32'
+            ;;
+        esac
+        ;;
+    esac
+  fi
+fi
+exec_prefix=${old_exec_prefix}
+prefix=${old_prefix}
+
 # Check whether compiler supports pointers to undefined structures
 AC_MSG_CHECKING(whether compiler supports pointers to undefined structures)
 AC_TRY_COMPILE([ typedef struct undefined_structure * undef_struct_ptr; ], ,
@@ -325,8 +366,8 @@ if test "x$with_java" = "xyes"; then
   AC_SUBST(JNI_CFLAGS)
 
   RPM_CONFIG_ARGS="$RPM_CONFIG_ARGS --with-java"
-  JAVA_RPM_CONTENTS_1='%dir /opt/%{name}/classes'
-  JAVA_RPM_CONTENTS_2=/opt/%{name}/classes/turbojpeg.jar
+  JAVA_RPM_CONTENTS_1='%dir %{_datadir}/classes'
+  JAVA_RPM_CONTENTS_2=%{_datadir}/classes/turbojpeg.jar
   WITH_JAVA=1
 else
   AC_MSG_RESULT(no)
@@ -401,6 +442,12 @@ AM_CONDITIONAL([SIMD_ARM], [test "x$simd_arch" = "xarm"])
 AM_CONDITIONAL([X86_64], [test "x$host_cpu" = "xx86_64" -o "x$host_cpu" = "xamd64"])
 AM_CONDITIONAL([WITH_TURBOJPEG], [test "x$with_turbojpeg" != "xno"])
 
+AC_ARG_VAR(PKGNAME, [distribution package name (default: libjpeg-turbo)])
+if test "x$PKGNAME" = "x"; then
+  PKGNAME=$PACKAGE_NAME
+fi
+AC_SUBST(PKGNAME)
+
 case "$host_cpu" in
   x86_64)
     RPMARCH=x86_64
@@ -424,9 +471,9 @@ AC_DEFINE_UNQUOTED([BUILD], "$BUILD", [Build number])
 # jconfig.h is a minimal version that allows this package to be built
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_HEADERS([jconfig.h])
-AC_CONFIG_FILES([pkgscripts/libjpeg-turbo.spec:release/libjpeg-turbo.spec.in])
+AC_CONFIG_FILES([pkgscripts/libjpeg-turbo.spec.tmpl:release/libjpeg-turbo.spec.in])
 AC_CONFIG_FILES([pkgscripts/makecygwinpkg:release/makecygwinpkg.in])
-AC_CONFIG_FILES([pkgscripts/makedpkg:release/makedpkg.in])
+AC_CONFIG_FILES([pkgscripts/makedpkg.tmpl:release/makedpkg.in])
 AC_CONFIG_FILES([pkgscripts/makemacpkg:release/makemacpkg.in])
 AC_CONFIG_FILES([pkgscripts/Description.plist:release/Description.plist.in])
 AC_CONFIG_FILES([pkgscripts/Info.plist:release/Info.plist.in])
index 6896fa2f3901c72c4eed5e107d59e9b31f99cb03..af97a05d5d597328546465addafe0c4b4b36c678 100644 (file)
@@ -42,12 +42,12 @@ clean-local:
        rm -f turbojpeg.jar
 
 install-exec-local: turbojpeg.jar
-       mkdir -p $(DESTDIR)/$(prefix)/classes
-       $(INSTALL) -m 644 turbojpeg.jar $(DESTDIR)/$(prefix)/classes/
+       mkdir -p $(DESTDIR)/$(datadir)/classes
+       $(INSTALL) -m 644 turbojpeg.jar $(DESTDIR)/$(datadir)/classes/
 
 uninstall-local:
-       rm -f $(DESTDIR)/$(prefix)/classes/turbojpeg.jar
-       if [ -d $(DESTDIR)/$(prefix)/classes ]; then rmdir $(DESTDIR)/$(prefix)/classes; fi
+       rm -f $(DESTDIR)/$(datadir)/classes/turbojpeg.jar
+       if [ -d $(DESTDIR)/$(datadir)/classes ]; then rmdir $(DESTDIR)/$(datadir)/classes; fi
 
 headers: all
        javah -d ${srcdir} org.libjpegturbo.turbojpeg.TJ; \
index c3fba3cf60a342ed4a77f420479b252981ef3f30..651bb33f09bc2a9b35f7ee7cc80e635f6d0e6e30 100644 (file)
@@ -1,11 +1,32 @@
+# Path under which libjpeg-turbo should be installed
+%define _prefix %{__prefix}
+
+# Path under which executables should be installed
+%define _bindir %{__bindir}
+
+# Path under which Java classes and man pages should be installed
+%define _datadir %{__datadir}
+
+# Path under which docs should be installed
+%define _docdir %{_defaultdocdir}/%{name}-%{version}
+
+# Path under which headers should be installed
+%define _includedir %{__includedir}
+
+# _libdir is set to %{_prefix}/%{_lib} by default
 %ifarch x86_64
-%define __lib lib64
+%define _lib lib64
 %else
-%define __lib lib
+%if "%{_prefix}" == "/opt/libjpeg-turbo"
+%define _lib lib32
+%endif
 %endif
 
+# Path under which man pages should be installed
+%define _mandir %{__mandir}
+
 Summary: A SIMD-accelerated JPEG codec that provides both the libjpeg and TurboJPEG APIs
-Name: @PACKAGE_NAME@
+Name: @PKGNAME@
 Version: @VERSION@
 Vendor: The libjpeg-turbo Project
 URL: http://www.libjpeg-turbo.org
@@ -16,11 +37,10 @@ License: BSD-style
 BuildRoot: %{_blddir}/%{name}-buildroot-%{version}-%{release}
 Prereq: /sbin/ldconfig
 %ifarch x86_64
-Provides: %{name} = %{version}-%{release}, turbojpeg = 2.00, libturbojpeg.so()(64bit)
+Provides: %{name} = %{version}-%{release}, libturbojpeg.so()(64bit)
 %else
-Provides: %{name} = %{version}-%{release}, turbojpeg = 2.00, libturbojpeg.so
+Provides: %{name} = %{version}-%{release}, libturbojpeg.so
 %endif
-Obsoletes: turbojpeg
 
 %description
 libjpeg-turbo is a JPEG image codec that uses SIMD instructions (MMX, SSE2,
@@ -45,27 +65,36 @@ of making high-speed JPEG compression/decompression technology available to a
 broader range of users and developers.
 
 #-->%prep
-#-->%setup -q
+#-->%setup -q -n libjpeg-turbo-%{version}
 
 #-->%build
-#-->./configure libdir=/opt/%{name}/%{__lib} mandir=/opt/%{name}/man JPEG_LIB_VERSION=@JPEG_LIB_VERSION@ SO_MAJOR_VERSION=@SO_MAJOR_VERSION@ SO_MINOR_VERSION=@SO_MINOR_VERSION@ --with-pic @RPM_CONFIG_ARGS@
-#-->make DESTDIR=$RPM_BUILD_ROOT libdir=/opt/%{name}/%{__lib} mandir=/opt/%{name}/man
+#-->./configure prefix=%{_prefix} bindir=%{_bindir} datadir=%{_datadir} \
+#-->   docdir=%{_docdir} includedir=%{_includedir} libdir=%{_libdir} \
+#-->   mandir=%{_mandir} JPEG_LIB_VERSION=@JPEG_LIB_VERSION@ \
+#-->   SO_MAJOR_VERSION=@SO_MAJOR_VERSION@ SO_MINOR_VERSION=@SO_MINOR_VERSION@ \
+#-->   --with-pic @RPM_CONFIG_ARGS@
+#-->make DESTDIR=$RPM_BUILD_ROOT
 
 %install
 
 rm -rf $RPM_BUILD_ROOT
-make install DESTDIR=$RPM_BUILD_ROOT libdir=/opt/%{name}/%{__lib} mandir=/opt/%{name}/man docdir=/opt/%{name}/doc exampledir=/opt/%{name}/doc
-rm -f $RPM_BUILD_ROOT/opt/%{name}/%{__lib}/*.la
-mkdir -p $RPM_BUILD_ROOT/usr/%{__lib}
-mv $RPM_BUILD_ROOT/opt/%{name}/%{__lib}/libturbojpeg.* $RPM_BUILD_ROOT/usr/%{__lib}
-/sbin/ldconfig -n $RPM_BUILD_ROOT/opt/%{name}/%{__lib}
-/sbin/ldconfig -n $RPM_BUILD_ROOT/usr/%{__lib}
-mkdir -p $RPM_BUILD_ROOT/usr/include
-mv $RPM_BUILD_ROOT/opt/%{name}/include/turbojpeg.h $RPM_BUILD_ROOT/usr/include
-ln -fs /usr/include/turbojpeg.h $RPM_BUILD_ROOT/opt/%{name}/include/
-ln -fs /usr/%{__lib}/libturbojpeg.a $RPM_BUILD_ROOT/opt/%{name}/%{__lib}/
-mkdir -p $RPM_BUILD_ROOT%{_defaultdocdir}
-mv $RPM_BUILD_ROOT/opt/%{name}/doc $RPM_BUILD_ROOT%{_defaultdocdir}/%{name}-%{version}
+make install DESTDIR=$RPM_BUILD_ROOT docdir=%{_docdir} exampledir=%{_docdir}
+rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
+/sbin/ldconfig -n $RPM_BUILD_ROOT%{_libdir}
+
+#-->%if 0
+
+LJT_LIBDIR=%{__libdir}
+if [ ! "$LJT_LIBDIR" = "%{_libdir}" ]; then
+       echo ERROR: libjpeg-turbo must be configured with libdir=%{_prefix}/%{_lib} when generating an in-tree RPM for this architecture.
+       exit 1
+fi
+
+#-->%endif
+
+%if "%{_prefix}" == "/opt/libjpeg-turbo" && "%{_docdir}" != "%{_prefix}/doc"
+       ln -fs %{_docdir} $RPM_BUILD_ROOT/%{_prefix}/doc
+%endif
 
 %post -p /sbin/ldconfig
 
@@ -76,44 +105,42 @@ rm -rf $RPM_BUILD_ROOT
 
 %files
 %defattr(-,root,root)
-%dir %{_defaultdocdir}/%{name}-%{version}
-%doc %{_defaultdocdir}/%{name}-%{version}/*
-%dir /opt/%{name}
-%dir /opt/%{name}/bin
-/opt/%{name}/bin/cjpeg
-/opt/%{name}/bin/djpeg
-/opt/%{name}/bin/jpegtran
-/opt/%{name}/bin/tjbench
-/opt/%{name}/bin/rdjpgcom
-/opt/%{name}/bin/wrjpgcom
-%dir /opt/%{name}/%{__lib}
-%ifarch x86_64
-%else
-/opt/%{name}/lib32
+%dir %{_docdir}
+%doc %{_docdir}/*
+%dir %{_prefix}
+%if "%{_prefix}" == "/opt/libjpeg-turbo" && "%{_docdir}" != "%{_prefix}/doc"
+ %{_prefix}/doc
 %endif
-/opt/%{name}/%{__lib}/libjpeg.so.@SO_MAJOR_VERSION@.@SO_AGE@.@SO_MINOR_VERSION@
-/opt/%{name}/%{__lib}/libjpeg.so.@SO_MAJOR_VERSION@
-/opt/%{name}/%{__lib}/libjpeg.so
-/opt/%{name}/%{__lib}/libjpeg.a
-/opt/%{name}/%{__lib}/libturbojpeg.a
-/usr/%{__lib}/libturbojpeg.so.0.0.0
-/usr/%{__lib}/libturbojpeg.so.0
-/usr/%{__lib}/libturbojpeg.so
-/usr/%{__lib}/libturbojpeg.a
-/usr/include/turbojpeg.h
-%dir /opt/%{name}/include
-/opt/%{name}/include/jconfig.h
-/opt/%{name}/include/jerror.h
-/opt/%{name}/include/jmorecfg.h
-/opt/%{name}/include/jpeglib.h
-/opt/%{name}/include/turbojpeg.h
-%dir /opt/%{name}/man
-%dir /opt/%{name}/man/man1
-/opt/%{name}/man/man1/cjpeg.1*
-/opt/%{name}/man/man1/djpeg.1*
-/opt/%{name}/man/man1/jpegtran.1*
-/opt/%{name}/man/man1/rdjpgcom.1*
-/opt/%{name}/man/man1/wrjpgcom.1*
+%dir %{_bindir}
+%{_bindir}/cjpeg
+%{_bindir}/djpeg
+%{_bindir}/jpegtran
+%{_bindir}/tjbench
+%{_bindir}/rdjpgcom
+%{_bindir}/wrjpgcom
+%dir %{_libdir}
+%{_libdir}/libjpeg.so.@SO_MAJOR_VERSION@.@SO_AGE@.@SO_MINOR_VERSION@
+%{_libdir}/libjpeg.so.@SO_MAJOR_VERSION@
+%{_libdir}/libjpeg.so
+%{_libdir}/libjpeg.a
+%{_libdir}/libturbojpeg.so.0.0.0
+%{_libdir}/libturbojpeg.so.0
+%{_libdir}/libturbojpeg.so
+%{_libdir}/libturbojpeg.a
+%dir %{_includedir}
+%{_includedir}/jconfig.h
+%{_includedir}/jerror.h
+%{_includedir}/jmorecfg.h
+%{_includedir}/jpeglib.h
+%{_includedir}/turbojpeg.h
+%dir %{_mandir}
+%dir %{_mandir}/man1
+%{_mandir}/man1/cjpeg.1*
+%{_mandir}/man1/djpeg.1*
+%{_mandir}/man1/jpegtran.1*
+%{_mandir}/man1/rdjpgcom.1*
+%{_mandir}/man1/wrjpgcom.1*
+%dir %{_datadir}
 @JAVA_RPM_CONTENTS_1@
 @JAVA_RPM_CONTENTS_2@
 
index 628e0a64f8a98fdc62fa622a2562389698575923..bd34b0b99698c676a64010e911f8fa6f5a829b1d 100644 (file)
@@ -23,9 +23,6 @@ makedeb()
        if [ $SUPPLEMENT = 1 ]; then
                PACKAGE_NAME=$PACKAGE_NAME\32
                DEBARCH=amd64
-               __LIB=lib32
-       else
-               __LIB=lib
        fi
 
        umask 022
@@ -36,52 +33,40 @@ makedeb()
                | sed s/{__VERSION}/$VERSION/g | sed s/{__BUILD}/$BUILD/g \
                | sed s/{__ARCH}/$DEBARCH/g > $TMPDIR/DEBIAN/control)
 
-       make install prefix=$TMPDIR/opt/$DIRNAME libdir=$TMPDIR/opt/$DIRNAME/$__LIB \
-               mandir=$TMPDIR/opt/$DIRNAME/man \
-               docdir=$TMPDIR/usr/share/doc/$DIRNAME-$VERSION \
-               exampledir=$TMPDIR/usr/share/doc/$DIRNAME-$VERSION
-       rm -f $TMPDIR/opt/$DIRNAME/$__LIB/*.la
-
        if [ $SUPPLEMENT = 1 ]; then
-               rm -rf $TMPDIR/opt/$DIRNAME/include
-               rm -rf $TMPDIR/opt/$DIRNAME/man
-               rm -rf $TMPDIR/opt/$DIRNAME/bin
-               rm -rf $TMPDIR/opt/$DIRNAME/classes
-               rm -rf $TMPDIR/usr
-       fi
-
-       mkdir -p $TMPDIR/usr/$__LIB
-       mv $TMPDIR/opt/$DIRNAME/$__LIB/libturbojpeg.* $TMPDIR/usr/$__LIB
-       ln -fs /usr/$__LIB/libturbojpeg.a $TMPDIR/opt/$DIRNAME/$__LIB/
-       /sbin/ldconfig -n $TMPDIR/opt/$DIRNAME/$__LIB
-       /sbin/ldconfig -n $TMPDIR/usr/$__LIB
-
-       if [ ! $SUPPLEMENT = 1 ]; then
-               if [ "$DEBARCH" = "amd64" ]; then
-                       ln -fs lib $TMPDIR/opt/$DIRNAME/lib64
-               else
-                       if [ ! "$__LIB" = "lib32" ]; then
-                               ln -fs lib $TMPDIR/opt/$DIRNAME/lib32
-                       fi
-               fi
-               mkdir -p $TMPDIR/usr/include
-               mv $TMPDIR/opt/$DIRNAME/include/turbojpeg.h $TMPDIR/usr/include
-               ln -fs /usr/include/turbojpeg.h $TMPDIR/opt/$DIRNAME/include/
+               make install DESTDIR=$TMPDIR bindir=/dummy/bin datadir=/dummy/data \
+                       docdir=/dummy/doc includedir=/dummy/include mandir=/dummy/man
+               rm -f $TMPDIR$LIBDIR/*.la
+               rm -rf $TMPDIR/dummy
        else
-               mkdir -p $TMPDIR/usr/lib/i386-linux-gnu
-               ln -fs /usr/lib32/libturbojpeg.so $TMPDIR/usr/lib/i386-linux-gnu/libturbojpeg.so
-               ln -fs /usr/lib32/libturbojpeg.a $TMPDIR/usr/lib/i386-linux-gnu/libturbojpeg.a
+               make install DESTDIR=$TMPDIR docdir=/usr/share/doc/$DIRNAME-$VERSION \
+                       exampledir=/usr/share/doc/$DIRNAME-$VERSION
+               rm -f $TMPDIR$LIBDIR/*.la
+               echo $PREFIX $DOCDIR
+               if [ "$PREFIX" = "/opt/libjpeg-turbo" -a "$DOCDIR" != "/usr/share/doc/$DIRNAME-$VERSION" ]; then
+                       ln -fs /usr/share/doc/$DIRNAME-$VERSION $TMPDIR$PREFIX/doc
+               fi
        fi
 
+       /sbin/ldconfig -n $TMPDIR$LIBDIR
+
        sudo chown -Rh root:root $TMPDIR/*
        dpkg -b $TMPDIR $PACKAGE_NAME\_$VERSION\_$DEBARCH.deb
 }
 
-PACKAGE_NAME=@PACKAGE_NAME@
+PACKAGE_NAME=@PKGNAME@
 VERSION=@VERSION@
 BUILD=@BUILD@
 DEBARCH=@DEBARCH@
 SRCDIR=@abs_top_srcdir@
+PREFIX=%{__prefix}
+BINDIR=%{__bindir}
+DATADIR=%{__datadir}
+DOCDIR=%{__docdir}
+INCDIR=%{__includedir}
+LIBDIR=%{__libdir}
+MANDIR=%{__mandir}
+
 
 makedeb 0
 if [ "$DEBARCH" = "i386" ]; then makedeb 1; fi