Name:           ipcmd
Version:        0.1.1
Release:        5%{?dist}
Summary:        Command-line interface to SysV semaphores and message queues

Group:          Applications/System
License:        BSD
URL:            https://github.com/nathanweeks/ipcmd/
Source0:        https://github.com/nathanweeks/ipcmd/archive/%{version}/%{name}-%{version}.tar.gz
BuildRoot:      %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

BuildRequires:  gcc
%if 0%{?suse_version}
BuildRequires:  posix_cc
%endif

%description
ipcmd exposes the XSI (SysV) semaphore and message queue APIs through a 
simple command-line interface, enabling scriptable inter-process 
communication and synchronization. It can be used to:

- Serialize the execution of certain commands during a parallel make 
  (e.g., the "ar" command when creating static libraries)

- Limit the number of concurrently executing processes

- Add process synchronization to scripts (e.g., barriers) and prevent 
  concurrent access to critical sections

- Prototype or debug applications that use SysV semaphores or message queues 


%prep
%setup -q
# 'for' loop initial declarations are only allowed in C99 mode
sed -e 's/^CC/#CC/g' -e 's/^CFLAGS.*/CFLAGS += -std=c99/g' -i Makefile


%build
# Makefile wants this directory already here
# https://github.com/nathanweeks/ipcmd/pull/1
install -d bin

# does not have a configure script, but we want to bring in RH defaults
echo '#!/bin/sh' > configure
chmod +x configure
%configure
make %{?_smp_mflags}


%check
make check


%install
rm -fR %{buildroot}
# no "make install" target
install -d %{buildroot}%{_bindir}
install -d %{buildroot}%{_mandir}/man1
install -m 755 bin/ipcmd %{buildroot}%{_bindir}/ipcmd
install -m 644 man/man1/ipcmd.1 %{buildroot}%{_mandir}/man1/ipcmd.1
# remove executable bits from example scripts
chmod -x examples/*.sh examples/*.ksh


%clean
rm -fR %{buildroot}


%files
%defattr(-,root,root)
%doc CHANGES LICENSE README TODO
%doc examples/*.sh examples/*.ksh
%{_bindir}/*
%{_mandir}/man1/*


%changelog
* Thu Aug 22 2019 Japheth Cleaver <cleaver@terabithia.org> - 0.1.1-5
- Add BuildRequires: gcc everywhere; add posix_cc on SUSE
- Remove executable bit from documentation examples
- Move homepage URL to GitHub
- Fix rpmlint warnings
- Add TODO file

* Mon Aug 12 2019 Japheth Cleaver <cleaver@terabithia.org> - 0.1.1-2
- Move source URL to GitHub

* Tue Apr 07 2015 Japheth Cleaver <cleaver@terabithia.org> - 0.1.1-1
- new package