blob: fce93e795156173a4b689fb3ca50e409596ff5da [file] [log] [blame]
Brad Bishopa6fcd562017-02-03 11:00:27 -05001#!/bin/sh
2
3yaml_top=$1
4toplevel_dirs=xyz
5interfaces=
6
Patrick Williams21e72fb2021-04-14 10:13:19 -05007if [ -d "$yaml_top/$toplevel_dirs" ]; then
8 cd "$yaml_top" || exit 1
9 interfaces=$(find $toplevel_dirs -name "*.interface.yaml")
Brad Bishopa6fcd562017-02-03 11:00:27 -050010fi
11
12for i in ${interfaces};
13do
Patrick Williams21e72fb2021-04-14 10:13:19 -050014 iface_path="$(dirname "$i")/$(basename "$i" .interface.yaml)"
15 iface="$(echo "$iface_path" | sed 's/\//./g')"
Brad Bishopa6fcd562017-02-03 11:00:27 -050016 cat <<MAKEFILE
17${i%.interface.yaml}/server.cpp: \$(extra_yamldir)/${i} ${i%.interface.yaml}/server.hpp
18 @mkdir -p \`dirname \$@\`
19 \$(AM_V_GEN)\$(SDBUSPLUSPLUS) -r \$(extra_yamldir) interface server-cpp ${iface} > \$@
20
21${i%.interface.yaml}/server.hpp: \$(extra_yamldir)/${i}
22 @mkdir -p \`dirname \$@\`
23 \$(AM_V_GEN)\$(SDBUSPLUSPLUS) -r \$(extra_yamldir) interface server-header ${iface} > \$@
24
25MAKEFILE
26
27done
28
29echo "extra_ifaces_cpp_SOURCES = \\"
30for i in ${interfaces};
31do
32 echo " ${i%.interface.yaml}/server.cpp \\"
33done
34echo
35
36echo "extra_ifaces_hpp_SOURCES = \\"
37for i in ${interfaces};
38do
39 echo " ${i%.interface.yaml}/server.hpp \\"
40done
41echo
42
43echo "extra_ifaces.cpp: \$(extra_ifaces_cpp_SOURCES)"
44if [ "$interfaces" ]; then
45 echo " \$(AM_V_GEN)cat \$^ > \$@"
46else
47 echo " \$(AM_V_GEN)touch \$@"
48fi
49
50cat << MAKEFILE
51
52.PHONY: clean-extra
53clean-extra:
54 for i in \$(extra_ifaces_cpp_SOURCES) \\
55 \$(extra_ifaces_hpp_SOURCES); \\
56 do \\
57 test -e \$\$i && rm \$\$i ; \\
58 test -d \`dirname \$\$i\` && rmdir -p \`dirname \$\$i\` ; \\
59 true; \\
60 done
61MAKEFILE