Browse Source

KISS build system up and running

feature/build_system
Maximilian Stiefel 3 years ago
parent
commit
1d1b95f533
  1. 2
      .gitignore
  2. 68
      Makefile
  3. 4
      include/stepper.h
  4. 2
      src/drivers/a4988.cpp
  5. 2
      src/hal/stepper.cpp
  6. 2
      src/main.cpp

2
.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++

68
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} "

4
include/stepper.h

@ -1,8 +1,8 @@
#ifndef INCLUDED_HAL_STEPPER
#define INCLUDED_HAL_STEPPER
#include <include/a4988.h>
#include <lib/json.hpp>
#include <a4988.h>
#include <json.hpp>
#include <thread>
namespace simon {

2
drivers/a4988.cpp → src/drivers/a4988.cpp

@ -1,4 +1,4 @@
#include <include/a4988.h>
#include <a4988.h>
#include <pigpio.h>
#include <queue>
#include <cmath>

2
hal/stepper.cpp → src/hal/stepper.cpp

@ -1,4 +1,4 @@
#include <include/stepper.h>
#include <stepper.h>
#include <thread>
#include <functional>
#include <iostream>

2
main.cpp → src/main.cpp

@ -1,5 +1,5 @@
#include <iostream>
#include <include/stepper.h>
#include <stepper.h>
#include <boost/program_options.hpp>
int main(int argc, char *argv[])
Loading…
Cancel
Save