Permalink
Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 102 lines (83 sloc) 1.73 KB
#!/bin/bash
# TODO? re-enable interactive and configure options
PROG_NAME=${0##*/}
# Output for the generated file
MAKEFILE=Makefile.config
STRIP=true
RM=
EXE=
OS_TYPE=
API=
API_DEP=
while [[ $# -ne 0 ]]; do
case $1 in
--api)
API_DEP="piqirun.ext redis-sync yojson curl";
API="-D API" ;;
*)
echo -e "\\x1b[33m[WARNING]\\x1b[0m Option $1 unknown and ignored.";;
esac
[[ $# -gt 0 ]] && shift
done
# Functions that print the checked information
# Length of line for print_check_*
LINE_WIDTH=65
print_check_gen() {
local n=$(( $LINE_WIDTH-${#2}-8 ))
printf "\\x1b[36m[INFO]\\x1b[0m %s " "$2"
printf ".%.0s" $(eval "echo {1.."$(($n))"}")
printf " \\x1b[%sm%s\\x1b[0m" "$1" "$3"
echo
}
print_check_ok() {
print_check_gen "32" "$1" "${2:-OK}"
}
# Functions to check the environment
check_os() {
OS_TYPE=`uname -s`
if [[ $OS_TYPE == "Linux" ]] ; then
print_check_ok "Checking OS type" "Linux"
EXE=
RM="/bin/rm -f"
STRIP=strip
elif [[ $OS_TYPE == "Darwin" ]] ; then
print_check_ok "Checking OS type" "Darwin"
EXE=
RM="/bin/rm -f"
STRIP=strip
else
print_check_ok "Checking OS type" "WINDOWS"
OS_TYPE="Win"
CAMLP5F+=" -D WINDOWS"
EXE=".exe"
RM="rm -f"
STRIP=true
fi
}
# Functions to print Makefile.config.
# Print common options, should be called first.
print_common_header() {
echo "# This file is generated by $0."
echo
echo "OS_TYPE=${OS_TYPE}"
}
print_tools() {
echo
echo "# Tools"
echo "STRIP=${STRIP}"
echo "RM=${RM}"
echo "EXE=${EXE}"
}
print_vars() {
echo "API=${API}"
echo "API_DEP=${API_DEP}"
}
print_makefile() {
(print_common_header
print_tools
print_vars
) > $MAKEFILE
}
# Print Makefile
check_os
print_makefile