kay's perl branch

This commit is contained in:
Jeff Hill
1997-04-11 20:44:03 +00:00
parent 8d6deea83d
commit 8013fecb61
24 changed files with 1981 additions and 126 deletions

View File

@@ -64,9 +64,13 @@ LIBSRCS += macCore.c
LIBSRCS += macUtil.c
LIBSRCS += sigPipeIgnore.c
LIBSRCS += dbmf.c
LIBSRCS += ipAddrToA.c
#
# if CPLUSPLUS isnt empty then include C++ src codes
# Note: After including/excluding files here,
# e.g. the C++ stuff,
# please check Com.def!
#
LIBSRCS += $(patsubst %,fdManager.cc,$(strip $(CPLUSPLUS)))
LIBSRCS += $(patsubst %,osiTimer.cc,$(strip $(CPLUSPLUS)))
@@ -75,7 +79,8 @@ LIBSRCS += $(patsubst %,osdTime.cc,$(strip $(CPLUSPLUS)))
# WIN32 has no getopt, we add it to the Com lib,
# special initialisation is done in winmain.c
LIBSRCS_WIN32 := getopt.c dllmain.cc
#LIBSRCS_WIN32 := getopt.c dllmain.cc
LIBSRCS_WIN32 := getopt.c
# Library to build:
# lib$(LIBRARY).a or ..dll/..exp/..lib
@@ -92,9 +97,7 @@ PROD_LIBS=Com
# tsTest does not use the default tsTest.c:
#TESTPROD_SRCS=tsSubr.c
#TESTPROD=tsTest
#TESTPROD=envtest
#TESTPROD = errMtst.c
PROD := impExpand
MAN3 = gpHash.3 freeList.3
@@ -118,29 +121,14 @@ ERR_S_FILES += $(TOP)/src/gdd/gddAppFuncTable.h
include $(TOP)/config/RULES.Host
# The WIN32 scripts are simpler versions that should
# work on all systems.
# In order to keep the old ones, however, I moved
# the new ones to WIN32. -kuk-
# Improvements:
# 1) use only the simpler scripts (well,..)
# 2) use C code instead (yes!)
#
ifdef WIN32
TOOLDIR=../os/WIN32
else
TOOLDIR=..
endif
# The real dependecies seem to confuse GNUmake:
# envData.c is rebuild every time...
#envData.c: ../envDefs.h $(TOP)/config/CONFIG_ENV $(TOP)/config/CONFIG_SITE_ENV
envData.c: ../envDefs.h
$(TOOLDIR)/bldEnvData $(TOP)/config
$(PERL) ../bldEnvData.pl $(TOP)/config
errSymTbl.c: $(ERR_S_FILES)
@$(RM) -f errSymTbl.c
$(TOOLDIR)/makeStatTbl $(ERR_S_FILES) >errSymTbl.c
$(PERL) ../makeStatTbl.pl $(ERR_S_FILES)
clean::
@$(RM) errSymTbl.c envData.c

View File

@@ -83,23 +83,15 @@ include $(TOP)/config/RULES.Vx
clean::
@$(RM) errSymTbl.c envData.c
# In principle the simplified scripts in ../WIN32
# should work on all archs, but I decided to
# keep the "originals" for now. -kuk-
ifeq ($(HOST_ARCH),WIN32)
TOOLDIR=../os/WIN32
else
TOOLDIR=..
endif
envData.c: ../envDefs.h $(TOP)/config/CONFIG_ENV \
$(TOP)/config/CONFIG_SITE_ENV
$(TOOLDIR)/bldEnvData $(TOP)/config
# The (otherwise correct) $(TOP)... dependencies are handled wrong by GNUmake,
# it rebuilds envData.c in any case:
#envData.c: ../envDefs.h $(TOP)/config/CONFIG_ENV $(TOP)/config/CONFIG_SITE_ENV
envData.c: ../envDefs.h
$(PERL) ../bldEnvData.pl $(TOP)/config
errSymTbl.o: errSymTbl.c
$(COMPILE.c) -o $@ $<
errSymTbl.c: $(ERR_S_FILES)
$(RM) errSymTbl.c ;\
$(TOOLDIR)/makeStatTbl $(ERR_S_FILES) >errSymTbl.c
$(PERL) ../makeStatTbl.pl $(ERR_S_FILES)

