DOC PREVIEW
FSU COP 4342 - COP 4342 Lecture Notes

This preview shows page 1-2-3-4-5-6 out of 17 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Fall 2006 Program Development 7makeMy description of the program make is that it+ takes a set of rules describing dependencies and+ describing creation of new filesin order to satisfy the requirements for the “creation” ofsome target.COP 4342Fall 2006 Program Development 7makeAnother description from Chapter 1 of the Gnu Makemanual:The make utility automatically determineswhich pieces of a large program need to berecompiled, and issues commands to recompilethem.COP 4342Fall 2006 Program Development 7Invoking makeThere are several options that are generally useful withmake:-f MAKEFILE # specify an alternative makefile to the defaults of# ’GNUmakefile’, ’Makefile’, or ’makefile’-k # continue for other targets even after an error-i # completely ignore errors-d # print debugging information-j [N] # fork off children to handle tasks. If N is# specified, create no more than N childrenCOP 4342Fall 2006 Program Development 7-C DIR # change directory to DIR before starting the make process-s # silent mode, don’t echo commandsCOP 4342Fall 2006 Program Development 7MakefilesMakefiles use rules to determine their actions. Therules look like:target: [ prerequisites ]-TAB- action-TAB- action-TAB- ...COP 4342Fall 2006 Program Development 7TargetsTargets usually either specify a file that is to be madevia this rule or just identify the rules for e xec ution (oftencalled a “phony” targe t.)Targets may also be implicit.COP 4342Fall 2006 Program Development 7PrerequisitesThese generally define the files that the target dependson, and the general idea is that if any of those have amodified (or creation) time later than the target, thenactions for the rule will be executed to create a newversion of the target (which you should try to make surehas a new modified or created time.)COP 4342Fall 2006 Program Development 7ActionsThese generally define the actions that are needed tocreate the target from the prerequisites. These actionsare largely executions of discrete programs such as gcc,make (yes, recursion is quite common), ld, bison, flex,and so on. Rules must consist of consecutive lines thatstart with a TAB character. Since these are usuallyinterpreted as shell comm ands, you can do things such asmulti-lines (but use the backslash to make sure that the“single-linedness” of your construction is clear):COP 4342Fall 2006 Program Development 7for name in dir1 dir2 dir3 \do ; \${MAKE} $name ; \doneCOP 4342Fall 2006 Program Development 7ActionsThere are also actual make conditionals which areinterpreted by make and not by the shell; these looklikeCOP 4342Fall 2006 Program Development 7ifeq (ARG1,ARG2)...endififdef (ARG1)...endifCOP 4342Fall 2006 Program Development 7Setting ordinary variablesYou can use “=” and “?=” to set ordinary variables:CFLAGS ?= -g -O3 # conditionally set ${CFLAGS} to# ‘‘-g -O3’’ iff it is not# already definedCC = /usr/bin/gcc ${CFLAGS} # unconditionally set ${CC} to# ‘‘/usr/bin/cc’’COP 4342Fall 2006 Program Development 7Pattern rulesOne of the nice things that you can do with make iscreate “pattern rules”.These are rules that let you abstract a pattern from aset of similar rules, and use that pattern in lieu of explicitlynaming all of those rules.For instance,COP 4342Fall 2006 Program Development 7%.o : %.ccc -c $< -o $@ # $@ refers to the# target, $< refers to# the *first* (and only)# prerequisiteCOP 4342Fall 2006 Program Development 7Automatic variables$@ # the target of the rule$< # the first prerequisite$^ # all of the prerequisites$? # all of the prerequisites that are newer than the target file$* # the ‘‘stem’’ only; essentially, this is the complement of the static portion# of the target definition... see Makefile-autoCOP 4342Fall 2006 Program Development 7Example Makefilestargets: 01-introduction-out.pdf 02-processes-out.pdf \03-shells1-out.pdf 03-shells2-out.pdf 04-shells3-out.pdf \05-shells4-out.pdf 06-environment-out.pdf 07-perl01-out.pdf \08-perl02-out.pdf 09-perl03-out.pdf 10-perl04-out.pdf \11-perl05-out.pdf 12-perl06-out.pdf 13-perl07-out.pdf \14-programdevel-out.pdf 15-programdevel02-out.pdf \16-programdevel03-out.pdf 17-programdevel04-out.pdf \18-programdevel05-out.pdf 19-programdevel06-out.pdf \20-programdevel07-out.pdf structure-out.pdf%-out.pdf: %.texpdflatex $<gij -jar pp4p.jar $*.pdf $*-out.pdfCOP 4342Fall 2006 Program Development 7Example Makefiles%.c:echo $*COP


View Full Document

FSU COP 4342 - COP 4342 Lecture Notes

Download COP 4342 Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view COP 4342 Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view COP 4342 Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?