Introduction to Unix CS 21 Lecture 17 Lecture

  • Slides: 52
Download presentation
Introduction to Unix – CS 21 Lecture 17

Introduction to Unix – CS 21 Lecture 17

Lecture Overview n More on La. Te. X n Inserting Figures n n n

Lecture Overview n More on La. Te. X n Inserting Figures n n n Creating your own commands Make n n n xfig Writing Makefiles Running make Revision Control Systems n n rcs CVS

Creating Figures In Unix n xfig n n n Simple drawing tool that allows

Creating Figures In Unix n xfig n n n Simple drawing tool that allows you to make diagrams and pictures Saves pictures to files called *. fig Can export pictures to Encapsulated Post. Script (*. eps)

Example Of xfig

Example Of xfig

Inserting Figures Into Latex Documents n Once you have a ps or eps file,

Inserting Figures Into Latex Documents n Once you have a ps or eps file, you can insert them into your La. Te. X documents n n One way: special{psfile=picture. eps} Might have to mess with the vskip as this tends to place the bottom of the picture on the current line and not the top of the picture.

Example Of Inserting A Figure

Example Of Inserting A Figure

Output Of Inserting A Figure

Output Of Inserting A Figure

Inserting With Space Adjustment

Inserting With Space Adjustment

Output Of Inserting A Figure With Space Adjustment

Output Of Inserting A Figure With Space Adjustment

Steps For Inserting A Figure Into La. Te. X n n n 1. Make

Steps For Inserting A Figure Into La. Te. X n n n 1. Make a figure using xfig (or some other tool that generates a. ps file) 2. Use the special{psfile=name. eps} command to place the picture in your document 3. Use vskip to position the picture correctly on the page

Is There Another Way? n n There are several other ways La. Te. X

Is There Another Way? n n There are several other ways La. Te. X supports “floating” objects n n n Figures and diagrams that can slightly move about the page depending on the text Can specify absolute locations of figures as well Read more about it!

La. Te. X Commands Versus Environments n Command n n n Used to perform

La. Te. X Commands Versus Environments n Command n n n Used to perform one singular task name{parameter} Environment n n n Used to perform a task at the beginning and end of a block begin{name} end{name}

Making A New Command n newcommand{name}[NUM]{COMMAND} n n NUM can be 0 -9 and

