# Tests by default. No tests: rpm -ba --define 'dotests 0' *.spec %{!?dotests: %define dotests 1} # The .so version was 8 for 2.5.0 and 9 for 2.6.1 - for 3.6.1 it is 17 for 3.7.1 it is 18 %define soname 22 %define _libdir64 %{_prefix}/lib64 ################################# # End of user-modifiable configs ################################# %define name protobuf %define version 3.19.6 %define release 2 %define javadir %{_prefix}/java %define libdir64 %{_prefix}/lib64 #python releated configs %global py_major 3.9 %global py_minor 16 %global python_major python%{py_major} %global python3_sitearch %(%{python_major} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(0))") %global python3_sitearch64 %(%{python_major} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))") Summary: Protocol Buffers - Google's data interchange format Name: %{name} Version: %{version} Release: %{release} License: BSD Group: Development/Libraries/C and C++ URL: https://github.com/protocolbuffers/protobuf Source0: https://github.com/protocolbuffers/protobuf/archive/v%{version}/%{name}-all-%{version}.tar.gz Source1: ftdetect-proto.vim Source2: protobuf-init.el Source3: https://github.com/google/googletest/archive/release-1.8.1.tar.gz#/googletest-release-1.8.1.tar.gz Source5: manifest.txt.in Source6: libprotobuf.so.22 Source7: libprotobuf-lite.so.22 Source8: libprotoc.so.22 Patch1: %{name}-2.5.0-atomicops_internals_aix.h.patch # Needed to rebootstrap with gtest 1.5.0 BuildRequires: libtool >= 2.4.7 BuildRequires: zlib-devel >= 1.2.13 BuildRequires: %{python_major}-devel >= %{py_major}.%{py_minor} BuildRequires: %{python_major}-setuptools >= 65.2.0 # Test while build GCC running with 1.11 BuildRequires: automake >= 1.14 BuildRequires: automake >= 1.16.5 BuildRequires: emacs >= 28.1 BuildRequires: libgcc >= 10 BuildRequires: libstdc++-devel >= 10 Requires: libstdc++ >= 10 Requires: libgcc >= 10 Requires: zlib >= 1.2.13 Prefix: %{_prefix} %ifos aix7.1 %define buildhost powerpc-ibm-aix7.1.0.0 %define osplat aix7 %endif %description Protocol Buffers are a way of encoding structured data in an efficient yet extensible format. Google uses Protocol Buffers for almost all of its internal RPC protocols and file formats. # package libprotoc - This RPM is named protobuf-compiler on Fedora %package compiler Summary: Protocol Buffers compiler Group: System/Libraries Requires: libstdc++ >= 10 Requires: libgcc >= 10 Requires: protobuf = %{version}-%{release} Obsoletes: %{name}-libprotoc # description libprotoc %description compiler This package contains Protocol Buffers compiler for all programming languages. %package lite Summary: Protocol Buffers LITE_RUNTIME libraries Group: System/Libraries Requires: libstdc++ >= 10 Requires: libgcc >= 10 %description lite Protocol Buffers built with optimize_for = LITE_RUNTIME. The LITE_RUNTIME option causes the compiler to generate code which only depends on libprotobuf-lite, which is much smaller than libprotobuf but lacks descriptors, reflection, and some other features. %package devel Summary: Header files, libraries and development documentation for %{name} Group: Development/Libraries/C and C++ Requires: protobuf = %{version}-%{release} Requires: protobuf-compiler = %{version}-%{release} Requires: zlib-devel >= 1.2.13 %description devel Development files for Google Protocol Buffers. This includes the Protocol Buffers compiler for all languages and C++ headers and libraries. %package java Summary: Java Bindings for Google Protocol Buffers Group: Development/Libraries/Java Conflicts: %{name}-compiler > %{version} Conflicts: %{name}-compiler < %{version} %description java This package contains the Java bindings for Google Protocol Buffers. %package python3 Requires: %{python_major} >= %{py_major}.%{py_minor} Summary: Python 3 bindings for Google Protocol Buffers Group: Development/Libraries/Python BuildArch: noarch BuildRequires: %{python_major}-devel >= %{py_major}.%{py_minor} BuildRequires: %{python_major}-setuptools >= 65.2.0 Requires: %{python_major}-six >= 1.13.0 Conflicts: %{name}-compiler > %{version} Conflicts: %{name}-compiler < %{version} %description python3 This package contains the Python 3 bindings for Google Protocol Buffers. %prep %setup -q -a 3 #setup -q %patch1 -p1 rm -rf /tmp/%{name}-%{version}-32bit cp -pr . /tmp/%{name}-%{version}-32bit rm -fr * mv /tmp/%{name}-%{version}-32bit 32bit cp -pr 32bit 64bit #mv googletest-release-1.8.1 gtest %build export RM="/usr/bin/rm -f" export CONFIG_SHELL=/opt/freeware/bin/bash export CONFIG_ENV_ARGS=/opt/freeware/bin/bash export AR="ar -X32_64" export NM="nm -X32_64" export PTHREAD_LIBS=-lpthread export PATCH=/opt/freeware/bin/patch # -DGOOGLE_PROTOBUF_OS_AIX is automatically set in code # Building 64 bit version cd 64bit export CC="gcc -maix64 -pthread -O2" export CXX="g++ -maix64 -pthread -O2" export OBJECT_MODE=64 export CFLAGS="-fPIC -I`pwd`/include -I/opt/freeware/include -I/usr/include" export CXXFLAGS="-fPIC -I`pwd`/include -I/opt/freeware/include -I/usr/include" export CPPFLAGS="-I`pwd`/include -I/opt/freeware/include -I/usr/include" export LDFLAGS="-Wl,-bbigtoc -L%{_libdir}/pthread/ppc64 -lcrypt" export LIBPATH=%{_builddir}/%{name}-%{version}/src/.libs:/opt/freeware/lib/pthread:/opt/freeware/lib # The configure file has to be generated using autoreconf ./autogen.sh ./configure \ --prefix=%{_prefix} \ --libdir=%{_libdir64} \ --host=%{buildhost} \ --target=%{buildhost} \ --build=%{buildhost} \ --disable-static # The -blibpath is required because libtool is preceeding pthread g++ libs # with non-pthread g++ libs in -blibpath # Primative hack to force -blibbpath in libtool to give precedence to pthread # There may be a libtool var/option to do this, but the main default library # directory /opt/freeware/lib was always first and the libstdc++.a symlink # there is non-pthread mv libtool libtool.orig #sed 's?-blibpath:?-blibpath:/opt/freeware/lib/pthread:?' libtool.orig > libtool sed 's?-blibpath:.*$?-blibpath:/opt/freeware/lib/pthread:/opt/freeware/lib64:/opt/freeware/lib:/usr/lib"?' libtool.orig > libtool chmod +x libtool # googleMOCK libtool # Primative hack to force -blibpath in libtool to give precedence to pthread # Must also add -blibpath and -lgtest to libgmock.* to find the dep libgtest.a mv third_party/googletest/googlemock/libtool third_party/googletest/googlemock/libtool.orig sed 's?\\\$wl-blibpath:.*$?-L../googletest/lib/.libs -lgtest \\$wl-blibpath:\\$progdir/../googletest/lib/.libs:/opt/freeware/lib/pthread/ppc64:/opt/freeware/lib64:/opt/freeware/lib:/usr/lib"?' third_party/googletest/googlemock/libtool.orig > third_party/googletest/googlemock/libtool.tmp1 # Also eliminate inclusion of flag -berok sed 's?^allow_undefined_flag=?allow_undefined_flag=" "\n# allow_undefined_flag=?' third_party/googletest/googlemock/libtool.tmp1 > third_party/googletest/googlemock/libtool chmod +x third_party/googletest/googlemock/libtool # googleTEST libtool # Primative hack to force -blibpath in libtool to give precedence to pthread mv third_party/googletest/googletest/libtool third_party/googletest/googletest/libtool.orig sed 's?-blibpath:.*$?-blibpath:/opt/freeware/lib/pthread/ppc64:/opt/freeware/lib64:/opt/freeware/lib:/usr/lib"?' third_party/googletest/googletest/libtool.orig > third_party/googletest/googletest/libtool.tmp1 sed 's?^allow_undefined_flag=?allow_undefined_flag=" "\n# allow_undefined_flag=?' third_party/googletest/googletest/libtool.tmp1 > third_party/googletest/googletest/libtool chmod +x third_party/googletest/googletest/libtool gmake -j8 cd java LIBPATH=`pwd`/../src/.libs:/opt/freeware/lib/pthread:/opt/freeware/lib ../src/protoc --java_out=core/src/main/java -I../src ../src/google/protobuf/descriptor.proto mkdir classes /sdk/bin/javac $extra_java_flags -d classes core/src/main/java/com/google/protobuf/*.java # Is the Java manifest still needed ? sed -e 's/@VERSION@/%version/' < %{SOURCE5} > manifest.txt /sdk/bin/jar cfm %{name}-java-%{version}.jar manifest.txt -C classes com cd .. cp -r python python3 cd python3 LIBPATH=`pwd`/../src/.libs:/opt/freeware/lib/pthread:/opt/freeware/lib %{python_major} setup.py build cd .. export LIBPATH=`pwd`/src/.libs:`pwd`/third_party/googletest/googlemock/lib/.libs/:`pwd`/third_party/googletest/googletest/lib/.libs/:/opt/freeware/lib/pthread:/opt/freeware/lib64:/opt/freeware/lib if [ "%{dotests}" == 1 ] then ( gmake -k check || true ) slibclean fi # Building 32 bit version cd ../32bit export CC="gcc -maix32 -D_LARGE_FILES -pthread -O2" export CXX="g++ -maix32 -D_LARGE_FILES -pthread -O2" export OBJECT_MODE=32 export CFLAGS="-fPIC -I`pwd`/include -I/opt/freeware/include -I/usr/include" export CXXFLAGS="-fPIC -I`pwd`/include -I/opt/freeware/include -I/usr/include" export CPPFLAGS="-I`pwd`/include -I/opt/freeware/include -I/usr/include" export LDFLAGS="-Wl,-bbigtoc -L%{_libdir}/pthread -lcrypt" export LIBPATH=%{_builddir}/%{name}-%{version}/src/.libs:/opt/freeware/lib/pthread:/opt/freeware/lib # The configure file has to be generated using autoreconf ./autogen.sh ./configure \ --prefix=%{_prefix} \ --libdir=%{_libdir} \ --host=%{buildhost} \ --target=%{buildhost} \ --build=%{buildhost} \ --disable-static # The -blibpath is required because libtool is preceeding pthread g++ libs # with non-pthread g++ libs in -blibpath # Primative hack to force -blibbpath in libtool to give precedence to pthread # There may be a libtool var/option to do this, but the main default library # directory /opt/freeware/lib was always first and the libstdc++.a symlink # there is non-pthread mv libtool libtool.orig sed 's?-blibpath:.*$?-blibpath:/opt/freeware/lib/pthread:/opt/freeware/lib:/usr/lib"?' libtool.orig > libtool chmod +x libtool # googleMOCK libtool # Primative hack to force -blibpath in libtool to give precedence to pthread # Must also add -blibpath and -lgtest to libgmock.* to find the dep libgtest.a mv third_party/googletest/googlemock/libtool third_party/googletest/googlemock/libtool.orig sed 's?\\\$wl-blibpath:.*$?-L../googletest/lib/.libs -lgtest \\$wl-blibpath:\\$progdir/../googletest/lib/.libs:/opt/freeware/lib/pthread:/opt/freeware/lib:/usr/lib"?' third_party/googletest/googlemock/libtool.orig > third_party/googletest/googlemock/libtool.tmp1 # Also eliminate inclusion of flag -berok sed 's?^allow_undefined_flag=?allow_undefined_flag=" "\n# allow_undefined_flag=?' third_party/googletest/googlemock/libtool.tmp1 > third_party/googletest/googlemock/libtool chmod +x third_party/googletest/googlemock/libtool # googleTEST libtool # Primative hack to force -blibpath in libtool to give precedence to pthread mv third_party/googletest/googletest/libtool third_party/googletest/googletest/libtool.orig sed 's?-blibpath:.*$?-blibpath:/opt/freeware/lib/pthread:/opt/freeware/lib:/usr/lib"?' third_party/googletest/googletest/libtool.orig > third_party/googletest/googletest/libtool.tmp1 sed 's?^allow_undefined_flag=?allow_undefined_flag=" "\n# allow_undefined_flag=?' third_party/googletest/googletest/libtool.tmp1 > third_party/googletest/googletest/libtool chmod +x third_party/googletest/googletest/libtool gmake -j8 cd java LIBPATH=`pwd`/../src/.libs:/opt/freeware/lib/pthread:/opt/freeware/lib ../src/protoc --java_out=core/src/main/java -I../src ../src/google/protobuf/descriptor.proto mkdir classes /sdk/bin/javac $extra_java_flags -d classes core/src/main/java/com/google/protobuf/*.java # Is the Java manifest still needed ? sed -e 's/@VERSION@/%version/' < %{SOURCE5} > manifest.txt /sdk/bin/jar cfm %{name}-java-%{version}.jar manifest.txt -C classes com cd .. cp -r python python3 #cd python3 #LIBPATH=`pwd`/../src/.libs:/opt/freeware/lib/pthread:/opt/freeware/lib /opt/freeware/libexec/python3.9_32 setup.py build #cd .. export LIBPATH=`pwd`/src/.libs:`pwd`/third_party/googletest/googlemock/lib/.libs/:`pwd`/third_party/googletest/googletest/lib/.libs/:/opt/freeware/lib/pthread:/opt/freeware/lib if [ "%{dotests}" == 1 ] then ( gmake -k check || true ) slibclean fi %install echo "RPM_BUILD_ROOT: $RPM_BUILD_ROOT" [ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf $RPM_BUILD_ROOT #Install 32bit cd 32bit make DESTDIR=$RPM_BUILD_ROOT install prefix=%{prefix} mv $RPM_BUILD_ROOT%{prefix}/bin/powerpc-ibm-aix7.1.0.0-protoc $RPM_BUILD_ROOT%{prefix}/bin/protoc_32 # no need for .la files rm %{buildroot}%{_libdir}/*.la # python3 #cd python3 #LIBPATH=`pwd`/../src/.libs:/opt/freeware/lib/pthread:/opt/freeware/lib /opt/freeware/libexec/python3.9_32 setup.py install \ # --prefix=%{_prefix} \ # --install-data=$RPM_BUILD_ROOT \ # --root $RPM_BUILD_ROOT \ # --record=INSTALLED_FILES #cd .. #Archive older libraries ( cd ${RPM_BUILD_ROOT}%{_libdir} cp %{SOURCE6} libprotobuf.so.22 /usr/bin/strip -X64 -e libprotobuf.so.22 /usr/bin/ar -X64 -q libprotobuf.a libprotobuf.so.22 cp %{SOURCE7} libprotobuf-lite.so.22 /usr/bin/strip -X64 -e libprotobuf-lite.so.22 /usr/bin/ar -X64 -q libprotobuf-lite.a libprotobuf-lite.so.22 cp %{SOURCE8} libprotoc.so.22 /usr/bin/strip -X64 -e libprotoc.so.22 /usr/bin/ar -X64 -q libprotoc.a libprotoc.so.22 ) #Install 64bit cd ../64bit make DESTDIR=$RPM_BUILD_ROOT install prefix=%{prefix} mv $RPM_BUILD_ROOT%{prefix}/bin/powerpc-ibm-aix7.1.0.0-protoc $RPM_BUILD_ROOT%{prefix}/bin/protoc_64 cd $RPM_BUILD_ROOT%{prefix}/bin ln -sf protoc_64 protoc cd - # no need for .la files rm %{buildroot}%{_libdir64}/*.la /usr/bin/ar -X64 -q %{buildroot}%{_libdir}/libprotobuf.a src/.libs/libprotobuf.so.30 /usr/bin/ar -X64 -q %{buildroot}%{_libdir}/libprotoc.a src/.libs/libprotoc.so.30 /usr/bin/ar -X64 -q %{buildroot}%{_libdir}/libprotobuf-lite.a src/.libs/libprotobuf-lite.so.30 cd $RPM_BUILD_ROOT%{prefix}/lib64 rm *.a %{__ln_s} ../lib/*.a . cd - # java cd java mkdir -p %{buildroot}%{javadir}/%{name} cp %{name}-java-%{version}.jar %{buildroot}%{javadir}/%{name}/%{name}-java-%{version}.jar %__ln_s %{name}-java-%{version}.jar %{buildroot}%{javadir}/%{name}/%{name}-java.jar %__ln_s %{name}-java-%{version}.jar %{buildroot}%{javadir}/%{name}/%{name}.jar cd .. # python3 cd python3 LIBPATH=`pwd`/../src/.libs:/opt/freeware/lib/pthread:/opt/freeware/lib %{python_major} setup.py install \ --prefix=%{_prefix} \ --install-data=$RPM_BUILD_ROOT \ --root $RPM_BUILD_ROOT \ --record=INSTALLED_FILES %clean # [ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT} %files %defattr(-, root, system,-) %doc 32bit/LICENSE %doc 32bit/CHANGES.txt 32bit/CONTRIBUTORS.txt 32bit/README.md %{_libdir64}/libprotobuf.a %{_libdir}/libprotobuf.a %files compiler %defattr(-, root, system,-) %doc 32bit/LICENSE %doc 32bit/CHANGES.txt 32bit/CONTRIBUTORS.txt 32bit/README.md %{_bindir}/protoc* %{_libdir64}/libprotoc.a %{_libdir}/libprotoc.a %files lite %defattr(-, root, system,-) %doc 32bit/LICENSE %doc 32bit/CHANGES.txt 32bit/CONTRIBUTORS.txt 32bit/README.md %{_libdir64}/libprotobuf-lite.a %{_libdir}/libprotobuf-lite.a %files devel %defattr(-,root,system,-) %doc 32bit/LICENSE %doc 32bit/CHANGES.txt 32bit/CONTRIBUTORS.txt 32bit/README.md %doc 32bit/examples/add_person.cc 32bit/examples/addressbook.proto %doc 32bit/examples/list_people.cc 32bit/examples/Makefile %doc 32bit/examples/README.md %{_includedir}/google/protobuf %{_libdir64}/pkgconfig/protobuf.pc %{_libdir}/pkgconfig/protobuf.pc # java %files java %defattr(-,root,system,-) %doc 32bit/LICENSE %doc 32bit/CHANGES.txt 32bit/CONTRIBUTORS.txt 32bit/README.md %doc 32bit/examples/AddPerson.java 32bit/examples/ListPeople.java %{javadir}/%{name}/protobuf* # python3 #%files -n python-%{name} -f python/INSTALLED_FILES %files python3 %defattr(-,root,system,-) %doc 32bit/LICENSE %doc 32bit/CHANGES.txt 32bit/CONTRIBUTORS.txt 32bit/python3/README.md %doc 32bit/examples/add_person.py 32bit/examples/list_people.py 32bit/examples/addressbook.proto %{python3_sitearch}/* %changelog * Mon Apr 03 2023 Ranjit Ranjan - 3.19.6-2 - Update to build with python 3.9. * Tue Dec 06 2022 Reshma V Kumar - 3.19.6-1 - Update to fix CVE-2022-3171,CVE-2022-1941 * Wed Mar 02 2022 Reshma V Kumar - 3.19.4-1 - Update to fix CVE-2021-22569 * Fri Nov 05 2021 Rishita Saha - 3.19.1-1 - Update to latest version * Thu Mar 19 2020 Ashwini Chandrappa - 3.11.4-1 - Initial port to AIX Toolbox - Updated to 3.11.4 * Fri Feb 08 2019 Michael Wilson - 3.6.1-1 - Update to version 3.6.1 - Largely inspired by Fedora 30 - Add option -pthread for c++ mutex/pthreads support, e.g. - export CXX="g++ -maix64 -pthread" - Add link with libatomic.a for 32 bit build for symbol __atomic_fetch_add_8 - Change LDFLAGS for %install to same as %build for pthread symbols __once_* - to find pthread/libstcc++.a before non-pthread version - -L:/opt/freeware/lib/pthread (a W/A for libtool issue) - Also add /opt/freeware/lib/pthread to head of -blibpath in libtool - so bin/protoc executes with pthread g++ libs - New java code requires use of Java7 javac (LPP Java7.sdk) - Change hard coded soname 8 to %{soname} for the AR commands * Thu Jun 7 2018 by Tony Reix 2.5.0-2 - Re-Port on AIX 6.1 - Add atomicops_internals_aix.h moved to AIX assembler - Fix 32bit/64bit management * Fri May 3 2013 by Bernard CAHEN 2.4.1-1 - Port on AIX 6.1