Created
July 25, 2022 09:05
-
-
Save huwan/4577bb9256e2588b203572499a6a7275 to your computer and use it in GitHub Desktop.
A generic Makefile based on https://spin.atomicobject.com/2016/08/26/makefile-c-projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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