[2/4] HR support: Add logic to fetch reference source code and build it

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
This commit is contained in:
Sylvain Munaut 2010-11-12 19:36:21 +01:00
parent 0d2a82c312
commit aa55d30d20
3 changed files with 84 additions and 1 deletions

View File

@ -27,6 +27,7 @@ AC_ARG_ENABLE(gsmhr,
[enable_gsmhr=0], [enable_gsmhr=1])
AM_CONDITIONAL(ENABLE_GSMHR, test "x$enable_gsmhr" = "x1")
if test "x$enable_gsmhr" = "x1"; then
AM_PATH_PYTHON([2.4])
AC_DEFINE(HAVE_LIBGSMHR, 1, [Define to 1 if libgsmhr is available])
fi

View File

@ -3,5 +3,21 @@ AM_CFLAGS = -fPIC -Wall ${SYMBOL_VISIBILITY}
LIBVERSION=0:0:0
REFSRC_PATH=refsrc
REFSRC_SRC=refsrc/dtx.c refsrc/globdefs.c refsrc/host.c refsrc/mathhalf.c refsrc/sp_enc.c refsrc/sp_rom.c refsrc/vad.c refsrc/err_conc.c refsrc/homing.c refsrc/mathdp31.c refsrc/sp_dec.c refsrc/sp_frm.c refsrc/sp_sfrm.c
${REFSRC_PATH}/.downloaded:
./fetch_sources.py "${REFSRC_PATH}"
for f in "${REFSRC_PATH}"/*.{c,h}; do \
sed -i -e"s/round/round_l2s/" "$$f"; \
done
sed -i -e"s/long int/int/" -e"s/long/int/" "${REFSRC_PATH}/typedefs.h"
touch $@
${REFSRC_PATH}/dtx.c: ${REFSRC_PATH}/.downloaded
lib_LTLIBRARIES = libgsmhr.la
libgsmhr_la_SOURCES = libgsmhr.c
libgsmhr_la_SOURCES = $(REFSRC_SRC) libgsmhr.c
clean-local:
-rm -rf ${REFSRC_PATH}

66
libgsmhr/fetch_sources.py Executable file
View File

@ -0,0 +1,66 @@
#!/usr/bin/env python
import urllib2
import os
import sys
import zipfile
try:
import cStringIO as StringIO
except:
import StringIO
SRC = "http://ftp.3gpp.org/Specs/2001-06/Ph2/06_series/0606-421/0606_421.zip"
def get_zipfile(data):
return zipfile.ZipFile(StringIO.StringIO(data))
def get_subfile_data(data, filename):
z = get_zipfile(data)
return z.read(filename)
def process_file(z, e):
fh = open(e.filename.lower(), 'w')
d = z.read(e).replace('\r','')
fh.write(d)
fh.close()
def main(*args):
# Args
if len(args) != 2:
print "Usage: %s target_dir" % args[0]
return
tgt = args[1]
# Create and go to target dir
if not os.path.isdir(tgt):
os.mkdir(tgt)
os.chdir(tgt)
# Get the original data
u = urllib2.urlopen(SRC)
d = u.read()
# Get DISK.zip
d = get_subfile_data(d, 'DISK.zip')
# Get Dir_C.zip
d = get_subfile_data(d, 'Dir_C.zip')
# Get zip file object
z = get_zipfile(d)
# Save each file
for e in z.filelist:
process_file(z, e)
if __name__ == '__main__':
main(*sys.argv)