Skip to content

Instantly share code, notes, and snippets.

@huwan
Created July 25, 2022 09:05
Show Gist options
  • Save huwan/4577bb9256e2588b203572499a6a7275 to your computer and use it in GitHub Desktop.
Save huwan/4577bb9256e2588b203572499a6a7275 to your computer and use it in GitHub Desktop.
TARGET ?= a.out
SRC_DIRS ?= .
SRCS := $(shell find $(SRC_DIRS) -name '*.cpp' -or -name '*.c')
OBJS := $(addsuffix .o,$(basename $(SRCS)))
DEPS := $(OBJS:.o=.d)
INC_DIRS := $(shell find $(SRC_DIRS) -type d -not -path '*/.*')
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
CPPFLAGS ?= $(INC_FLAGS) -MMD -MP -Wall -g -std=c++17
LDFLAGS := -pthread -lm
$(TARGET): $(OBJS)
$(CXX) $(LDFLAGS) $(OBJS) -o $@ $(LDLIBS)
$(RM) $(OBJS) $(DEPS)
.PHONY: clean
clean:
$(RM) $(TARGET) $(OBJS) $(DEPS)
-include $(DEPS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment