%define _libdir64 %{_prefix}/lib64 %define sorev 0 Name: libimagequant Version: 2.12.2 Release: 1 Summary: Palette quantization library Group: System Environment/Libraries License: GPLv3+ and MIT URL: https://github.com/ImageOptim/libimagequant Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz Patch0: %{name}-%{version}-aix.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot BuildRequires: make %description Small, portable C library for high-quality conversion of RGBA images to 8-bit indexed-color (palette) images. The library is available as 32-bit and 64-bit. %package devel Summary: Development files for %{name} Group: System Environment/Libraries Requires: %{name} = %{version}-%{release} %description devel The %{name}-devel package contains libraries and header files for developing applications that use %{name}. If you are compiling a 32-bit program, no special compiler options are needed. If you are compiling a 64-bit program, you have to compile and link your application with "xlc_r -q64" or "gcc -maix64". %prep %setup -q %patch0 # fake a as AIX5L V5.1 and XLC/C++ V7 doesn't have one cat > stdbool.h << EOF #ifndef stdbool_h_wrapper #define stdbool_h_wrapper typedef enum {false = 0, true = 1} bool; #endif EOF mkdir ../32bit mv * ../32bit mv ../32bit . mkdir 64bit cd 32bit && tar cf - . | (cd ../64bit ; tar xpf -) %build export CC="xlc_r -qlanglvl=stdc99" export PATH=/opt/freeware/bin:$PATH cd 64bit # first build the 64-bit version export OBJECT_MODE=64 export LDFLAGS="-L/opt/freeware/lib64 -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib64:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000" ./configure \ --prefix=%{_prefix} \ --libdir=%{_libdir64} \ --disable-sse \ CC="${CC}" CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" gmake %{?_smp_mflags} # create shared object CreateExportList -X64 %{name}.exp %{name}.a ${CC} -qmkshrobj %{name}.a -o %{name}.so.%{sorev} -bE:%{name}.exp -bernotok -lm rm -f lib%{name}.a %{name}.exp cat imagequant.pc.in | sed 's|PREFIX|%{_prefix}|g' | sed 's|prefix}/lib|prefix}/lib64|g' > imagequant.pc cd ../32bit # now build the 32-bit version export OBJECT_MODE=32 export LDFLAGS="-L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000" ./configure \ --prefix=%{_prefix} \ --disable-sse \ CC="${CC}" CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" gmake %{?_smp_mflags} # create shared object CreateExportList -X32 %{name}.exp %{name}.a ${CC} -qmkshrobj %{name}.a -o %{name}.so.%{sorev} -bE:%{name}.exp -bernotok -lm rm -f lib%{name}.a %{name}.exp cat imagequant.pc.in | sed 's|PREFIX|%{_prefix}|g' > imagequant.pc %install [ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT} mkdir -p ${RPM_BUILD_ROOT}%{_libdir} mkdir -p ${RPM_BUILD_ROOT}%{_libdir}/pkgconfig mkdir -p ${RPM_BUILD_ROOT}%{_libdir64} mkdir -p ${RPM_BUILD_ROOT}%{_libdir64}/pkgconfig mkdir -p ${RPM_BUILD_ROOT}%{_includedir} cp 32bit/libimagequant.so.0 ${RPM_BUILD_ROOT}%{_libdir} cp 64bit/libimagequant.so.0 ${RPM_BUILD_ROOT}%{_libdir64} cp 32bit/imagequant.pc ${RPM_BUILD_ROOT}%{_libdir}/pkgconfig cp 64bit/imagequant.pc ${RPM_BUILD_ROOT}%{_libdir64}/pkgconfig cp 32bit/libimagequant.h ${RPM_BUILD_ROOT}%{_includedir} /usr/bin/ar -X32 -rv ${RPM_BUILD_ROOT}%{_libdir}/libimagequant.a 32bit/libimagequant.so.0 /usr/bin/ar -X64 -q ${RPM_BUILD_ROOT}%{_libdir}/libimagequant.a 64bit/libimagequant.so.0 ( cd ${RPM_BUILD_ROOT} for dir in include lib lib64 do mkdir -p usr/${dir} cd usr/${dir} ln -sf ../..%{_prefix}/${dir}/* . cd - done ) %clean [ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT} %files %doc 32bit/COPYRIGHT %doc 32bit/README.md 32bit/CHANGELOG %{_libdir}/*.a %{_libdir}/*.so* %{_libdir64}/*.so* /usr/lib/*.a /usr/lib/*.so* /usr/lib64/*.so* %files devel %{_includedir}/* %{_libdir}/pkgconfig/imagequant.pc %{_libdir64}/pkgconfig/imagequant.pc /usr/include/* %changelog * Wed May 29 2019 Michael Perzl - 2.12.2-1 - first version for AIX V5.1 and higher