kay's perl branch
This commit is contained in:
2
Makefile
2
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
|
||||
|
||||
|
||||
43
README.Perl
Normal file
43
README.Perl
Normal file
@@ -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!
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
36
src/include/makeEpicsVersion.pl
Normal file
36
src/include/makeEpicsVersion.pl
Normal 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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
151
src/libCom/bldEnvData.pl
Normal 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
151
src/libCom/env/bldEnvData.pl
vendored
Normal 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
|
||||
102
src/libCom/error/makeStatTbl.pl
Normal file
102
src/libCom/error/makeStatTbl.pl
Normal 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
102
src/libCom/makeStatTbl.pl
Normal 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";
|
||||
|
||||
36
src/libCom/misc/makeEpicsVersion.pl
Normal file
36
src/libCom/misc/makeEpicsVersion.pl
Normal 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;
|
||||
|
||||
|
||||
4
src/libCom/os/WIN32/README.getopt
Normal file
4
src/libCom/os/WIN32/README.getopt
Normal 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-
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
22
src/sequencer/makeVersion.pl
Normal file
22
src/sequencer/makeVersion.pl
Normal file
@@ -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=<IN>;
|
||||
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;
|
||||
@@ -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
|
||||
|
||||
|
||||
39
src/tools/cp.pl
Normal file
39
src/tools/cp.pl
Normal file
@@ -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
|
||||
108
src/tools/installEpics.pl
Normal file
108
src/tools/installEpics.pl
Normal file
@@ -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 <read-only> 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
|
||||
1023
src/tools/makeBaseApp.pl
Normal file
1023
src/tools/makeBaseApp.pl
Normal file
File diff suppressed because it is too large
Load Diff
23
src/tools/mkdir.pl
Normal file
23
src/tools/mkdir.pl
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/usr/local/bin/perl
|
||||
#
|
||||
# UNIX-mkdir in Perl
|
||||
#
|
||||
# -p option generates full path to given dir
|
||||
|
||||
use File::Path;
|
||||
use Getopt::Std;
|
||||
getopt();
|
||||
|
||||
foreach $dir ( @ARGV )
|
||||
{
|
||||
if ($opt_p)
|
||||
{
|
||||
mkpath ($dir) or die "Cannot make directory $dir";
|
||||
}
|
||||
else
|
||||
{
|
||||
mkdir ($dir, 0777) or die "Cannot make directory $dir";
|
||||
}
|
||||
}
|
||||
|
||||
# EOF mkdir.pl
|
||||
69
src/tools/mv.pl
Normal file
69
src/tools/mv.pl
Normal file
@@ -0,0 +1,69 @@
|
||||
#!/usr/local/bin/perl
|
||||
#
|
||||
# UNIX-mv in Perl
|
||||
|
||||
use File::Copy;
|
||||
|
||||
sub Usage
|
||||
{
|
||||
my ($txt) = @_;
|
||||
|
||||
print "Usage:\n";
|
||||
print "\tmv oldname newname\n";
|
||||
print "\tmv file [ file2 file3 ...] directory\n";
|
||||
print "\nError: $txt\n" if $txt;
|
||||
|
||||
exit 2;
|
||||
}
|
||||
|
||||
sub Move
|
||||
{
|
||||
my ($src, $dest) = @_;
|
||||
|
||||
print "Move($src, $dest)\n";
|
||||
|
||||
copy ($src, $dest) or die "Cannot copy $src to $dest";
|
||||
unlink ($src) or die "Cannot remove $src";
|
||||
}
|
||||
|
||||
# return filename.ext from Drive:/path/a/b/c/filename.ext
|
||||
sub Filename
|
||||
{
|
||||
my ($file) = @_;
|
||||
|
||||
$file =~ s'.*[/\\]'';
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
# 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];
|
||||
|
||||
print "move @sources into $target\n";
|
||||
|
||||
# If target is (already existent) directory,
|
||||
# move files into it:
|
||||
if (-d $target)
|
||||
{
|
||||
foreach $file ( @sources )
|
||||
{
|
||||
Move ($file, "$target/" . Filename($file));
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
# Otherwise the target is a filename.
|
||||
# Now 'mv' may be either a 'move' or a 'rename',
|
||||
# in any case it requires exactly two args: old and new name.
|
||||
|
||||
Usage("Need exactly one source") if $#sources != 0;
|
||||
$source = @sources[0];
|
||||
|
||||
# Move only if a simple rename
|
||||
# fails (e.g. across file systems):
|
||||
Move ($source, $target) unless (rename $source, $target);
|
||||
|
||||
# EOF mv.pl
|
||||
32
src/tools/rm.pl
Normal file
32
src/tools/rm.pl
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/usr/local/bin/perl
|
||||
#
|
||||
# UNIX-rm in Perl
|
||||
|
||||
use File::Path;
|
||||
use File::Find;
|
||||
use Getopt::Std;
|
||||
|
||||
getopt();
|
||||
|
||||
foreach $arg ( @ARGV )
|
||||
{
|
||||
next unless -e $arg;
|
||||
|
||||
if (-d $arg)
|
||||
{
|
||||
if ($opt_r and $opt_f)
|
||||
{
|
||||
rmtree $arg;
|
||||
}
|
||||
else
|
||||
{
|
||||
rmdir ($arg) or die "Cannot delete $arg";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unlink ($arg) or die "Cannot delete $arg";
|
||||
}
|
||||
}
|
||||
|
||||
# EOF rm.pl
|
||||
Reference in New Issue
Block a user