From 8013fecb612c7435bbbadc19f7b1e452c54b2012 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Fri, 11 Apr 1997 20:44:03 +0000 Subject: [PATCH] kay's perl branch --- Makefile | 2 +- README.Perl | 43 ++ src/ca/windows_depen.c | 27 +- src/dbtools/Makefile.Host | 7 +- src/include/Makefile.Host | 17 +- src/include/makeEpicsVersion.pl | 36 + src/libCom/Makefile.Host | 28 +- src/libCom/Makefile.Vx | 20 +- src/libCom/bldEnvData.pl | 151 ++++ src/libCom/env/bldEnvData.pl | 151 ++++ src/libCom/error/makeStatTbl.pl | 102 +++ src/libCom/makeStatTbl.pl | 102 +++ src/libCom/misc/makeEpicsVersion.pl | 36 + src/libCom/os/WIN32/README.getopt | 4 + src/sequencer/Makefile.Host | 5 +- src/sequencer/Makefile.Vx | 5 +- src/sequencer/makeVersion.pl | 22 + src/tools/Makefile.Host | 55 +- src/tools/cp.pl | 39 + src/tools/installEpics.pl | 108 +++ src/tools/makeBaseApp.pl | 1023 +++++++++++++++++++++++++++ src/tools/mkdir.pl | 23 + src/tools/mv.pl | 69 ++ src/tools/rm.pl | 32 + 24 files changed, 1981 insertions(+), 126 deletions(-) create mode 100644 README.Perl create mode 100644 src/include/makeEpicsVersion.pl create mode 100644 src/libCom/bldEnvData.pl create mode 100644 src/libCom/env/bldEnvData.pl create mode 100644 src/libCom/error/makeStatTbl.pl create mode 100644 src/libCom/makeStatTbl.pl create mode 100644 src/libCom/misc/makeEpicsVersion.pl create mode 100644 src/libCom/os/WIN32/README.getopt create mode 100644 src/sequencer/makeVersion.pl create mode 100644 src/tools/cp.pl create mode 100644 src/tools/installEpics.pl create mode 100644 src/tools/makeBaseApp.pl create mode 100644 src/tools/mkdir.pl create mode 100644 src/tools/mv.pl create mode 100644 src/tools/rm.pl diff --git a/Makefile b/Makefile index 9dbf9991b..577d5a035 100644 --- a/Makefile +++ b/Makefile @@ -30,5 +30,5 @@ built_release: uninstall:: @DIR1=`pwd`;cd $(INSTALL_LOCATION);DIR2=`pwd`;cd $$DIR1;\ - if [ "$$DIR1" != "$$DIR2" ]; then rm -fr $(INSTALL_LOCATION)/config; fi + if [ "$$DIR1" != "$$DIR2" ]; then $(RMDIR) $(INSTALL_LOCATION)/config; fi diff --git a/README.Perl b/README.Perl new file mode 100644 index 000000000..c3037c9c9 --- /dev/null +++ b/README.Perl @@ -0,0 +1,43 @@ +Perl +==== + +A number of shell scripts are now Perl scripts, +most important: + +tools/installEpics.pl +include/makeEpicsVersion.pl +libCom/bldEnvData.pl +libCom/makeStatSymTbl.pl +sequencer/makeVersion.pl + +WIN32 also uses +tools/cp.pl, mv.pl, rm.pl, mkdir.pl +which should behave like the UNIX cp, mv, rm, rmdir. +All systems could use the Perl versions but that seems +to be overkill for UNIX. + +Advantages: +* no need for ls, date, basename, grep, awk, sed, ..., + which made the make UNIX-specific. +* Perl is currently available for Unix, OS/2, WIN32, VMS + and the scripts should work on all those systems + +Disadvantage: +* You have to get Perl, look e.g. at http://www.perl.com + + +Compile Perl: +No big deal, +* on UNIX say 'configure' and 'gnumake', +* on Windows use MX Visual C++, + use File/Open Workspace to open the Makefile {PERL}/perl5i.mak, + use Build/Batch build to select eiher the Release or Debug targets. + + You can do the same with the Makefile {Perl}/Ext/WIN32/win32.mak + - nice tools but not necessary for EPICS. + + Then call {PERL}/bin/perlw32-install.bat + +In any case, read the texts that come with perl! + + diff --git a/src/ca/windows_depen.c b/src/ca/windows_depen.c index b2b626234..cc461fa49 100644 --- a/src/ca/windows_depen.c +++ b/src/ca/windows_depen.c @@ -32,6 +32,9 @@ * Modification Log: * ----------------- * $Log$ + * Revision 1.25 1997/04/10 19:26:20 jhill + * asynch connect, faster connect, ... + * * Revision 1.24 1997/01/09 22:14:26 jhill * installed changes on hostBuild branch * @@ -50,27 +53,6 @@ * Revision 1.20 1995/12/19 19:36:20 jhill * function prototype changes * - * Revision 1.19 1995/11/29 19:15:42 jhill - * added $Log$ - * added Revision 1.24 1997/01/09 22:14:26 jhill - * added installed changes on hostBuild branch - * added - * added Revision 1.23.2.1 1996/11/25 16:29:18 jhill - * added stuct=>struct and added debug msg - * added - * added Revision 1.23 1996/11/02 00:51:12 jhill - * added many pc port, const in API, and other changes - * added - * added Revision 1.22 1996/09/16 16:40:13 jhill - * added make EPICS version be the console title - * added - * added Revision 1.21 1996/08/05 19:20:29 jhill - * added removed incorrect ver number - * added - * Revision 1.20 1995/12/19 19:36:20 jhill - * function prototype changes - * to the header - * */ /* @@ -496,7 +478,7 @@ BOOL epicsShareAPI DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved) #if _DEBUG /* for gui applications, setup console for error messages */ if (AllocConsole()) { - SetConsoleTitle(EPICS_VERSION_STRING); + SetConsoleTitle(BASE_VERSION_STRING); freopen( "CONOUT$", "a", stderr ); } #ifndef NO_PROCESS_MSG @@ -558,4 +540,3 @@ return TRUE; } - diff --git a/src/dbtools/Makefile.Host b/src/dbtools/Makefile.Host index 3af5bee65..265c3a8a9 100644 --- a/src/dbtools/Makefile.Host +++ b/src/dbtools/Makefile.Host @@ -19,14 +19,15 @@ MAN1 := dbLoadTemplate.1 subtool.1 MAN3 := dbLoadRecords.3 dbLoadTemplate.3 MAN5 := templatefile.5 dbfile.5 +# --------------------------------------- # the BSlib is not ported to WIN32, # this results in less buildable products -# +# --------------------------------------- ifdef WIN32 # uses getopt, optind, optarg from lib Com: PROD_LIBS := Db Com -PROD := dbLoadTemplate +PROD := subtool dbLoadTemplate else @@ -39,8 +40,6 @@ LIBRARY := BSlib # all use BSlib, dbLoadTemplate needs lib Db: # (it doesn't hurt if all link Db...) # -# but -# PROD_LIBS := BSlib Db Com PROD := subtool dbLoadTemplate rdbls rdbapplist PVSserver diff --git a/src/include/Makefile.Host b/src/include/Makefile.Host index a671dcb20..fa13a39f9 100644 --- a/src/include/Makefile.Host +++ b/src/include/Makefile.Host @@ -8,7 +8,7 @@ INC += epicsVersion.h INC += gsd_sync_defs.h INC += module_types.h INC += shareLib.h -INC += createSoftLinks.sh +#INC += createSoftLinks.sh INC += bsdProto.h INC += task_params.h INC += osiMutexNOOP.h @@ -17,15 +17,10 @@ OSINC += osiSock.h include $(TOP)/config/RULES.Host -include $(TOP)/config/CONFIG_BASE_VERSION - +# This seems to be handled wrong by gnumake: +# epicsVersion.h is rebuild in any case, +# no matter what date ...CONFIG_BASE_VERSION has epicsVersion.h: $(TOP)/config/CONFIG_BASE_VERSION - @$(RM) $@ - @echo "#define EPICS_VERSION $(EPICS_VERSION)" > $@ - @echo "#define EPICS_REVISION $(EPICS_REVISION)" >> $@ - @echo "#define EPICS_MODIFICATION $(EPICS_MODIFICATION)" >> $@ - @echo "#define EPICS_UPDATE_NAME $(EPICS_UPDATE_NAME)" >> $@ - @echo "#define EPICS_UPDATE_LEVEL $(EPICS_UPDATE_LEVEL)" >> $@ - @echo "#define EPICS_VERSION_STRING \"$(EPICS_VERSION_STRING)\" " >> $@ - @echo "#define epicsReleaseVersion \"@(#)$(EPICS_VERSION_STRING) $(CVS_DATE)\" " >> $@ + perl ../makeEpicsVersion.pl $(TOP)/config/CONFIG_BASE_VERSION + diff --git a/src/include/makeEpicsVersion.pl b/src/include/makeEpicsVersion.pl new file mode 100644 index 000000000..5c78fc500 --- /dev/null +++ b/src/include/makeEpicsVersion.pl @@ -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 () +{ + 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; + + diff --git a/src/libCom/Makefile.Host b/src/libCom/Makefile.Host index 5301978c1..033fec8cb 100644 --- a/src/libCom/Makefile.Host +++ b/src/libCom/Makefile.Host @@ -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 diff --git a/src/libCom/Makefile.Vx b/src/libCom/Makefile.Vx index ddf2577ad..cf64db716 100644 --- a/src/libCom/Makefile.Vx +++ b/src/libCom/Makefile.Vx @@ -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) diff --git a/src/libCom/bldEnvData.pl b/src/libCom/bldEnvData.pl new file mode 100644 index 000000000..55b01d360 --- /dev/null +++ b/src/libCom/bldEnvData.pl @@ -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 "; +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 () +{ + 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 () + { + # 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 diff --git a/src/libCom/env/bldEnvData.pl b/src/libCom/env/bldEnvData.pl new file mode 100644 index 000000000..55b01d360 --- /dev/null +++ b/src/libCom/env/bldEnvData.pl @@ -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 "; +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 () +{ + 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 () + { + # 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 diff --git a/src/libCom/error/makeStatTbl.pl b/src/libCom/error/makeStatTbl.pl new file mode 100644 index 000000000..ccac0d8cc --- /dev/null +++ b/src/libCom/error/makeStatTbl.pl @@ -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"; + diff --git a/src/libCom/makeStatTbl.pl b/src/libCom/makeStatTbl.pl new file mode 100644 index 000000000..ccac0d8cc --- /dev/null +++ b/src/libCom/makeStatTbl.pl @@ -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"; + diff --git a/src/libCom/misc/makeEpicsVersion.pl b/src/libCom/misc/makeEpicsVersion.pl new file mode 100644 index 000000000..5c78fc500 --- /dev/null +++ b/src/libCom/misc/makeEpicsVersion.pl @@ -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 () +{ + 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; + + diff --git a/src/libCom/os/WIN32/README.getopt b/src/libCom/os/WIN32/README.getopt new file mode 100644 index 000000000..815329b73 --- /dev/null +++ b/src/libCom/os/WIN32/README.getopt @@ -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- diff --git a/src/sequencer/Makefile.Host b/src/sequencer/Makefile.Host index aaf7d0bb3..b0e2b039c 100644 --- a/src/sequencer/Makefile.Host +++ b/src/sequencer/Makefile.Host @@ -30,9 +30,8 @@ include $(TOP)/config/RULES.Host # snc.c: snc_lex.c -sncVersion.c: ../Version - $(RM) sncVersion.c - ../makeVersion ../Version > sncVersion.c +sncVersion.c: ../Version ../makeVersion.pl + $(PERL) ../makeVersion.pl ../Version sncVersion clean:: @$(RM) y.output sncVersion.c snc_lex.c snc.c snc.h diff --git a/src/sequencer/Makefile.Vx b/src/sequencer/Makefile.Vx index bc445f94b..d3ada5438 100644 --- a/src/sequencer/Makefile.Vx +++ b/src/sequencer/Makefile.Vx @@ -22,6 +22,5 @@ $(PROD): $(OBJS) $(RM) $@ $(LINK.c) $@ $(OBJS) $(LDLIBS) -seqVersion.c: ../Version - $(RM) seqVersion.c - ../makeSeqVersion ../Version > seqVersion.c +seqVersion.c: ../Version ../makeVersion.pl + $(PERL) ../makeVersion.pl ../Version seqVersion diff --git a/src/sequencer/makeVersion.pl b/src/sequencer/makeVersion.pl new file mode 100644 index 000000000..aef6f6cd4 --- /dev/null +++ b/src/sequencer/makeVersion.pl @@ -0,0 +1,22 @@ +#!/usr/local/bin/perl +# +# makeVersion - create the snc version module +# +# Usage: perl makeVersion.pl {Version_file} {Symbol Name} + +$version_file = $ARGV[0]; +$symbol = $ARGV[1]; +$out = "$symbol.c"; + +open IN, $version_file or die "Cannot open $version_file"; +$version=; +chomp $version; +close IN; + +$date = localtime(); + +open OUT, ">$out" or die "Cannot create $out"; +print OUT "/* $out - version & date */\n"; +print OUT "/* Created by makeVersion.pl */\n"; +print OUT "char *$symbol = \"\@(#)SNC/SEQ Version $version : $date\";\n"; +close OUT; diff --git a/src/tools/Makefile.Host b/src/tools/Makefile.Host index 214a16b0f..69e15cf06 100644 --- a/src/tools/Makefile.Host +++ b/src/tools/Makefile.Host @@ -5,57 +5,18 @@ TOP = ../../.. include $(TOP)/config/CONFIG_BASE # install these scripts: -SCRIPTS := installEpics getrel makeBaseApp +# +# WIN32 also uses rm.pl, cp.pl, mkdir.pl, rmdir.pl +# byt they are called from here, not installed +SCRIPTS := installEpics.pl makeBaseApp.pl -# But: before anything is done, installEpics has to be in place +# Before anything is done, installEpics has to be in place. # The first action in a full build & install is 'make inc.host', # that's where we hook into: -inc:: $(INSTALL_BIN)/installEpics +inc:: $(INSTALL_BIN)/installEpics.pl - -# This Makefile.Host is ugly -# because the install process (chmod ...) -# is different for WIN32. -# -# This is usually hidden in installEpics, -# but we are about to install installEpics... -# -# The same applies to the 'os' directory: -# If we are on e.g. WIN32 and have os/WIN32/stuff, -# that whould have precedence over ./stuff. -# But again: we are just installing the Makesystem here. -# -# -kuk- - -ifdef WIN32 - -$(INSTALL_BIN)/installEpics: ../os/WIN32/installEpics - @echo "Installing $@ for WIN32" - @../os/WIN32/testmkdir $(INSTALL_LOCATION_BIN) - @../os/WIN32/testmkdir $(INSTALL_BIN) - @../os/WIN32/installEpics ../os/WIN32/testmkdir $(INSTALL_BIN) - @../os/WIN32/installEpics ../os/WIN32/installEpics $(INSTALL_BIN) -else - -$(INSTALL_BIN)/installEpics: testmkdir installEpics - @echo "Installing $@" - @./testmkdir $(INSTALL_LOCATION_BIN) - @./testmkdir $(INSTALL_BIN) - @./installEpics -m 555 testmkdir $(INSTALL_BIN) - @./installEpics -m 555 installEpics $(INSTALL_BIN) - -# make sure the scripts are executable: -testmkdir: ../testmkdir - @$(RM) $@ - @$(CP) $< $@ - @$(CHMOD) 755 $@ - -installEpics: ../installEpics - @$(RM) $@ - @$(CP) $< $@ - @$(CHMOD) 755 $@ - -endif +$(INSTALL_BIN)/installEpics.pl: ../installEpics.pl + $(PERL) ../installEpics.pl -d -m 555 ../installEpics.pl $(INSTALL_BIN) include $(TOP)/config/RULES.Host diff --git a/src/tools/cp.pl b/src/tools/cp.pl new file mode 100644 index 000000000..a1fea0eb4 --- /dev/null +++ b/src/tools/cp.pl @@ -0,0 +1,39 @@ +#!/usr/local/bin/perl +# +# UNIX-cp in Perl + +use File::Copy; + +sub Usage +{ + my ($txt) = @_; + + print "Usage:\n"; + print "\tcp file1 file2\n"; + print "\tcp file [ file2 file3 ...] directory\n"; + print "\nError: $txt\n" if $txt; + + exit 2; +} + +# need at least two args: ARGV[0] and ARGV[1] +Usage("need more args") if $#ARGV < 1; + +$target=$ARGV[$#ARGV]; +@sources=@ARGV[0..$#ARGV-1]; + +if (-d $target) +{ + foreach $file ( @sources ) + { + copy ($file, "$target/$file"); + } +} +else +{ + Usage("Cannot copy more than one source into a single target") + if ($#sources != 0); + copy ($sources[0], $target); +} + +# EOF cp.pl diff --git a/src/tools/installEpics.pl b/src/tools/installEpics.pl new file mode 100644 index 000000000..2bf171808 --- /dev/null +++ b/src/tools/installEpics.pl @@ -0,0 +1,108 @@ +#!/usr/local/bin/perl +# +# InstallEpics.pl +# +# InstallEpics is used within makefiles to copy new versions of +# files into a destination directory. +# Based on installEpics shell script. +# +# 2-4-97 -kuk- +# +########################################################## + +use Getopt::Std; +use File::Path; +use File::Copy; + +$tool=$0; +$tool=~ s'.*[/\\].+''; # basename +$mode=0755; + +# get command line options +getopt "m"; +$mode = oct ($opt_m) if ($opt_m); + +# Complain about obsolete options: +Usage("unknown option given") if ($opt_g or $opt_o or $opt_c or $opt_s); + +$num_files = $#ARGV; +# at least two args required +Usage ("Nothing to install") if ($num_files < 1); + +# split args in file1 ... fileN target_dir: +@files=@ARGV[0..$num_files-1]; +$install_dir=$ARGV[$num_files]; +$install_dir =~ s[\\][/]g; # maybe fix DOS-style path +$install_dir =~ s[/$][]; # remove trailing '/' + +# Do we have to create the directory? +unless (-d $install_dir) +{ + # Create dir only if -d option given + Usage ("$install_dir does not exist") unless ($opt_d); + + # Create all the subdirs that lead to $install_dir + mkpath ($install_dir, 1, 0777); +} + +foreach $source ( @files ) +{ + Usage ("Can't find file '$source'") unless -f $source; + + $basename=$source; + $basename=~s'.*[/\\]''; + $target = "$install_dir/$basename"; + + # The Win32 filesystem seems to be 'slow', + # i.e. $target may look like 'up to date' + # unless you wait an hour. + # -> skip this test on WIN32 ? + #if (-f $target and $^O ne "MSWin32") + if (-f $target) + { + if (-M $target < -M $source and + -C $target < -C $source) + { + print "$target is up to date\n"; + next; + } + else + { + # remove old target, make sure it is deletable: + chmod 0777, $target; + unlink $target; + } + } + + # print "Installing $source into $install_dir\n"; + copy ($source, $target) or die "Copy failed"; + + # chmod 0555 DOES work on WIN32, but: + # Another chmod 0777 to make it write- and deletable + # will then fail. + # -> you have to use Win32::SetFileAttributes + # to get rid of those files from within Perl. + # Because the chmod is not really needed on WIN32, + # just skip it! + chmod $mode, $target unless ($^O eq "MSWin32"); +} + +sub Usage +{ + my ($txt) = @_; + + print "Usage:\n"; + print "\t$tool [ -m mode ] file ... directory\n"; + print "\n"; + print "\t-d Create non-exising directories\n"; + print "\t-m mode Set the mode for the installed file"; + print " (0755 by default)\n"; + print "\tfile Name of file\n"; + print "\tdirectory Destination directory\n"; + + print "$txt\n" if $txt; + + exit 2; +} + +# EOF installEpics.pl diff --git a/src/tools/makeBaseApp.pl b/src/tools/makeBaseApp.pl new file mode 100644 index 000000000..0ef13bfa4 --- /dev/null +++ b/src/tools/makeBaseApp.pl @@ -0,0 +1,1023 @@ +#!/usr/local/bin/perl +# +# Author: Kay-Uwe Kasemir, +# based on Marty Kraimer's makeBaseApp +# +# 1-27-97 +# +# Notes: +# 1) The perl location /usr/local/bin/perl may be wrong, +# the safest way to run this script is via a direct +# perl