You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 07-Building-with-Make.md
+8-9Lines changed: 8 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -36,8 +36,7 @@ Using the powers of `git`, you travel into the future, read the rest of this cha
36
36
Instead of this hippie artisanal handcrafted sandwich garbage, you sit your past self down at their terminal and whisper savory nothings[^nothings] in their ear.
37
37
They --- you --- crack open a fresh editor and pen the pastrami of your dreams:
38
38
39
-
```makefile
40
-
39
+
```{.makefile .numberLines}
41
40
pickles: cucumbers vinegar dill
42
41
brine --with=dill cucumbers
43
42
@@ -139,7 +138,7 @@ Along with each target goes one or more commands that, when run, create the targ
139
138
For example, let's say you want to build an executable named `program` by compiling all the C`++` files in the current directory.
140
139
Youcoulddothefollowing:
141
140
142
-
```makefile
141
+
```{.makefile .numberLines}
143
142
program:
144
143
g++ *.cpp -o program
145
144
```
@@ -170,7 +169,7 @@ For our example, let's suppose we have a classic CS 1570 assignment with a `main
170
169
Whenever any one of these files change, we want to recompile `program`.
171
170
We specify these dependencies after the colon following the target name:
172
171
173
-
```makefile
172
+
```{.makefile .numberLines}
174
173
program: main.cpp funcs.h funcs.cpp
175
174
g++ *.cpp -o program
176
175
```
@@ -182,7 +181,7 @@ Not to worry: you can have one target depend on files produced by other targets!
182
181
Then, `make` will do the work of running each compilation and linking step as needed.
183
182
Continuing our example, we add two new targets for our object files, `main.o` and `funcs.o`:
184
183
185
-
```makefile
184
+
```{.makefile .numberLines}
186
185
program: main.o funcs.o
187
186
g++ main.o funcs.o -o program
188
187
@@ -226,7 +225,7 @@ and `make` will be like, "Sure thing, boss! Look at me, not being confused at al
226
225
Let's make a `clean` target for our example from the last section.
227
226
Having a target named `clean` that gets rid of all the compiled files in your current directory is good `make` etiquette.
228
227
229
-
```makefile
228
+
```{.makefile .numberLines}
230
229
program: main.o funcs.o
231
230
g++ main.o funcs.o -o program
232
231
@@ -276,7 +275,7 @@ We'll make a `CFLAGS` variable to hold the "release" flags and a `DEBUGFLAGS` va
276
275
That way, if we want to change our flags later on, we only need to look in one spot.
277
276
We'll also add a phony `debug` target so that running `make debug` builds our program in debug mode.
278
277
279
-
```makefile
278
+
```{.makefile .numberLines}
280
279
CFLAGS = -O2
281
280
DEBUGFLAGS = -g -Wall -Wextra
282
281
@@ -333,7 +332,7 @@ Hmm, but how would we write a command for this target? `g++` still needs to know
333
332
334
333
Let's rewrite our example using a pattern target to make the object files:
0 commit comments