DOC PREVIEW
FSU COP 4342 - COP 4342 Program Development

This preview shows page 1-2-3-4 out of 13 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 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 13 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 13 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 13 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

makeMy description of the program make is that ittakes a set of rules describing dependencies anddescribing creation of new filesin order to satisfy the requirements for the “creation” of some target.Unix Tools: Program Development 6makeAnother description from Chapter 1 of the Gnu Make manual:The make utility automaticallydetermines which pieces of alarge program need to berecompiled, and issues commandsto recompile them.Unix Tools: Program Development 6Invoking makeThere are several options that are generally useful with make:-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 children-C DIR # change directory to DIR before starting the make process-s # silent mode, don’t echo commandsUnix Tools: Program Development 6MakefilesMakefiles use rules to determine their actions. The rules look like:target: [ prerequisites ]-TAB- action-TAB- action-TAB- ...Unix Tools: Program Development 6TargetsTargets usually either specify a file that is to be made via this rule orjust identify the rules for execution (often called a “phony” target.)Targets may also be implicit.Unix Tools: Program Development 6PrerequisitesThese generally define the files that the target depends on, and thegeneral idea is that if any of those have a modified (or creation) timelater than the target, then actions for the rule will be executed to createa new version of the target (which you should try to make sure has anew modified or created time.)Unix Tools: Program Development 6ActionsThese generally define the actions that are needed to create the targetfrom the prerequisites. These actions are largely executions ofdiscrete programs such as gcc, make (yes, recursion is quitecommon), ld, bison, flex, and so on. Rules must consist ofconsecutive lines that start with a TAB character. Since these areusually interpreted as shell commands, you can do things such asmulti-lines (but use the backslash to make sure that the“single-linedness” of your construction is clear):for name in dir1 dir2 dir3 \do ; \${MAKE} $name ; \doneUnix Tools: Program Development 6ActionsThere are also actual make conditionals which are interpreted bymake and not by the shell; these look likeifeq (ARG1,ARG2)...endififdef (ARG1)...endifUnix Tools: Program Development 6Setting 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’’Unix Tools: Program Development 6Pattern rulesOne of the nice things that you can do with make is create “patternrules”.These are rules that let you abstract a pattern from a set of similarrules, and use that pattern in lieu of explicitly naming all of thoserules.For instance,%.o : %.ccc -c $< -o $@ # $@ refers to the# target, $< refers to# the*first*(and only)# prerequisiteUnix Tools: Program Development 6Automatic 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-autoUnix Tools: Program Development 6Example 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.pdfUnix Tools: Program Development 6Example Makefiles%.c:echo $*Unix Tools: Program Development


View Full Document

FSU COP 4342 - COP 4342 Program Development

Download COP 4342 Program Development
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 Program Development 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 Program Development 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?