## ----------------------------------------------------------------------------
##                                                                           --
##  Filename        : $Source: /cvsroot/gnade/gnade/rpm/Makefile,v $
##  Description     : Build RPMS from the distribution                       --
##  Author          : Michael Erdmann <Michael.Erdmann@snafu.de>             --
##  Created On      : 1-May-2002                                             --
##  Last Modified By: $Author: merdmann $                                    --
##  Last Modified On: $Date: 2004/04/03 20:07:05 $                           --
##  Version         : $Revision: 1.13 $
##  Status          : $State: Exp $
##                                                                           --
##  Copyright (C) 2002,2003                                                  --
##                                                                           --
##  GNADE is copyrighted by the persons and institutions enumerated in the   --
##  AUTHORS file. This file is located in the root directory of the          --
##  GNADE distribution.                                                      --
##                                                                           --
##  GNADE is free software;  you can redistribute it  and/or modify it under  --
##  terms of the  GNU General Public License as published  by the Free Soft- --
##  ware  Foundation;  either version 2,  or (at your option) any later ver- --
##  sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
##  OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
##  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
##  for  more details.  You should have  received  a copy of the GNU General --
##  Public License  distributed with GNAT;  see file COPYING.  If not, write --
##  to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
##  MA 02111-1307, USA.                                                      --
##                                                                           --
##  As a special exception,  if other files  instantiate  generics from      --
##  GNADE Ada units, or you link GNADE Ada units or libraries with other       --
##  files  to produce an executable, these  units or libraries do not by     --
##  itself cause the resulting  executable  to  be covered  by the  GNU      --
##  General  Public  License.  This exception does not however invalidate    --
##  any other reasons why  the executable file  might be covered by the      --
##  GNU Public License.                                                      --
##                                                                           --
##  This package is  implemented to work with GNAT, the GNU Ada compiler.    --
##                                                                           --
##  Contact                                                                  --
##  =======                                                                  --
##  Error reports shall be handled via http://gnade.sourceforge.net          --
##  Features and ideas via: gnade-develop@lists.sourceforge.net              --
##                                                                           --
##  Author contact:                                                          --
##               purl:/net/michael.erdmann                                   --
##                                                                           --
## ----------------------------------------------------------------------------
##
##  Functional Description
##  ======================
##
##  Restrictions
##  ============
##  None
##
##  References
##  ==========
##  None
##
## 
##  
include ../make.conf

DIST=$(exportdir)/gnade-src-$(VERSION).tar.gz
STAGE=a
##
## Where the RPM is loacted on your system. You may have to adopt this 
## to your system.
##
RPM=/usr/src/packages

RPMSRC=$(RPM)/SOURCES/gnade.tar.gz
RPMS=$(RPM)/RPMS/$(ARCH)
SRPMS=$(RPM)/SRPMS

M4FLAGS= --define=VERSION=$(VERSION) \
	 --define=NATIVE_BINDINGS="$(NATIVE_BINDINGS)" \
	 --define=BUILD=`cat .version` 
##
## Per default do nothing
##
all:

##
## In case of a distribution we build the list of files to be included.
##
dist:
	@if test `id -g` = "0" ; then \
	   $(MAKE) rpm ;\
	else		\
	   echo "*** Warining, RPM needs to be build as user root, step skiped ****" ; \
	fi

##
## Build the rpms
##
rpm:	$(RPMSRC)
	rm -rf *.rpm
	m4 $(M4FLAGS) gnade.m4 > gnade.spec
	( export PATH=/usr/local/bin:/usr/gnat/bin:$$PATH && \
	  rpmbuild -b$(STAGE) --target=$(ARCH) gnade.spec ) >build.log 2>build.error
	mv $(RPMS)/gnade-$(VERSION)*.rpm $(exportdir)
	mv $(SRPMS)/gnade-$(VERSION)*.rpm $(exportdir)

$(RPMSRC): $(DIST) version
	cp $(DIST) $(RPMSRC)

##$(RPMFILES):
##	(cd .. &&  $(RPMLIST) )

##
## count the build number up each time we make an rpm
##
version:
	@if [ ! -f .version ] ; \
	   then echo 1 > .version ; \
	   else  expr 0`cat .version` + 1 > .version ; \
        fi
	@echo "RPM Build : " `cat .version` 
##
##
##
dep:

##
## Cleanup
##
clean:
	rm -rf *~ *~*~ gnade.spec *.log

distclean: clean
	rm -rf $(RPMFILES)
	rm -rf $(expordir) *.rpm
	rm .version

publish:
	ncftpput upload.sourceforge.net /incoming $(exportdir)/gnade-$(VERSION)-*.src.rpm
	ncftpput upload.sourceforge.net /incoming $(exportdir)/gnade-$(VERSION)-*.i686.rpm
