diff --git a/.gitignore b/.gitignore index 4342cc9..17d6a39 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ *.swp -bin/* +build/* # Created by https://www.toptal.com/developers/gitignore/api/c++ # Edit at https://www.toptal.com/developers/gitignore?templates=c++ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2fb9f03 --- /dev/null +++ b/Makefile @@ -0,0 +1,68 @@ +# +# ************************************************************** +# * Simple C++ Makefile Template * +# * * +# * Author: Arash Partow (2003) * +# * URL: http://www.partow.net/programming/makefile/index.html * +# * Modified: Maximilian Stiefel (2021) * +# * * +# * Copyright notice: * +# * Free use of this C++ Makefile template is permitted under * +# * the guidelines and in accordance with the the MIT License * +# * http://www.opensource.org/licenses/MIT * +# * * +# ************************************************************** +# + +CXX := -clang +CXXFLAGS := -pedantic-errors -Wall -Wextra -Werror -std=c++20 -pthread +LDFLAGS := -lstdc++ -lrt -lpigpio -lm -lboost_program_options +BUILD := ./build +OBJ_DIR := $(BUILD)/objects +APP_DIR := $(BUILD)/app +TARGET := SaMcam +INCLUDE := -Iinclude/ -Ilib/ +SRC := \ + $(wildcard src/drivers/*.cpp)\ + $(wildcard src/hal/*.cpp) \ + $(wildcard src/*.cpp) \ + +OBJECTS := $(SRC:%.cpp=$(OBJ_DIR)/%.o) +DEPENDENCIES \ + := $(OBJECTS:.o=.d) + +all: build $(APP_DIR)/$(TARGET) + +$(OBJ_DIR)/%.o: %.cpp + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -MMD -o $@ + +$(APP_DIR)/$(TARGET): $(OBJECTS) + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) -o $(APP_DIR)/$(TARGET) $^ $(LDFLAGS) + +-include $(DEPENDENCIES) + +.PHONY: all build clean debug release info + +build: + @mkdir -p $(APP_DIR) + @mkdir -p $(OBJ_DIR) + +debug: CXXFLAGS += -DDEBUG -g +debug: all + +release: CXXFLAGS += -O2 +release: all + +clean: + -@rm -rvf $(OBJ_DIR)/* + -@rm -rvf $(APP_DIR)/* + +info: + @echo "[*] Application dir: ${APP_DIR} " + @echo "[*] Object dir: ${OBJ_DIR} " + @echo "[*] Sources: ${SRC} " + @echo "[*] Objects: ${OBJECTS} " + @echo "[*] Dependencies: ${DEPENDENCIES} " + @echo "[*] Linker flags: ${LDFLAGS} " diff --git a/include/stepper.h b/include/stepper.h index e115660..0d72934 100644 --- a/include/stepper.h +++ b/include/stepper.h @@ -1,8 +1,8 @@ #ifndef INCLUDED_HAL_STEPPER #define INCLUDED_HAL_STEPPER -#include -#include +#include +#include #include namespace simon { diff --git a/drivers/a4988.cpp b/src/drivers/a4988.cpp similarity index 99% rename from drivers/a4988.cpp rename to src/drivers/a4988.cpp index 9e4fc53..f385246 100644 --- a/drivers/a4988.cpp +++ b/src/drivers/a4988.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/hal/stepper.cpp b/src/hal/stepper.cpp similarity index 99% rename from hal/stepper.cpp rename to src/hal/stepper.cpp index f39042e..727a24a 100644 --- a/hal/stepper.cpp +++ b/src/hal/stepper.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/main.cpp b/src/main.cpp similarity index 97% rename from main.cpp rename to src/main.cpp index de6032a..c3123e4 100644 --- a/main.cpp +++ b/src/main.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include int main(int argc, char *argv[])