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 1
/
Makefile
78 lines (65 loc) · 2.51 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
drivers=sts3x
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 utils clean_utils
all: prepare $(drivers) utils
prepare: sts-common/sts_git_version.c
$(drivers): prepare
cd $@ && $(MAKE) $(MFLAGS)
sts-common/sts_git_version.c: FORCE
git describe --always --dirty | \
awk 'BEGIN \
{print "/* THIS FILE IS AUTOGENERATED */"} \
{print "#include \"sts_git_version.h\""} \
{print "const char * STS_DRV_VERSION_STR = \"" $$0"\";"} \
END {}' > $@ || echo "Can't update version, not a git repository"
$(release_drivers): sts-common/sts_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 sts-common/* "$${pkgdir}" && \
cp -r $${driver}/* "$${pkgdir}" && \
cp CHANGELOG.md LICENSE "$${pkgdir}" && \
echo 'sts_driver_dir = .' >> $${pkgdir}/user_config.inc && \
echo 'sts_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 -sfn $${pkgname} $@
release: clean $(release_drivers)
utils:
$(MAKE) -C utils
clean_utils:
$(MAKE) -C utils clean
$(clean_drivers):
export rel=$@ && \
export driver=$${rel#clean_} && \
cd $${driver} && $(MAKE) clean $(MFLAGS) && cd -
clean: $(clean_drivers)
rm -rf release sts-common/sts_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;