blob: a82326136b3dea51195f55206a176cf7c6032323 [file] [log] [blame]
Stefan Taunerbf97bdc2013-03-09 17:55:35 +00001#!/bin/sh
2
3scriptname=$(readlink -f "$0") 2>/dev/null
4path=$(dirname "$scriptname")/.. 2>/dev/null
Maximilian Brune25224562024-04-11 21:05:26 +02005if [ ! -e "$path/flashchips.c" -o ! -e "$path/include/flashchips.h" ]; then
Stefan Taunerbf97bdc2013-03-09 17:55:35 +00006 echo "Warning: could not calculate flashchips.[ch]'s directory. Trying current..."
7 path="."
Maximilian Brune25224562024-04-11 21:05:26 +02008 if [ ! -e "$path/flashchips.c" -o ! -e "$path/include/flashchips.h" ]; then
Stefan Taunerbf97bdc2013-03-09 17:55:35 +00009 echo "Nope, sorry!"
10 exit 1
11 fi
12fi
13
Maximilian Brune25224562024-04-11 21:05:26 +020014chips=$(sed -re '/#define [A-Z]/ !d' -e '/_ID\s/d' -e 's/\s*#define\s+([[:alnum:]_]+)\s+.*/\1/' "$path/include/flashchips.h")
Stefan Taunerbf97bdc2013-03-09 17:55:35 +000015for c in $chips ; do
16 if ! grep "$c" "$path/flashchips.c" >/dev/null ; then
17 if [ -n "$1" ]; then
Maximilian Brune25224562024-04-11 21:05:26 +020018 grep -o "$c.*" "$path/include/flashchips.h"
Stefan Taunerbf97bdc2013-03-09 17:55:35 +000019 else
20 echo "$c"
21 fi
22 fi
23done