diff options
Diffstat (limited to 'src/pmgenmap')
-rw-r--r-- | src/pmgenmap/GNUmakefile | 34 | ||||
-rwxr-xr-x | src/pmgenmap/pmgenmap.sh | 103 |
2 files changed, 137 insertions, 0 deletions
diff --git a/src/pmgenmap/GNUmakefile b/src/pmgenmap/GNUmakefile new file mode 100644 index 0000000..bd4b042 --- /dev/null +++ b/src/pmgenmap/GNUmakefile @@ -0,0 +1,34 @@ +#!gmake +# +# Copyright (c) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. +# +# 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. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# + +TOPDIR = ../.. +include $(TOPDIR)/src/include/builddefs + +LSRCFILES = pmgenmap.sh + +default: + +include $(BUILDRULES) + +install: + $(INSTALL) -m 755 pmgenmap.sh $(PCP_BIN_DIR)/pmgenmap + +default_pcp : default + +install_pcp : install diff --git a/src/pmgenmap/pmgenmap.sh b/src/pmgenmap/pmgenmap.sh new file mode 100755 index 0000000..f6e6b4c --- /dev/null +++ b/src/pmgenmap/pmgenmap.sh @@ -0,0 +1,103 @@ +#! /bin/sh +# +# Copyright (c) 1997 Silicon Graphics, Inc. All Rights Reserved. +# +# 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. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# Generate a Performance Metrics Name Space Map from a specification file +# + +# Get standard environment +. $PCP_DIR/etc/pcp.env + +prog=`basename $0` +if [ $# -gt 1 -o "X$1" = "X-?" ] +then + echo "Usage: $prog [infile]" + exit 1 +fi +if [ $# -eq 0 ] +then + pathnamename="<stdin>" + name="<stdin>" +else + if [ ! -f $1 ] + then + echo "$prog: cannot open \"$1\"" + exit 1 + fi + pathname=`pwd`/$1 + name=$1 +fi + +cat <<End-of-File +/* + * Performance Metrics Name Space Map + * Built by $prog from the file + * $name + * on `date` + * + * Do not edit this file! + */ + +End-of-File + +# Deal with either Windows or Unix variants of text files +cat $1 | tr '\r\n' '\n' | $PCP_AWK_PROG ' +$1 == "#" { if (comment) text = text "\n *" + comment++ + for (i = 2; i <= NF; i++) + text = text " " $i + next + } +comment > 0 { if (comment == 1) + print "/*" text " */" + else + print "/*\n *" text "\n */" + comment = 0 + text = "" + } +NF == 0 { print; next } +NF == 2 && $2 == "{" { if (state != 0) { + printf "[%s:%d] nested group?\n","'$1'",NR + exit 1 + } + printf "char *%s[] = {\n",$1 + state = 1 + ord = 0 + next + } +NF == 2 && state == 1 { printf "#define %s %d\n",$2,ord + ord++ + printf " \"%s\",\n",$1 + next + } +NF == 1 && $1 == "}" { printf "\n" + printf "};\n\n" + state = 0 + next + } + { printf "[%s:%d] syntax error\n","'$name'",NR + exit 1 + } +END { if (state) { + printf "[%s:%d] unterminated group?\n","'$name'",NR + exit 1 + } + if (comment == 1) + print "/*" text " */" + else if (comment > 1) + print "/*\n *" text "\n */" + }' |