view scripts/mk-component.sh @ 303:f76436d19a7a default tip

!GPRS config: fix long-standing AT+COPS chance hanging bug There has been a long-standing bug in FreeCalypso going back years: sometimes in the AT command bring-up sequence of an ACI-only MS, the AT+COPS command would produce only a power scan followed by cessation of protocol stack activity (only L1 ADC traces), instead of the expected network search sequence. This behaviour was seen in different FC firmware versions going back to Citrine, and seemed to follow some law of chance, not reliably repeatable. This bug has been tracked down and found to be specific to !GPRS configuration, stemming from our TCS2/TCS3 hybrid and reconstruction of !GPRS support that was bitrotten in TCS3.2/LoCosto version. ACI module psa_mms.c, needed only for !GPRS, was missing in the TCS3 version and had to be pulled from TCS2 - but as it turns out, there is a new field in the MMR_REG_REQ primitive that needs to be set correctly, and that psa_mms.c module is the place where this initialization needed to be added.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 08 Jun 2023 08:23:37 +0000
parents 08ecd0bd517d
children
line wrap: on
line source

#!/bin/sh

if [ $# -lt 1 -o $# -gt 2 ]
then
	echo "usage: $0 component-lib [flavor]" 1>&2
	exit 1
fi

LIBNAME="$1"

if [ -n "$2" ]
then
	recipe_file="components/$1-$2"
else
	recipe_file="components/$1"
fi

if [ ! -f "$recipe_file" ]
then
	echo "Error: $recipe_file not found" 1>&2
	exit 1
fi

if [ -z "$BUILD_DIR" ]
then
	echo "Error: BUILD_DIR= must be passed via environment" 1>&2
	exit 1
fi

set -e

mkdir -p $BUILD_DIR/$LIBNAME

# beginning of the Makefile
echo "all:	$LIBNAME.lib" > $BUILD_DIR/$LIBNAME/Makefile
echo >> $BUILD_DIR/$LIBNAME/Makefile

# shell functions to be used in the recipes

make_version() {
	case $# in
	    1)
		echo "$1_version.c:" >> $BUILD_DIR/$LIBNAME/Makefile
		echo "	../../scripts/make-version.sh $1 > $1_version.c" \
			>> $BUILD_DIR/$LIBNAME/Makefile
		;;
	    2)
		echo "$2_version.c:" >> $BUILD_DIR/$LIBNAME/Makefile
		echo "	../../scripts/make-version.sh $1 > $2_version.c" \
			>> $BUILD_DIR/$LIBNAME/Makefile
		;;
	    *)
		echo "Error: make_version takes 1 or 2 arguments" 1>&2
		exit 1
		;;
	esac
	echo >> $BUILD_DIR/$LIBNAME/Makefile
}

asm_file() {
	if [ $# != 1 ]
	then
		echo "Error: asm_file takes 1 argument" 1>&2
		exit 1
	fi
	objname=`basename "$1" .s`.obj
	helpers/makeline dep $objname "$1" >> $BUILD_DIR/$LIBNAME/Makefile
	helpers/makeline cmd ../../toolwrap/asm470 ${ASMFLAGS} "$1" '$@' \
		>> $BUILD_DIR/$LIBNAME/Makefile
	echo >> $BUILD_DIR/$LIBNAME/Makefile
	OBJS="$OBJS $objname"
}

cfile_plain() {
	if [ $# != 1 ]
	then
		echo "Error: cfile_plain takes 1 argument" 1>&2
		exit 1
	fi
	objname=`basename "$1" .c`.obj
	helpers/makeline dep $objname "$1" >> $BUILD_DIR/$LIBNAME/Makefile
	case "$objname" in
		*[A-Z]*)
			helpers/makeline cmd rm -f '$@' \
				>> $BUILD_DIR/$LIBNAME/Makefile
			;;
	esac
	helpers/makeline cmd ../../toolwrap/cl470 -q -c ${CFLAGS} ${CPPFLAGS} \
		"$1" >> $BUILD_DIR/$LIBNAME/Makefile
	case "$objname" in
		*[A-Z]*)
			objname_lc=`echo $objname | tr A-Z a-z`
			helpers/makeline cmd mv $objname_lc $objname \
				>> $BUILD_DIR/$LIBNAME/Makefile
			;;
	esac
	echo >> $BUILD_DIR/$LIBNAME/Makefile
	OBJS="$OBJS $objname"
}

cfile_str2ind() {
	if [ $# != 1 ]
	then
		echo "Error: cfile_str2ind takes 1 argument" 1>&2
		exit 1
	fi
	if [ "$USE_STR2IND" = 1 ]
	then
		objname=`basename "$1" .c`.obj
		pp_name=`echo $1 | sed -e 's/\.c$/.pp/' | tr A-Z a-z`
		pp__name=`echo $1 | sed -e 's/\.c$/.pp_/' | tr A-Z a-z`
		helpers/makeline dep $objname "$1" \
			>> $BUILD_DIR/$LIBNAME/Makefile
		case "$objname" in
			*[A-Z]*)
				helpers/makeline cmd rm -f '$@' \
					>> $BUILD_DIR/$LIBNAME/Makefile
				;;
		esac
		helpers/makeline cmd ../../toolwrap/cl470 -q -po -p? -x \
			${CPPFLAGS} "$1" >> $BUILD_DIR/$LIBNAME/Makefile
		helpers/makeline cmd ../../toolwrap/str2ind -a \
			-t ../str2ind.tab -l ../str2ind.log \
			-f "$pp_name" >> $BUILD_DIR/$LIBNAME/Makefile
		helpers/makeline cmd ../../toolwrap/cl470 -q -c ${CFLAGS} \
			"$pp__name" >> $BUILD_DIR/$LIBNAME/Makefile
		helpers/makeline cmd @rm -f "$pp_name" \
			>> $BUILD_DIR/$LIBNAME/Makefile
		helpers/makeline cmd @rm -f "$pp__name" \
			>> $BUILD_DIR/$LIBNAME/Makefile
		case "$objname" in
			*[A-Z]*)
				objname_lc=`echo $objname | tr A-Z a-z`
				helpers/makeline cmd mv $objname_lc $objname \
					>> $BUILD_DIR/$LIBNAME/Makefile
				;;
		esac
		echo >> $BUILD_DIR/$LIBNAME/Makefile
		OBJS="$OBJS $objname"
	else
		cfile_plain "$1"
	fi
}

cfile_symlink() {
	if [ $# != 1 ]
	then
		echo "Error: cfile_symlink takes 1 argument" 1>&2
		exit 1
	fi
	localcopy=`basename "$1"`
	echo "$localcopy:" >> $BUILD_DIR/$LIBNAME/Makefile
	echo "	ln -s $1 ." >> $BUILD_DIR/$LIBNAME/Makefile
	echo >> $BUILD_DIR/$LIBNAME/Makefile
	cfile_plain $localcopy
}

# invoke the recipe

SRC=../../src
OBJS=
. "$recipe_file"

# finish the Makefile

helpers/makeline dep $LIBNAME.lib ${OBJS} >> $BUILD_DIR/$LIBNAME/Makefile
echo '	../../toolwrap/ar470 r $@ $^' >> $BUILD_DIR/$LIBNAME/Makefile
echo >> $BUILD_DIR/$LIBNAME/Makefile
echo 'clean:' >> $BUILD_DIR/$LIBNAME/Makefile
echo '	rm -f *.obj *.lib *.c' >> $BUILD_DIR/$LIBNAME/Makefile