151
src/libCom/bldEnvData.pl Normal file
View File

@@ -0,0 +1,151 @@
#!/usr/local/bin/perl
#
# Author: Kay-Uwe Kasemir
# based on bldEnvData shell scripts, Andrew Johnson (RGO)
# Date: 1-30-97
#
# Experimental Physics and Industrial Control System (EPICS)
#
# tool to build envData.c from envDefs.h and config/CONFIG*ENV
use Cwd;
# We need exactly one argument:
$usage="Usage:\tbldEnvData <config-Directory>";
die $usage unless $#ARGV==0;
$start_dir=cwd();
$config_dir=$ARGV[0];
# Don't see a reason for this directory hopping,
# it's copied from the original:
chdir $config_dir or die "cannot change dir to $config_dir";
$config_dir=cwd();
chdir $start_dir;
$SRC = "../envDefs.h";
$env_data = "${config_dir}/CONFIG_ENV";
$site_data= "${config_dir}/CONFIG_SITE_ENV";
$out_name = "envData.c";
$OUT = "> $out_name";
# $tool = basename of this script
$tool=$0;
$tool=~ s'.*/'';
# Start by extracting the ENV_PARAM declarations from $SRC
# i.e. gather the names of params we are interested in:
#
open SRC or die "Cannot open $SRC";
while (<SRC>)
{
if (m'epicsShareExtern[ \t]+const[ \t]+ENV_PARAM[ \t]+([A-Za-z_]+)[ \t;]*')
{
$need_var{$1} = 1;
}
}
close SRC;
# Read the default values from the config file into shell variables
sub GetVars
{
my ($filename) = @_;
open IN, $filename or die "Cannot read $filename";
while (<IN>)
{
# word space = space rest
if (m'([A-Za-z_]+)[ \t]*=[ \t]*(.*)')
{
$var = $1;
# Check if we need that variable:
next unless $need_var{$var};
# cosmetics:
# Some vars are given as "",
# so that $value{$var} is empty (=undefined).
# To avoid "no value for .." warning I use %have_value
$have_value{$var} = 1;
$value{$var} = $2;
# remove '"'
if ($value{$var} =~ m'"(.*)"')
{
$value{$var} = $1;
}
}
}
close IN;
}
GetVars ($env_data);
GetVars ($site_data);
# Generate header file
#
print "Generating $out_name\n";
open OUT or die "cannot create $out_name";
# Write header
print OUT "/*\t$out_name\n";
print OUT " *\n";
print OUT " *\tcreated by $tool\n";
print OUT " *\n";
print OUT " *\tfrom:\n";
print OUT " *\t$SRC\n";
print OUT " *\t$env_data\n";
print OUT " *\t$site_data\n";
print OUT " *\n";
print OUT " *\t" . localtime() . "\n";
print OUT " *\n";
print OUT " */\n";
print OUT "\n";
print OUT "#define epicsExportSharedSymbols\n";
print OUT "#include \"envDefs.h\"\n";
print OUT "#include \"shareLib.h\"\n";
print OUT "\n";
# Print variables
#
foreach $var ( sort keys %need_var )
{
if ($have_value{$var})
{
$default = $value{$var};
}
else
{
$default = "";
print "Cannot find value for $var\n";
}
printf OUT "epicsShareDecl const ENV_PARAM %s = { \"%s\", \"%s\" };\n",
$var, $var, $default;
}
# Now create an array pointing to all parameters
print OUT "\n";
print OUT "epicsShareDecl const ENV_PARAM* env_param_list[EPICS_ENV_VARIABLE_COUNT+1] =\n";
print OUT "{\n";
# Contents are the addresses of each parameter
foreach $var ( sort keys %need_var )
{
print OUT "\t&$var,\n";
}
# Finally finish list with 0
print OUT "\t0\n";
print OUT "};\n";
print OUT "\n";
print OUT "/*\tEOF $out_name */\n";
close OUT;
# EOF bldEnvData.pl

