-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·131 lines (113 loc) · 3.03 KB
/
configure
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
#
# This file is part of the Offenbach Project
#
# (c) 2019-2024 Yannoff (https://github.com/yannoff)
#
# @project Offenbach
# @author Yannoff (https://github.com/yannoff)
# @link https://github.com/yannoff/offenbach
# @license http://opensource.org/licenses/MIT
#
# For the full copyright and license information,
# please view the LICENSE file bundled with this
# software sources.
#
# Installation configure script
#
vars=( prefix bindir mandir )
files=()
# Default value for prefix dir
prefix=/usr
usage() {
if [ $# -gt 0 ]
then
echo
printf "$@"
echo
fi
cat >&2 <<EOH
Usage:
$0 [--prefix=<prefix>] [--bindir=<bindir>] [--mandir=<mandir>] file1 [...file2 [file3]]
$0 [--prefix=<prefix>] [--bindir=<bindir>] [--mandir=<mandir>] --list list-file
Options:
--help, -h Display this help and exit
--prefix The prefix dir (defaults to $prefix)
--bindir The binary install dir (defaults to \$PREFIX/bin)
--mandir The manual install dir (defaults to \$PREFIX/share/man)
--list Read the list of files to include from the given file instead of command arguments
EOH
}
while [ $# -gt 0 ]
do
case $1 in
# Support passing options in the --option=value form
--*=*)
arg=$1
option=${arg%%=*}
value=${arg##*=}
shift 1
set -- ${option} ${value} $@
;;
--help|-h|--usage)
usage
exit 0
;;
--prefix)
prefix=$2
shift 2
;;
--bindir)
bindir=$2;
shift 2
;;
--mandir)
mandir=$2;
shift 2
;;
--list)
files=(`xargs --arg-file=$2`)
shift 2
;;
--*)
printf '\nUnrecognized option "%s", ignoring.\n' $1
shift
;;
*)
files+=( $1 )
shift
;;
esac
done
if [ ${#files[*]} -eq 0 ]
then
usage "%s\n%s\n%s" "Cannot establish the list of files to copy." \
"Please provide them either as command-line arguments," \
"either via a list file."
exit 1
fi
[ -z "$bindir" ] && bindir=${prefix}/bin
[ -z "$mandir" ] && mandir=${prefix}/share/man
printf "\n\033[01;32mConfigured variables:\033[00m\n---------------------\n"
for v in ${vars[@]}
do
printf "%s: %s\n" $v ${!v}
done
# Build Makefile base using heredoc
cat > Makefile <<EOT
# vim: set noexpandtab
all:
echo "Everything OK. Run: sudo make install"
install:
EOT
# Build included files list
printf "\n\033[01;32mFiles to be included:\033[00m\n---------------------\n"
for f in "${files[@]}"
do
printf "\tcp -v %s %s\n" $f $bindir 1>>Makefile
printf "+ copy: %s\n" $f
done
# Run parts if found
printf "\n\033[01;32mRequirement checks:\033[00m\n---------------------\n"
[ -d configure.d/ ] && run-parts --arg=${bindir} configure.d 1>>Makefile
printf "\n\033[01;32mGenerated\033[00m Makefile.\n\n"