###############################################################################
#    keyboard emulator project
#
#    Copyright (C) 1998-2003 Reznic Valery <valery_reznic@users.sourceforge.net>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
###############################################################################

SOURCES =                   \
   Makefile                 \
   $(PACKAGE).spec.in       \

EXTRA_DIST = $(PACKAGE).spec

TOP_DIR = ..

all-local:

define SpecFile
   VERSION=`cat $(TOP_DIR)/VERSION`                             && \
   RELEASE=`cat $(TOP_DIR)/RELEASE`                             && \
   {                                                               \
      echo "%define my_name        $$PACKAGE"                   && \
      echo "%define my_version     $$VERSION"                   && \
      echo "%define my_release     $$RELEASE"                   && \
      echo                                                      && \
      cat $(PACKAGE).spec.in                                    && \
      echo && echo "%changelog" && cat $(TOP_DIR)/ChangeLog     && \
      :                                                          ; \
   }
endef

SPEC_DEP =                          \
   Makefile                         \
   $(PACKAGE).spec.in               \
   $(TOP_DIR)/VERSION               \
   $(TOP_DIR)/RELEASE               \
   $(TOP_DIR)/ChangeLog             \

clean-local:
	$(RM) $(EXTRA_DIST)

include $(TOP_DIR)/Makefile.include

$(PACKAGE).spec: $(SPEC_DEP)
	$(RM) $@
	$(SpecFile) > $@ || { $(RM) $@; exit 1; }

