File:  [ELWIX - Embedded LightWeight unIX -] / elwix / build_init.sh
Revision 1.5: download - view: text, annotated - select for diffs - revision graph
Thu Mar 11 13:59:50 2021 UTC (3 years, 1 month ago) by misho
Branches: MAIN
CVS tags: elwix2_8, elwix2_7, HEAD, ELWIX2_7, ELWIX2_6
ver 2.6

#!/bin/sh
#
# ELWIX build script for setup host cross compile process - *** START FIRST *** -
#
# (C) AITNET ltd - Sofia/Bulgaria <office@aitnet.org>
#    by Michael Pounov <misho@elwix.org>
#
# $Id: build_init.sh,v 1.5 2021/03/11 13:59:50 misho Exp $
#

# ./build_init.sh [custom build rc.elwix config]
if [ -n "$1" ]; then
	cd config
	ln -sf $1 rc.elwix
	cd -
fi

[ -r ./config/rc.elwix ] && . ./config/rc.elwix
if [ X"${ELWIX_IS_CONFIGURED}" != X"YES" ]; then
	echo
	echo "ELWIX project is not configured !?!"
	echo
	exit 1
fi

if [ ! -d $BSDSRC ]; then
	echo
	echo "ELWIX project is not configured - missing BSD sources !?!"
	echo
	exit 1
fi

if [ "${USER}" != "root" ]; then
	echo
	echo "ELWIX project is not configured - Init must build under root !?!"
	echo
	exit 1
fi

clean_pkgsrc()
{
	echo "+++ Clean ELWIX pkgsrc ..."
#	MNTEXISTS=$(mount | awk -vpkgsrc="${PKGSRC_DIR}" -vdstmnt="${WORLD}/usr/pkgsrc" \
#		'($1 == pkgsrc && $3 == dstmnt) { printf("YES"); }')
#	if [ "${MNTEXISTS}" != "YES" ]; then
#		umount ${WORLD}/usr/pkgsrc
#	fi

	rm -f /elwix ${WORLD}/usr/pkgsrc
	echo "+++ Erased pkgsrc helper dirs!"
}

clean_init()
{
	echo "+++ Clean ELWIX Projects ..."
	echo -n "Erase *ALL* builded ELWIX projects [NO/yes]? "
	read LINE
	if [ X"$LINE" = X"yes" ]; then
		clean_pkgsrc

		find ${BSDSRC} -name "*.o" -exec rm {} +

		chflags -Rf noschg,nosunlink ${TOPDIR}
		rm -rf $TOPDIR
		mkdir -p $TOPDIR
		echo "+++ Erased *ALL* builded ELWIX projects!"
	fi
}

install_init()
{
	echo "+++ Install ELWIX Project directories ..."

	install -d $REL
	install -d $DEST
	install -d $OBJS
	install -d $ADIR

	install -d $BSDOBJ

#	ln -sf $BSDSRC

	echo "ELWIX Platform:${PLATFORM} Version:${VERSION} TargetArch:${TARGET_ARCH}" >${TOPDIR}/elwix.ver
}

### main()
install -d ${TOPDIR}

V=$(CheckVer ${TOPDIR}/elwix.ver)
if [ $? -ne 0 -o X"$V" != X"${VERSION}" ]; then
	echo " Not found valid version or different version from current - Start CLEAN *ALL*"
	rm -rf $TOPDIR
	mkdir -p $TOPDIR
	echo "+++ CLEAN *ALL* complete"
else
	clean_init
fi

install_init

echo "+++ Complete Init ELWIX"

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>