Unix™ System V
Total Page:16
File Type:pdf, Size:1020Kb
___ALTOS _ UNIX™ SYSTEM V .. SUPPORT Tools GuidE UNIXTM System V Support Tools Guide ACKNClfLEDGEMENTS The Altos logo, as it appears in this manual, is a registered trademark of Altos Computer Systems. EtherneeM is a trademark of Xerox Corporation. HYPERchanneYM is a trademark of Network Systems Corporation. UNIX™ is a trademark of AT&T Bell Labor ator ies. VAXTM is a trademark of Digital Equipment Corporation. WE™ is a trademark of AT&T Technologies. CONTENTS Chapter 1. INTRODUCTION Chapter 2. A PROGRAM FOR MAINT AINING COMPUTER PROGRAMS (make) Chapter 3. AUGMENTED VERSION OF -make Chapter 4. SOURCE CODE CONTROL SYSTEM USER GUIDE Chapter 5. THE M4 MACRO PROCESSOR Chapter 6. THE awk PROGRAMMING LANGUAGE Chapter 7. THE LINK EDITOR Chapter 8. THE COMMON OBJECT FILE FORMAT Chapter 9. ARBITRARY PRECISION DESK CALCULATOR LANGUAGE (BC) Chapter 10. INTERACTIVE DESK CALCULATOR (DC) Chapter 11. LEXICAL ANALYZER GENERATOR (LEX) Chapter 12. YET ANOTHER COMPILER- COMPILER (yacc) Chapter 13. UNIX SYSTEM TO UNIX SYSTEM COpy (UUCP) - 1 - Chapter 1 INTRODUCTION The SUPPORT TOOLS volume is a description of the various software "tools" that aid the UNIX* operating system user. The user should have at least 2 years of specialized training in computer related fields such as programming or use the UNIX system primarily for software system development. The following paragraphs contain a brief description of each chapter. The chapter A PROGRAM FOR MAINTAINING COMPUTER PROGRAMS (make) describes a software tool for maintaining, updating, and regenerating groups of computer programs. The many activities of program development and maintenance are made simpler by the make program. The chapter AUGMENTED VERSION OF "make" describes the modifications made to handle many of the problems within the original make program. The chapter SOURCE CODE CONTROL SYSTEM (SCeS) USER'S GUIDE describes the collection of SCCS programs under the UNIX operating system. The SCCS programs act as a "custodian" over the UNIX system files. The chapter M4 MACRO PROCESSOR describes a general purpose macro processor that may be used as a front end for rational Fortran, C, and other programming languages. The chapter "awk" PROGRAMMING LANGUAGE describes a software tool designed to make many common information retrieval and text manipulation tasks easy to state and to perform. * Trademark of AT&T Bell Laboratories 1-1 INTRODUCTION The chapter LINK EDITOR describes a software tool (ld) that creates load files by combining object files, performing relocation, and resolving internal references. The chapter COMMON OBJECT FILE FORMAT (COFF) describes the output file produced on some UNIX systems by the assembler and the link editor. The chapter ARBITRARY PRECISION DESK CALCULATOR LANGUAGE (BC) describes a compiler for doing arbitrary precision arithmetic on the UNIX operating system. The chapter INTERACTIVE DESK CALCULATOR (DC) describes a program implemented on the UNIX operating system to do arbitrary-precision integer arithmetic. The chapter LEXICAL ANALYZER GENERATOR (Lex) describes a software tool that lexically processes character input streams. The chapter YET ANOTHER COMPILER-COMPILER (yacc) describes the yacc program. The yacc program provides a general tool for imposing structure on the input to a computer program. The chapter REMOTE JOB ENTRY (RJE) describes a subsystem that supports remote job entries from a UNIX operating system to an IBM/360 or /370 host computer. The RJE uses a set of background processes to support remote job entries. The chapter UNIX SYSTEM TO UNIX SYSTEM COpy (UUCP) describes a network that provides information exchange (between UNIX systems) over the direct distance dialing network. The support tools provide an added dimension to the basic UNIX software commands. The "tools" described enable the user to fully utilize the UNIX operating system. 1-2 Chapter 2 A PROGRAM FOR MAINTAINING COMPUTER PROGRAMS (make) PAGE GENERAL. 2-1 BASIC FEATURES. 2-5 DESCRIPTION FILES AND SUBSTITUTIONS. 2-8 COMMAND USAGE. .. 2-11 SUFFIXES AND TRANSFORMATION RULES .................... 2-12 IMPLICIT RULES............................................. 2-14 SUGGESTIONS AND WARNINGS. .. 2-15 Chapter 2 A PROGRAM FOR MAINTAINING COMPUTER PROGRAMS (make) GENERAL In a programming project, a common practice is to divide large programs into smaller pieces that are more manageable. The pieces may require several different treatments such as being processed by a macro processor or sophisticated program generators (e.g., Yacc or Lex). The project continues to become more complex as the output of these generators are compiled with special options and with certain definitions and declarations. A sequence of code transformations develops which is difficult to remember. The resulting code may need further transformation by loading the code with certain libraries under control of special options. Related maintenance activities also complicate the process further by running test scripts and installing validated modules. Another activity that complicates program development is a long editing session. A programmer may lose track of the files changed and the object modules still valid especially when a change to a declaration can make a dozen other files obsolete. The programmer must also remember to compile a routine that has been changed or that uses changed declarations. The "make" is a software tool that maintains, updates, and regenerates groups of computer programs. A programmer can easily forget • Files that are dependent upon other files. • Files that were modified recently. • Files that need to be reprocessed or recompiled after a change in the source. • The exact sequence of operations needed to make an exercise a new version of the program. 2-1 MAKE The many activities of program development and maintenance are made simpler by the make program. The make program provides a method for maintaining up-to-date versions of programs that result from many operations on a number of files. The make program can keep track of the sequence of commands that create certain files and the list of files that require other files to be current before the operations can be done. Whenever a change is made in any part of a program, the make command creates the proper files simply, correctly, and with a minimum amount of effort. The make program also provides a simple macro substitution facility and the ability to encapsulate commands in a single file for convenient administration. The basic operation of make is to • Find the name of the needed target file in the description. • Ensure that all of the files on which it depends exit and are up to date. • Create the target file if it has not been modified SInce its generators were modified. The descriptor file really defines the graph of dependencies. The make program determines the necessary work by performing a depth-first search of the graph of dependencies. If the information on interfile dependencies and command sequences is stored in a file, the simple command make is frequently sufficient to update the interesting files regardless of the number edited since the last make. In most cases, the description file is easy to write and changes infrequently. It is usually easier to type the make command than to issue even one of the needed operations, so the typical cycle of program development operations becomes think - edit - make - test ... 2-2 MAKE The make program is most useful for medium-sized programming projects. The make program does not solve the problems of maintaining multiple source versions or of describing huge programs. As an' example of the use of make, the description file used to maintain the make command is given. The code for make is spread over a number of C language source files and a Yacc grammar. The description file contains: # Description file for the Make command p = Ip FILES = Makefile version.c defs main.c doname.c misc.c files.c dosys.c gram.y lex.c gcos.c OBJECTS = version.o main.o doname.o misc.o files.o dosys.o gram.o LIBES= -IS LINT = lint -p CFLAGS =-0 make: $(OBJECTS) cc $(CFLAGS) $(OBJECTS) $(LIBES) -0 make size make $(OBJECTS): defs gram.o: lex.c cleanup: - rm *.0 gram.c -du install: @size make lusr/bin/make cp make lusr/bin/make ; rm make print: $(FILES) # print recently changed files pr $? I $P touch print 2-3 MAKE test: make -dp I grep -v TIME >lzap lusr/bin/make -dp I grep -v TIME >2zap diff lzap 2zap rm lzap 2zap lint: dosys.c doname.c files.c main.c misc.c version.c gram.c $(LINT) dosys.c doname.c files.c main.c misc.c version.c gram.c arch: ar uv Isys/source/s2/make.a $(FILES) The make program usually prints out each command before issuing it. The following output results from typing the simple command make in a directory containing only the source and description files: cc -0 -c verSlOn.c cc -0 -c malll.C cc -0 -c doname.c cc -0 -c mlSC.C cc -0 -c files.c cc -0 -c dosys.c yacc gram.y mv y.tab.c gram.c cc -0 -c gram.c cc version.o main.o doname.o misc.o files.o dosys.o gram.o -IS -0 make 13188+3348+3044 = 19580b = 046174b Although none of the source files or grammars were mentioned by name in the description file, make found them using its suffix rules and issued the needed commands. The string of digits results from the size make command. The printing of the command line itself was suppressed by an @ sign. The @ sign on the size command in the description file suppressed the printing of the command, so only the sizes are written. 2-4 MAKE The. last few entries in the description file are useful maintenance sequences. The "print" entry prints only the files changed since the last make print command.