#/bin/bash
echo "// File autogenerated, do not modify directly!" > phpstubstr.h
echo "typedef struct { const char * filename; const char * data; } pcbc_stub_data;" >> phpstubstr.h
echo "pcbc_stub_data PCBC_PHP_CODESTR[] = {" >> phpstubstr.h

add_file () {
  echo "{\"[CouchbaseNative]/$1\",\"\\n\" \\" >> phpstubstr.h
  tail -n+2 "stub/$1" | sed 's/\\/\\\\/g' | sed 's/\"/\\\"/g' | sed 's/^\(.*\)$/\"\1\\n\" \\/' >> phpstubstr.h
  echo "\"\"}," >> phpstubstr.h
}

add_file "constants.php"
add_file "connstr.php"
add_file "default_transcoder.php"
add_file "CouchbaseViewQuery.class.php"
add_file "CouchbaseN1qlQuery.class.php"
add_file "CouchbaseCluster.class.php"
add_file "CouchbaseClusterManager.class.php"
add_file "CouchbaseBucket.class.php"
add_file "CouchbaseBucketManager.class.php"

echo "};" >> phpstubstr.h
echo "Generated phpstubstr.h"

#/bin/bash -E
echo "// File autogenerated, do not modify directly!" > phpstubstr.h
echo "typedef struct { const char * filename; const char * data; } pcbc_stub_data;" >> phpstubstr.h
echo "pcbc_stub_data PCBC_PHP_CODESTR[] = {" >> phpstubstr.h

add_file () {
  echo "{\"[CouchbaseNative]/$1\",\"\\n\" \\" >> phpstubstr.h
  tail -n+2 "stub/$1" | sed 's/\\/\\\\/g' | sed 's/\"/\\\"/g' | sed 's/^\(.*\)$/\"\1\\n\" \\/' >> phpstubstr.h
  echo "\"\"}," >> phpstubstr.h
}

add_file "constants.php"
add_file "connstr.php"
add_file "default_transcoder.php"
add_file "CouchbaseViewQuery.class.php"
add_file "CouchbaseN1qlQuery.class.php"
add_file "CouchbaseCluster.class.php"
add_file "CouchbaseClusterManager.class.php"
add_file "CouchbaseBucket.class.php"
add_file "CouchbaseBucketManager.class.php"

echo "};" >> phpstubstr.h
echo "Generated phpstubstr.h"

Make sure slash in echo will not be expanded
Make sure slash in echo will not be expanded

Fixes run on OpenIndiana

Change-Id: I8be7fe789d3736e3d3548bcd92615257eaf5aeb4
Reviewed-on: http://review.couchbase.org/63253
Tested-by: Sergey Avseyev <87f6d5e4fd3644c3c20800cde7fd3ad1569370b3@gmail.com>
Reviewed-by: Sergey Avseyev <87f6d5e4fd3644c3c20800cde7fd3ad1569370b3@gmail.com>
