Skip to content

Instantly share code, notes, and snippets.

@sshravan
Created November 5, 2018 20:08
Show Gist options
  • Save sshravan/cea33008f36892699fcb81500b15c358 to your computer and use it in GitHub Desktop.
Save sshravan/cea33008f36892699fcb81500b15c358 to your computer and use it in GitHub Desktop.
My sample Makefile
CXX=g++
CXXFLAGS=-g -std=c++11 -Wall -Wextra -Wcast-align -pedantic
LDFLAGS :=
SRC_DIR := src
OBJ_DIR := bin
SRC_FILES := $(wildcard $(SRC_DIR)/*.cpp)
OBJ_FILES := $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRC_FILES))
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
dsl: $(OBJ_FILES)
$(CXX) $(LDFLAGS) -o $@ $^
all: dsl
default: dsl
run: dsl
./dsl
clean:
rm -f $(OBJ_DIR)/*.o
rm -f dsl
.PHONY: clean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment