Current way is like this, which looks quite clumsy..
ex1_test : ex1.o ex1_test.o
cc -o ex1_test ex1.o ex1_test.o
ex2_test : ex2.o ex2_test.o
cc -o ex2_test ex2.o ex2_test.o
ex3_test : ex3.o ex3_test.o
cc -o ex3_test ex3.o ex3_test.o
Is there a variable that I can use to represent the current target and reduce the duplicate?
Thanks!
Step 1, introduce automatic variables:
Step 2, realize that these rules all look the same, and replace them with a pattern rule: