Skip to content

Instantly share code, notes, and snippets.

@zapstar
Created March 11, 2018 14:34
Show Gist options
  • Save zapstar/b94b8f5077d5c8820bf8d87ad1d5ff92 to your computer and use it in GitHub Desktop.
Save zapstar/b94b8f5077d5c8820bf8d87ad1d5ff92 to your computer and use it in GitHub Desktop.
Makefile to generate separate binaries for each source file
CXX=clang++
CXXFLAGS=-Wall -Werror -std=c++11
all: $(patsubst %.cpp, %.out, $(wildcard *.cpp))
%.out: %.cpp Makefile
$(CXX) $(CXXFLAGS) $< -o $(@:.out=)
clean: $(patsubst %.cpp, %.clean, $(wildcard *.cpp))
%.clean:
rm -f $(@:.clean=)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment