-
Notifications
You must be signed in to change notification settings - Fork 5
/
configure.sh
executable file
·164 lines (145 loc) · 4.68 KB
/
configure.sh
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
# usage:
#
# <POSIX bourne shell> configure.sh [--gnu_make=/path/to/gnu/make]
# [--bourne_shell=/path/to/bourne/shell]
# [--boot_file=/path/to/custom/boot/file]
MAKL_DIR="`pwd`"
export MAKL_DIR
makl_conf_h="/dev/null"
export makl_conf_h
# setup a temporary toolchain to please makl.init
host="`uname -rs | tr '[A-Z]' '[a-z]' | sed -e 's/ //g'`"
MAKL_PLATFORM=$host
export MAKL_PLATFORM
TC_SETUP_SOURCED="true"
export TC_SETUP_SOURCED
echo "set up temporary toolchain to please makl.init (will be overwritten)"
. setup/tc_setup.sh
# initialize makl/cf
. "${MAKL_DIR}"/cf/makl.init
makl_args_init "$@"
# initialize command line handlers:
#
# --gnu_make=...
makl_args_def \
"gnu_make" \
"=GNUMAKEPATH" "" \
"set GNU make executable path on this system"
__makl_gnu_make ()
{
[ $# -eq 1 ] || makl_err 1 "--gnu_make needs one argument"
makl_set_var_mk GNU_MAKE "$@"
}
# --bourne_shell=...
makl_args_def \
"bourne_shell" \
"=BOURNESHELLPATH" "" \
"set Bourne shell executable path on this system"
__makl_bourne_shell ()
{
[ $# -eq 1 ] || makl_err 1 "--bourne_shell needs one argument"
makl_set_var_mk BOURNE_SHELL "$@"
}
# --boot_file=...
makl_args_def \
"boot_file" \
"=BOOTFILEPATH" "" \
"explicitly supply a MaKL bootstrap file"
__makl_boot_file ()
{
[ $# -eq 1 ] || makl_err 1 "--boot_file needs one argument"
BOOT_FILE="$@"
}
makl_args_def \
"no_man" \
"" "" \
"disable compilation of man pages (using xml2man)"
__makl_no_man ()
{
makl_set_var_mk "NO_MAN"
}
# tool deps
makl_optional 1 "featx" "xml2man" # => HAVE_XML2MAN, PATH_XML2MAN
makl_args_handle "$@"
# set destination for MaKL bells and whistles
makl_set_var_mk MAKL_ROOT "`makl_get_var_mk SHAREDIR`/makl-`cat VERSION`"
# if no explicit bootstrap file was supplied, go for autodetection
if [ -z "${BOOT_FILE}" ]
then
case $host
in
linux*) boot_file="boot/linux.cfg" ;;
darwin*) boot_file="boot/darwin.cfg" ;;
freebsd*) boot_file="boot/freebsd.cfg" ;;
netbsd*) boot_file="boot/netbsd.cfg" ;;
openbsd*) boot_file="boot/openbsd.cfg" ;;
minix*)
# Prefer GCC if available else fall back to default ACK suite
if [ -x "/usr/pkg/bin/gcc" ]
then
boot_file="boot/minix-gnu.cfg"
else
boot_file="boot/minix-ack.cfg"
fi
;;
sunos*)
grep OpenSolaris /etc/release 2>&1 > /dev/null
if [ $? -ne 0 ]
then
boot_file="boot/solaris.cfg"
else
if [ -d /opt/SunStudioExpress ]
then
boot_file="boot/opensolaris-sunstudio.cfg"
elif [ -d "/usr/gnu/bin" ]
then
boot_file="boot/opensolaris-gnu.cfg"
else
makl_err 1 "No Sun Studio nor GNU environment found (install gcc-dev or ss-dev)"
fi
fi
;;
cygwin*) boot_file="boot/cygwin.cfg" ;;
mingw*) boot_file="boot/mingw.cfg" ;;
dragonfly*) boot_file="boot/dragonfly.cfg" ;;
*)
echo "no boot file for $host found: trying the default..."
boot_file="boot/default.cfg"
;;
esac
else
boot_file="${BOOT_FILE}"
fi
# source-in platform configuration
echo "using $boot_file for bootstrapping MaKL"
. "$boot_file"
# NOTE: command line has precedence over bootstrap settings
[ -z "`makl_get_var_mk GNU_MAKE`" ] && \
makl_set_var_mk "GNU_MAKE" "${gnu_make}"
[ -z "`makl_get_var_mk BOURNE_SHELL`" ] && \
makl_set_var_mk "BOURNE_SHELL" "${bourne_shell}"
# check that needed tools are in place
t1="`makl_get_var_mk GNU_MAKE`"
t2="`makl_get_var_mk BOURNE_SHELL`"
[ -x "${t1}" ] || \
makl_err 1 "${t1} not found, install it first. ${gnu_make_hint}"
[ -x "${t2}" ] || \
makl_err 1 "${t2} not found, install it first. ${bourne_shell_hint}"
# do final toolchain/shlib setup
MAKL_TC_FILE="${toolchain_file}"
export MAKL_TC_FILE
MAKL_SHLIB_FILE="${shlib_file}"
export MAKL_SHLIB_FILE
# apply substitution as needed
# assume TC_SETUP_SOURCED is still there
. setup/tc_setup.sh
makl_file_sub "bin/maklsh" \
"bin/lib/maklsh_catalog" \
"bin/lib/maklsh_run" \
"bin/lib/maklsh_tc" \
"bin/lib/maklsh_funcs"
# write Makefile.conf
. "${MAKL_DIR}"/cf/makl.term
# output optional platform specific message
[ -n "${install_hint}" ] && echo ${install_hint}
exit 0