-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
43 lines (31 loc) · 969 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Target executable
TARGET := main
# Build directory
BUILD_DIR := build
# Compiler and flags
CC := gcc
CFLAGS := -Wall -Wextra -pedantic -g -pthread
# Path to OpenSSL header files
CFLAGS += -Iopenssl-3.2.2/ -Imqtt/ -Imqtt/MQTTPacket/
# Percorso agli header files di nanoModbus
CFLAGS += -InanoMODBUS/
# Libraries
LIBS := -lstdc++ -Lopenssl-3.2.2 -lssl -lcrypto
# Source files
#SRCS := main.c modbus_task.c mqtt_task.c nanoMODBUS/nanomodbus.c utilis.c mqtt/MQTTInterface.c mqtt/MQTTClient.c
SRCS := $(wildcard *.c nanoMODBUS/*.c mqtt/*.c mqtt/MQTTPacket/*.c)
# Object files (within the build directory)
OBJS := $(patsubst %.c,$(BUILD_DIR)/%.o,$(SRCS))
# Default target
all: $(TARGET)
# Build the target
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) $^ -o $@ $(LIBS)
# Compile source files into object files (within the build directory)
$(BUILD_DIR)/%.o: %.c
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
# Clean up
clean:
rm -f $(TARGET) $(OBJS)
.PHONY: all clean