add makefile, improve gitignore, formatting

master
Ondřej Hruška 3 days ago
parent c0fb0e8122
commit 715d12f29a
  1. 3
      .gitignore
  2. 8
      CMakeLists.txt
  3. 25
      Makefile
  4. 2
      src/main_simpletest.c

3
.gitignore vendored

@ -1,2 +1,3 @@
/cmake-build-debug/
.idea
/build/
/.idea

@ -9,10 +9,10 @@ add_executable(modbus
src/modbus.c
src/main.c
src/stcpsc.c
src/hexdump.c
src/hexdump.h
src/parsehex.c
src/parsehex.h)
src/hexdump.c
src/hexdump.h
src/parsehex.c
src/parsehex.h)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

@ -0,0 +1,25 @@
BUILD_DIR := build
EXECUTABLE := modbus
.PHONY: all build run clean rebuild debug release help
all: build
# Configure and build the project
build:
@mkdir -p $(BUILD_DIR)
@cd $(BUILD_DIR) && cmake ..
@cmake --build $(BUILD_DIR)
@echo "Build complete. Executable: $(BUILD_DIR)/$(EXECUTABLE)"
# Run the built executable, build if needed
run: build
@echo "Running $(EXECUTABLE)..."
@./$(BUILD_DIR)/$(EXECUTABLE)
# Clean build artifacts
clean:
@rm -rf $(BUILD_DIR)
@echo "Build directory cleaned"
# Rebuild from scratch
rebuild: clean build

@ -1,3 +1,5 @@
// This test shows how the library could be used to implement a Modbus RTU device
#include <stdio.h>
#include "modbus.h"
#include "hexdump.h"

Loading…
Cancel
Save