1#
2# Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
3# 
4# This program is free software; you can redistribute it and/or modify it
5# under the terms of version 2 of the GNU General Public License as
6# published by the Free Software Foundation.
7# 
8# This program is distributed in the hope that it would be useful, but
9# WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# 
12# Further, this software is distributed without any warranty that it is
13# free of the rightful claim of any third person regarding infringement
14# or the like.  Any license provided herein, whether implied or
15# otherwise, applies only to this software file.  Patent licenses, if
16# any, provided herein do not apply to combinations of this program with
17# other software, or any other product whatsoever.
18# 
19# You should have received a copy of the GNU General Public License along
20# with this program; if not, write the Free Software Foundation, Inc., 59
21# Temple Place - Suite 330, Boston MA 02111-1307, USA.
22# 
23# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24# Mountain View, CA  94043, or:
25# 
26# http://www.sgi.com 
27# 
28# For further information regarding this notice, see: 
29# 
30# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31#
32
33TOPDIR = ../..
34TREEROOT = $(shell cd ${TOPDIR}; pwd)
35include $(TOPDIR)/include/builddefs
36
37SPECF = $(PKG_NAME).spec
38LDIRT = *.rpm $(SPECF) rpmmacros rpmfiles* rpm-*.rc
39
40LSRCFILES = macros.template $(SPECF).in rpm-2.rc.template
41
42default install install-dev install-lib:
43
44include $(BUILDRULES)
45
46# Generate a binary rpm file
47dist : default $(SPECF) rpm-$(RPM_VERSION).rc
48	$(RPMBUILD) -ba --rcfile ./rpm-$(RPM_VERSION).rc $(SPECF)
49
50# Because rpm prior to v.2.90 does not support macros and old style config
51# is not supported by rpm v.3, we have to resort to such ugly hacks
52ifneq ($(RPM_VERSION),2)
53rpm-$(RPM_VERSION).rc : rpmmacros
54	@$(SED) -e '/^macrofiles:/s|~/.rpmmacros|rpmmacros|' </usr/lib/rpm/rpmrc >$@
55
56rpmmacros : macros.template
57	@$(SED) -e 's|%topdir%|$(TREEROOT)|g' < $< > $@
58else
59rpm-2.rc: rpm-2.rc.template
60	@$(SED) -e 's|%topdir%|$(TOPDIR)|g' < $< > $@
61endif
62
63# Generate the rpm specfile format file list from the install-sh manifest
64rpmfiles rpmfiles-dev rpmfiles-lib:
65	$(SORT) -u $$DIST_MANIFEST | $(AWK) > $@ '\
66$$1 == "d" { printf ("%%%%dir %%%%attr(%s,%s,%s) %s\n", $$2, $$3, $$4, $$5); } \
67$$1 == "f" { if (match ($$6, "$(PKG_MAN_DIR)") || \
68                match ($$6, "$(PKG_DOC_DIR)")) \
69                printf ("%%%%doc "); \
70            if (match ($$6, "$(PKG_MAN_DIR)")) \
71                printf ("%%%%attr(%s,%s,%s) %s*\n", $$2, $$3, $$4, $$6); \
72            else \
73                printf ("%%%%attr(%s,%s,%s) %s\n", $$2, $$3, $$4, $$6); } \
74$$1 == "l" { if (match ($$3, "$(PKG_MAN_DIR)") || \
75                match ($$3, "$(PKG_DOC_DIR)")) \
76                printf ("%%%%doc "); \
77            if (match ($$3, "$(PKG_MAN_DIR)")) \
78                printf ("%%%%attr(0777,root,root) %s*\n", $$3); \
79            else \
80                printf ("%%%%attr(0777,root,root) %s\n", $$3); }'
81
82.PHONY: $(SPECF)
83${SPECF} : ${SPECF}.in
84	$(SED) -e's|@pkg_name@|$(PKG_NAME)|g' \
85	    -e's|@pkg_version@|$(PKG_VERSION)|g' \
86	    -e's|@pkg_release@|$(PKG_RELEASE)|g' \
87	    -e's|@pkg_distribution@|$(PKG_DISTRIBUTION)|g' \
88	    -e's|@build_root@|$(DIST_ROOT)|g' \
89	    -e'/^BuildRoot: *$$/d' \
90	    -e's|@make@|$(MAKE)|g' < $< > $@
91