-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
92 lines (74 loc) · 2.93 KB
/
Copy pathMakefile
File metadata and controls
92 lines (74 loc) · 2.93 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Air Quality Monitor — GCC/Clang (Linux, macOS, MSYS2/MinGW on Windows)
TARGET = air_quality_monitor
SRC_DIR = src
INC_DIR = include
PLUGIN_DIR = plugins
SRCS = $(SRC_DIR)/app/main.c \
$(SRC_DIR)/core/globals.c \
$(SRC_DIR)/core/aqm_paths.c \
$(SRC_DIR)/core/aqm_platform.c \
$(SRC_DIR)/core/aqm_db.c \
$(SRC_DIR)/sensor/sensor_loader.c \
$(SRC_DIR)/sensor/sensor_utils.c \
$(SRC_DIR)/sensor/sensor_info.c \
$(SRC_DIR)/sensor/sensor_detector.c \
$(SRC_DIR)/data/insert_data.c \
$(SRC_DIR)/data/fetch_data.c \
$(SRC_DIR)/report/alert_system.c \
$(SRC_DIR)/data/export_to_csv.c \
$(SRC_DIR)/config/configure_limits.c \
$(SRC_DIR)/data/generate_statistics.c \
$(SRC_DIR)/maintenance/backup_database.c \
$(SRC_DIR)/maintenance/data_cleanup.c \
$(SRC_DIR)/sensor/interval_collection.c \
$(SRC_DIR)/report/generate_pdf_report.c \
$(SRC_DIR)/config/config_persistence.c
CC ?= gcc
CFLAGS = -Wall -Wextra -std=c99 -I$(INC_DIR) -I$(INC_DIR)/core -I$(INC_DIR)/sensor
LIBS = -lsqlite3
SHARED_CFLAGS = -Wall -Wextra -std=c99 -I$(INC_DIR) -I$(INC_DIR)/core -I$(INC_DIR)/sensor
ifeq ($(OS),Windows_NT)
PLUGIN_EXT = dll
SHARED_FLAGS = -shared
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
PLUGIN_EXT = dylib
SHARED_FLAGS = -dynamiclib
else
PLUGIN_EXT = so
SHARED_FLAGS = -shared -fPIC
LIBS += -ldl
endif
endif
# PDF via libharu: HAVE_HPDF=0 if libhpdf is not installed (typical on Windows unless you use vcpkg/MSYS).
ifeq ($(OS),Windows_NT)
HAVE_HPDF ?= 0
else
HAVE_HPDF ?= 1
endif
ifeq ($(HAVE_HPDF),1)
CFLAGS += -DHAVE_HPDF
LIBS += -lhpdf
endif
# Optional: wiringPi (Linux/Raspberry Pi). Keeps Windows/macOS builds working by default.
HAVE_WIRINGPI ?= 0
ifeq ($(HAVE_WIRINGPI),1)
CFLAGS += -DHAVE_WIRINGPI
LIBS += -lwiringPi
endif
.PHONY: all clean plugins
all: $(TARGET)
plugins: $(PLUGIN_DIR)/dht22_plugin.$(PLUGIN_EXT) $(PLUGIN_DIR)/bme680_plugin.$(PLUGIN_EXT) $(PLUGIN_DIR)/pms5003_plugin.$(PLUGIN_EXT) $(PLUGIN_DIR)/mhz19_plugin.$(PLUGIN_EXT)
$(TARGET): $(SRCS)
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
$(PLUGIN_DIR)/dht22_plugin.$(PLUGIN_EXT): $(PLUGIN_DIR)/dht22_plugin.c $(INC_DIR)/sensor/sensor.h $(INC_DIR)/core/globals.h
$(CC) $(SHARED_CFLAGS) $(SHARED_FLAGS) -o $@ $<
$(PLUGIN_DIR)/bme680_plugin.$(PLUGIN_EXT): $(PLUGIN_DIR)/bme680_plugin.c $(INC_DIR)/sensor/sensor.h $(INC_DIR)/core/globals.h
$(CC) $(SHARED_CFLAGS) $(SHARED_FLAGS) -o $@ $<
$(PLUGIN_DIR)/pms5003_plugin.$(PLUGIN_EXT): $(PLUGIN_DIR)/pms5003_plugin.c $(INC_DIR)/sensor/sensor.h $(INC_DIR)/core/globals.h
$(CC) $(SHARED_CFLAGS) $(SHARED_FLAGS) -o $@ $<
$(PLUGIN_DIR)/mhz19_plugin.$(PLUGIN_EXT): $(PLUGIN_DIR)/mhz19_plugin.c $(INC_DIR)/sensor/sensor.h $(INC_DIR)/core/globals.h
$(CC) $(SHARED_CFLAGS) $(SHARED_FLAGS) -o $@ $<
clean:
rm -f $(TARGET) $(TARGET).exe *.o *.so *.dylib *.dll plugins/*.so plugins/*.dylib plugins/*.dll