Making A New Command n newcommand{name}[NUM]{COMMAND} n n NUM can be 0 -9 and represents the number of arguments passed to the command Each parameter will be passed in a separate brace when called Inside the command, {#1} will retrieve the value of the first parameter, {#2} will retrieve the second, and so on… Example: n n newcommand{assignment}[1]{bf CS 21 Assignment {#1}} Usage: assignment{2}

Example Of A New Command

Example Of A New Command

Output Of Our New Command

Output Of Our New Command

Making A New Environment n n n newenvironment{name}[NUM]{BEGIN COMMANDS}{END COMMANDS} You must specify what

Making A New Environment n n n newenvironment{name}[NUM]{BEGIN COMMANDS}{END COMMANDS} You must specify what happens when you begin an environment and what happens when you end and environment Example: You might need a header and a signature for a letter, that would be the start and end of a “letter” environment

Example Of A New Environment

Example Of A New Environment

Output Of Our New Environment

Output Of Our New Environment

La. Te. X Basics n n That should be enough for you to get

La. Te. X Basics n n That should be enough for you to get a good handle on how La. Te. X works There a lot more commands and formatting techniques in La. Te. X If you can think of how your paper should be, you can probably get La. Te. X to format it that way Read more about it!

Make n A generic tool for running and compiling programs n n Usually used

Make n A generic tool for running and compiling programs n n Usually used in conjunction with C programs Not restricted to C files Used to automate all of the steps in creating a final product We will use make to automate the creation of. ps files from La. Te. X files

Makefiles n n Make requires a special file named “Makefile” or “makefile” in your

Makefiles n n Make requires a special file named “Makefile” or “makefile” in your current directory This is read in by make and contains a list of all commands that will be executed

Format Of A Makefile VARIABLE DECLARATIONS TARGET: DEPENDENCIES COMMANDS Must be a tab!

Format Of A Makefile VARIABLE DECLARATIONS TARGET: DEPENDENCIES COMMANDS Must be a tab!

Variable Declarations In Makefiles n Typically all caps (but doesn’t have to be) n

Variable Declarations In Makefiles n Typically all caps (but doesn’t have to be) n n Example: MYDIR=/home/csgrads/villarre Using variables is done just like bash shell n cat ${MYDIR}/my. File

Targets In A Makefile n First target listed is special n n You can

Targets In A Makefile n First target listed is special n n You can specify a specific target on the command line n n Always the main target Example: make all Make will execute all of the commands listed under the target in order to “make” the target

Example Of A Makefile

Example Of A Makefile

Dependencies n n Before make can create a target, it checks and makes sure

Dependencies n n Before make can create a target, it checks and makes sure that any other target that the first target is dependant on is constructed Make automatically keeps track of what files need to be reprocessed since the last time it was run

Graphical Representation Of Dependencies target. One: depend. One depend. Two echo “done” depend. One:

Graphical Representation Of Dependencies target. One: depend. One depend. Two echo “done” depend. One: echo “depend. One done” depend. Two: echo “depend. Two done”

Example Of Dependencies

Example Of Dependencies

Using make To Do Actual Work n Task: n n Get a printable file

Using make To Do Actual Work n Task: n n Get a printable file from a La. Te. X document we are working with Steps: n n Run latex on the. tex file Run dvips on the. dvi file generated

Example Makefile

Example Makefile

Example Run

Example Run

Implicit Rules And Variables In make n Make knows how to do some certain

Implicit Rules And Variables In make n Make knows how to do some certain tasks automatically n n n Depends on a set of automatically declared variables Example: Make knows that in order to get a. dvi file, it can run ${TEX} on a. tex file Unfortunately, some of these variables are set to values you don’t want n Fortunately you can override the values of these variables

Example Of Implicit Rules

Example Of Implicit Rules

Fake Targets n Targets with no dependencies can be used to simply execute commands

Fake Targets n Targets with no dependencies can be used to simply execute commands at will n n Referred to as Phony targets (can be specified as such as well) Common usage of Phony targets are to clean up directories

Using make To Clean Up Directories n Latex creates a whole bunch of files

Using make To Clean Up Directories n Latex creates a whole bunch of files we don’t need or may want to clean up n n n All we need is the. tex file and we can create everything else. aux, . log, . dvi, . ps can all be removed Create a special phony target called “clean” that executes the rm command

Example Of make clean

Example Of make clean

Make Basics n n n You now know how makefiles work and should be

Make Basics n n n You now know how makefiles work and should be able to come up with a few working examples Of course, make is much, much more complex than what I’ve shown here, but this is enough to be functional Read more about it!

Revision Control Systems n Have you ever been working on a program or paper

Revision Control Systems n Have you ever been working on a program or paper and changed something substanital? n n Have you ever wanted to go back to an older version that you threw away? Revision control systems are designed to help you with just these sorts of issues

Purpose Of Revision Control n n n Allows you to go back to previous

Purpose Of Revision Control n n n Allows you to go back to previous versions Maintain a history of changes Locks out others from messing with the same file at the same time

rcs – A Simple Revision Control Scheme n rcs is a system that will

rcs – A Simple Revision Control Scheme n rcs is a system that will control access to a project and keep track of all changes and revisions n n n rcs ci co

Setting Up The System For RCS n n Create a subdirectory named RCS in

Setting Up The System For RCS n n Create a subdirectory named RCS in the directory that contains the files you want to manage Check in all of the files that you want to manage in order to get an initial revision n This removes the originals and creates a new file with the extension “, v” in the RCS directory

Checking In n Usage: ci [FLAGS] file n n Stands for check in Keeps

Checking In n Usage: ci [FLAGS] file n n Stands for check in Keeps track of revision and version number Starts at 1. 1 (revision. version) and increments the version every time you check in Flag: n n -r. NUM Checks in the file with the given revision and version number

Example Of Checking In

Example Of Checking In

Checking Out For Reading n Usage: co [FLAGS] file n n Stands for check

Checking Out For Reading n Usage: co [FLAGS] file n n Stands for check out By default, checks out the most recently checked in version Can’t check the file back in Flag: n -r. NUM n Check out revision and version NUM

Example Of Checking Out For Reading

Example Of Checking Out For Reading

Checking Out Locked n n n co –l file Checks out a copy that

Checking Out Locked n n n co –l file Checks out a copy that can be modified and checked back in Will prevent other users from checking out a version that they can modify n Only allows one person changing a file at a time

Example

Example

Checking History Of A File rlog n n The rlog command will print out

Checking History Of A File rlog n n The rlog command will print out all of the log messages that you typed in when you checked in a modified file Usage: rlog filename

Other Access Restrictions - rcs n n Usage: rcs [FLAGS] file -a. LOGIN n

Other Access Restrictions - rcs n n Usage: rcs [FLAGS] file -a. LOGIN n n -e. LOGIN n n Add LOGIN to the list of users that can check out a file Remove LOGIN from the list of users that can check out a file Check out the man page for more information!

CVS – Concurrent Versions System n n A more advanced version of RCS Works

CVS – Concurrent Versions System n n A more advanced version of RCS Works on hierarchical collections of directories n n n Trees and branches Works over networks as well Typical distribution format for Unix packages in development

In Lab Today n n Document construction with La. Te. X Writing Makefiles to

In Lab Today n n Document construction with La. Te. X Writing Makefiles to manage your La. Te. X files

Next Time n Quiz #3 n n Setting up packages n n n Perl,

Next Time n Quiz #3 n n Setting up packages n n n Perl, La. Te. X, make Configure scripts Apt, rpm Running jobs at prescribed times