ctcr

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 代码 · 共 174 行

TXT
174
字号
#!/bin/sh# @(#)ctcr	4.1	(ULTRIX)	7/17/90## ctc, ctcr - ctrace, compile, and optionally run a C program## /************************************************************************# *									*# *			Copyright (c) 1986 by				*# *		Digital Equipment Corporation, Maynard, MA		*# *			All rights reserved.				*# *									*# *   This software is furnished under a license and may be used and	*# *   copied  only  in accordance with the terms of such license and	*# *   with the  inclusion  of  the  above  copyright  notice.   This	*# *   software  or  any  other copies thereof may not be provided or	*# *   otherwise made available to any other person.  No title to and	*# *   ownership of the software is hereby transferred.			*# *									*# *   This software is  derived  from  software  received  from Bell 	*# *   Laboratories.  Use, duplication, or disclosure is  subject  to	*# *   restrictions  under  license  agreements  with  AT&T.		*# *									*# *   The information in this software is subject to change  without	*# *   notice  and should not be construed as a commitment by Digital	*# *   Equipment Corporation.						*# *									*# *   Digital assumes no responsibility for the use  or  reliability	*# *   of its software on equipment which is not supplied by Digital.	*# *									*# ************************************************************************/#/*# *# *   Modification History:# *# * 19-Aug-87 logcher# *	Added /bin/sh header and '#' for comments in front of # *	copyright.# */if test $# = 0then	cat <<!Usage:	ctc  [ ctrace options ] file ... [ makefile target ] [ make macros ]	ctcr [ ctrace options ] file ... [ makefile target ] [ make macros ]!	exitfi# get any initial parameter values:if test -f .ctcr_initthen	. .ctcr_initfi# default parameter values:MAKE=${MAKE-make}# get the arguments:for ido	case $i in	*.[cly])	if test "$lastarg" != -r			then	firstfile=$i				break			fi			;;	-r)		CTRACEFLAGS="$CTRACEFLAGS $i '$2'"			shift 2			;;	*)		CTRACEFLAGS="$CTRACEFLAGS '$i'"			shift	esac	lastarg=$idonefor ido	case $i in	*.[cly])	files="$files $i"			;;			# note: $i may contain embedded blanks.	*)		if expr "$i" : '[^=]*=' >/dev/null			then	MAKEFLAGS="$MAKEFLAGS $i" # don't quote make args			else	TARGET=$i			fi	esacdoneif [ $firstfile ]then	:else	echo missing file parameter	exit 1fi# check for a makefile:for i in [Mm]akefile s.[Mm]akefile *.mkdo	case $i in	ctcr_temp.mk)	;;	Makefile|makefile|s.Makefile|s.makefile|[!*]*.mk)	makefile=$i ;;	esacdone# make sure that the makefile is for the traced files:prefix=`expr $firstfile : '\(.*\)\..$'`if [ $makefile ] && egrep "^$prefix.o[^a-z]|[^a-z]$prefix.o[^a-z]|[^a-z]$prefix.o$" $makefile >/dev/nullthen	# change the TARGET name in a copy of the makefile:	pwd=`pwd`	TARGET=${TARGET-`basename $pwd`}	patterns="s/^$TARGET\([^a-z.]\)/$TARGET.t\1/gs/\([^a-z]\)$TARGET\([^a-z.]\)/\1$TARGET.t\2/gs/\([^a-z]\)$TARGET$/\1$TARGET.t/gs/^$TARGET\.b\([^a-z]\)/$TARGET.t.b\1/gs/\([^a-z]\)$TARGET.b\([^a-z]\)/\1$TARGET.t.b\2/gs/\([^a-z]\)$TARGET.b$/\1$TARGET.t.b/g"	# change a copy of the makefile to trace each file:	for i in $files	do	prefix=`expr $i : '\(.*\)\..$'`		patterns="$patternss/^$prefix\.o\([^a-z]\)/$prefix\.t.o\1/gs/\([^a-z]\)$prefix\.o\([^a-z]\)/\1$prefix\.t.o\2/gs/\([^a-z]\)$prefix\.o$/\1$prefix\.t.o/g"	done	sed "$patterns" $makefile >ctcr_temp.mk		# change a copy of any 3bldp spec file to trace each file:	if test -f $TARGET.b	then	sed "$patterns" $TARGET.b >$TARGET.t.b	fi	# force relinking because the traced file's .t.o file may be up-to-date.	rm -f $TARGET.telse	# create a makefile:	TARGET=${TARGET-a.out}	cat >ctcr_temp.mk <<!$TARGET.t: $prefix.t.o	cc $LDFLAGS $prefix.t.o -o $TARGET.t!fi# Add the transformation rules for tracing C, lex, and yacc files:# Note: Can't use $*.t.c in place of temp.c because editing $*.c will not remake $*.t.c.cat >>ctcr_temp.mk <<!.SUFFIXES: .t.o.c.t.o:	ctrace $CTRACEFLAGS $< >ctcr_temp.c	$(CC) $(CFLAGS) -c ctcr_temp.c	rm ctcr_temp.c	mv ctcr_temp.o \$@.l.t.o:	ltrace $(LTRACEFLAGS) $< >ctcr_temp.l	$(LEX) $(LFLAGS) ctcr_temp.l	rm ctcr_temp.l	$(CC) $(CFLAGS) -c lex.yy.c	rm lex.yy.c	mv lex.yy.o \$@.y.t.o:	ltrace $(LTRACEFLAGS) $< | yaccer $(YACCERFLAGS) >ctcr_temp.y	$(YACC) $(YFLAGS) ctcr_temp.y	rm ctcr_temp.y	$(CC) $(CFLAGS) -c y.tab.c	rm y.tab.c	mv y.tab.o \$@!# trace and compile the file:command="$MAKE -f ctcr_temp.mk $MAKEFLAGS $TARGET.t"echo $command$command# Run target file if no errors and this script was not called as ctc.if [ $? -eq 0 ]then	rm -f ctcr_temp.* $TARGET.t.b	if [ $0 != ctc ]	then	set -x		$TARGET.t $RUNFLAGS	fifi

⌨️ 快捷键说明

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