1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# This is the makefile for fill_array
# You are free to copy/adapt this code

# syntax for a rule
#<target>: <dependencies>
#   <command>
#   <command>

# compiles our executable test_fill_array using object files
# runs the linker step of compiling
test_fill_array: test_fill_array.o fill_array.o
    gcc test_fill_array.o fill_array.o -o test_fill_array

# compiles fill_array.c into an object file
# runs the preprocessor and the compiler steps of compiling
fill_array.o: fill_array.c fill_array.h
    gcc -c fill_array.c

# compiles test_fill_array.c into an object file
test_fill_array.o: test_fill_array.c fill_array.h
    gcc -c test_fill_array.c

# compiles test_fill_array then runs it
run: test_fill_array
    ./test_fill_array

cleanrun: clean run

# removes all files produced by this makefile
clean:
    rm -f *.o
    rm -f test_fill_array

# prints out Hello
# because sometimes we need a computer to tell us hello
hello:
    echo "Hello"

.PHONY: clean hello run cleanrun

© Copyright 2022 Alexander J. Quinn         This content is protected and may not be shared, uploaded, or distributed.