+function dummy_blob {
+ #$1 = filename
+ if test -f $1; then
+ echo $1 exists, something is wrong >&2
+ exit 1
+ else
+ hack_fwmk "NONFREE_FW += $2"
+ fi
+}
+
+function clean_fw {
+ #$1 = firmware text input, $2 = firmware output
+ if test ! -f $1; then
+ echo $1 does not exist, something is wrong >&2
+ exit 1
+ elif test -f $2; then
+ echo $2 exists, something is wrong >&2
+ exit 1
+ fi
+ clean_blob $1
+ dummy_blob $2
+}
+
+function hack_fwmk {
+ if test ! -f firmware/Makefile; then
+ echo firmware/Makefile does not exist, something is wrong >&2
+ exit 1
+ fi
+
+ sed -i "/^[ ]*fw-shipped-all[ ]*:=[ ]*/i\
+$1
+" firmware/Makefile
+}
+