Added gitignore and makefile

master
Mark 2022-06-24 19:58:10 -07:00
parent 732b716d8d
commit a97cbb249b
Signed by: Mark
GPG Key ID: AD62BB059C2AAEE4
2 changed files with 52 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
/.vscode
# Build files and final binary
/build
test

47
Makefile Normal file
View File

@ -0,0 +1,47 @@
TARGET_EXEC := test
BUILD_DIR := ./build
SRC_DIRS := ./src
# False targets
# (these are the only ones you manually run)
all: $(TARGET_EXEC)
run: all
./$(TARGET_EXEC)
clean:
-rm -r $(BUILD_DIR)
@echo ""
.PHONY: clean all run
#################################################
# Flags and autodetection
# -MMD and -MP generate makefiles with extension .d.
CPPFLAGS := -Wall -MMD -MP -I src
LDFLAGS := -l fftw3
# Find all cpp files in source dirs
SRCS := $(shell find $(SRC_DIRS) -name '*.cpp')
# Turns ./build/a.cpp into ./build/a.cpp.o
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
# Turns ./build/a.cpp.o into ./build/a.cpp.d
DEPS := $(OBJS:.o=.d)
#################################################
# Build targets
# C++ build step
$(BUILD_DIR)/%.cpp.o: %.cpp
mkdir -p $(dir $@)
g++ $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
# Final build step
$(TARGET_EXEC) : $(OBJS)
g++ $(OBJS) -o $@ $(LDFLAGS)
# Include generated makefiles
-include $(DEPS)