summaryrefslogtreecommitdiffstats
path: root/build.sh
blob: 4e2be4db1f3cba7c386bfab98acc71d1c5e36d13 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh

if [ -z "${WSPKGDIR}" ]; then
    printf '\033[1;31mWSPKGDIR is not defined so I cannot build package for you :(\033[m\n'
    if [ -f "../wspkg/wspkg-mk/packages.mk" ]; then
        printf 'You may want to try WSPKGDIR="%s/wspkg" %s\n' "$(dirname "$(pwd)")" "$0"
    elif [ -f "/usr/share/wspkg/wspkg-mk/packages.mk" ]; then
        printf 'You may want to try WSPKGDIR=/usr/share/wspkg %s\n' "$0"
    elif [ -f "/usr/pkg/share/wspkg/wspkg-mk/packages.mk" ]; then
        printf 'You may want to try WSPKGDIR=/usr/pkg/share/wspkg %s\n' "$0"
    elif [ -f "/usr/local/share/wspkg/wspkg-mk/packages.mk" ]; then
        printf 'You may want to try WSPKGDIR=/usr/local/share/wspkg %s\n' "$0"
    fi
    exit 1
fi

[ -z "$1" ] && printf 'Usage: %s makefile\n' "$0" && exit 1
if [ -d "$1" ]; then
    makefile="${1}.mk"
else
    makefile="${1}"
fi
shift

: "${MAKE:="make"}"
printf '\033[1;33mRunning\033[m: %s -f "%s" WSPKGDIR="%s"' "${MAKE}" "${makefile}" "${WSPKGDIR}"
for arg in "$@"; do
    printf ' %s' "${arg}"
done
printf '\n\n'
if "${MAKE}" -f "${makefile}" WSPKGDIR="${WSPKGDIR}" "$@"; then
    printf '\n\033[1;32mDone! ;-)\033[m\n'
else
    printf '\n\033[1;31mSorry... :(\033[m\n'
fi