forked from ebassi/graphene
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·179 lines (153 loc) · 5.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
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
#!/bin/bash
# configure script adapter for Meson
# Based on build-api: https://github.com/cgwalters/build-api
# Copyright 2010, 2011, 2013 Colin Walters <[email protected]>
# Copyright 2016, 2017 Emmanuele Bassi
# Licensed under the new-BSD license (http://www.opensource.org/licenses/bsd-license.php)
# Build API variables:
sanitycheck() {
# $1 = arg name
# $1 = arg command
# $2 = arg alternates
local cmd=$( which $2 2>/dev/null )
if [ -x "$cmd" ]; then
read "$1" <<< "$cmd"
return 0
fi
test -z $3 || {
for alt in $3; do
cmd=$( which $alt 2>/dev/null )
if [ -x "$cmd" ]; then
read "$1" <<< "$cmd"
return 0
fi
done
}
echo -e "\e[1;31mERROR\e[0m: Command '$2' not found"
exit 1
}
set_option() {
# $1 = arg name
# $2 = arg value
if [ ${dir_options[$1]+_} ]; then
dir_options[$1]=$2
elif [ ${default_options[$1]+_} ]; then
meson_options[$1]=$2
else
echo -e "\e[1;33mINFO\e[0m: Ignoring unknown option '$1'"
fi
}
set_bool_option() {
# $1 = arg name
# $2 = arg value
if [ ${default_options[$1]+_} ]; then
meson_options[$1]=$2
else
echo -e "\e[1;33mINFO\e[0m: Ignoring unknown option '$1'"
fi
}
sanitycheck MESON 'meson'
sanitycheck MESONTEST 'mesontest'
sanitycheck NINJA 'ninja' 'ninja-build'
declare -A dir_options=(
['prefix']=""
['bindir']=""
['sbindir']=""
['libexecdir']=""
['datarootdir']=""
['datadir']=""
['sysconfdir']=""
['libdir']=""
['mandir']=""
['includedir']=""
)
declare -A default_options=(
['gtk-doc']=false
['man']=false
['introspection']=true
)
declare -A meson_options
rematch_bool='^--(enable|disable)[-](.+)'
rematch_option='^--([[:alnum:]-]+)[=]?(.+)*'
while (($# > 0)); do
if [[ $1 =~ $rematch_bool || $1 =~ $rematch_option ]]; then
var1=${BASH_REMATCH[1]}
var2=${BASH_REMATCH[2]:-$2}
test -z "${BASH_REMATCH[2]}" && shift
case "$var1" in
enable) set_bool_option $var2 true;;
disable) set_bool_option $var2 false;;
*) set_option $var1 $var2;;
esac
else
echo -e "\e[1;31mERROR\e[0m: Unknown option '$1'"
fi
shift
done
# Defaults
test -z ${dir_options['prefix']} && dir_options['prefix']="/usr/local"
test -z ${dir_options['bindir']} && dir_options['bindir']=${dir_options['prefix']}/bin
test -z ${dir_options['sbindir']} && dir_options['sbindir']=${dir_options['prefix']}/sbin
test -z ${dir_options['libexecdir']} && dir_options['libexecdir']=${dir_options['prefix']}/bin
test -z ${dir_options['datarootdir']} && dir_options['datarootdir']=${dir_options['prefix']}/share
test -z ${dir_options['datadir']} && dir_options['datadir']=${dir_options['datarootdir']}
test -z ${dir_options['sysconfdir']} && dir_options['sysconfdir']=${dir_options['prefix']}/etc
test -z ${dir_options['libdir']} && dir_options['libdir']=${dir_options['prefix']}/lib
test -z ${dir_options['mandir']} && dir_options['mandir']=${dir_options['prefix']}/share/man
test -z ${dir_options['includedir']} && dir_options['includedir']=${dir_options['prefix']}/include
# The source directory is the location of this file
srcdir=$(dirname $0)
# The build directory is the current location
builddir=`pwd`
# If we're calling this file from the source directory then
# we automatically create a build directory and ensure that
# both Meson and Ninja invocations are relative to that
# location
if [[ -f "${builddir}/meson.build" ]]; then
mkdir -p _build
builddir="${builddir}/_build"
NINJA_OPT="-C ${builddir}"
fi
# Wrapper Makefile for Ninja
cat > Makefile <<END
# Generated by configure; do not edit
all:
CC="\$(CC)" CXX="\$(CXX)" ${NINJA} ${NINJA_OPT}
install:
DESTDIR="\$(DESTDIR)" ${NINJA} ${NINJA_OPT} install
check:
${MESONTEST} ${NINJA_OPT}
END
cmd_options=""
for key in "${!meson_options[@]}"; do
cmd_options="$cmd_options -Denable-$key=${meson_options[$key]}"
done
echo "Summary:"
echo " meson:....... ${MESON}"
echo " ninja:....... ${NINJA}"
echo " prefix:...... ${dir_options['prefix']}"
echo " bindir:...... ${dir_options['bindir']}"
echo " sbindir:..... ${dir_options['sbindir']}"
echo " libexecdir:.. ${dir_options['libexecdir']}"
echo " datarootdir:. ${dir_options['datarootdir']}"
echo " datadir:..... ${dir_options['datadir']}"
echo " sysconfdir:.. ${dir_options['sysconfdir']}"
echo " libdir:...... ${dir_options['libdir']}"
echo " mandir:...... ${dir_options['mandir']}"
echo " includedir:.. ${dir_options['includedir']}"
echo " additional:.."
echo " -${cmd_options}"
exec ${MESON} \
--prefix=${dir_options['prefix']} \
--libdir=${dir_options['libdir']} \
--libexecdir=${dir_options['libexecdir']} \
--datadir=${dir_options['datadir']} \
--sysconfdir=${dir_options['sysconfdir']} \
--bindir=${dir_options['bindir']} \
--includedir=${dir_options['includedir']} \
--mandir=${dir_options['mandir']} \
--default-library shared \
${cmd_options} \
${builddir} \
${srcdir}
# vim: ai ts=8 noet sts=2 ft=sh