Skip to content

Instantly share code, notes, and snippets.

@yuvalif
Created February 5, 2018 08:42
Show Gist options
  • Save yuvalif/ad5a527c10bc90658fd9247bf2865de4 to your computer and use it in GitHub Desktop.
Save yuvalif/ad5a527c10bc90658fd9247bf2865de4 to your computer and use it in GitHub Desktop.
Making all .cpp files in the directory, each one into its own target
# making all .cpp files in the directory
# each one into its own target
CXX ?= g++
CXXFLAGS ?= -Wall -std=c++11
.PHONY: all clean
SRCS = $(wildcard *.cpp)
PROGS = $(patsubst %.cpp,%,$(SRCS))
all: $(PROGS)
%: %.cpp
$(CXX) $(CXXFLAGS) -o $@ $<
clean:
rm -f $(PROGS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment