1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# WARNING:  This is not the same as HW08.  I am illustrating concepts, not doing HW08.
#           There may be some similarities.  Some names will be changed deliberately.

# Rule 'test_print_twos' builds the (executable) file test_print_twos.
test_print_twos:  test_print_twos.o  print_twos.o
    # Link object files to create executable.
    gcc  test_print_twos.o  print_twos.o  -o test_print_twos

# Rule 'test_print_twos.o' builds the (object file) file test_print_twos.o.
test_print_twos.o:  test_print_twos.c
    # Compile test_print_twos.c to an object file test_print_twos.o.
    gcc  -c  test_print_twos.c

# Rule 'print_twos.o' builds the (object file) file print_twos.o.
print_twos.o:  print_twos.c
    # Compile print_twos.c to an object file print_twos.o.
    gcc  -c  print_twos.c

run:  test_print_twos
    ./test_print_twos

.PHONY:  run
# Every rule that does not create a file by the name of that rule's target (e.g., "run")
# is a "phony rule" and must be listed after .PHONY: ▒    Yes, this is bizarre.

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