PRO_DIR=`pwd`
CONFIG_IVSysMan="IVSysMan_Ge3.xml"


cd ../../ 

app_name=(
#driver_lidar_rs16
#driver_gps_hcp2
driver_gps_ins550d
driver_can_nvidia_agx
#driver_can_kvaser
driver_map_trace
detection_radar_delphi_esr
detection_lidar_distributed_server
#detection_lidar_grid
#view_pointcloud
view_gps
view_rawcan
view_radar
IVSysMan
ivmapmake
view_ivlog
tool_querymsg
detection_chassis
ui_ads_hmi
decition_brain
#decition_brain_ge3
controller_ge3
driver_map_xodrload
tool_xodrobj
ivlog_record
adciv_record
)

for x in ${app_name[@]}
do
	echo "deploy $x"
	cp ./bin/${x} ./
	./deploy.sh $x
	rm ${x}
done

lib_name=(
	libmodulecomm.so
	libndt_cpu.so
	libxmlparam.so
	libivfault.so
	libivlog.so
	libplatformif.so
	libivbacktrace.so
	libivexit.so
)

for x in ${lib_name[@]}
do
	echo "link lib $x"
	patchelf --set-rpath '$ORIGIN' ./bin/$x
done

echo "creat IVSysMan.xml"
cp ./other/$CONFIG_IVSysMan ./deploy/app/IVSysMan.xml
cp ./other/ADS_decision.xml ./deploy/app/ADS_decision.xml
sed -i "s|xxxxxx|$PRO_DIR/deploy/app|g" ./deploy/app/IVSysMan.xml

cp ./bin/*.so ./deploy/app/lib/

echo ""
echo "***************"
echo "***  done!  ***"
echo "***************"