RPM TREE

First you need to get a rpm working directory.

set your rpm topdir in your rpmmacros file

ludo@idefix:~ % echo "%_topdir /home/ludo/rpm" > ~/.rpmmacros

create your rpm directories tree

ludo@idefix:~ % for dir in rpm rpm/BUILD rpm/SPECS rpm/SRPMS rpm/SOURCES rpm/RPMS rpm/RPMS/i386
for> do
for>  mkdir $dir
for> done
ludo@idefix:~ %

SPEC FILE

our spec file

ludo@idefix:.../common/s2a/api_tools/s2a_bin % cat packages/rpm/s2a.spec
Vendor:       Ludovic Francois
Name:         s2a
Release:      3
License:      GPL (cf http://www.fsf.org)
Group:        unsorted
Provides:     s2a
Packager:     lfrancois@datadirectnet.com
Version:      0.0.1
Summary:      Monitoring and administration tools for DataDirect Networks s2a
Source:       s2a-0.0.1.tar.gz 
BuildRoot:    /var/tmp/%{name}-buildroot
%description
Monitoring and administration tools for DataDirect Networks s2a appliances.
This tools supports:
  - s2a6000
  - s2a3000
  - s2a8500
  - s2a9500
You will find  the main binary named s2a, with  this binary you could
get a remote access on the storage system and make all cli monitoring
and administration tasks from your unix command line.
%prep
%setup
%build
./configure --prefix=/usr --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --sysconfdir=/etc/s2a
make
%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
install -d -m 755               ${RPM_BUILD_ROOT}/etc/cron.d/
install -m 644 debian/cron.d    ${RPM_BUILD_ROOT}/etc/cron.d/s2a
install -d -m 755               ${RPM_BUILD_ROOT}/usr/share/doc/s2a/
install -m 644 ChangeLog        ${RPM_BUILD_ROOT}/usr/share/doc/s2a/ChangeLog
install -m 644 README           ${RPM_BUILD_ROOT}/usr/share/doc/s2a/README
install -m 644 TODO             ${RPM_BUILD_ROOT}/usr/share/doc/s2a/TODO
install -m 644 src/scripts/README.ddn_disk_rebuild  ${RPM_BUILD_ROOT}/usr/share/doc/s2a/README.ddn_disk_rebuild
install -m 644 src/scripts/README.ddn_rrdtool       ${RPM_BUILD_ROOT}/usr/share/doc/s2a/README.ddn_rrdtool
install -m 644 COPYING          ${RPM_BUILD_ROOT}/usr/share/doc/s2a/copyright
%files
%defattr(-,root,root)
/etc/s2a/ddn_uptodate/ddn_uptodate_default.cfg
/etc/s2a/ddn_uptodate/ddn_uptodate_sgi.cfg
/etc/cron.d/s2a
/usr/bin/s2a
/usr/bin/ddn_tree
/usr/bin/ddn_disk_rebuild
/usr/bin/ddn_rrdtool
/usr/bin/ddn_diff
/usr/bin/ddn_dump
/usr/bin/ddn_restore
/usr/bin/ddn_richmedia
/usr/bin/ddn_uptodate
/usr/bin/ddn_temperature
/usr/share/s2a/images/ddn_logo.gif
/usr/share/s2a/images/DDNlogo.jpg
/usr/share/s2a/images/DDNtoasterview-logo.png
/usr/share/s2a/images/splash_s2a_bin.jpg
/usr/share/s2a/images/splash_s2a_bin.png
/usr/share/man/man1/s2a.1.gz
/usr/share/doc/s2a/README
/usr/share/doc/s2a/TODO
/usr/share/doc/s2a/README.ddn_disk_rebuild
/usr/share/doc/s2a/README.ddn_rrdtool
/usr/share/doc/s2a/copyright
/usr/share/doc/s2a/ChangeLog
ludo@idefix:.../common/s2a/api_tools/s2a_bin %

Makefile.am

rule in my Makefile.am

# Build source and binary rpms. For rpm-3.0 and above, the ~/.rpmmacros
# must contain the following line:
# %_topdir /home/ludo/rpm
# cd /home/ludo/rpm ; mkdir -p SOURCES BUILD RPMS/i386 SPECS SRPMS

rpm:
    $(MAKE) distdir ; \
    mv $(PACKAGE)-$(VERSION) $(PACKAGE)-0.0.1 ; \
    tar cvzf $(PACKAGE)-0.0.1.tar.gz $(PACKAGE)-0.0.1 ; \
    $(RM) -rf $(PACKAGE)-0.0.1 ; \
    RPM_TOPDIR=`rpm --showrc | perl -n -e 'print if(s/.*_topdir\s+(.*)/$$1/)'` ; \
    cp $(srcdir)/packages/rpm/s2a.spec $$RPM_TOPDIR/SPECS ; \
    cp $(PACKAGE)-0.0.1.tar.gz $$RPM_TOPDIR/SOURCES/ ; \
    rpmbuild -ba --clean --rmsource $$RPM_TOPDIR/SPECS/$(PACKAGE).spec ; \
    mv $$RPM_TOPDIR/RPMS/i386/$(PACKAGE)-*.rpm packages/rpm ; \
    mv $$RPM_TOPDIR/SRPMS/$(PACKAGE)-*.src.rpm packages/rpm

command to launch

ludo@idefix:.../common/s2a/api_tools/s2a_bin % make rpm
[...]
Wrote: /home/ludo/rpm/SRPMS/s2a-0.0.1-3.src.rpm
Wrote: /home/ludo/rpm/RPMS/i386/s2a-0.0.1-3.i386.rpm
Executing(--clean): /bin/sh -e /var/tmp/rpm-tmp.96254
+ umask 022
+ cd /home/ludo/rpm/BUILD
+ rm -rf s2a-0.0.1
+ exit 0
ludo@idefix:.../common/s2a/api_tools/s2a_bin %

results

ludo@idefix:.../common/s2a/api_tools/s2a_bin % find | egrep "s2a.*rpm"
./packages/rpm/s2a-0.0.1-3.i386.rpm
./packages/rpm/s2a-0.0.1-3.src.rpm
ludo@idefix:.../common/s2a/api_tools/s2a_bin %

Errors

check-files

Checking for unpackaged file(s): /usr/lib/rpm/check-files /var/tmp/s2a-buildroot
error: Installed (but unpackaged) file(s) found:
   /usr/bin/s2a

if you have some files you don't want in the BuildRoot add in your spec file at the files section the define below:

%files
%defattr(-,root,root)
%define _unpackaged_files_terminate_build 0

Or it's maybe the same problem I got, you need just to clean your buildroot in your spec file:

%install
rm -rf $RPM_BUILD_ROOT