#!/bin/sh
firmware="powerfip-firmware"
library="libpowerfip"

PWRFIP_FW_DIR=/usr/local/lib/firmware
PWRFIP_HDR_DIR=/usr/local/include/powerfip
PWRFIP_LIB_DIR=/usr/local/lib

# remove the firmware from the target directory
rm ${PWRFIP_FW_DIR}/${firmware}.bin

# remove static/shared library from the target directory
rm ${PWRFIP_LIB_DIR}/${library}.a
rm ${PWRFIP_LIB_DIR}/${library}.so.*
rm ${PWRFIP_LIB_DIR}/${library}.so

# remove the headers from the target directory
rm ${PWRFIP_HDR_DIR}/libpowerfip.h
rm ${PWRFIP_HDR_DIR}/mbox-common.h
rm ${PWRFIP_HDR_DIR}/powerfip-common.h
rm ${PWRFIP_HDR_DIR}/powerfip-drv.h
rm ${PWRFIP_HDR_DIR}/powerfip-mbox-common.h

# delete the powerfip header directory if empty
if [ `ls ${PWRFIP_HDR_DIR} | wc -l` -eq 0 ];
then
    rmdir ${PWRFIP_HDR_DIR}
fi

# delete the powerfip firmware directory if empty
if [ `ls ${PWRFIP_FW_DIR} | wc -l` -eq 0 ];
then
    rmdir ${PWRFIP_FW_DIR}
fi