%define name physfs
%define version 2.0.2
%define release 1%{?_dist_release}

Summary: Library to provide abstract access to various archives
Name: %{name}
Version: %{version}
Release: %{release}
Source0: http://icculus.org/physfs/downloads/%{name}-%{version}.tar.gz
Patch0: do_not_link_against_curses.diff
Patch1: remove_unused_variable.diff


License: BSD
Group: System Environment/Libraries
URL: http://icculus.org/physfs/

BuildRequires: zlib-devel, readline-devel, doxygen
BuildRequires: cmake
BuildRequires: wxGTK-devel
BuildRoot: %{_tmppath}/%{name}-%{version}-root

%description
 PhysicsFS is a library to provide abstract access to various archives. 
It is intended for use in video games, and the design was somewhat 
inspired by Quake 3's file subsystem. 
The programmer defines a "write directory" on the physical filesystem. 
No file writing done through the PhysicsFS API can leave that write directory, 
for security. 
For example, an embedded scripting language cannot write outside 
of this path if it uses PhysFS for all of its I/O, which means 
that untrusted scripts can run more safely. 
Symbolic links can be disabled as well, for added safety. 
For file reading, the programmer lists directories and archives 
that form a "search path". 
Once the search path is defined, it becomes a single, 
transparent hierarchical filesystem. 
This makes for easy access to ZIP files in the same way 
as you access a file directly on the disk, 
and it makes it easy to ship a new archive 
that will override a previous archive on a per-file basis. 
Finally, PhysicsFS gives you platform-abstracted means to determine 
if CD-ROMs are available, the user's home directory, 
where in the real filesystem your program is running, etc.

%package devel
Summary: Development libraries and headers for physfs
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}

%description devel
This package contains the libraries and headers necessary for developing
packages with physfs functionality.


%prep
%setup -q
%patch0 -p1
%patch1 -p1

%build
%ifarch x86_64
mv CMakeLists.txt CMakeLists.txt.orig
cat CMakeLists.txt.orig \
	| sed "s/LIBRARY DESTINATION lib/LIBRARY DESTINATION %{_lib}/" \
	| sed "s/ARCHIVE DESTINATION lib/ARCHIVE DESTINATION %{_lib}/" \
	> CMakeLists.txt
%endif
cmake -D CMAKE_INSTALL_PREFIX=%{_prefix} .
make %{?_smp_mflags}
doxygen

%install
%{__rm} -rf ${RPM_BUILD_ROOT}
make DESTDIR=${RPM_BUILD_ROOT} install
#%{__rm} -rf ${RPM_BUILD_ROOT}%{_libdir}/*.la
mkdir -p $RPM_BUILD_ROOT%{_mandir}/man3
install -m0644 docs/man/man3/* $RPM_BUILD_ROOT%{_mandir}/man3

# Handle man page conflicts (bz #183705) from Fedora
mv $RPM_BUILD_ROOT%{_mandir}/man3/author.3 \
    $RPM_BUILD_ROOT%{_mandir}/man3/physfs-author.3
mv $RPM_BUILD_ROOT%{_mandir}/man3/description.3 \
    $RPM_BUILD_ROOT%{_mandir}/man3/physfs-description.3
mv $RPM_BUILD_ROOT%{_mandir}/man3/extension.3 \
    $RPM_BUILD_ROOT%{_mandir}/man3/physfs-extension.3
mv $RPM_BUILD_ROOT%{_mandir}/man3/major.3 \
    $RPM_BUILD_ROOT%{_mandir}/man3/physfs-major.3
mv $RPM_BUILD_ROOT%{_mandir}/man3/minor.3 \
    $RPM_BUILD_ROOT%{_mandir}/man3/physfs-minor.3
mv $RPM_BUILD_ROOT%{_mandir}/man3/patch.3 \
    $RPM_BUILD_ROOT%{_mandir}/man3/physfs-patch.3
mv $RPM_BUILD_ROOT%{_mandir}/man3/url.3 \
    $RPM_BUILD_ROOT%{_mandir}/man3/physfs-url.3

%clean
%{__rm} -rf ${RPM_BUILD_ROOT}

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%defattr(-,root,root,-)
%doc CHANGELOG.txt CREDITS.txt LICENSE.txt TODO.txt
%{_libdir}/*.so.*
%{_bindir}/test_physfs
%{_bindir}/wxtest_physfs

%files devel
%defattr(-,root,root,-)
%doc docs/html/ docs/latex/
%{_includedir}/physfs.h
%{_libdir}/*.a
#%{_libdir}/*.la
%{_libdir}/*.so
%{_mandir}/man3/*

%changelog
* Wed Jul 11 2012 Toshiharu Kudoh <toshi.kd2@gmail.com> - 2.0.2-1
- new upstream release
- added Patch0,1 from Debian sid
- added BuildRequires: wxGTK-devel

* Thu Oct 09 2008 Shu KONNO <owa@bg.wakwak.com> 1.1.1-1vl5
- applied new versioning policy

* Wed Jan 03 2008 Shu KONNO <owa@bg.wakwak.com> 1.1.1-0vl3
- updated CMakeLists.txt for lib64

* Fri Sep 07 2007 Atsushi SHICHI <ats777@gmail.com> 1.1.1-0vl2
- remove "-D PHYSFS_BUILD_TEST:BOOL=OFF" from cmake option.
- add test_physfs to %%files.

* Wed Sep 06 2007 Atsushi SHICHI <ats777@gmail.com> 1.1.1-0vl1
- new upstream release.
- add "BuildRequires: cmake".
- to use cmake instead of %%configure.
- update %%files.
- temporarily remove test_physfs from %%files.
- remove libphysfs.la from %%files devel.

* Mon Sep 3 2007 Munehiro Yamamoto <myamamoto@g.math.s.chiba-u.ac.jp> 1.1.0-0vl1
- initial build for Vine Linux 4.1

* Mon Oct 17 2005 Munehiro Yamamoto <myamamoto@g.math.s.chiba-u.ac.jp> 1.1.0-0vlmp2
- change Group: System Environment/Libraries

* Fri Jun 24 2005 Munehiro Yamamoto <myamamoto@g.math.s.chiba-u.ac.jp> 1.0.0-0vlmp1
- initial build for Vine Linux 3.2

# end of file
