3 # Convert standard input to a C char array, write to a file, then create an
4 # MD5 sum of that file and append said MD5 sum as char array to the file.
8 # Filter out whitespace, empty lines, and comments.
10 sed 's/^[[:space:]]*//; /^$/d; /^\/\//d'
13 # Convert stdin to a \0-terminated char array.
15 echo "static const char $1[] = {"
16 od -v -A n -t x1 | sed 's/[[:space:]]*\([[:alnum:]]\{2\}\)/0x\1, /g'
20 # Print MD5 hash w/o newline character to not embed the character in the array.
22 # md5sum is not standard, so try different platform-specific alternatives.
23 { md5sum "$1" || md5 -q "$1" || digest -a md5 "$1"; } 2>/dev/null |
24 cut -b -32 | tr -d '\n\r'
27 trap 'rm -f "$1.temp"' EXIT
29 sanitize | tee "$1.temp" |
30 dump 'x264_opencl_source' > "$1"
33 dump 'x264_opencl_source_hash' >> "$1"