]> git.ipfire.org Git - ipfire-3.x.git/commitdiff
gmp: Add sse2 optimized version of library.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 4 Dec 2011 00:00:23 +0000 (01:00 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 4 Dec 2011 00:00:23 +0000 (01:00 +0100)
gmp/gmp.nm

index 5ad22836c9eb99ca787c7b854e07b6ea2eedee44..51f20d4ce5a1a9010e4bdd617f5a3efc23ea8c1d 100644 (file)
@@ -5,7 +5,7 @@
 
 name       = gmp
 version    = 5.0.1
-release    = 1
+release    = 2
 
 groups     = System/Libraries
 url        = http://gmplib.org/
@@ -31,36 +31,111 @@ build
                m4
        end
 
-       ABI = standard
+       # Build different versions of gmp to enhance the speed
+       # of the OS.
+       build_versions = base
+
+       export ABI = standard
 
        if "%{DISTRO_ARCH}" == "x86_64"
                ABI = 64
        end
 
        if "%{DISTRO_ARCH}" == "i686"
+               # Build sse2 enabled version of gmp.
+               build_versions += sse2
+
                ABI = 32
        end
 
+       configure_options += \
+               --prefix=/usr \
+               --enable-cxx \
+               --enable-mpbsd \
+               --disable-static
+
+       prepare_cmds
+               for version in %{build_versions}; do
+                       mkdir build-${version}
+
+                       cd build-${version}
+                       ln -svf ../configure .
+                       cd ..
+               done
+       end
+
        build
-               ABI=%{ABI} \
-               ./configure \
-                       --prefix=/usr \
-                       --enable-cxx \
-                       --enable-mpbsd \
-                       --disable-static
-
-               make %{PARALLELISMFLAGS}
+               for version in %{build_versions}; do
+                       cd build-${version}
+
+                       CFLAGS="%{CFLAGS}"
+                       CXXFLAFS="%{CXXFLAGS}"
+                       if [ "${version}" = "sse2" ]; then
+                               # Enable sse2.
+                               CFLAGS="${CFLAGS} -march=pentium4"
+                               CXXFLAGS="${CXXFLAGS} -march=pentium4"
+                       fi
+
+                       CFLAGS="${CFLAGS}" \
+                       CXXFLAGS="${CXXFLAGS}" \
+                               ./configure \
+                                       %{configure_options}
+
+                       # Kill RPATHs.
+                       sed -e 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' \
+                               -e 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' \
+                               -e 's|-lstdc++ -lm|-lstdc++|' \
+                               -i libtool
+
+                       make %{PARALLELISMFLAGS} \
+                               CFLAGS="${CFLAGS}" \
+                               CXXFLAGS="${CXXFLAGS}"
+
+                       cd ..
+               done
        end
 
        test
-               make check
+               for version in %{build_versions}; do
+                       cd build-${version}
+
+                       make check
+
+                       cd ..
+               done
+       end
+
+       install
+               for version in %{build_versions}; do
+                       cd build-${version}
+
+                       if [ "${version}" = "sse2" ]; then
+                               # Manually install sse2 libs.
+                               mkdir -pv %{BUILDROOT}/usr/lib/sse2
+
+                               install -m 755 .libs/libgmp.so.*.* %{BUILDROOT}/usr/lib/sse2
+                               cp -a .libs/libgmp.so.[^.]* %{BUILDROOT}/usr/lib/sse2
+                               chmod 755 %{BUILDROOT}/usr/lib/sse2/libgmp.so.[^.]*
+
+                               install -m 755 .libs/libgmpxx.so.*.* %{BUILDROOT}/usr/lib/sse2
+                               cp -a .libs/libgmpxx.so.? %{BUILDROOT}/usr/lib/sse2
+                               chmod 755 %{BUILDROOT}/usr/lib/sse2/libgmpxx.so.?
+
+                               install -m 755 .libs/libmp.so.*.* %{BUILDROOT}/usr/lib/sse2
+                               cp -a .libs/libmp.so.? %{BUILDROOT}/usr/lib/sse2
+                               chmod 755 %{BUILDROOT}/usr/lib/sse2/libmp.so.?
+                       else
+                               make install DESTDIR="%{BUILDROOT}"
+                       fi
+
+                       cd ..
+               done
        end
 end
 
 packages
        package %{name}
-       end
-       
+
        package %{name}-devel
                template DEVEL
        end