Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSC 253 Lecture 14.

Similar presentations


Presentation on theme: "CSC 253 Lecture 14."— Presentation transcript:

1 CSC 253 Lecture 14

2 Makefiles The purpose of using make is to—
Allow us to type less when we need to recompile. Allow us to use fewer includes. Allow skipping of files that do not need to be recompiled when something changes. a. and b. a. and c. b. and c.

3 Changing the makefile Consider the makefile from the lecture: CC=gcc C_OPTS=-pedantic-errors all: charcat linecat charcat: charcat.c     $(CC) $(C_OPTS) -o charcat charcat.c linecat: linecat.c     $(CC) $(C_OPTS) -o linecat linecat.c clean:     rm -f linecat charcat What’d happen if linecat was not on the all line? linecat wouldn’t be recompiled when make is invoked linecat would never be recompiled. Compilation errors would occur in charcat. The compiler would produce an a.out rather than linecat.

4 Suppose one file #includes another …
Assume that file a.c contains #include b.h, which of the following lines should be included in the makefile? a: -o a a.c b.c a: -o a a.c b.h b: -o b b.c a.c b: -o b b.c a.h a: -o a a.c a: -o b a.c

5 Suppose files are separately compiled …
Recall that in Lecture 7, we needed to compile gcc -o lifetime lifetime.c other.c Neither file #included the other, but lifetime.c calls the testsum function in other.c. If we wanted to make lifetime, what should the line in the makefile say? lifetime: lifetime.c other.c lifetime: lifetime.c other.h lifetime: lifetime.c other: other.c lifetime.h b and d


Download ppt "CSC 253 Lecture 14."

Similar presentations


Ads by Google