This repository has been archived by the owner on Apr 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathMakefile
193 lines (175 loc) · 7.81 KB
/
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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
drivers=sgp30 sgpc3 svm30 sgpc3_with_shtc1 sgp40 sgp40_voc_index
clean_drivers=$(foreach d, $(drivers), clean_$(d))
release_drivers=$(foreach d, $(drivers), release/$(d)) release/sgp40_voc_index_arduino
.PHONY: FORCE all $(release_drivers) $(clean_drivers) style-check style-fix prepare-embedded-sht docs
all: prepare $(drivers)
prepare: sgp-common/sgp_git_version.c prepare-embedded-sht
$(drivers): prepare
cd $@ && $(MAKE) $(MFLAGS)
prepare-embedded-sht:
cd embedded-sht && make prepare
sgp-common/sgp_git_version.c: FORCE
git describe --always --dirty | \
awk 'BEGIN \
{print "/* THIS FILE IS AUTOGENERATED */"} \
{print "#include \"sgp_git_version.h\""} \
{print "const char * SGP_DRV_VERSION_STR = \"" $$0"\";"} \
END {}' > $@ || echo "Can't update version, not a git repository"
docs:
cd docs && make latexpdf
$(release_drivers): prepare
export rel=$@ && \
export driver=$${rel#release/} && \
export tag="$$(git describe --always --dirty)" && \
export pkgname="$${driver}-$${tag}" && \
export pkgdir="release/$${pkgname}" && \
rm -rf "$${pkgdir}" && mkdir -p "$${pkgdir}" && \
cp -r embedded-common/hw_i2c/ "$${pkgdir}" && \
cp -r embedded-common/sw_i2c/ "$${pkgdir}" && \
cp embedded-common/sensirion_arch_config.h "$${pkgdir}" && \
cp embedded-common/sensirion_common.c "$${pkgdir}" && \
cp embedded-common/sensirion_common.h "$${pkgdir}" && \
cp embedded-common/sensirion_i2c.h "$${pkgdir}" && \
cp -r sgp-common/* "$${pkgdir}" && \
cp -r $${driver}/* "$${pkgdir}" && \
cp CHANGELOG.md LICENSE "$${pkgdir}" && \
echo 'sensirion_common_dir = .' >> $${pkgdir}/user_config.inc && \
echo 'sgp_common_dir = .' >> $${pkgdir}/user_config.inc && \
echo "$${driver}_dir = ." >> $${pkgdir}/user_config.inc && \
cd "$${pkgdir}" && $(MAKE) $(MFLAGS) && $(MAKE) clean $(MFLAGS) && cd - && \
cd release && zip -r "$${pkgname}.zip" "$${pkgname}" && cd - && \
ln -sf $${pkgname} $@
release/sgp40: prepare docs
export rel=$@ && \
export driver=$${rel#release/} && \
export tag="$$(git describe --always --dirty)" && \
export pkgname="$${driver}-$${tag}" && \
export pkgdir="release/$${pkgname}" && \
rm -rf "$${pkgdir}" && mkdir -p "$${pkgdir}" && \
cp -r embedded-common/hw_i2c/ "$${pkgdir}" && \
cp -r embedded-common/sw_i2c/ "$${pkgdir}" && \
cp embedded-common/LICENSE "$${pkgdir}" && \
cp embedded-common/sensirion_arch_config.h "$${pkgdir}" && \
cp embedded-common/sensirion_common.c "$${pkgdir}" && \
cp embedded-common/sensirion_common.h "$${pkgdir}" && \
cp embedded-common/sensirion_i2c.h "$${pkgdir}" && \
cp embedded-common/README.md "$${pkgdir}" && \
cp -r sgp-common/* "$${pkgdir}" && \
cp -r $${driver}/* "$${pkgdir}" && \
cp docs/Application_Note_SGP40.pdf $${pkgdir} && \
cp CHANGELOG.md LICENSE "$${pkgdir}" && \
echo 'sensirion_common_dir = .' >> $${pkgdir}/user_config.inc && \
echo 'sgp_common_dir = .' >> $${pkgdir}/user_config.inc && \
echo "$${driver}_dir = ." >> $${pkgdir}/user_config.inc && \
cd "$${pkgdir}" && $(MAKE) $(MFLAGS) && $(MAKE) clean $(MFLAGS) && cd - && \
cd release && zip -r "$${pkgname}.zip" "$${pkgname}" && cd - && \
ln -sf $${pkgname} $@
release/sgp40_voc_index: prepare docs
$(RM) $@
export rel=$@ && \
export driver=$${rel#release/} && \
export tag="$$(git describe --always --dirty)" && \
export pkgname="$${driver}-$${tag}" && \
export pkgdir="release/$${pkgname}" && \
rm -rf "$${pkgdir}" && mkdir -p "$${pkgdir}" && \
cp embedded-common/*.[ch] $${pkgdir} && \
cp -r embedded-common/hw_i2c $${pkgdir} && \
cp -r embedded-common/sw_i2c $${pkgdir} && \
cp sgp40/sgp40.[ch] $${pkgdir} && \
cp sgp-common/*.[ch] $${pkgdir} && \
cp embedded-sht/sht-common/*.[ch] $${pkgdir} && \
cp embedded-sht/shtc1/shtc1.[ch] $${pkgdir} && \
cp $${driver}/Makefile $${pkgdir} && \
cp $${driver}/*.[ch] $${pkgdir} && \
cp $${driver}/default_config.inc $${pkgdir} && \
for i in $${driver}_dir sgp_driver_dir sht_driver_dir sensirion_common_dir \
sgp_common_dir sht_common_dir sgp40_dir shtc1_dir; \
do echo "$$i = ." >> $${pkgdir}/user_config.inc; \
done && \
cp docs/Application_Note_SGP40_VOC_Index_Driver.pdf $${pkgdir} && \
cd "$${pkgdir}" && $(MAKE) $(MFLAGS) && $(MAKE) clean $(MFLAGS) && cd - && \
cd release && zip -r "$${pkgname}.zip" "$${pkgname}" && cd - && \
ln -sf $${pkgname} $@
release/sgp40_voc_index_arduino: prepare docs
$(RM) $@
export rel=$@ && \
export driver=$${rel#release/} && \
export tag="$$(git describe --always --dirty)" && \
export pkgname="$${driver}-$${tag}" && \
export pkgdir="release/$${pkgname}" && \
echo $${pkgname} $${pkgdir} && \
rm -rf "$${pkgdir}" && mkdir -p "$${pkgdir}/sgp40_voc_index" && \
cp embedded-common/*.[ch] $${pkgdir}/sgp40_voc_index && \
cp embedded-common/hw_i2c/sample-implementations/arduino/*.cpp $${pkgdir}/sgp40_voc_index && \
cp sgp40/sgp40.[ch] $${pkgdir}/sgp40_voc_index && \
cp sgp40_voc_index/*.[ch] $${pkgdir}/sgp40_voc_index && \
cp sgp40_voc_index/sgp40_voc_index_example_usage.ino $${pkgdir}/sgp40_voc_index/sgp40_voc_index.ino && \
rm $${pkgdir}/sgp40_voc_index/*example_usage.c && \
cp sgp-common/*.[ch] $${pkgdir}/sgp40_voc_index && \
cp embedded-sht/sht-common/*.[ch] $${pkgdir}/sgp40_voc_index && \
cp embedded-sht/shtc1/shtc1.[ch] $${pkgdir}/sgp40_voc_index && \
cp docs/Application_Note_SGP40_VOC_Index_Driver_Arduino.pdf $${pkgdir}/ && \
cd release && zip -r "$${pkgname}.zip" "$${pkgname}" && cd - && \
ln -sf $${pkgname} $@
release/svm30: release/sgp30 prepare-embedded-sht
export rel=$@ && \
export driver=$${rel#release/} && \
export tag="$$(git describe --always --dirty)" && \
export pkgname="$${driver}-$${tag}" && \
export pkgdir="release/$${pkgname}" && \
cp -r release/sgp30/ $${pkgdir} && \
cp -r embedded-sht/sht-common/* $${pkgdir} && \
cp -r embedded-sht/utils/* $${pkgdir} && \
cp -r embedded-sht/shtc1/* $${pkgdir} && \
cp $${driver}/Makefile $${pkgdir} && \
cp $${driver}/*.[ch] $${pkgdir} && \
cp $${driver}/default_config.inc $${pkgdir} && \
for i in $${driver}_dir sgp_driver_dir sht_driver_dir sensirion_common_dir \
sgp_common_dir sht_common_dir sht_utils_dir sgp30_dir shtc1_dir; \
do echo "$$i = ." >> $${pkgdir}/user_config.inc; \
done && \
cd "$${pkgdir}" && $(MAKE) $(MFLAGS) && $(MAKE) clean $(MFLAGS) && cd - && \
cd release && zip -r "$${pkgname}.zip" "$${pkgname}" && cd - && \
ln -sf $${pkgname} $@
release/sgpc3_with_shtc1: release/sgpc3 prepare-embedded-sht
export rel=$@ && \
export driver=$${rel#release/} && \
export tag="$$(git describe --always --dirty)" && \
export pkgname="$${driver}-$${tag}" && \
export pkgdir="release/$${pkgname}" && \
cp -r release/sgpc3/ $${pkgdir} && \
cp -r embedded-sht/sht-common/* $${pkgdir} && \
cp -r embedded-sht/utils/* $${pkgdir} && \
cp -r embedded-sht/shtc1/* $${pkgdir} && \
cp $${driver}/Makefile $${pkgdir} && \
cp $${driver}/*.[ch] $${pkgdir} && \
cp $${driver}/default_config.inc $${pkgdir} && \
for i in $${driver}_dir sgp_driver_dir sht_driver_dir sensirion_common_dir \
sgp_common_dir sht_common_dir sht_utils_dir sgpc3_dir shtc1_dir; \
do echo "$$i = ." >> $${pkgdir}/user_config.inc; \
done && \
cd "$${pkgdir}" && $(MAKE) $(MFLAGS) && $(MAKE) clean $(MFLAGS) && cd - && \
cd release && zip -r "$${pkgname}.zip" "$${pkgname}" && cd - && \
ln -sf $${pkgname} $@
release: clean $(release_drivers)
$(clean_drivers):
export rel=$@ && \
export driver=$${rel#clean_} && \
cd $${driver} && $(MAKE) clean $(MFLAGS) && cd -
clean: $(clean_drivers)
rm -rf release
style-fix:
@if [ $$(git status --porcelain -uno 2> /dev/null | wc -l) -gt "0" ]; \
then \
echo "Refusing to run on dirty git state. Commit your changes first."; \
exit 1; \
fi; \
git ls-files | grep -e '\.\(c\|h\|cpp\)$$' | xargs clang-format -i -style=file;
style-check: style-fix
@if [ $$(git status --porcelain -uno 2> /dev/null | wc -l) -gt "0" ]; \
then \
echo "Style check failed:"; \
git diff; \
git checkout -f; \
exit 1; \
fi;