title: How to create reference to an .o file in Makefile
body: <p>I was given two .o files with corresponding .h files to use for an assignment, but I do not know how to get the compiler to use the .o files.  This is the Makefile I am currently using:</p>
  
  <pre><code>    TARGET = prog
  LIBS = -lm
  CC = gcc
  CFLAGS = -g -Wall
  
  .PHONY: default all clean
  
  default: $(TARGET)
  all: default
  
  OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))
  HEADERS = $(wildcard *.h)
  
  %.o: %.c $(HEADERS)
      $(CC) $(CFLAGS) -c $&lt; -o $@
  
  .PRECIOUS: $(TARGET) $(OBJECTS)
  
  $(TARGET): $(OBJECTS)
      $(CC) $(OBJECTS) -Wall $(LIBS) -o $@
  
  clean:
      -rm -f *.o
      -rm -f $(TARGET)
  </code></pre>
  
  <p>I believe I need to add the file1.o and file2.o at the end, but I am not sure if that is right.  I do have the .h files in the C source files when appropriate, so the only reason that I can think of for the compilation error is that the .o files are not being compiled with my code.</p>