blob: d03c964bedfdd6881a4813e6d439ebaa0ceeee07 (
plain)
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
|
#!/bin/bash
# configure script adapter for Meson
# Based on build-api: https://github.com/cgwalters/build-api
# Copyright 2010, 2011, 2013 Colin Walters <walters@verbum.org>
# Copyright 2016 Emmanuele Bassi
# Licensed under the new-BSD license (http://www.opensource.org/licenses/bsd-license.php)
# Build API variables:
# Little helper function for reading args from the commandline.
# it automatically handles -a b and -a=b variants, and returns 1 if
# we need to shift $3.
read_arg() {
# $1 = arg name
# $2 = arg value
# $3 = arg parameter
local rematch='^[^=]*=(.*)$'
if [[ $2 =~ $rematch ]]; then
read "$1" <<< "${BASH_REMATCH[1]}"
else
read "$1" <<< "$3"
# There is no way to shift our callers args, so
# return 1 to indicate they should do it instead.
return 1
fi
}
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
}
sanitycheck MESON 'meson'
sanitycheck NINJA 'ninja' 'ninja-build'
while (($# > 0)); do
case "${1%%=*}" in
--prefix) read_arg prefix "$@" || shift;;
--bindir) read_arg bindir "$@" || shift;;
--sbindir) read_arg sbindir "$@" || shift;;
--libexecdir) read_arg libexecdir "$@" || shift;;
--datarootdir) read_arg datarootdir "$@" || shift;;
--datadir) read_arg datadir "$@" || shift;;
--sysconfdir) read_arg sysconfdir "$@" || shift;;
--libdir) read_arg libdir "$@" || shift;;
--mandir) read_arg mandir "$@" || shift;;
--includedir) read_arg includedir "$@" || shift;;
--enable-gtk-doc) enable_docs='-Dgtk-doc=true';;
--disable-gtk-doc) enable_docs='-Dgtk-doc=false';;
--enable-stemmer) enable_stemmer='-Dstemmer=true';;
--disable-stemmer) enable_stemmer='-Dstemmer=false';;
--enable-dep11) enable_dep11='-Ddep11=true';;
--disable-dep11) enable_dep11='-Ddep11=false';;
--enable-man) enable_man='-Dman=true';;
--disable-man) enable_man='-Dman=false';;
--enable-rpm) enable_rpm='-Drpm=true';;
--disable-rpm) enable_rpm='-Drpm=false';;
--enable-alpm) enable_alpm='-Dalpm=true';;
--disable-alpm) enable_alpm='-Dalpm=false';;
--enable-builder) enable_builder='-Dbuilder=true';;
--disable-builder) enable_builder='-Dbuilder=false';;
--enable-fonts) enable_fonts='-Dfonts=true';;
--disable-fonts) enable_fonts='-Dfonts=false';;
--enable-introspection) enable_introspection='-Dintrospection=true';;
--disable-introspection) enable_introspection='-Dintrospection=false';;
*) echo -e "\e[1;33mINFO\e[0m: Ignoring unknown option '$1'";;
esac
shift
done
# Defaults
test -z ${prefix} && prefix="/usr/local"
test -z ${bindir} && bindir=${prefix}/bin
test -z ${sbindir} && sbindir=${prefix}/sbin
test -z ${libexecdir} && libexecdir=${prefix}/bin
test -z ${datarootdir} && datarootdir=${prefix}/share
test -z ${datadir} && datadir=${datarootdir}
test -z ${sysconfdir} && sysconfdir=${prefix}/etc
test -z ${libdir} && libdir=${prefix}/lib
test -z ${mandir} && mandir=${prefix}/share/man
test -z ${includedir} && includedir=${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
echo "Summary:"
echo " meson:....... ${MESON}"
echo " ninja:....... ${NINJA}"
echo " prefix:...... ${prefix}"
echo " bindir:...... ${bindir}"
echo " sbindir:..... ${sbindir}"
echo " libexecdir:.. ${libexecdir}"
echo " datarootdir:. ${datarootdir}"
echo " datadir:..... ${datadir}"
echo " sysconfdir:.. ${sysconfdir}"
echo " libdir:...... ${libdir}"
echo " mandir:...... ${mandir}"
echo " includedir:.. ${includedir}"
echo " additional:.."
echo " - docs: ${enable_docs:-default}"
echo " - man: ${enable_man:-default}"
echo " - introspection: ${enable_introspection:-default}"
echo " - stemmer: ${enable_stemmer:-default}"
echo " - DEP-11: ${enable_dep11:-default}"
echo " - RPM: ${enable_rpm:-default}"
echo " - fonts: ${enable_fonts:-default}"
echo " - alpm: ${enable_alpm:-default}"
echo " - builder: ${enable_builder:-default}"
exec ${MESON} \
--prefix=${prefix} \
--libdir=${libdir} \
--libexecdir=${libexecdir} \
--datadir=${datadir} \
--sysconfdir=${sysconfdir} \
--bindir=${bindir} \
--includedir=${includedir} \
--mandir=${mandir} \
--default-library shared \
${enable_docs} \
${enable_man} \
${enable_introspection} \
${enable_stemmer} \
${enable_dep11} \
${enable_rpm} \
${enable_alpm} \
${enable_builder} \
${enable_fonts} \
${builddir} \
${srcdir}
# vim: ai ts=8 noet sts=2 ft=sh
|