Makefile: compile all *.cpp files and create individual executables

This is an example of a Makefile the compiles all *.cpp files in the current folder and turns them all into individual executables

CC=g++
CFLAGS=-c -Wall
SOURCES = $(wildcard *.cpp)
EXECS = $(SOURCES:%.cpp=%)

all: $(EXECS)

clean:
	rm $(EXECS)

Tested on OSX 10.14 and GNU Make 3.81

Comments are closed.