#!/bin/sh

# convert_to_mlnx_en: Adapts a tree to be mlnx_en
#
# Called with --from-buildpl when run from build.pl

mv ofed_scripts/mlnx_en/MLNX_EN_Linux_README.txt .
mv ofed_scripts/mlnx_en/MLNX_EN_Linux_Release_Notes.txt .
mv ofed_scripts/mlnx_en/LICENSE .
mv drivers/infiniband/debug ./drivers/net/ethernet/mellanox

mv ofed_scripts/mlnx_en/mlx4.files ../

./ofed_scripts/ofed_patch.sh

if [ ! -e configure ]; then
	ln -s ofed_scripts/configure .
fi

rm -rf debian
mv ofed_scripts/mlnx_en/debian ./debian

if [ -d "scripts" ]; then
	rm -rf scripts
fi
mv ofed_scripts/mlnx_en/ ./scripts
rm -rf lib
rm -rf fs
rm -rf net/9p
rm -rf net/rds
rm -rf net/sched
rm -rf net/smc
rm -rf net/sunrpc
rm -rf kernel
rm -rf include-nfs
rm -rf include/scsi
rm -rf include/linux/rds.h
rm -rf drivers/net/ethernet/chelsio
rm -rf drivers/net/eipoib
rm -rf drivers/net/ethernet/mellanox/mlx4_vnic
rm -rf drivers/scsi/
rm -rf Documentation

mv drivers/infiniband/hw/mlx5/mlx5_ib-dummy .
rm -rf drivers/infiniband
mkdir -p drivers/infiniband/hw/mlx5
mv mlx5_ib-dummy drivers/infiniband/hw/mlx5/

mv scripts/mlnx_en.spec .
/bin/rm -f ofed_scripts/mlnx-ofa_kernel.spec

if [ -f "compat/autogen.sh" ]; then
	cd compat && ./autogen.sh >/dev/null 2>&1 && cd -
fi

