1#!/bin/sh
2
3# Copyright (c) 2011-2012 Xiph.Org Foundation and Mozilla Corporation
4#
5#  This file is extracted from RFC6716. Please see that RFC for additional
6#  information.
7#
8#  Redistribution and use in source and binary forms, with or without
9#  modification, are permitted provided that the following conditions
10#  are met:
11#
12#  - Redistributions of source code must retain the above copyright
13#  notice, this list of conditions and the following disclaimer.
14#
15#  - Redistributions in binary form must reproduce the above copyright
16#  notice, this list of conditions and the following disclaimer in the
17#  documentation and/or other materials provided with the distribution.
18#
19#  - Neither the name of Internet Society, IETF or IETF Trust, nor the
20#  names of specific contributors, may be used to endorse or promote
21#  products derived from this software without specific prior written
22#  permission.
23#
24#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25#  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
28#  OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29#  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31#  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32#  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33#  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34#  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
36#Stop on errors
37set -e
38#Set the CWD to the location of this script
39[ -n "${0%/*}" ] && cd "${0%/*}"
40
41toplevel=".."
42destdir="opus_source"
43
44echo packaging source code
45rm -rf "${destdir}"
46mkdir "${destdir}"
47mkdir "${destdir}/src"
48mkdir "${destdir}/silk"
49mkdir "${destdir}/silk/float"
50mkdir "${destdir}/silk/fixed"
51mkdir "${destdir}/celt"
52mkdir "${destdir}/include"
53for f in `cat "${toplevel}"/opus_sources.mk "${toplevel}"/celt_sources.mk \
54 "${toplevel}"/silk_sources.mk "${toplevel}"/opus_headers.mk \
55 "${toplevel}"/celt_headers.mk "${toplevel}"/silk_headers.mk \
56 | grep '\.[ch]' | sed -e 's/^.*=//' -e 's/\\\\//'` ; do
57  cp -a "${toplevel}/${f}" "${destdir}/${f}"
58done
59cp -a "${toplevel}"/src/opus_demo.c "${destdir}"/src/
60cp -a "${toplevel}"/src/opus_compare.c "${destdir}"/src/
61cp -a "${toplevel}"/celt/opus_custom_demo.c "${destdir}"/celt/
62cp -a "${toplevel}"/Makefile.unix "${destdir}"/Makefile
63cp -a "${toplevel}"/opus_sources.mk "${destdir}"/
64cp -a "${toplevel}"/celt_sources.mk "${destdir}"/
65cp -a "${toplevel}"/silk_sources.mk "${destdir}"/
66cp -a "${toplevel}"/README.draft "${destdir}"/README
67cp -a "${toplevel}"/COPYING "${destdir}"/COPYING
68cp -a "${toplevel}"/tests/run_vectors.sh "${destdir}"/
69
70GZIP=-9 tar --owner=root --group=root --format=v7 -czf opus_source.tar.gz "${destdir}"
71echo building base64 version
72cat opus_source.tar.gz| base64 | tr -d '\n' | fold -w 64 | \
73 sed -e 's/^/\<spanx style="vbare"\>###/' -e 's/$/\<\/spanx\>\<vspace\/\>/' > \
74 opus_source.base64
75
76
77#echo '<figure>' > opus_compare_escaped.c
78#echo '<artwork>' >> opus_compare_escaped.c
79#echo '<![CDATA[' >> opus_compare_escaped.c
80#cat opus_compare.c >> opus_compare_escaped.c
81#echo ']]>' >> opus_compare_escaped.c
82#echo '</artwork>' >> opus_compare_escaped.c
83#echo '</figure>' >> opus_compare_escaped.c
84
85if [[ ! -d ../opus_testvectors ]] ; then
86  echo "Downloading test vectors..."
87  wget 'http://opus-codec.org/testvectors/opus_testvectors.tar.gz'
88  tar -C .. -xvzf opus_testvectors.tar.gz
89fi
90echo '<figure>' > testvectors_sha1
91echo '<artwork>' >> testvectors_sha1
92echo '<![CDATA[' >> testvectors_sha1
93(cd ../opus_testvectors; sha1sum *.bit *.dec) >> testvectors_sha1
94#cd opus_testvectors
95#sha1sum *.bit *.dec >> ../testvectors_sha1
96#cd ..
97echo ']]>' >> testvectors_sha1
98echo '</artwork>' >> testvectors_sha1
99echo '</figure>' >> testvectors_sha1
100
101echo running xml2rfc
102xml2rfc draft-ietf-codec-opus.xml draft-ietf-codec-opus.html &
103xml2rfc draft-ietf-codec-opus.xml
104wait
105