Bläddra i källkod

do not use C++ ios unless explicitly instructed to build stream components with new with_cxx option (solves implicit libstdc++ link problem in other packages like gtk2/gimp)

Michael Schloh von Bennewitz 21 år sedan
förälder
incheckning
f148ff09d7
1 ändrade filer med 61 tillägg och 1 borttagningar
  1. 61 1
      tiff/tiff.spec

+ 61 - 1
tiff/tiff.spec

@@ -34,7 +34,10 @@ Class:        BASE
 Group:        Graphics
 License:      GPL
 Version:      3.7.1
-Release:      20041222
+Release:      20050118
+
+#   package library options (a 'yes' builds both libtiff and libtiff_cxx)
+%option       with_cxx  no
 
 #   list of sources
 Source0:      ftp://ftp.remotesensing.org/pub/libtiff/tiff-%{version}.tar.gz
@@ -46,6 +49,10 @@ BuildPreReq:  OpenPKG, openpkg >= 20040130
 PreReq:       OpenPKG, openpkg >= 20040130
 BuildPreReq:  jpeg, zlib
 PreReq:       jpeg, zlib
+%if "%{with_cxx}" == "yes"
+BuildPreReq:  gcc
+PreReq:       gcc
+%endif
 AutoReq:      no
 AutoReqProv:  no
 
@@ -63,10 +70,52 @@ AutoReqProv:  no
 
 %prep
     %setup -q
+    %{l_shtool} subst \
+        -e 's;enable_c++;enable_cxx;' \
+        -e 's;\[^-_$as_cr_alnum];[^+-_$as_cr_alnum];' \
+        -e 's;\(echo \$ac_feature | sed \)\(.\)\([^\`]*\);\1\2\3 | sed \2s/+/x/g\2;g' \
+        configure
 
 %build
+%if "%{with_cxx}" == "yes"
+    #   conditionally build libtiff_cxx with C++ streams as user's request
+    CC="%{l_cc}" \
+    CXX="%{l_cxx}" \
+    CFLAGS="%{l_cflags -O}" \
+    CXXFLAGS="%{l_cxxflags -O}" \
+    CPPFLAGS="%{l_cppflags}" \
+    LDFLAGS="%{l_ldflags}" \
+    ./configure \
+        --prefix=%{l_prefix} \
+        --includedir=%{l_prefix}/include/tiff \
+        --disable-shared \
+        --enable-static \
+        --enable-c++ \
+        --with-zlib-include-dir=%{l_prefix}/include \
+        --with-zlib-lib-dir=%{l_prefix}/lib \
+        --with-jpeg-include-dir=%{l_prefix}/include \
+        --with-jpeg-lib-dir=%{l_prefix}/lib \
+        --without-x
+    %{l_make} %{l_mflags -O}
+
+    #   save C++ library for later installation, and clean out the rest
+    %{l_shtool} mkdir -f -p -m 755 tmpcxx/.libs
+    mv libtiff/.libs/libtiff.a tmpcxx/.libs/libtiff_cxx.a
+    mv libtiff/.libs/libtiff.lai tmpcxx/.libs/libtiff_cxx.lai
+    mv libtiff/libtiff.la tmpcxx/libtiff_cxx.la
+    ln -s ../libtiff_cxx.la tmpcxx/.libs/libtiff_cxx.la
+    %{l_shtool} subst \
+        -e 's;libtiff;libtiff_cxx;g' \
+        tmpcxx/.libs/libtiff_cxx.lai \
+        tmpcxx/.libs/libtiff_cxx.la
+    %{l_make} %{l_mflags -O} distclean
+%endif
+
+    #   unconditionally build libtiff without C++ streams
     CC="%{l_cc}" \
+    CXX= \
     CFLAGS="%{l_cflags -O}" \
+    CXXFLAGS= \
     CPPFLAGS="%{l_cppflags}" \
     LDFLAGS="%{l_ldflags}" \
     ./configure \
@@ -74,6 +123,8 @@ AutoReqProv:  no
         --includedir=%{l_prefix}/include/tiff \
         --disable-shared \
         --enable-static \
+        --disable-c++ \
+        --with-zlib-include-dir=%{l_prefix}/include \
         --with-zlib-include-dir=%{l_prefix}/include \
         --with-zlib-lib-dir=%{l_prefix}/lib \
         --with-jpeg-include-dir=%{l_prefix}/include \
@@ -84,6 +135,15 @@ AutoReqProv:  no
 %install
     rm -rf $RPM_BUILD_ROOT
     %{l_make} %{l_mflags -O} install DESTDIR=$RPM_BUILD_ROOT
+%if "%{with_cxx}" == "yes"
+    #   conditionally install libtiff_cxx just like the Makefile does
+    ( cd tmpcxx
+      ../libtool --mode=install \
+          `grep "^INSTALL =" ../libtiff/Makefile | %{l_shtool} subst -e 's;[^=]*= \(.*\)$;\1;'` \
+          libtiff_cxx.la \
+          $RPM_BUILD_ROOT%{l_prefix}/lib
+    ) || exit $?
+%endif
     ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man3
       for manpage in *.3tiff; do
           base=`echo $manpage | sed -e 's;\.3tiff$;;'`