-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
71 lines (60 loc) · 2.42 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=sps30-i2c
clean_drivers=$(foreach d, $(drivers), clean_$(d))
release_drivers=$(foreach d, $(drivers), release/$(d))
.PHONY: FORCE all prepare $(release_drivers) $(clean_drivers) style-check style-fix
all: prepare $(drivers)
prepare: sps-common/sps_git_version.c
$(drivers): prepare
cd $@ && $(MAKE) $(MFLAGS)
sps-common/sps_git_version.c: FORCE
git describe --always --dirty | \
awk 'BEGIN \
{print "/* THIS FILE IS AUTOGENERATED */"} \
{print "#include \"sps_git_version.h\""} \
{print "const char * SPS_DRV_VERSION_STR = \"" $$0"\";"} \
END {}' > $@ || echo "Can't update version, not a git repository"
$(release_drivers): sps-common/sps_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 sps-common/* "$${pkgdir}" && \
cp -r $${driver}/* "$${pkgdir}" && \
cp CHANGELOG.md LICENSE "$${pkgdir}" && \
echo 'sps_driver_dir = .' >> $${pkgdir}/user_config.inc && \
echo 'sensirion_common_dir = .' >> $${pkgdir}/user_config.inc && \
echo 'sps_common_dir = .' >> $${pkgdir}/user_config.inc && \
echo 'sps30_i2c_dir = .' >> $${pkgdir}/user_config.inc && \
cd "$${pkgdir}" && $(MAKE) $(MFLAGS) && $(MAKE) clean $(MFLAGS) && cd - && \
cd release && zip -r "$${pkgname}.zip" "$${pkgname}" && cd - && \
ln -sfn $${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 sps30-i2c/sps_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-6.0 -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;