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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
#! /bin/sh
#
# opkbootstrap
# configure
# Configuration script to generate Makefile.
#
# Copyright (C) 2012 Patrick "P. J." McDermott
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
PACKAGE='opkbootstrap'
VERSION='0.1.0'
print_usage()
{
printf 'Usage: %s [OPTION]...\n' "$1"
}
print_help()
{
cat <<EOF
\`configure' configures ${PACKAGE} ${VERSION} to adapt to many kinds of systems.
$(print_usage "${1}")
Configuration:
-h, --help display this help and exit
-V, --version display version information and exit
-q, --quiet do not print \`checking ...' messages
--srcdir=SRCDIR find the scripts in SRCDIR
default: configure dir
Installation directories:
--prefix=PREFIX install files under PREFIX
default: /usr/local
--bindir=BINDIR install scripts in BINDIR
default: PREFIX/bin
--libdir=LIBDIR install library scripts in LIBDIR
default: PREFIX/lib
--datadir=DATADIR expect to find data in DATADIR
default: PREFIX/share
--mandir=MANDIR install manual pages in MANDIR
default: PREFIX/share/man
EOF
}
print_version()
{
cat <<EOF
${PACKAGE} ${VERSION} configure
Not generated by GNU Autoconf
Copyright (C) 2011-2012 Patrick "P. J." McDermott
License: GNU GPL version 3 or later <http://www.gnu.org/licenses/gpl.html>.
This configure script is free software: you can redistribute and/or modify it.
There is NO WARRANTY, to the extent permitted by law.
EOF
}
opts=$(getopt -n "${0}" -o 'hVq' -l 'help,version,quiet' \
-l 'srcdir:,prefix:,bindir:,libdir:,mandir:' -- "${@}")
if [ ${?} -ne 0 ]; then
print_usage "${0}" >&2
exit 1;
fi
eval set -- "${opts}"
while true; do
case "${1}" in
-h|--help)
print_help "${0}"
exit 0
;;
-V|--version)
print_version
exit 0
;;
-q|--quiet)
QUIET=true
shift
;;
--srcdir)
SRCDIR="${2}"
shift 2
;;
--prefix)
PREFIX="${2}"
shift 2
;;
--bindir)
BINDIR="${2}"
shift 2
;;
--libdir)
LIBDIR="${2}"
shift 2
;;
--datadir)
DATADIR="${2}"
shift 2
;;
--mandir)
MANDIR="${2}"
shift 2
;;
--)
shift
break
;;
*)
print_usage "${0}" >&2
exit 1
;;
esac
done
if [ -z "${QUIET}" ]; then
QUIET=false
fi
if [ -z "${SRCDIR}" ]; then
SRCDIR=$(dirname "${0}")
fi
# Make SRCDIR an absolute path if it isn't already.
SRCDIR=$(cd ${SRCDIR} && pwd)
if [ -z "${PREFIX}" ]; then
PREFIX=/usr/local
fi
if [ -z "${BINDIR}" ]; then
BINDIR=${PREFIX}/bin
fi
if [ -z "${LIBDIR}" ]; then
LIBDIR=${PREFIX}/lib
fi
if [ -z "${DATADIR}" ]; then
DATADIR=${PREFIX}/share
fi
if [ -z "${MANDIR}" ]; then
MANDIR=${PREFIX}/share/man
fi
find_dependency()
{
dep=${1}
var=${2}
shift 2
${QUIET} || printf 'checking for %s... ' "${dep}"
while [ ${#} -gt 0 ]; do
if [ -f "${1}/${dep}" ]; then
${QUIET} || printf '%s/%s\n' "${1}" "${dep}"
eval "${var}=${1}/${dep}"
return 0
fi
shift
done
${QUIET} || printf 'not found\n'
missing_dependencies=true
return 1
}
missing_dependencies=false
find_dependency sh SHELL /bin
find_dependency install INSTALL /usr/bin
find_dependency make MAKE /usr/bin
if ${missing_dependencies}; then
printf '\nSome dependencies could not be found.\n'
printf 'Please make sure all dependencies are installed and try again.\n\n'
exit 1
fi
sed_script="
s&@shell@&${SHELL}&
s&@install@&${INSTALL} -c&
s&@make@&${MAKE}&
s&@srcdir@&${SRCDIR}&
s&@prefix@&${PREFIX}&
s&@bindir@&${BINDIR}&
s&@libdir@&${LIBDIR}&
s&@datadir@&${DATADIR}&
s&@mandir@&${MANDIR}&
s&@package@&${PACKAGE}&
s&@version@&${VERSION}&"
# Replace configuration variables in Makefile.in
mkdir -p src lib man
sed "$sed_script" ${SRCDIR}/Makefile.in > Makefile
sed "$sed_script" ${SRCDIR}/src/Makefile.in > src/Makefile
sed "$sed_script" ${SRCDIR}/lib/Makefile.in > lib/Makefile
sed "$sed_script" ${SRCDIR}/man/Makefile.in > man/Makefile
printf '\nConfiguration complete!\n\n'
|