Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
release.pl 2.95 KiB
# FILENAME...	release.pl
#
# USAGE... This PERL script is used in conjunction with a start_epics_xxx
#          script to setup environment variables for medm.  It defaults to
#          csh output, but a switch enables bash output (second form below).
#
# ORIGINAL AUTHOR: Ron Sluiter
# 
# SYNOPSIS...	perl release.pl (<ioctop> directory)
#               perl -s release.pl -form=bash (<ioctop> directory)  
#
#
#
# MODIFICATION LOG...
# 03/25/04 rls Support for GATEWAY environment variable.
# 04/08/04 rls Bug fix for spaces between macro and '=' sign; e.g. MPF = /home/mpf.
# 01/25/08 rls Support "include" entries without a macro; e.g. "include /home/ioc/configure/MASTER_RELEASE"
# 01/29/08 rls Bug fix; "($macro) =" line is wrong.
# 04/06/11 daa Add bash output format support.
# 03/20/15 kcl Rewrite to use recursive function, allows in-place resolution of included files
# 03/02/17 kmp Also look for macros in optional include files

#
#Version:       $Revision$
#Modified By:   $Author$
#Last Modified: $Date$

use Env;

$top = $ARGV[0];

sub Parse
{	
	my ($file, $applications) = @_;	
	
	if (-r "$file")
	{
		open(my $fh, "$file") or die "Cannot open $file\n";
		
		while ($line = <$fh>)
		{			
			next if ( $line =~ /\s*#/ );
			
			chomp($line);
			$line =~ s/\r//g;
			$_ = $line;
			
			#test for "include" command
			($prefix,$post) = /(.*)\s* (.*)/;
			
			if ($prefix eq "include" || $prefix eq "-include")
			{
				($prefix,$macro,$post) = /(.*)\s* \s*\$\((.*)\)(.*)/;
				
				if ($macro eq "")
				{
					#true if no macro is present
					#the following looks for
					#prefix = post
					($prefix,$post) = /(.*)\s* \s*(.*)/;
				}
				else
				{
					$base = $applications{$macro};
				
					if ($base eq "")
					{
						#print "error: $macro was not previously defined\n";
					}
					else