#!/bin/sh### add_to_all_subs.shif[-z"$2"]; thenechoecho"This script adds lines in source file to target file in all CHDK "echo"platform sub directories which have a non-zero target file:"echo" cat source >> platform/*/sub/*/target"echo"Use it when you have found a new function or RAM address for a single platform"echo"to prevent building problems with other platforms, and to ease porting"echo"your feature to other models. Run in CHDK source tree root."echoecho"usage: add_to_all_subs.sh target source"echoecho"example:"echo" place a dummy stub in stubfile and a dummy function in libfile, then"echo" add_to_all_subs.sh stubs_entry_2.S stubfile"echo" add_to_all_subs.sh lib.c libfile"echoecho"stubfile contains the code to add to the end of all stubs_entry_2.S"echo"files in the chdk platform tree. It could be a commented out line"echo"(or lines if you are adding more than one function)."echoecho"libfile contains the code to add to the end of all platform lib.c files"echo"in the chdk platform tree."echoecho"See the example stubfile and libfile."exit0fitargetfile=$1sourcefile=$2if[!-r$sourcefile]; thenecho"error: Cannot read source: $sourcefile, exiting"exit0fifor p in platform/*/sub/*; do# only try directoriesif[-d$p]; then# check that target file exits and that it is writable and non-zeroif[-s$p/$targetfile]&&[-w$p/$targetfile]; thenecho$pecho" adding lines from $sourcefile to $p/$targetfile"echo>>$p/$targetfilecat$sourcefile>>$p/$targetfileelseecho$p/$targetfile not found, not non-zero or not writable. Skipping.