Stefan Tauner | bf97bdc | 2013-03-09 17:55:35 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | scriptname=$(readlink -f "$0") 2>/dev/null |
| 4 | path=$(dirname "$scriptname")/.. 2>/dev/null |
Maximilian Brune | 2522456 | 2024-04-11 21:05:26 +0200 | [diff] [blame] | 5 | if [ ! -e "$path/flashchips.c" -o ! -e "$path/include/flashchips.h" ]; then |
Stefan Tauner | bf97bdc | 2013-03-09 17:55:35 +0000 | [diff] [blame] | 6 | echo "Warning: could not calculate flashchips.[ch]'s directory. Trying current..." |
| 7 | path="." |
Maximilian Brune | 2522456 | 2024-04-11 21:05:26 +0200 | [diff] [blame] | 8 | if [ ! -e "$path/flashchips.c" -o ! -e "$path/include/flashchips.h" ]; then |
Stefan Tauner | bf97bdc | 2013-03-09 17:55:35 +0000 | [diff] [blame] | 9 | echo "Nope, sorry!" |
| 10 | exit 1 |
| 11 | fi |
| 12 | fi |
| 13 | |
Maximilian Brune | 2522456 | 2024-04-11 21:05:26 +0200 | [diff] [blame] | 14 | chips=$(sed -re '/#define [A-Z]/ !d' -e '/_ID\s/d' -e 's/\s*#define\s+([[:alnum:]_]+)\s+.*/\1/' "$path/include/flashchips.h") |
Stefan Tauner | bf97bdc | 2013-03-09 17:55:35 +0000 | [diff] [blame] | 15 | for c in $chips ; do |
| 16 | if ! grep "$c" "$path/flashchips.c" >/dev/null ; then |
| 17 | if [ -n "$1" ]; then |
Maximilian Brune | 2522456 | 2024-04-11 21:05:26 +0200 | [diff] [blame] | 18 | grep -o "$c.*" "$path/include/flashchips.h" |
Stefan Tauner | bf97bdc | 2013-03-09 17:55:35 +0000 | [diff] [blame] | 19 | else |
| 20 | echo "$c" |
| 21 | fi |
| 22 | fi |
| 23 | done |