-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·212 lines (194 loc) · 6.8 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
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
207
208
209
210
211
212
#!/bin/sh
#
# Copyright (c) 2013 Mark Heily <[email protected]>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
usage() {
cat << "EOF"
Usage: configure [options]
Installation options:
--bindir [DIRECTORY] TODO describe this [$(EPREFIX)/bin]
--datadir [DIRECTORY] TODO describe this [$(DATAROOTDIR)]
--datarootdir [DIRECTORY] TODO describe this [$(PREFIX)/share]
--docdir [DIRECTORY] TODO describe this [$(DATAROOTDIR)/doc/$(PACKAGE)]
--eprefix [DIRECTORY] TODO describe this [$(PREFIX)]
--includedir [DIRECTORY] TODO describe this [$(PREFIX)/include]
--infodir [DIRECTORY] TODO describe this [$(DATAROOTDIR)/info]
--libdir [DIRECTORY] TODO describe this [$(EPREFIX)/lib]
--libexecdir [DIRECTORY] TODO describe this [$(EPREFIX)/libexec]
--localedir [DIRECTORY] TODO describe this [$(DATAROOTDIR)/locale]
--localstatedir [DIRECTORY] TODO describe this [$(PREFIX)/var]
--mandir [DIRECTORY] TODO describe this [$(DATAROOTDIR)/man]
--oldincludedir [DIRECTORY] TODO describe this [/usr/include]
--pkgconfigdir [DIRECTORY] where to install pkg-config files [$(LIBDIR)/pkgconfig]
--pkgdatadir [DIRECTORY] TODO describe this [$(DATADIR)/$(PACKAGE)]
--pkgincludedir [DIRECTORY] TODO describe this [$(INCLUDEDIR)/$(PACKAGE)]
--pkglibdir [DIRECTORY] TODO describe this [$(LIBDIR)/$(PACKAGE)]
--prefix [DIRECTORY] TODO describe this [/usr/local]
--sbindir [DIRECTORY] TODO describe this [$(EPREFIX)/sbin]
--sharedstatedir [DIRECTORY] TODO describe this [$(PREFIX)/com]
--sysconfdir [DIRECTORY] TODO describe this [$(PREFIX)/etc]
Project options:
System types:
--build BUILD set the system type for building
--host HOST cross-compile programs to run on a different system type
--target TARGET build a compiler for cross-compiling
Optional Features:
Common options:
--disable-static Disable generation of static libraries
--disable-option-checking
-h, --help Show this message
-V, --version Display version information and exit
EOF
}
err() {
echo "*** ERROR *** $*"
exit 1
}
require_var() {
key=$1
eval "val=\$$key"
if [ "$val" = "" ] ; then
echo "ERROR: you must provide --$2 as a command line option"
exit 1
fi
}
echo "# Automatically generated by ./configure -- do not edit" > config.mk
for arg in $*
do
if [ `echo "$arg" | grep "^--"` = "$arg" ] ; then
key=`echo $arg | sed "s/^--//; s/=.*//; s/^with-//;"`
val=`echo $arg | sed "s/.*=//"`
uc_key=`echo "$key" | tr "a-z" "A-Z" | tr "-" "_"`
case $key in
"help")
usage
exit 1
;;
bindir|datadir|datarootdir|docdir|includedir|infodir|libdir|libexecdir|localedir|localstatedir|mandir|pkgconfigdir|pkgdatadir|pkgincludedir|pkglibdir|prefix|sbindir|sharedstatedir|sysconfdir)
echo "$uc_key=$val" >> config.mk
;;
exec-prefix)
echo "EPREFIX=$val" >> config.mk
;;
program-prefix)
if [ "$val" != "" ] ; then err "FIXME - not implemented" ; fi
;;
disable-static)
echo "$uc_key=1" >> config.mk
;;
build|host)
# TODO: we should split this up, and override the other Makeconf
# variables like *_VENDOR, *_ARCH, *_CPU, *_KERNEL, *_SYSTEM
echo "$uc_key=$val" >> config.mk
eval "${key}_system_type=\"$val\""
;;
disable-option-checking)
# Not implemented, this behavior is the default (for now)
;;
disable-dependency-tracking)
# Not implemented, dependency tracking is done in Ruby (for now)
;;
# Android-specific variables
ndk|sdk)
echo "$uc_key=$val" >> config.mk
eval "$key=\"$val\""
;;
*)
echo "Warning: unrecognized option: $arg"
;;
esac
fi
done
# Android-specific options
if [ "`echo ${host_system_type} | grep androideabi`" != "" ] ; then
exec ./configure.rb $*
# require_var ndk with-ndk
# require_var sdk with-sdk
fi
printf "checking for a C compiler... "
for cmd in ${host_system_type}-cc cc gcc gcc4 clang
do
$cmd --version >/dev/null 2>&1
if [ $? -eq 0 ] ; then cc="$cmd" ; break ; fi
done
if [ -n "$CC" ] ; then cc="$CC" ; fi
if [ -n "$cc" ] ; then
echo "$cc"
echo "CC=$cc" >> config.mk
if [ "$cc" != "cc" ] ; then echo "LD=$cc" >> config.mk ; fi
if [ -n "$CFLAGS" ] ; then echo "CFLAGS=$CFLAGS" >> config.mk ; fi
else
echo "not found"
err "Please install a compiler and add it to your PATH"
fi
printf "checking for ar.. "
for ar in ${host_system_type}-ar ar gar
do
$ar --version >/dev/null 2>&1
if [ $? -eq 0 ] ; then ar="$ar" ; break ; fi
done
if [ -n "$ar" ] ; then
echo "$ar"
echo "AR=$ar" >> config.mk
else
echo "not found"
err "Please install an archiver and add it to your PATH"
fi
printf "checking for ranlib.. "
for ranlib in ${host_system_type}-ranlib ranlib
do
$ar --version >/dev/null 2>&1
if [ $? -eq 0 ] ; then ranlib="$ranlib" ; break ; fi
done
if [ -n "$ranlib" ] ; then
echo "$ranlib"
echo "RANLIB=$ranlib" >> config.mk
else
echo "not found"
err "Please install ranlib and add it to your PATH"
fi
printf "checking for a usable make command... "
for cmd in make gmake
do
$cmd --version >/dev/null 2>&1
if [ $? -eq 0 ] ; then make="$cmd" ; break ; fi
done
if [ -n "$make" ] ; then
echo "yes"
echo "MAKE=$make" >> config.mk
else
echo "not found"
err "Please install GNU Make and add it to your PATH as either make or gmake"
fi
# Allow additional variables from the environment to override the defaults
#
test -n "$LD" && echo "LD=$LD" >> config.mk
test -n "$LDFLAGS" && echo "LDFLAGS=$LDFLAGS" >> config.mk
# TODO: need to add Makefile support for: LIBS, CPP, CPPFLAGS
UNAME=$(uname)
case $UNAME in
Linux|Darwin)
ln -s Makefile.linux Makefile
;;
SunOS)
ln -s Makefile.solaris Makefile
;;
*)
echo "$UNAME OS not supported."
;;
esac
rm -f config.h
$make config.h
cp config.h src/common/config.h