⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 makedep.pl

📁 是地震解释软件OpenglTect的源码,3d效果很棒
💻 PL
字号:
;#_Pmake________________________________________________________________________;#;# This perl script provides the header file dependencies for a Pmake Makefile;# Original script by Jean-Paul Lefevre (Total GPH);# Adapted for Pmake by Bert Bril;# RCS : $Id: makedep.pl,v 1.2 2003/09/25 12:56:42 arend Exp $;#______________________________________________________________________________warn "Running ...\n" if $verbose;do SetDefaults();do GetArg();do BuildVpath();do BuildNodep();@command = ($cpp, $flags, @ipath, @files, "|");do PrintVar() if $debug;do CheckVar();do ProcessFiles();do RemoveDep();do CleanupDep();do CreateOutFile();warn "Done ...\n" if $verbose;;#______________________________________________________________________________;#;#	Purpose	: Print variables for debuggingsub	PrintVar {	print "script   : $script\n";	print "verbose  : $verbose\n";	print "debug    : $debug\n";	print "outfile  : $outfile\n";	print "ndepfile : $ndepfile\n";	print "\n";	1;};#______________________________________________________________________________;#;#	Purpose	: Set default value to variables.sub	SetDefaults {	warn "Setting default values ...\n" if $verbose;	$verbose  = 0;	$Pdebug   = 0;	$debug    = 0;	$libvar	  = "LIBWORK";	$bindir	  = "BINDIR";	$cpp	  = "$ENV{'GNUCC'}";	$flags	  = "-D$ENV{'HDIR'} -M";	$basename = '[!#%\+\-0-~]*';	$filename = "[!-~]*";	@ipath	  = ();	@vpath	  = ();	@files	  = ();	@progs	  = ();	@libsrcs  = ();	if ($0 =~ m%/%) {		$script	= $1 if ($0 =~ m%/($basename)$%);	}	else {		$script	= $0;	}	$ndepfile = "$ENV{'WORK'}/Pmake/NoDepend";	if( ! -e $ndepfile ) {		$ndepfile = "$ENV{'PMAKE'}/NoDepend";		if( ! -e $ndepfile ) {			undef $ndepfile;		}	}	$outfile = ".deps";	@nodep  = ("/usr/include","/usr/include/sys","/usr/include/X11");	1;};#______________________________________________________________________________;#;#	Purpose	: Parse the command line;#	Usage	:  -v -d -f outfile -n nodepfile -Ipath   files ...sub	GetArg {	warn "Parsing command line ...\n" if $verbose;	while(@ARGV && ($_ = $ARGV[0]) =~ /^-(.)(.*)/) {		if($ARGV[0] eq "-v") {			$verbose = 1;		}		elsif($ARGV[0] eq "-D") {			$Pdebug   = 1;		}		elsif($ARGV[0] eq "-d") {			$verbose = 1;			$debug   = 1;		}		elsif($ARGV[0] eq "-f") {			$outfile = $ARGV[1];			shift(@ARGV);		}		elsif($ARGV[0] eq "-n") {			$ndepfile = $ARGV[1];			shift(@ARGV);		}		elsif($1 eq "I") {			@ipath = (@ipath, $ARGV[0]);		}		shift(@ARGV);	}	warn "Parsed command line ...\n" if $debug;	while(@ARGV && ($_ = $ARGV[0]) =~ /(.)(.*)/) {		if ($1 eq "=") {			@libsrcs = (@libsrcs, $2);		}		else {			@progs = (@progs, $2);		}		shift(@ARGV);	}	warn "Separated lib and prog sources ...\n" if $debug;	foreach (@progs) {		s/\@//;	}	@files = (@libsrcs, @progs);	warn "files are @files ...\n" if $debug;	foreach (@progs) {		s/\..*$//;	}	warn "progs are @progs ...\n" if $debug;	warn "libsrcs are @libsrcs ...\n" if $debug;	1;};#______________________________________________________________________________;#;#	Purpose	: Check some variables.;#	Remark	: exit if wrong settings.sub	CheckVar {	warn "Checking variables ...\n" if $verbose;	if( ! @files) {		warn "No sources to make dependencies !\n" if $verbose;		exit 0;	}	1;};#______________________________________________________________________________;#;#	Purpose	: Build list of path to be removed in dependenciessub	BuildVpath {	warn "Building vpath ...\n" if $verbose;	@vpath = @ipath;	foreach (@vpath) {		s/-I//g;		s/(\.)/\\$1/g;	}	print "vpath :\n@vpath\n\n" if $debug;	1;};#______________________________________________________________________________;#;#	Purpose	: Update list of no dependency regular expressions;#	Remark	: quote special characters; # indicates commentsub	BuildNodep {	return if ! defined $ndepfile;	warn "Building nodep ...\n" if $verbose;	open(NODEP, "$ndepfile") || die "Cannot open $ndepfile !\n";	while(<NODEP>) {		next line if /^#/;      # comment		next line if /^\s*$/;   # empty string		chop;		s/(\W)/\\$1/g;		@nodep = (@nodep, $_);	}	close NODEP;	print "No dependencies :\n@nodep\n\n" if $debug;	1;};#______________________________________________________________________________;#;#	Purpose	: Get full list of dependencies.;#	Remark	: sub	ProcessFiles {	warn "Processing files ...\n" if $verbose;	open(DEPEND, "@command") || die "Cannot run @command !\n";	while(<DEPEND>) {		if (/^($filename\.o): /) {			@modules = (@modules,$1);			@headers = (@headers, "#",				($' =~ /($filename\.[ih]+[fhxp]?[xp]?)/g));			print "Processing: $1 ...\n" if $Pdebug;		}		else {			@headers =				(@headers, /($filename\.[ih]+[fhxp]?[xp]?)/g);		}	}	close DEPEND;	print "Full headers :\n@headers\n\n" if $debug;	1;};#______________________________________________________________________________;#;#	Purpose	: Remove some dependencies;#	Remark	: Loop on headers list then loop on no dependencies listsub	RemoveDep {	warn "Removing dependencies ...\n" if $verbose;	local(@list);	local($file, $donot, $depend);	foreach $file (@headers) {		$depend = 1;		foreach $donot (@nodep) {			if(($file =~ m/$donot/)) {				$depend = 0;				last;			}		}		if($depend) {			@list = (@list, $file);		}	}	@headers = @list;	print "Simple headers :\n@headers\n\n" if $debug;	1;};#______________________________________________________________________________;#;#	Purpose	: Remove path;#	Remark	: Loop on headers list then loop on path listsub	CleanupDep {	warn "Clearing pathnames ...\n" if $verbose;	local($file, $path);	foreach $file (@headers) {		foreach $path (@vpath) {			$file =~ s%$path/%%;		}	}	print "Clean headers :\n@headers\n\n" if $debug;	1;};#______________________________________________________________________________;#;#	Purpose	: Update outfilesub	CreateOutFile {	warn "Creating new $outfile ...\n" if $verbose;	local($mark)	= "Do NOT delete this line";	local($string);	local($where);	$string = ">$outfile";	open(DEPFILE, $string) || die "Can't open $string !\n";	do OutputDep();	close(DEPFILE);	1;};#______________________________________________________________________________;#;#	Purpose	: Print list of dependencies;#	Remark	: blocks of names are vertically alignedsub	OutputDep {	warn "Writing dependencies ...\n" if $verbose;	local($i)	= 0;	local($n)	= $#headers + 1;	local($max)	= 77;	local($len) 	=  0;	local($dec)	= &MaxLength(@modules) + length($libvar) + 7;	local($margin)	= " " x $dec;	local($string);	local($found);	local($module);	local($prog);	local($progfound);	foreach $module (@modules) {		$found = 0;		foreach $prog (@progs) {			if($module =~ m/$prog\.o/) {				$found = 1;				$progfound = $prog;			}		}		if ( $found ) {			$string  = " \$($bindir)\/$progfound";		}		else {			$string  = "\$($libvar)($module)";		}		$len     = length("$string") + 2;		$string .= " " x ($dec - $len);		$string .= " :";		$len	 = $dec;		print DEPFILE "\n$string";		for($i++ ; $i < $n && $headers[$i] ne "#"; $i++) {			if($len + length($headers[$i]) > $max) {				print DEPFILE " \\\n";				$string = "$margin $headers[$i]";				$len    = length("$string");			}			else {				$string = " $headers[$i]";				$len   += length($string);			}			print DEPFILE "$string";		}	}	print DEPFILE "\n";	1;};#______________________________________________________________________________;#;#	Purpose	: Return length of the longest string in the listsub	MaxLength {	local($max) = 0;	local($len) = 0;	local($item);	foreach $item (@_) {		$len = length($item);		$max = $len if($len > $max);	}	$max + 1;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -