Last active
May 9, 2024 10:31
-
-
Save KouroshAlinaghi/e82e523bf5984562077c9c82d670cd1e to your computer and use it in GitHub Desktop.
Makefile
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
APP_NAME=youpick | |
CC=g++ | |
C_FLAGS=-std=c++20 -Wall -Wextra | |
OBJECTS_DIR=lib | |
SRC_DIR=src | |
SRCS=$(shell find ${SRC_DIR} -type f \( -name "*.cpp" \)) | |
HEADERS=$(shell find ${SRC_DIR} -type f \( -name "*.hpp" \)) | |
OBJECTS=$(patsubst $(SRC_DIR)/%.cpp, $(OBJECTS_DIR)/%.o, ${SRCS}) | |
$(APP_NAME): $(OBJECTS) | format | |
$(CC) $(C_FLAGS) $^ -o ${APP_NAME} | |
$(OBJECTS): $(HEADERS) | $(OBJECTS_DIR) | |
$(OBJECTS_DIR)/%.o: $(SRC_DIR)/%.cpp | |
$(CC) $(C_FLAGS) -c $< -o $@ | |
$(OBJECTS_DIR): | |
cp $(SRC_DIR) $(OBJECTS_DIR) -r | |
find $(OBJECTS_DIR) -type f \( -name "*.cpp" -o -name "*.hpp" \) -exec rm {} \; | |
clean: | |
rm -rf lib ${APP_NAME} | |
format: | |
find . -type f \( -name '*.cpp' -or -name '*.hpp' \) -exec clang-format -i {} + |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment