view scripts/mk-component-gcc.sh @ 192:4f40ae165be4

abb.c & init.c: sync with Magnetite for Luna additions These Luna target-specific additions are conditionalized on CONFIG_TARGET_LUNA, a C preprocessor symbol that will never be defined in Selenite, hence this change has exactly zero impact on FC Selenite. However, they are being pulled in as a sync in order to keep the diff between Magnetite and Selenite to a minimum; keeping this diff to a minimum increases our opportunities for possible evolution of future FC firmwares.
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 23 May 2020 07:03:46 +0000
parents 2106617f1291
children
line wrap: on
line source

#!/bin/sh

if [ $# != 1 ]
then
	echo "usage: $0 component-lib" 1>&2
	exit 1
fi

LIBNAME="$1"
recipe_file="components/$1"

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.a" > $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`.o
	helpers/makeline dep $objname "$1" >> $BUILD_DIR/$LIBNAME/Makefile
	helpers/makeline cmd arm-elf-gcc -c ${ASMFLAGS} ${CPPFLAGS} "$1" \
		>> $BUILD_DIR/$LIBNAME/Makefile
	echo >> $BUILD_DIR/$LIBNAME/Makefile
	OBJS="$OBJS $objname"
}

c_file() {
	if [ $# != 1 ]
	then
		echo "Error: c_file takes 1 argument" 1>&2
		exit 1
	fi
	objname=`basename "$1" .c`.o
	helpers/makeline dep $objname "$1" >> $BUILD_DIR/$LIBNAME/Makefile
	helpers/makeline cmd arm-elf-gcc -c ${CFLAGS_gcc} ${CPPFLAGS} "$1" \
		>> $BUILD_DIR/$LIBNAME/Makefile
	echo >> $BUILD_DIR/$LIBNAME/Makefile
	OBJS="$OBJS $objname"
}

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
	c_file $localcopy
}

# invoke the recipe

COMPILER=gcc
SRC=../../src
OBJS=
MMI=0
. "$recipe_file"

# finish the Makefile

helpers/makeline dep $LIBNAME.a ${OBJS} >> $BUILD_DIR/$LIBNAME/Makefile
echo '	arm-elf-ar rcu $@ $^' >> $BUILD_DIR/$LIBNAME/Makefile
echo '	arm-elf-ranlib $@' >> $BUILD_DIR/$LIBNAME/Makefile
echo >> $BUILD_DIR/$LIBNAME/Makefile
echo 'clean:' >> $BUILD_DIR/$LIBNAME/Makefile
echo '	rm -f *.[oa] *.c' >> $BUILD_DIR/$LIBNAME/Makefile