EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  <19971998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  <19971998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Make, Scripts, Shell, Perl!?
From: Kay-Uwe Kasemir <[email protected]>
To: [email protected]
Date: Tue, 04 Feb 1997 15:05:43 -0700
Hi All:

As everyone noticed who has been following this thread so far,
we are getting closer and closer to a language-war ;-)

I'd like to underline why I wrote the initial mail
on "Make, Scripts, Shell, Perl!?":

        Build EPICS on PCs, using as little
        additional tools as possible.

I don't want to over-estimate this goal,
but I would consider a working PC-port of EPICS
essential for the long term future of EPICS.

There might be ways to port a UNIX-style shell,
ls, cp, mv, rm, awk, sed, grep, basename, date, sort,
chmod, touch, ...
to Windows.
But: If there is a way to build EPICS on PCs
without all these tools, that looks better to me.

Therefore I would definitely like to get rid of all shell-scripts
because every changed or new shell script can break the
EPICS-build on the PC: Just call another of the
familar tools like 'find' or misspell 'sort -u' as 'uniq'
and we need to port another tool to Windows.

But what common tool shall replace shell&Co?

Excuse me if this sounds west-coast
(if you like, blame it on my small English vocabulary),
but maybe we should make this a less academic discussion:

Can Python or TCL or ? really do what Perl does?
* Who is willing to demonstrate that?
* Who will rewite at least the essential scripts
        tools/installEpics.pl
        include/makeEpicsVersion.pl
        libCom/bldEnvData.pl
        libCom/makeStatSymTbl.pl
        sequencer/makeVersion.pl
  in whatever (s)he likes so that these new scripts
  work on both UNIX and Windows?

I have rewritten the ones listed above in Perl and I can now
build EPICS on sun4 and WIN32 using gnumake and Perl.
(A shell is still needed for some remaining shell-lines in Makefiles,
 I emilinated the need for all other UNIX-tools that were listed above).

What I liked most about Perl when using it:
- It compiled right out of the box on WIN32 and sun4
- It took about one week @2h/day to learn it.
- Converting the scripts was really easy
- Perl code might not win readability awards
  but it's certainly better than many shell scripts.
- The Perl scripts have about the same size _but_ they have
  better error checking/messages and comments.
  Stripped versions would be smaller.
- Perl offers system-independend ways for all that I needed:
  + check file dates,
  + create/rename/copy/remove files,
  + extract basenames etc.,
  + reg-exp. parsing of files
  + 'find', i.e. parse file trees,
  + generate full directory paths,
    e.g. mkpath("a/b/c") = mkdir("a") if not already there, then mkdir
("a/b")...
    I haven't tried this, but it should also work on VMS, paths like
    Root:[dir] are then parsed accordingly.

If anyone can do this in Python or tcl or ...
and this other tool could also be used to interprete
formulars in DM etc. then of course we should forget
about Perl and use the better tool.

-Kay




For what it's worth: base/tools/installEpics.pl
If non-perlists ignore the '$', '@' prefix on variables
I think it's readable.


#!/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-3-97 -kuk-
#
##########################################################

use Getopt::Std;
use File::Path;
use File::Copy;

$tool=$0;
$tool=~ s'.*[/\\].+'';  # simple 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 install_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";

    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 $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






Navigate by Date:
Prev: Re: Make, Scripts, Shell, Perl!? Richard Wolff
Next: Re: Make, Scripts, Shell, Perl!? Richard Wolff
Index: 1994  1995  1996  <19971998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Make, Scripts, Shell, Perl!? Richard Wolff
Next: Re: Make, Scripts, Shell, Perl!? Richard Wolff
Index: 1994  1995  1996  <19971998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 10 Aug 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·