]> Git — Sourcephile - julm/air-duino.git/blob - GNUmakefile
fix png/$(sensor) rules
[julm/air-duino.git] / GNUmakefile
1 # Licence: WTFPLv2 <http://www.wtfpl.net/txt/copying/>
2 # Copyright 2015: Julien Moutinho <julm+air@autogeree.net>
3
4 .SECONDARY:
5 .SUFFIXES:
6 MAKEFLAGS += -r
7 RRD_CF:=AVERAGE
8 SENSORS:= \
9 humidity \
10 temperature \
11 quality \
12 particles
13
14 .rrd = $(wildcard rrd/*/*.rrd)
15
16 all: png
17
18 #
19 ## INO
20 ###
21
22 # For GNU/Linux
23 ARDUINO_DIR := /usr/share/arduino/
24 ARDMK_DIR := /usr/share/arduino/
25 AVR_TOOLS_DIR := /usr
26
27 # For Seeeduino
28 BOARD_TAG := uno
29
30 ARDUINO_LIBS := \
31 AirQuality_Sensor \
32 DustSensor \
33 Humidity_Temperature_Sensor \
34 LCD_Display9696 \
35 Wire
36
37 USER_LIB_PATH := $(abspath ./libraries)
38
39 include $(ARDMK_DIR)/Arduino.mk
40
41 ino: $(TARGET_EEP) $(TARGET_HEX)
42
43 #
44 ## PNG
45 ###
46 .PHONY: png $(addprefix png/,$(SENSORS))
47 png: $(addprefix png/,$(SENSORS))
48
49 ym=$(patsubst %.rrd,,$(notdir $*))
50 month_begin=$(shell date +'%s' -d '$(ym)/01')
51 month_end=$(shell date +'%s' -d '$(ym)/01 + 1 month - 1 second')
52 month_length=$(shell date +'%d' -d '$(ym)/01 + 1 month - 1 second')
53 day_begin=$(shell date +'%s' -d '$(ym)/$(day)')
54 day_end=$(shell date +'%s' -d '$(ym)/$(day) + 1 month - 1 second')
55
56 define png/sensor
57 sensor:=$1
58 label:=$2
59 png/$$(sensor): \
60 $$(patsubst rrd/%.rrd,png/$$(sensor)/%.png,$$(.rrd))
61 echo $$@
62
63 png/$$(sensor)/%.png: rrd/%.rrd
64 mkdir -p png/$$(sensor)/$$*
65 rrdtool graph $$@ \
66 -w 785 -h 120 -a PNG \
67 --slope-mode \
68 --start $$(month_begin) --end $$(month_end) \
69 --vertical-label '$$(label)' \
70 --x-grid HOUR:8:DAY:1:DAY:1:86400:%d \
71 DEF:$$(sensor)=rrd/$$*.rrd:$$(sensor):$$(RRD_CF) \
72 LINE1:$$(sensor)'#ff0000':"$$(sensor)"
73 for day in $$(shell seq -w $$(month_length)); \
74 do \
75 day_begin=$$$$(date +'%s' -d "$$(ym)/$$$$day"); \
76 day_end=$$$$(date +'%s' -d "$$(ym)/$$$$day + 1 day - 1 second"); \
77 rrdtool graph png/$$(sensor)/$$*/$$$$day.png \
78 -w 785 -h 120 -a PNG \
79 --slope-mode \
80 --start $$$$day_begin --end $$$$day_end \
81 --vertical-label '$$(label)' \
82 --x-grid MINUTE:10:HOUR:1:HOUR:1:0:%H \
83 DEF:$$(sensor)=rrd/$$*.rrd:$$(sensor):$$(RRD_CF) \
84 LINE1:$$(sensor)'#ff0000':"$$(sensor)"; \
85 done
86 endef
87
88 )=)
89 $(eval $(call png/sensor,temperature,Température (°C$)))
90 $(eval $(call png/sensor,humidity,Humidité (%$)))
91 $(eval $(call png/sensor,particles,Particules))
92 $(eval $(call png/sensor,quality,Qualité de l’air))