jwboyer / rpms / abc

Forked from rpms/abc 3 years ago
Clone
Blob Blame History Raw
# Python packaging notes:
# 1. Upstream does not yet support python 3, so we build for python 2 only.
# 2. The python build does not link against the library stored in _libdir,
#    because it has to be built differently.  Look for instances of
#    "#ifdef ABC_PYTHON_EMBED ... #endif" in the source code.  Hence, the
#    python2 subpackage is indepedent of the -libs subpackage.

# Upstream doesn't make releases.  We have to check the code out of Mercurial.
%global owner   alanmi
%global commit  9d6335cdb362
%global hgdate  20141130

Name:           abc
Version:        1.01
Release:        2.hg%{hgdate}%{?dist}
Summary:        Sequential logic synthesis and formal verification

# This would be MIT, but we link with readline
License:        GPLv3+
URL:            http://www.eecs.berkeley.edu/~alanmi/abc/abc.htm
Source0:        https://bitbucket.org/%{owner}/%{name}/get/%{commit}.zip
# Man page created by Jerry James using upstream text; hence, it is covered by
# the same copyright and license as the code.
Source1:        %{name}.1
# Fedora-specific patch: do not use the bundled libraries
Patch0:         %{name}-bundlelib.patch
# Fedora-specific patch: build a shared library instead of a static library
Patch1:         %{name}-sharedlib.patch

BuildRequires:  bzip2-devel
BuildRequires:  python2-devel
BuildRequires:  readline-devel
BuildRequires:  swig
BuildRequires:  zlib-devel

Requires:       %{name}-libs%{?_isa} = %{version}-%{release}

%description
ABC is a growing software system for synthesis and verification of
binary sequential logic circuits appearing in synchronous hardware
designs.  ABC combines scalable logic optimization based on And-Inverter
Graphs (AIGs), optimal-delay DAG-based technology mapping for look-up
tables and standard cells, and innovative algorithms for sequential
synthesis and verification.

ABC provides an experimental implementation of these algorithms and a
programming environment for building similar applications.  Future
development will focus on improving the algorithms and making most of
the packages stand-alone.  This will allow the user to customize ABC for
their needs as if it were a toolbox rather than a complete tool.

%package libs
Summary:        Library for sequential synthesis and verification

%description libs
This package contains the core functionality of ABC as a shared library.

%package devel
Summary:        Headers and libraries for developing with ABC
Requires:       %{name}-libs%{?_isa} = %{version}-%{release}

%description devel
Headers and libraries for developing applications that use ABC.

%package python2
Summary:        Python 2 interface to ABC

%description python2
Python 2 interface to ABC

%prep
%setup -q -c
pushd %{owner}-%{name}-%{commit}
%patch0
%patch1

# Do not use the bundled libraries
rm -fr lib src/misc/{bzlib,zlib} src/sat/bsat2

# Fix end of line encodings
for fil in readme.md readmeaig; do
  sed -i.orig 's/\r//' ${fil}
  touch -r ${fil}.orig ${fil}
  rm -f ${fil}.orig
done
popd

# Prepare for the python 2 build
cp -a %{owner}-%{name}-%{commit} %{name}-python2

# Set the version number in the man page
sed 's/@VERSION@/%{version} (%{hgdate})/' %{SOURCE1} > %{name}.1
touch -r %{SOURCE1} %{name}.1

%build
# Build the library and binary
pushd %{owner}-%{name}-%{commit}
make %{?_smp_mflags} libabc.so OPTFLAGS="%{optflags} -fPIC -DNDEBUG" \
  LD="g++ $RPM_LD_FLAGS"
g++ src/base/main/main.o -o %{name} -L. -labc
popd

# Build for python 2
pushd %{name}-python2
make libabc.a %{?_smp_mflags} OPTFLAGS="%{optflags} -fPIC -DNDEBUG" \
  LD="g++ $RPM_LD_FLAGS" ABC_PYTHON="%{__python2}"
cd src/python
%{__python2} setup.py build
popd

%install
pushd %{owner}-%{name}-%{commit}
# Install the library
mkdir -p %{buildroot}%{_libdir}
install -p -m 0755 lib%{name}.so.0.0.0 %{buildroot}%{_libdir}
ln -s lib%{name}.so.0.0.0 %{buildroot}%{_libdir}/lib%{name}.so.0
ln -s lib%{name}.so.0 %{buildroot}%{_libdir}/lib%{name}.so

# Install the header files
mkdir -p %{buildroot}%{_includedir}/%{name}
for fil in $(find -O3 src -name \*.h); do
  dir=$(dirname $fil | cut -d/ -f3-)
  mkdir -p %{buildroot}%{_includedir}/%{name}/$dir
  install -p -m 0644 $fil %{buildroot}%{_includedir}/%{name}/$dir
done

# Install the binary
mkdir -p %{buildroot}%{_bindir}
install -p -m 0755 %{name} %{buildroot}%{_bindir}
popd

# Install the man page
mkdir -p %{buildroot}%{_mandir}/man1
install -p -m 0644 %{name}.1 %{buildroot}%{_mandir}/man1

# Install the python2 interface
pushd %{name}-python2
cd src/python
%{__python2} setup.py install -O1 --skip-build --root %{buildroot}
mkdir %{buildroot}%{python2_sitearch}/%{name}
mv %{buildroot}%{python2_sitearch}/*.py* %{buildroot}%{python2_sitearch}/*.so \
   %{buildroot}%{python2_sitearch}/%{name}
chmod 0755 %{buildroot}%{python2_sitearch}/%{name}/*.so
popd

%post libs -p /sbin/ldconfig

%postun libs -p /sbin/ldconfig

%files
%doc %{owner}-%{name}-%{commit}/readme.md %{owner}-%{name}-%{commit}/readmeaig
%{_bindir}/%{name}
%{_mandir}/man1/%{name}*

%files libs
%license %{owner}-%{name}-%{commit}/copyright.txt
%{_libdir}/lib%{name}.so.*

%files devel
%{_includedir}/%{name}/
%{_libdir}/lib%{name}.so

%files python2
%license %{owner}-%{name}-%{commit}/copyright.txt
%{python2_sitearch}/*

%changelog
* Wed Dec  3 2014 Jerry James <loganjerry@gmail.com> - 1.01-2.hg20141130
- Drop unnecessary jquery Provides
- Fix file permissions

* Mon Dec  1 2014 Jerry James <loganjerry@gmail.com> - 1.01-1.hg20141130
- Initial RPM