| 1 |
# $Id: Makefile,v 1.12 2003/09/23 22:26:12 suso Exp $ |
| 2 |
# num-utils A set of programs for doing operations on numbers |
| 3 |
# Copyright (C) 2002-2003 Suso Banderas |
| 4 |
|
| 5 |
# This program is free software; you can redistribute it and/or |
| 6 |
# modify it under the terms of the GNU General Public License |
| 7 |
# as published by the Free Software Foundation; either version 2 |
| 8 |
# of the License, or (at your option) any later version. |
| 9 |
# |
| 10 |
# This program is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with this program; if not, write to the Free Software |
| 17 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 |
# |
| 19 |
# You may contact the author at <[email protected]>. |
| 20 |
|
| 21 |
VERSION = $(shell cat VERSION) |
| 22 |
PROJECT = num-utils |
| 23 |
DIST = $(PROJECT)-$(VERSION) |
| 24 |
FILES = $(shell cat MANIFEST) |
| 25 |
UTILS = average bound interval normalize numgrep numprocess numsum random range round |
| 26 |
DOCS = CHANGELOG COPYING LICENSE MANIFEST template README GOALS WARNING |
| 27 |
TESTS = file fractionalnums numbers numbers2 README zeros |
| 28 |
# rpm --showrc is gettin to be hard to parse anymore. |
| 29 |
#RPMDIR = /usr/src/redhat |
| 30 |
RPMDIR = $(shell rpm --showrc | grep " _topdir" | \ |
| 31 |
perl -n -e \ |
| 32 |
'/_topdir(?:\s+|\s+:\s+)(\/.*|%{_usrsrc}.*$$)/; \ |
| 33 |
$$dir = $$1; $$dir =~ s|%{_usrsrc}|/usr/src|; print "$$1\n";') |
| 34 |
|
| 35 |
# Modify these as nessecary |
| 36 |
PERL = /usr/bin/perl |
| 37 |
BINDIR = /usr/bin |
| 38 |
TOPDIR = $(ROOT)/usr |
| 39 |
MANDIR = $(TOPDIR)/share/man/man1 |
| 40 |
DOCDIR = $(TOPDIR)/share/doc/$(DIST) |
| 41 |
BINDIR = $(TOPDIR)/bin |
| 42 |
TARFILE = $(DIST).tar.gz |
| 43 |
RPMFILE = $(RPMDIR) |
| 44 |
SPECFILE= $(PROJECT).spec |
| 45 |
RPMFILE = $(RPMDIR)/RPMS/noarch/$(DIST)-1.noarch.rpm |
| 46 |
SRPMFILE= $(RPMDIR)/SRPMS/$(DIST)-1.src.rpm |
| 47 |
|
| 48 |
|
| 49 |
all: manpages |
| 50 |
for file in $(UTILS) ; do \ |
| 51 |
cat $$file | sed 's|^#!/usr/bin/perl|#!$(PERL)|' > $$file.out ; \ |
| 52 |
mv $$file.out $$file ; chmod a+x $$file ; done |
| 53 |
|
| 54 |
install: |
| 55 |
install -m 0755 -o 0 -g 0 -d $(BINDIR) |
| 56 |
for util in $(UTILS) ; do \ |
| 57 |
install -m 0755 -o 0 -g 0 $$util $(BINDIR) ; done |
| 58 |
|
| 59 |
install -m 0755 -o 0 -g 0 -d $(DOCDIR) |
| 60 |
for doc in $(DOCS) ; do \ |
| 61 |
install -m 0644 -o 0 -g 0 $$doc $(DOCDIR) ; done |
| 62 |
|
| 63 |
install -m 0755 -o 0 -g 0 -d $(MANDIR) |
| 64 |
for man in $(UTILS) ; do \ |
| 65 |
install -m 0644 -o 0 -g 0 $$man.1.gz $(MANDIR) ; done |
| 66 |
|
| 67 |
uninstall: |
| 68 |
for util in $(UTILS) ; do \ |
| 69 |
rm -f $(BINDIR)/$$util ; done |
| 70 |
rmdir $(BINDIR) |
| 71 |
|
| 72 |
for doc in $(DOCS) ; do \ |
| 73 |
rm -f $(DOCDIR)/$$doc ; done |
| 74 |
rmdir $(DOCDIR) |
| 75 |
|
| 76 |
for man in $(UTILS) ; do \ |
| 77 |
rm -f $(MANDIR)/$$man.1.gz ; done |
| 78 |
rmdir $(MANDIR) |
| 79 |
|
| 80 |
manpages: |
| 81 |
for doc in $(UTILS) ; do \ |
| 82 |
pod2man $$doc > $$doc.1 ; \ |
| 83 |
gzip $$doc.1 ; chmod 644 $$doc.1.gz \ |
| 84 |
; done |
| 85 |
|
| 86 |
rpminstall: |
| 87 |
install -m 0755 -d $(BINDIR) |
| 88 |
for util in $(UTILS) ; do \ |
| 89 |
install -m 0755 $$util $(BINDIR) ; done |
| 90 |
|
| 91 |
install -m 0755 -d $(DOCDIR) |
| 92 |
for doc in $(DOCS) ; do \ |
| 93 |
install -m 0644 $$doc $(DOCDIR) ; done |
| 94 |
|
| 95 |
install -m 0755 -d $(MANDIR) |
| 96 |
for man in $(UTILS) ; do \ |
| 97 |
install -m 0644 $$man.1.gz $(MANDIR) ; done |
| 98 |
|
| 99 |
clean: |
| 100 |
rm -f $(PROJECT).spec |
| 101 |
rm -f $(TARFILE) |
| 102 |
for file in $(UTILS) ; do \ |
| 103 |
rm -f $$file.1 ; done |
| 104 |
for file in $(UTILS) ; do \ |
| 105 |
cat $$file | sed 's|^#!$(PERL)|#!/usr/bin/perl|' > $$file.out ; \ |
| 106 |
mv $$file.out $$file ; chmod a+x $$file ; done |
| 107 |
|
| 108 |
dist: $(TARFILE) |
| 109 |
|
| 110 |
|
| 111 |
test: |
| 112 |
for file in $(UTILS) ; do $(PERL) -Tcw $$file ; done |
| 113 |
|
| 114 |
$(TARFILE): $(FILES) |
| 115 |
rm -fr $(DIST) |
| 116 |
rm -f $(TARFILE) |
| 117 |
mkdir $(DIST) |
| 118 |
perl -pe 'chomp; symlink "../$$_", "$(DIST)/$$_" or die $$!' MANIFEST |
| 119 |
tar zchf $(DIST).tar.gz $(DIST) --exclude CVS |
| 120 |
rm -r $(DIST) |
| 121 |
|
| 122 |
rpm: $(RPMFILE) $(SRPMFILE) |
| 123 |
|
| 124 |
$(RPMFILE): do-rpm |
| 125 |
|
| 126 |
$(SRPMFILE): do-rpm |
| 127 |
|
| 128 |
do-rpm: $(TARFILE) $(SPECFILE) |
| 129 |
cp $(SPECFILE) $(RPMDIR)/SPECS/ |
| 130 |
cp $(TARFILE) $(RPMDIR)/SOURCES/ |
| 131 |
rpmbuild -ba $(RPMDIR)/SPECS/$(SPECFILE) |
| 132 |
|
| 133 |
$(SPECFILE): $(SPECFILE).in VERSION |
| 134 |
perl -pe 's[\@(\S+)\@] \ |
| 135 |
[open F, $$1 or die; $$x = join "", <F>; chomp $$x; $$x]ge' \ |
| 136 |
< $< > $@ |
| 137 |
|