summaryrefslogtreecommitdiff
path: root/configure
blob: 72abed07d6b881a3b68b5c181175e3b9e415a6f0 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/sh -e

HERE="$(dirname $(readlink -f ${0}))";

##
# Full list of all possible repositories.
#
repos=$(grep -v ^# <<EOF
system
user
legacy
experimental
EOF
);

##
# Do not build any repos by default.
#
build="";

##
# Usage.
#
usage ()
{
    printf "Usage: %s OPTION [OPTION] ...\n" "${0}";

    printf "\nOptions:\n\n";
    cat <<"EOF"
    --simulate      Sleep 1 second instead of build
EOF

    printf "\nRepositories:\n\n";
    for k in ${repos}; do
        printf "    --enable-%s\n" "${k}";
    done
    printf "\n";
}

##
# Enable repositories only explicitly.
#
_find=;
_fake=0; # default not a simulation
for arg; do
    case "${arg}" in
        --enable-*)
            for repo in ${repos}; do
                _find=0;
                if test "${arg##*-}" = "${repo}"; then
                    build="${build} ${repo}";
                    _find=1;
                    break;
                fi
            done
            if test ${_find} -eq 0; then
                printf "E: Repository '%s' is not supported!\n" "${arg##*-}";
                exit 1;
            fi
            ;;
        --simulate)
            _fake=1;
            ;;
        *)
            printf "E: Option '%s' is not supported!\n" "${arg}";
            exit 1;
            ;;
    esac
done

##
# Sorted order.
#
build=$(printf "%s\n" "${build}" | tr ' ' '\n' | sort | uniq | xargs);

##
# Sanity checks.
#
if test "${#build}" -eq 0; then
    usage;
    exit 0;
fi

##
# Generate Makefile.
#
printf "Generating subpackage index ...\n";
"${HERE}"/scripts/setup;
printf "Generating dependency list ...\n";
"${HERE}"/scripts/deplist ${build} | "${HERE}"/scripts/genmake ${_fake};

##
# Generate report.
#
printf "\nSuccess!\n\n";

_numpkgs=$(grep -E '^.*/.*:' "${HERE}"/Makefile | wc -l);
printf "    Packages\t: %s\n" "${_numpkgs}";
printf "\n";

if test ${_fake} -eq 1; then
    printf "SIMULATION ONLY! NO PACKAGES WILL BE BUILT!\n\n";
fi