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 9
/
Makefile
71 lines (60 loc) · 2.35 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
drivers=scd30
clean_drivers=$(foreach d, $(drivers), clean_$(d))
release_drivers=$(foreach d, $(drivers), release/$(d))
.PHONY: FORCE all $(release_drivers) $(clean_drivers) style-check style-fix
all: prepare $(drivers)
prepare: scd-common/scd_git_version.c
$(drivers): prepare
cd $@ && $(MAKE) $(MFLAGS)
scd-common/scd_git_version.c: FORCE
git describe --always --dirty | \
awk 'BEGIN \
{print "/* THIS FILE IS AUTOGENERATED */"} \
{print "#include \"scd_git_version.h\""} \
{print "const char * SCD_DRV_VERSION_STR = \"" $$0"\";"} \
END {}' > $@
$(release_drivers): scd-common/scd_git_version.c
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 scd-common/* "$${pkgdir}" && \
cp -r $${driver}/* "$${pkgdir}" && \
cp CHANGELOG.md LICENSE "$${pkgdir}" && \
echo 'scd_driver_dir = .' >> $${pkgdir}/user_config.inc && \
echo 'scd_common_dir = .' >> $${pkgdir}/user_config.inc && \
echo 'sensirion_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: clean $(release_drivers)
$(clean_drivers):
export rel=$@ && \
export driver=$${rel#clean_} && \
cd $${driver} && $(MAKE) clean $(MFLAGS) && cd -
clean: $(clean_drivers)
rm -rf release scd30/scd_git_version.c
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;