title: How to make `make` make an a executable for each C file in a folder?
body: <p>My question is deceptively simple, but I have lost several hours of study trying to get the solution. I'm trying to create a Makefile that builds an executable for each .c file in a directory.</p>
  
  <p>I have tried the following:</p>
  
  <pre><code>CC = gcc
  SRCS = $(wildcard *.c)
  OBJS = $(patsubst %.c,%.o,$(SRCS))
  
  all: $(OBJS)
  $(CC) $&lt; -o $@
  
  %.o: %.c
      $(CC) $(CPFLAGS)  -c  $&lt;
  </code></pre>
  
  <p>but this way it is creating only <code>.o</code> files, and not any executables. I need a rule that makes an executable for each of these <code>.o</code> files. Something like the following:</p>
  
  <pre><code>gcc src.o -o src
  </code></pre>