-
Notifications
You must be signed in to change notification settings - Fork 38
/
Makefile
92 lines (77 loc) · 3.09 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
drivers=sht3x sht4x shtc1
sample-projects=shtc3-stm32-uvision
clean_drivers=$(foreach d, $(drivers), clean_$(d))
release_drivers=$(foreach d, $(drivers), release/$(d))
release_sample_projects=$(foreach s, $(sample-projects), release/$(s))
.PHONY: FORCE all $(release_drivers) $(clean_drivers) style-check style-fix \
utils clean_utils
all: prepare $(drivers) utils
prepare: sht-common/sht_git_version.c
$(drivers): prepare
cd $@ && $(MAKE) $(MFLAGS)
sht-common/sht_git_version.c: FORCE
git describe --always --dirty | \
awk 'BEGIN \
{print "/* THIS FILE IS AUTOGENERATED */"} \
{print "#include \"sht_git_version.h\""} \
{print "const char * SHT_DRV_VERSION_STR = \"" $$0"\";"} \
END {}' > $@ || echo "Can't update version, not a git repository"
$(release_drivers): sht-common/sht_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 sht-common/* "$${pkgdir}" && \
cp -r $${driver}/* "$${pkgdir}" && \
cp CHANGELOG.md LICENSE "$${pkgdir}" && \
echo 'sensirion_common_dir = .' >> $${pkgdir}/user_config.inc && \
echo 'sht_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_sample_projects):
export rel=$@ && \
export sample_project=$${rel#release/} && \
export tag="$$(git describe --always --dirty)" && \
export pkgname="$${sample_project}-sample-project-$${tag}" && \
export pkgdir="release/$${pkgname}" && \
rm -rf "$${pkgdir}" && mkdir -p "$${pkgdir}" && \
sample-projects/$${sample_project}/prepare_release.sh "$${pkgdir}" && \
cd release && zip -r "$${pkgname}.zip" "$${pkgname}" && cd - && \
ln -sfn $${pkgname} release/$${sample_project}
release: clean $(release_drivers) $(release_sample_projects)
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) clean_utils
rm -rf release
$(RM) sht-common/sht_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;