]> git.ozlabs.org Git - ccan/blob - tools/gen_deps.sh
e38dffab022cae2fc5f6ddf683f34adf1c69aa08
[ccan] / tools / gen_deps.sh
1 #! /bin/sh
2
3 # Compute the test dependencies for a ccan module. Usage:
4 # tools/gen_deps.sh ccan/path/to/module
5
6 path=$1
7 module=`echo $path | sed 's/^ccan\///g'`
8
9 # The test depends on the test sources ...
10 test_srcs=`ls $path/test/*.[ch] 2>/dev/null | tr '\n' ' '`
11
12 # ... and the object files of our module (rather than the sources, so
13 #     that we pick up the resursive dependencies for the objects)
14 module_objs=`ls $path/*.c 2>/dev/null | sed 's/.c$/.o/g' | tr '\n' ' '`
15
16 # ... and on the modules this test uses having passed their tests
17 deps=$(echo `$path/info testdepends` `$path/info depends` | tr ' ' '\n' | \
18        sort | uniq | sed -e 's/$/\/.ok/g' -e '/^\/.ok$/d' | tr '\n' ' ')
19
20 # Print the test targets and target aliases
21 echo "${module}_ok_deps := $test_srcs $module_objs $deps"
22 echo "$path/.ok: \$(${module}_ok_deps)"
23 echo "$path/.fast.ok: \$(${module}_ok_deps:%.ok=%.fast.ok)"