151
src/libCom/env/bldEnvData.pl vendored Normal file
View File

@@ -0,0 +1,151 @@
#!/usr/local/bin/perl
#
# Author: Kay-Uwe Kasemir
# based on bldEnvData shell scripts, Andrew Johnson (RGO)
# Date: 1-30-97
#
# Experimental Physics and Industrial Control System (EPICS)
#
# tool to build envData.c from envDefs.h and config/CONFIG*ENV
use Cwd;
# We need exactly one argument:
$usage="Usage:\tbldEnvData <config-Directory>";
die $usage unless $#ARGV==0;
$start_dir=cwd();
$config_dir=$ARGV[0];
# Don't see a reason for this directory hopping,
# it's copied from the original:
chdir $config_dir or die "cannot change dir to $config_dir";
$config_dir=cwd();
chdir $start_dir;
$SRC = "../envDefs.h";
$env_data = "${config_dir}/CONFIG_ENV";
$site_data= "${config_dir}/CONFIG_SITE_ENV";
$out_name = "envData.c";
$OUT = "> $out_name";
# $tool = basename of this script
$tool=$0;
$tool=~ s'.*/'';
# Start by extracting the ENV_PARAM declarations from $SRC
# i.e. gather the names of params we are interested in:
#
open SRC or die "Cannot open $SRC";
while (<SRC>)
{
if (m'epicsShareExtern[ \t]+const[ \t]+ENV_PARAM[ \t]+([A-Za-z_]+)[ \t;]*')
{
$need_var{$1} = 1;
}
}
close SRC;
# Read the default values from the config file into shell variables
sub GetVars
{
my ($filename) = @_;
open IN, $filename or die "Cannot read $filename";
while (<IN>)
{
# word space = space rest
if (m'([A-Za-z_]+)[ \t]*=[ \t]*(.*)')
{
$var = $1;
# Check if we need that variable:
next unless $need_var{$var};
# cosmetics:
# Some vars are given as "",
# so that $value{$var} is empty (=undefined).
# To avoid "no value for .." warning I use %have_value
$have_value{$var} = 1;
$value{$var} = $2;
# remove '"'
if ($value{$var} =~ m'"(.*)"')
{
$value{$var} = $1;
}
}
}
close IN;
}
GetVars ($env_data);
GetVars ($site_data);
# Generate header file
#
print "Generating $out_name\n";
open OUT or die "cannot create $out_name";
# Write header
print OUT "/*\t$out_name\n";
print OUT " *\n";
print OUT " *\tcreated by $tool\n";
print OUT " *\n";
print OUT " *\tfrom:\n";
print OUT " *\t$SRC\n";
print OUT " *\t$env_data\n";
print OUT " *\t$site_data\n";
print OUT " *\n";
print OUT " *\t" . localtime() . "\n";
print OUT " *\n";
print OUT " */\n";
print OUT "\n";
print OUT "#define epicsExportSharedSymbols\n";
print OUT "#include \"envDefs.h\"\n";
print OUT "#include \"shareLib.h\"\n";
print OUT "\n";
# Print variables
#
foreach $var ( sort keys %need_var )
{
if ($have_value{$var})
{
$default = $value{$var};
}
else
{
$default = "";
print "Cannot find value for $var\n";
}
printf OUT "epicsShareDecl const ENV_PARAM %s = { \"%s\", \"%s\" };\n",
$var, $var, $default;
}
# Now create an array pointing to all parameters
print OUT "\n";
print OUT "epicsShareDecl const ENV_PARAM* env_param_list[EPICS_ENV_VARIABLE_COUNT+1] =\n";
print OUT "{\n";
# Contents are the addresses of each parameter
foreach $var ( sort keys %need_var )
{
print OUT "\t&$var,\n";
}
# Finally finish list with 0
print OUT "\t0\n";
print OUT "};\n";
print OUT "\n";
print OUT "/*\tEOF $out_name */\n";
close OUT;
# EOF bldEnvData.pl

