405 lines
11 KiB
Bash
405 lines
11 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# shellcheck disable=SC1091
|
|
source "${ROOTDIR}/scripts/husky_vars.sh"
|
|
source "${ROOTDIR}/scripts/helpers/git.sh"
|
|
|
|
function husky_build() {
|
|
local component=$1
|
|
echo "* Building husky..."
|
|
|
|
# User might (re)build only one component.
|
|
if [ "${component}" != "" ]; then
|
|
echo "!!! Building only '${component}'!"
|
|
|
|
local funcname="husky_build_${component}"
|
|
${funcname}
|
|
|
|
exit 0
|
|
fi
|
|
|
|
# Build sequence was taken from husky-git package from Arch Linux AUR.
|
|
husky_build_huskylib
|
|
husky_build_smapi
|
|
husky_build_fidoconf
|
|
husky_build_areafix
|
|
husky_build_hptzip
|
|
husky_build_hpt
|
|
husky_build_areastat
|
|
husky_build_hptsqfix
|
|
husky_build_htick
|
|
husky_build_hptkill
|
|
husky_build_nltools
|
|
husky_build_sqpack
|
|
husky_build_bsopack
|
|
}
|
|
|
|
function husky_build_areafix() {
|
|
echo "* Building husky's areafix..."
|
|
|
|
_husky_build_common_start "areafix" "${_HUSKY_AREAFIX_GIT}"
|
|
|
|
rm fidoconf huskylib smapi &>/dev/null
|
|
ln -s ../fidoconf/fidoconf fidoconf
|
|
ln -s ../huskylib/huskylib huskylib
|
|
ln -s ../smapi/smapi smapi
|
|
|
|
rm -rf build &>/dev/null
|
|
|
|
if ! cmake -Bbuild \
|
|
-DBUILD_SHARED_LIBS=OFF \
|
|
-Dhusky_LIB="${ROOTDIR}/dist/husky/lib/libhusky.a" \
|
|
-Dsmapi_LIB="${ROOTDIR}/dist/husky/lib/libsmapi.a" \
|
|
-Dfidoconfig_LIB="${ROOTDIR}/dist/husky/lib/libfidoconfig.a" \
|
|
-DCMAKE_INSTALL_PREFIX:PATH="${_HUSKY_BIN_DIR}"; then
|
|
echo "! Failed to configure areafix!"
|
|
exit 1
|
|
fi
|
|
|
|
_husky_build_common_end "areafix"
|
|
}
|
|
|
|
function husky_build_areastat() {
|
|
echo "* Building husky's areastat..."
|
|
|
|
_husky_build_common_start "areastat" "${_HUSKY_AREASTAT_GIT}"
|
|
|
|
rm huskylib smapi &>/dev/null
|
|
ln -s ../huskylib/huskylib huskylib
|
|
ln -s ../smapi/smapi smapi
|
|
|
|
rm -rf build &>/dev/null
|
|
|
|
# areastat's cvsdate.h placed in different place.
|
|
mv cvsdate.h h/cvsdate.h
|
|
|
|
if ! cmake -Bbuild \
|
|
-DBUILD_SHARED_LIBS=OFF \
|
|
-Dhusky_LIB="${ROOTDIR}/dist/husky/lib/libhusky.a" \
|
|
-Dsmapi_LIB="${ROOTDIR}/dist/husky/lib/libsmapi.a" \
|
|
-DCMAKE_INSTALL_PREFIX:PATH="${_HUSKY_BIN_DIR}"; then
|
|
echo "! Failed to configure areastat!"
|
|
exit 1
|
|
fi
|
|
|
|
_husky_build_common_end "areastat"
|
|
}
|
|
|
|
function husky_build_bsopack() {
|
|
echo "* Building husky's bsopack..."
|
|
|
|
_husky_build_common_start "bsopack" "${_HUSKY_BSOPACK_GIT}"
|
|
|
|
rm fidoconf huskylib smapi &>/dev/null
|
|
ln -s ../fidoconf/fidoconf fidoconf
|
|
ln -s ../huskylib/huskylib huskylib
|
|
ln -s ../smapi/smapi smapi
|
|
|
|
rm -rf build &>/dev/null
|
|
|
|
# bsopack requires patch to work with cmake.
|
|
git apply <"${ROOTDIR}/patches/bsopack.patch"
|
|
|
|
# bsopack's cvsdate.h placed in different place.
|
|
#mv cvsdate.h h/cvsdate.h
|
|
|
|
if ! cmake -Bbuild \
|
|
-DBUILD_SHARED_LIBS=OFF \
|
|
-Dfidoconfig_LIB="${ROOTDIR}/dist/husky/lib/libfidoconfig.a" \
|
|
-Dhusky_LIB="${ROOTDIR}/dist/husky/lib/libhusky.a" \
|
|
-Dsmapi_LIB="${ROOTDIR}/dist/husky/lib/libsmapi.a" \
|
|
-DCMAKE_INSTALL_PREFIX:PATH="${_HUSKY_BIN_DIR}"; then
|
|
echo "! Failed to configure bsopack!"
|
|
exit 1
|
|
fi
|
|
|
|
_husky_build_common_end "bsopack"
|
|
}
|
|
|
|
function husky_build_fidoconf() {
|
|
echo "* Building husky's fidoconf..."
|
|
|
|
_husky_build_common_start "fidoconf" "${_HUSKY_FIDOCONF_GIT}"
|
|
|
|
rm huskylib smapi &>/dev/null
|
|
ln -s ../huskylib/huskylib huskylib
|
|
ln -s ../smapi/smapi smapi
|
|
|
|
rm -rf build &>/dev/null
|
|
|
|
if ! cmake -Bbuild \
|
|
-DBUILD_SHARED_LIBS=OFF \
|
|
-Dhusky_LIB="${ROOTDIR}/dist/husky/lib/libhusky.a" \
|
|
-Dsmapi_LIB="${ROOTDIR}/dist/husky/lib/libsmapi.a" \
|
|
-DCMAKE_INSTALL_PREFIX:PATH="${_HUSKY_BIN_DIR}"; then
|
|
echo "! Failed to configure fidoconf!"
|
|
exit 1
|
|
fi
|
|
|
|
_husky_build_common_end "fidoconf"
|
|
}
|
|
|
|
function husky_build_hpt() {
|
|
echo "* Building husky's hpt..."
|
|
|
|
_husky_build_common_start "hpt" "${_HUSKY_HPT_GIT}"
|
|
|
|
rm areafix fidoconf hptzip huskylib smapi &>/dev/null
|
|
ln -s ../areafix/areafix areafix
|
|
ln -s ../fidoconf/fidoconf fidoconf
|
|
ln -s ../hptzip/hptzip hptzip
|
|
ln -s ../huskylib/huskylib huskylib
|
|
ln -s ../smapi/smapi smapi
|
|
|
|
rm -rf build &>/dev/null
|
|
|
|
if ! cmake -Bbuild \
|
|
-DBUILD_SHARED_LIBS=OFF \
|
|
-Dareafix_LIB="${ROOTDIR}/dist/husky/lib/libareafix.a" \
|
|
-Dfidoconfig_LIB="${ROOTDIR}/dist/husky/lib/libfidoconfig.a" \
|
|
-Dhptzip_LIB="${ROOTDIR}/dist/husky/lib/libhptzip.a" \
|
|
-Dhusky_LIB="${ROOTDIR}/dist/husky/lib/libhusky.a" \
|
|
-Dsmapi_LIB="${ROOTDIR}/dist/husky/lib/libsmapi.a" \
|
|
-DCMAKE_INSTALL_PREFIX:PATH="${_HUSKY_BIN_DIR}"; then
|
|
echo "! Failed to configure hpt!"
|
|
exit 1
|
|
fi
|
|
|
|
_husky_build_common_end "hpt"
|
|
}
|
|
|
|
function husky_build_hptkill() {
|
|
echo "* Building husky's hptkill..."
|
|
|
|
_husky_build_common_start "hptkill" "${_HUSKY_HPTKILL_GIT}"
|
|
|
|
rm fidoconf huskylib smapi &>/dev/null
|
|
ln -s ../fidoconf/fidoconf fidoconf
|
|
ln -s ../huskylib/huskylib huskylib
|
|
ln -s ../smapi/smapi smapi
|
|
|
|
rm -rf build &>/dev/null
|
|
|
|
if ! cmake -Bbuild \
|
|
-DBUILD_SHARED_LIBS=OFF \
|
|
-Dfidoconfig_LIB="${ROOTDIR}/dist/husky/lib/libfidoconfig.a" \
|
|
-Dhusky_LIB="${ROOTDIR}/dist/husky/lib/libhusky.a" \
|
|
-Dsmapi_LIB="${ROOTDIR}/dist/husky/lib/libsmapi.a" \
|
|
-DCMAKE_INSTALL_PREFIX:PATH="${_HUSKY_BIN_DIR}"; then
|
|
echo "! Failed to configure hptkill!"
|
|
exit 1
|
|
fi
|
|
|
|
_husky_build_common_end "hptkill"
|
|
}
|
|
|
|
function husky_build_hptsqfix() {
|
|
echo "* Building husky's hptsqfix..."
|
|
|
|
_husky_build_common_start "hptsqfix" "${_HUSKY_HPTSQFIX_GIT}"
|
|
|
|
rm fidoconf huskylib smapi &>/dev/null
|
|
ln -s ../fidoconf/fidoconf fidoconf
|
|
ln -s ../huskylib/huskylib huskylib
|
|
ln -s ../smapi/smapi smapi
|
|
|
|
rm -rf build &>/dev/null
|
|
|
|
# hptsqfix's cvsdate.h placed in different place.
|
|
mv cvsdate.h h/cvsdate.h
|
|
|
|
if ! cmake -Bbuild \
|
|
-DBUILD_SHARED_LIBS=OFF \
|
|
-Dfidoconfig_LIB="${ROOTDIR}/dist/husky/lib/libfidoconfig.a" \
|
|
-Dhusky_LIB="${ROOTDIR}/dist/husky/lib/libhusky.a" \
|
|
-Dsmapi_LIB="${ROOTDIR}/dist/husky/lib/libsmapi.a" \
|
|
-DCMAKE_INSTALL_PREFIX:PATH="${_HUSKY_BIN_DIR}"; then
|
|
echo "! Failed to configure hptsqfix!"
|
|
exit 1
|
|
fi
|
|
|
|
_husky_build_common_end "hptsqfix"
|
|
}
|
|
|
|
function husky_build_hptzip() {
|
|
echo "* Building husky's hptzip..."
|
|
|
|
_husky_build_common_start "hptzip" "${_HUSKY_HPTZIP_GIT}"
|
|
|
|
rm huskylib &>/dev/null
|
|
ln -s ../huskylib/huskylib huskylib
|
|
|
|
rm -rf build &>/dev/null
|
|
|
|
if ! cmake -Bbuild \
|
|
-DBUILD_SHARED_LIBS=OFF \
|
|
-Dhusky_LIB="${ROOTDIR}/dist/husky/lib/libhusky.a" \
|
|
-DCMAKE_INSTALL_PREFIX:PATH="${_HUSKY_BIN_DIR}"; then
|
|
echo "! Failed to configure hptzip!"
|
|
exit 1
|
|
fi
|
|
|
|
_husky_build_common_end "hptzip"
|
|
}
|
|
|
|
function husky_build_htick() {
|
|
echo "* Building husky's htick..."
|
|
|
|
_husky_build_common_start "htick" "${_HUSKY_HTICK_GIT}"
|
|
|
|
rm areafix fidoconf hptzip huskylib smapi &>/dev/null
|
|
ln -s ../areafix/areafix areafix
|
|
ln -s ../fidoconf/fidoconf fidoconf
|
|
ln -s ../hptzip/hptzip hptzip
|
|
ln -s ../huskylib/huskylib huskylib
|
|
ln -s ../smapi/smapi smapi
|
|
|
|
rm -rf build &>/dev/null
|
|
|
|
if ! cmake -Bbuild \
|
|
-DBUILD_SHARED_LIBS=OFF \
|
|
-Dareafix_LIB="${ROOTDIR}/dist/husky/lib/libareafix.a" \
|
|
-Dfidoconfig_LIB="${ROOTDIR}/dist/husky/lib/libfidoconfig.a" \
|
|
-Dhptzip_LIB="${ROOTDIR}/dist/husky/lib/libhptzip.a" \
|
|
-Dhusky_LIB="${ROOTDIR}/dist/husky/lib/libhusky.a" \
|
|
-Dsmapi_LIB="${ROOTDIR}/dist/husky/lib/libsmapi.a" \
|
|
-DCMAKE_INSTALL_PREFIX:PATH="${_HUSKY_BIN_DIR}"; then
|
|
echo "! Failed to configure htick!"
|
|
exit 1
|
|
fi
|
|
|
|
_husky_build_common_end "htick"
|
|
}
|
|
|
|
function husky_build_huskylib() {
|
|
echo "* Building husky's huskylib..."
|
|
|
|
_husky_build_common_start "huskylib" "${_HUSKY_HUSKYLIB_GIT}"
|
|
|
|
if ! cmake \
|
|
-Bbuild \
|
|
-DBUILD_SHARED_LIBS=OFF \
|
|
-DCMAKE_INSTALL_PREFIX:PATH="${_HUSKY_BIN_DIR}"; then
|
|
echo "! Failed to configure huskylib!"
|
|
exit 1
|
|
fi
|
|
|
|
_husky_build_common_end "huskylib"
|
|
}
|
|
|
|
function husky_build_nltools() {
|
|
echo "* Building husky's nltools..."
|
|
|
|
_husky_build_common_start "nltools" "${_HUSKY_NLTOOLS_GIT}"
|
|
|
|
rm fidoconf hptzip huskylib smapi &>/dev/null
|
|
ln -s ../fidoconf/fidoconf fidoconf
|
|
ln -s ../hptzip/hptzip hptzip
|
|
ln -s ../huskylib/huskylib huskylib
|
|
ln -s ../smapi/smapi smapi
|
|
|
|
rm -rf build &>/dev/null
|
|
|
|
# nltools's cvsdate.h placed in different place.
|
|
mv cvsdate.h h/cvsdate.h
|
|
|
|
if ! cmake -Bbuild \
|
|
-DBUILD_SHARED_LIBS=OFF \
|
|
-Dfidoconfig_LIB="${ROOTDIR}/dist/husky/lib/libfidoconfig.a" \
|
|
-Dhptzip_LIB="${ROOTDIR}/dist/husky/lib/libhptzip.a" \
|
|
-Dhusky_LIB="${ROOTDIR}/dist/husky/lib/libhusky.a" \
|
|
-Dsmapi_LIB="${ROOTDIR}/dist/husky/lib/libsmapi.a" \
|
|
-DCMAKE_INSTALL_PREFIX:PATH="${_HUSKY_BIN_DIR}"; then
|
|
echo "! Failed to configure nltools!"
|
|
exit 1
|
|
fi
|
|
|
|
_husky_build_common_end "nltools"
|
|
}
|
|
|
|
function husky_build_smapi() {
|
|
echo "* Building husky's smapi..."
|
|
|
|
_husky_build_common_start "smapi" "${_HUSKY_SMAPI_GIT}"
|
|
|
|
rm huskylib &>/dev/null
|
|
ln -s ../huskylib/huskylib huskylib
|
|
|
|
rm -rf build &>/dev/null
|
|
|
|
if ! cmake \
|
|
-Bbuild \
|
|
-DBUILD_SHARED_LIBS=OFF \
|
|
-Dhusky_LIB="${ROOTDIR}/dist/husky/lib/libhusky.a" \
|
|
-DCMAKE_INSTALL_PREFIX:PATH="${_HUSKY_BIN_DIR}"; then
|
|
echo "! Failed to configure smapi!"
|
|
exit 1
|
|
fi
|
|
|
|
_husky_build_common_end "smapi"
|
|
}
|
|
|
|
function husky_build_sqpack() {
|
|
echo "* Building husky's sqpack..."
|
|
|
|
_husky_build_common_start "sqpack" "${_HUSKY_SQPACK_GIT}"
|
|
|
|
rm fidoconf huskylib smapi &>/dev/null
|
|
ln -s ../fidoconf/fidoconf fidoconf
|
|
ln -s ../huskylib/huskylib huskylib
|
|
ln -s ../smapi/smapi smapi
|
|
|
|
rm -rf build &>/dev/null
|
|
|
|
if ! cmake -Bbuild \
|
|
-DBUILD_SHARED_LIBS=OFF \
|
|
-Dfidoconfig_LIB="${ROOTDIR}/dist/husky/lib/libfidoconfig.a" \
|
|
-Dhusky_LIB="${ROOTDIR}/dist/husky/lib/libhusky.a" \
|
|
-Dsmapi_LIB="${ROOTDIR}/dist/husky/lib/libsmapi.a" \
|
|
-DCMAKE_INSTALL_PREFIX:PATH="${_HUSKY_BIN_DIR}"; then
|
|
echo "! Failed to configure sqpack!"
|
|
exit 1
|
|
fi
|
|
|
|
_husky_build_common_end "sqpack"
|
|
}
|
|
|
|
function _husky_build_common_end() {
|
|
local name=$1
|
|
|
|
if ! cmake --build build; then
|
|
echo "! Failed to build husky's ${name}!"
|
|
exit 1
|
|
fi
|
|
|
|
if ! cd build; then
|
|
echo "! Failed to change directory to build when trying to install ${name}!"
|
|
exit 1
|
|
fi
|
|
|
|
if ! make install; then
|
|
echo "! Failed to install husky's ${name}!"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
function _husky_build_common_start() {
|
|
local name=$1
|
|
local git_repo=$2
|
|
|
|
git_source "husky/${name}" "${git_repo}"
|
|
|
|
if ! cd "${ROOTDIR}/src/husky/${name}"; then
|
|
echo "! Failed to change directory to husky's ${name} sources!"
|
|
exit 1
|
|
fi
|
|
|
|
_husky_generate_version
|
|
}
|
|
|
|
function _husky_generate_version() {
|
|
echo "* Generating version file..."
|
|
echo "char cvs_date[]=\"$(date +'%Y%m%d')-git\";" >"cvsdate.h"
|
|
echo "* Version file: '$(cat cvsdate.h)'"
|
|
}
|