Commit cbd8d7b6 authored by Diego Biurrun's avatar Diego Biurrun Committed by Fiona Glaser

build: Replace cltostr.pl by a shell script

This avoids a dependency on Perl to build OpenCL support.
parent d8b6ce7f
......@@ -137,7 +137,7 @@ endif
ifeq ($(HAVE_OPENCL),yes)
common/oclobj.h: common/opencl/x264-cl.h $(wildcard $(SRCPATH)/common/opencl/*.cl)
cat $^ | perl $(SRCPATH)/tools/cltostr.pl x264_opencl_source > $@
cat $^ | $(SRCPATH)/tools/cltostr.sh $@
GENERATED += common/oclobj.h
SRCS += common/opencl.c encoder/slicetype-cl.c
endif
......
......@@ -1046,15 +1046,6 @@ ASFLAGS="$ASFLAGS -DBIT_DEPTH=$bit_depth"
libdl=""
if [ "$opencl" = "yes" ]; then
opencl="no"
log_check "for perl"
output=$(perl -v)
if [ "$output" = "" ]; then
log_fail
echo 'OpenCL support requires perl to compile.'
echo 'use --disable-opencl to compile without OpenCL.'
exit 1
fi
log_ok
# cygwin can use opencl if it can use LoadLibrary
if [ $SYS = WINDOWS ] || ([ $SYS = CYGWIN ] && cc_check windows.h "" "LoadLibraryW(0);") ; then
opencl="yes"
......
# Perl script used for compiling OpenCL src into x264 binary
#
# Copyright (C) 2013-2014 x264 project
# Authors: Steve Borho <sborho@multicorewareinc.com>
use Digest::MD5 qw(md5_hex);
# xxd takes a VAR, which will be the variable name
# and BYTES, a string of bytes to beencoded.
sub xxd
{
my %args = @_;
my $var = $args{VAR};
my $bytes = $args{BYTES};
my @hexbytes;
my @bytes = split //, $$bytes;
foreach $b (@bytes)
{
push @hexbytes, sprintf("0x%02X", ord($b));
}
# Format 'em nice and pretty-like.
print 'static const char ' . $var . '[] = {' . "\n";
my $count = 0;
foreach my $h (@hexbytes)
{
print "$h, ";
$count++;
if ($count == 16)
{
print "\n";
$count = 0;
}
}
print "\n0x00 };\n\n";
return;
}
if (@ARGV < 1)
{
printf "%s: VARNAME ", $0 . "\n";
exit(-1);
}
my @lines;
while(<STDIN>)
{
s/^\s+//; # trim leading whitespace
if (/^\/\//)
{
next; # skip the line if it starts with '//'
}
push @lines, $_;
}
my $lines = join '', @lines;
xxd(VAR => @ARGV[0], BYTES => \$lines);
my $hash = md5_hex($lines);
@hash = ( $hash =~ m/../g );
xxd(VAR => @ARGV[0] . "_hash", BYTES => \$hash);
#!/bin/sh
# Convert standard input to a C char array, write to a file, then create an
# MD5 sum of that file and append said MD5 sum as char array to the file.
FILE=$1
# Filter out whitespace, empty lines, and comments.
sanitize() {
sed 's/^[[:space:]]*//; /^$/d; /^\/\//d'
}
# Convert stdin to a \0-terminated char array.
dump() {
printf 'static const char %s[] = {\n' $1
od -v -A n -t x1 | sed 's/.\(..\)/0x\1, /g'
printf '0x00 };\n'
}
# Print MD5 hash w/o newline character to not embed the character in the array.
hash() {
# md5sum is not standard, so try different platform-specific alternatives.
{ md5sum $1 2> /dev/null || md5 -q $1 || digest -a md5 $1; } |
cut -b -32 | tr -d '\n\r'
}
trap "rm -f $FILE.temp" EXIT
sanitize | tee $FILE.temp |
dump x264_opencl_source > $FILE
hash $FILE.temp |
dump x264_opencl_source_hash >> $FILE
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment