Blob Blame History Raw
# Use our own configure in order to prevent --target
%global pccconfigure \
 export CFLAGS="%{optflags}"; \
 export CXXFLAGS="%{optflags}"; \
 export FFLAGS="%{optflags} -I%{_fmoddir}"; \
 ./configure --program-prefix= --prefix=%{_prefix} --exec-prefix=%{_prefix} --bindir=%{_bindir} --sbindir=%{_sbindir} --sysconfdir=%{_sysconfdir} --datadir=%{_datadir} --includedir=%{_includedir} --libdir=%{_libdir} --libexecdir=%{_libexecdir} --localstatedir=%{_localstatedir} --sharedstatedir=%{_sharedstatedir} --mandir=%{_mandir} --infodir=%{_infodir}

# Used CVS snapshot
%global snapshot 100413

Name:		pcc
Version:	0.9.9
Release:	0.4.%{snapshot}cvs%{?dist}
Summary:	The Portable C Compiler
Group:		Development/Languages
License:	BSD with advertising and BSD and ISC 
URL:		http://pcc.ludd.ltu.se/
Source0:	http://pcc.ludd.ltu.se/ftp/pub/pcc/pcc-%{snapshot}.tgz
Source1:	http://pcc.ludd.ltu.se/ftp/pub/pcc-libs/pcc-libs-%{snapshot}.tgz
# Patch to disable the use of -g on pcc-libs-090805/csu/linux/crtbegin.c which is partly assembler code
Patch0:		pcc-090808-optflags.patch

BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
# Currently only x86 and x86_64 supported both in ppc and ppc-libs
ExclusiveArch:	%{ix86} x86_64
BuildRequires:	bison flex
Requires:	glibc-devel

%description
The compiler is based on the original Portable C Compiler by Stephen C.
Johnson, written in the late 70's. Even though much of the compiler has been
rewritten, some of the basics still remain.
PCC debuted in Unix Version 7 and replaced the DMR compiler (Dennis Ritchie's
original C compiler) in both System V and the BSD 4.x releases. Some history
about pcc is in the A History of UNIX before Berkeley: UNIX Evolution:
1975-1984 and in the Evolution of C.

About 50% of the frontend code and 80% of the backend code has been rewritten.
Most stuff is written by Anders Magnusson, with the exception of the data-flow
analysis part and the SSA conversion code which is written by Peter A Jonsson,
and the Mips port that were written as part of a project by undergraduate
students at LuleƄ University of Technology (LTU).

%prep
%setup -q -n pcc-%{snapshot} -a1
# Get rid of the default optimization flag
find . -name Makefile.in |xargs sed -i 's| -O | |g'
# Rename the libs directory for the patch to work
mv pcc-libs-%{snapshot} pcc-libs
# Apply patch
%patch0 -p1


%build
export CFLAGS_NODEBUG=`echo %{optflags}|sed "s|-g||g"`
# Set architecture directory needed for include flag
%ifarch x86_64
export archdir=amd64
%endif
%ifarch %{ix86}
export archdir=i386
%endif

# First, build the library.
cd pcc-libs
%pccconfigure
make CFLAGS="-I${archdir} -Ilinux -I. %{optflags}" CFLAGS_NODEBUG="-I${archdir} -Ilinux -I. $CFLAGS_NODEBUG" 
#%{?_smp_mflags}
cd ..
# Then, build the compiler
%pccconfigure --with-assembler=%{_bindir}/as --with-linker=%{_bindir}/ld \
 --with-libdir=%{_libdir} --with-incdir=%{_includedir}
make 
#%{?_smp_mflags}


%install
rm -rf %{buildroot}
# Install the libraries
make -C pcc-libs install DESTDIR=%{buildroot} strip=no
# Install the compiler
make install DESTDIR=%{buildroot} strip=no
# Fix man file perms
chmod 644 %{buildroot}%{_mandir}/man1/*
# Rename cpp man page
mv  %{buildroot}%{_mandir}/man1/{,pcc-}cpp.1
# Directory for pcc-specific include files
mkdir -p %{buildroot}%{_includedir}/pcc


%clean
rm -rf %{buildroot}


%files
%defattr(-,root,root,-)
%{_bindir}/pcc
%{_libdir}/pcc/
%{_includedir}/pcc/
%{_libexecdir}/cpp
%{_libexecdir}/ccom
%{_mandir}/man1/ccom.1.*
%{_mandir}/man1/pcc-cpp.1.*
%{_mandir}/man1/pcc.1.*

%changelog
* Wed Apr 14 2010 Jussi Lehtola <jussilehtola@fedoraproject.org> - 0.9.9-0.4.100413cvs
- Update to 20100413.

* Sun Aug 16 2009 Jussi Lehtola <jussilehtola@fedoraproject.org> - 0.9.9-0.4.090816cvs
- Update to 20090816, adding support for x86_64.
- Use own configure macro to disable cross compilation.

* Thu Aug 13 2009 Jussi Lehtola <jussilehtola@fedoraproject.org> - 0.9.9-0.3.090813cvs
- Removed unneeded BR: byacc.
- Update to 20090813.

* Tue Aug 11 2009 Jussi Lehtola <jussilehtola@fedoraproject.org> - 0.9.9-0.2.090811cvs
- Spec file cleanups.
- Update to 20090811.

* Sun Aug 09 2009 Jussi Lehtola <jussilehtola@fedoraproject.org> - 0.9.9-0.2.090809cvs
- Changed --with-libdir to %%{_libdir} to make pcc use the glibc version of crt0.o by suggestion of upstream.
- Update to 20090809.

* Sat Aug 08 2009 Jussi Lehtola <jussilehtola@fedoraproject.org> - 0.9.9-0.1.090808cvs
- First release.