Presentation is loading. Please wait.

Presentation is loading. Please wait.

2000 Copyrights, Danielle S. Lahmani UNIX Tools G22.2245-001, Fall 2000 Danielle S. Lahmani Lecture 9.

Similar presentations


Presentation on theme: "2000 Copyrights, Danielle S. Lahmani UNIX Tools G22.2245-001, Fall 2000 Danielle S. Lahmani Lecture 9."— Presentation transcript:

1 2000 Copyrights, Danielle S. Lahmani UNIX Tools G22.2245-001, Fall 2000 Danielle S. Lahmani email: lahmani@cs.nyu.edu Lecture 9

2 2000 Copyrights, Danielle S. Lahmani UNIX Development Tools Make source control mechanisms –SCCS –RCS

3 2000 Copyrights, Danielle S. Lahmani MAKE reference:”Make a Programming for maintaining Computer Programs,” S.I.Feldman, BellLabs, 1978 make: “program for maintaining computer programs” developed at Bell Labs around 1978 automatically updates files for users based on a series of dependency rules stored in a special format file called a “makefile”.

4 2000 Copyrights, Danielle S. Lahmani make make can run with any programming language whose compiler can be run from a shell cmd. can describe any tasks where some files must be updated automatically from others whenever the others change. typical usage: executable is updated from object files which are in turn made by compiling source files uses makefile rules and file last modification times to decide which files need to be updated

5 2000 Copyrights, Danielle S. Lahmani Makefile format Targetlist : dependency list command list targetlist list of target files, that is the name of the executable file that will be produced command list: is a list of zero or more command lines, needed to reconstruct the target files from the dependency files

6 2000 Copyrights, Danielle S. Lahmani Invoking Make make -f makefile make target make make: looks for file makefile or Makefile in current directory, picks first target listed in the makefile

7 2000 Copyrights, Danielle S. Lahmani Make: Sequence of execution Make executes all commands associated with target in makefile if one of 2 conditions is satisfied. –file “target” does not exist –file “target” exists but one of the sourcefiles in the dependencylist has been modified more recentrly than file “target”

8 2000 Copyrights, Danielle S. Lahmani Make: Suggestions and Warnings make -n prints cmds without execution make -ts causes relevant files to be up to date make -d verbose output cmds listed in command list executed as /bin/sh provides macro substitution ability to encapsulate cmds in a single file for easy administration install: cp main1 /usr/bin/myprog; rm main1

9 2000 Copyrights, Danielle S. Lahmani Comparison between make and GNU make GNU make is usually /usr/local/bin/make Function | GNU make | SUN make Basic Rule target : dependency1... Same sh commandline1 sh commandline2... Variables VAR = Same... $(VAR)...

10 2000 Copyrights, Danielle S. Lahmani make and GNU make comparisons Function | GNU make | SUN make ----------------------------------------------------------------------------- Pattern Rule t1%t2 : d1%d2 Same... $*... Automatic Variable $@ == target Same in commandline $* == % pattern $* == % pattern OR target w/out suffix $< == first dependency $< == all dependencies $^ == all dependencies Not Defined

11 2000 Copyrights, Danielle S. Lahmani GNU make and make comparison Function | GNU make | SUN make ------------------------------------------------------------------------------ Automatic Variable in dependency list $$@ means target Same Predefined Pattern %.o : %.c Same Rules (Small Sample) % : SCCS Same % : RCS N/A Variables used in CFLAGS = Same Predefined Patterns CPPFLAGS = Same (Small Sample) CC = Same

12 2000 Copyrights, Danielle S. Lahmani GNU Make and Make comparison Function | GNU make | SUN make ------------------------------------------------------------------------------ Automatic #include include $(OBJ:.o=.d).KEEP_STATE: dependency generation %.d: %.c for C programs /bin/sh -ec 'gcc -MM -MG $(CPPFLAGS) $*.c | sed '\''s/$*\.o[ :]*/$@ &/g'\'' > $@' (Just include these # The previous line is for GNU make only line(s) in the # Handles missing.h files # All.h files must be makefile) # (with RCS or SCCS) # present. # Doesn't notice if a # Notices if makefile # makefile command changes # command changes.

13 2000 Copyrights, Danielle S. Lahmani RCS and SCCS RCS: Revision Control System SCCS is the UNIX Source Code Control System provide the ability to store/access and protect all of the versions of source code files.

14 2000 Copyrights, Danielle S. Lahmani SCCS provides the following benefits 1. if program has multiple versions, it keeps track only of differences between multiple versions. 2. allows only one person at the time to do the editing 3. provides a way to look at the history of program development

15 2000 Copyrights, Danielle S. Lahmani SCCS: Basic operations Admin or create utility to create an SCCS file. the SCCS file cannot be edited or compiled directly, it contains special info. get or edit utility to edit a file specifying for reading or writing (-e) option. delta utility to return a new version of a file to the SCCS system prs allows you to obtain a file's history. sact allows you to see the current editing activities on a particular SCCS file.

16 2000 Copyrights, Danielle S. Lahmani RCS: Basic Operations mkdir RCS: for setup ci foo: check in new file foo co foo: get read only file foo co -l foo: get writable version of file foo.rcsdiff [-r ] foo.c: compare foo.c with checked -in foo.c

17 2000 Copyrights, Danielle S. Lahmani RCS and SCCS Comparison (Prof. Thomas Anantharanam's Notes) Version Control: ID Numbering : 1.1 -> 1.2 -> 1.3... -> 2.1 -> 2.2 -> 2.3... \ -> 1.2.1.1 -> 1.2.1.2 ->... 1.2.2.1 -> 1.2.2.2... ID's with 2 digits are called "main line" or "trunk" versions. ID's with 4 (in RCS 4 or more) digits are called "branch" versions.

18 2000 Copyrights, Danielle S. Lahmani RCS and SCCS Comparison (Prof. Thomas Anantharanam's Notes) Function | GNU RCS | SCCS ------------------------------------------------------------------------------ setup mkdir RCS mkdir SCCS check in new foo.c ci foo.c sccs create foo.c check in update to foo.c ci foo.c sccs delta foo.c get readonly foo.c co foo.c sccs get foo.c get writeable foo.c co -l foo.c sccs edit foo.c

19 2000 Copyrights, Danielle S. Lahmani RCS and SCCS Comparison (Prof. Thomas Anantharanam's Notes) Function | GNU RCS | SCCS ------------------------------------------------------------------------------ Specify next version ID co -l foo.c sccs edit - r foo.c (Default : increment ci -r foo.c sccs delta foo.c last ID digit by one) # id is ID without # the last digit! compare foo.c with rcsdiff [-r ] foo.c sccs diffs [-r ] \ checked in foo.c foo.c [-r if not latest]

20 2000 Copyrights, Danielle S. Lahmani RCS and SCCS Comparison (Prof. Thomas Anantharanam's Notes) Function | GNU RCS | SCCS ------------------------------------------------------------------------------ list versions of foo.c rlog foo.c sccs print foo.c Insert version in code char *ID = "$Id$; char *ID = "%A%"; Display these versions ident what in compiled program.


Download ppt "2000 Copyrights, Danielle S. Lahmani UNIX Tools G22.2245-001, Fall 2000 Danielle S. Lahmani Lecture 9."

Similar presentations


Ads by Google