View File

@@ -0,0 +1,102 @@
#!/usr/local/bin/perl
#
# makeStatTbl.pl - Create Error Symbol Table
#
# Kay-Uwe Kasemir, 1-31-97,
# based on makeStatTbl shell script.
#
# SYNOPSIS
# perl makeStatTbl.pl hdir [...]
#
# DESCRIPTION
# This tool creates a symbol table (ERRSYMTAB) structure which contains the
# names and values of all the status codes defined in the .h files in the
# specified directory(s). The status codes must be prefixed with "S_"
# in order to be included in this table.
# A "err.h" file must exist in each hdir which defines the module
# numbers, eg. "M_". The table is created on standard output.
#
# This tool's primary use is for creating an error status table used
# by errPrint, and errSymFind.
#
# FILES
# errMdef.h module number file for each h directory
#
# SEE ALSO: errnoLib(1), symLib(1)
#*/
use Cwd;
die "No args (files to parse) given" if ($#ARGV < 0);
# parse all lines of all files given:
while (<>)
{
if (m'^#define[ /t]*S_')
{
chomp;
push @err_sym_line, $_;
}
}
$out_name = "errSymTbl.c";
$dir = cwd();
open OUT, ">$out_name" or die "Cannot open $out_name";
print OUT "/*\n";
print OUT " * status code symbol table\n";
print OUT " *\n";
print OUT " * CREATED BY makeStatTbl.pl\n";
print OUT " * FROM $dir\n";
print OUT " * ON " . localtime() . "\n";
print OUT " */\n";
print OUT "\n";
print OUT "#include \"errMdef.h\"\n";
print OUT "#include \"errSymTbl.h\"\n";
print OUT "\n";
$count = 0;
foreach $line ( @err_sym_line )
{
print OUT "$line\n";
# define S_symbol /* comment */
if ($line =~ m'[ \t#]define[ \t]*(S_[A-Za-z0-9_]+).*\/\*(.+)\*\/')
{
$symbol[$count] = $1;
$comment[$count]= $2;
++$count;
}
else
{
# Some status values for '0' (=OK) have no comment:
unless ($line =~ m'[ \t#]define[ \t]*(S_[A-Za-z0-9_]+)')
{
die "cannot decode this line:\n$line\n";
}
}
}
print OUT "\n";
print OUT "LOCAL ERRSYMBOL symbols[] =\n";
print OUT "{\n";
for ($i=0; $i<$count; ++$i)
{
printf OUT "\t{ \"%s\", (long) %s },\n",
$comment[$i], $symbol[$i];
}
print OUT "};\n";
print OUT "\n";
print OUT "LOCAL ERRSYMTAB symTbl =\n";
print OUT "{\n";
print OUT "\tNELEMENTS(symbols), /* current number of symbols in table */\n";
print OUT "\tsymbols, /* ptr to symbol array */\n";
print OUT "};\n";
print OUT "\n";
print OUT "ERRSYMTAB_ID errSymTbl = &symTbl;\n";
print OUT "\n";
print OUT "/*\tEOF $out_name */\n";

102
src/libCom/makeStatTbl.pl Normal file
View File

@@ -0,0 +1,102 @@
#!/usr/local/bin/perl
#
# makeStatTbl.pl - Create Error Symbol Table
#
# Kay-Uwe Kasemir, 1-31-97,
# based on makeStatTbl shell script.
#
# SYNOPSIS
# perl makeStatTbl.pl hdir [...]
#
# DESCRIPTION
# This tool creates a symbol table (ERRSYMTAB) structure which contains the
# names and values of all the status codes defined in the .h files in the
# specified directory(s). The status codes must be prefixed with "S_"
# in order to be included in this table.
# A "err.h" file must exist in each hdir which defines the module
# numbers, eg. "M_". The table is created on standard output.
#
# This tool's primary use is for creating an error status table used
# by errPrint, and errSymFind.
#
# FILES
# errMdef.h module number file for each h directory
#
# SEE ALSO: errnoLib(1), symLib(1)
#*/
use Cwd;
die "No args (files to parse) given" if ($#ARGV < 0);
# parse all lines of all files given:
while (<>)
{
if (m'^#define[ /t]*S_')
{
chomp;
push @err_sym_line, $_;
}
}
$out_name = "errSymTbl.c";
$dir = cwd();
open OUT, ">$out_name" or die "Cannot open $out_name";
print OUT "/*\n";
print OUT " * status code symbol table\n";
print OUT " *\n";
print OUT " * CREATED BY makeStatTbl.pl\n";
print OUT " * FROM $dir\n";
print OUT " * ON " . localtime() . "\n";
print OUT " */\n";
print OUT "\n";
print OUT "#include \"errMdef.h\"\n";
print OUT "#include \"errSymTbl.h\"\n";
print OUT "\n";
$count = 0;
foreach $line ( @err_sym_line )
{
print OUT "$line\n";
# define S_symbol /* comment */
if ($line =~ m'[ \t#]define[ \t]*(S_[A-Za-z0-9_]+).*\/\*(.+)\*\/')
{
$symbol[$count] = $1;
$comment[$count]= $2;
++$count;
}
else
{
# Some status values for '0' (=OK) have no comment:
unless ($line =~ m'[ \t#]define[ \t]*(S_[A-Za-z0-9_]+)')
{
die "cannot decode this line:\n$line\n";
}
}
}
print OUT "\n";
print OUT "LOCAL ERRSYMBOL symbols[] =\n";
print OUT "{\n";
for ($i=0; $i<$count; ++$i)
{
printf OUT "\t{ \"%s\", (long) %s },\n",
$comment[$i], $symbol[$i];
}
print OUT "};\n";
print OUT "\n";
print OUT "LOCAL ERRSYMTAB symTbl =\n";
print OUT "{\n";
print OUT "\tNELEMENTS(symbols), /* current number of symbols in table */\n";
print OUT "\tsymbols, /* ptr to symbol array */\n";
print OUT "};\n";
print OUT "\n";
print OUT "ERRSYMTAB_ID errSymTbl = &symTbl;\n";
print OUT "\n";
print OUT "/*\tEOF $out_name */\n";

View File

@@ -0,0 +1,36 @@
#!/usr/local/bin/perl
#
print "Building epicsVersion.h from CONFIG_BASE_VERSION\n";
die unless $#ARGV==0;
open VARS, $ARGV[0] or die "Cannot get variables from $ARGV[0]";
while (<VARS>)
{
if (/EPICS_VERSION=(.*)/) { $ver = $1; }
if (/EPICS_REVISION=(.*)/) { $rev = $1; }
if (/EPICS_MODIFICATION=(.*)/) { $mod = $1; }
if (/EPICS_UPDATE_NAME=(.*)/) { $upd_name = $1; }
if (/EPICS_UPDATE_LEVEL=(.*)/) { $upd_level = $1; }
if (/CVS_DATE="\\(.*)"/) { $cvs_date = $1; }
}
$ver_str = "$ver.$rev.$mod.$upd_name.$upd_level";
print "Found EPICS Version $ver_str\n";
open OUT, ">epicsVersion.h";
print OUT "#define BASE_VERSION $ver\n";
print OUT "#define BASE_REVISION $rev\n";
print OUT "#define BASE_MODIFICATION $mod\n";
print OUT "#define BASE_UPDATE_NAME $upd_name\n";
print OUT "#define BASE_UPDATE_LEVEL $upd_level\n";
print OUT "#define BASE_VERSION_STRING \"EPICS Version $ver_str\"\n";
print OUT "#define epicsReleaseVersion \"@(#)Version R$ver_str $cvs_date\"\n";
close OUT;

View File

@@ -0,0 +1,4 @@
I took this from the GNU grep sources that should
also be part of the NT tools of this EPICS release.
-kuk-