-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·362 lines (305 loc) · 8.05 KB
/
configure
File metadata and controls
executable file
·362 lines (305 loc) · 8.05 KB
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
#!/bin/sh
#
# w32x: gui toolkit in c (w32x)
# configure script
# Copyright (c) Devin Smith 2009-2017
#
# This script is based on various scripts from other open source projects.
# Major portions are straight from qemu, ffmpeg, and gxemul.
###############################################################################
# default parameters
PREFIX="/usr/local"
VERSION="0.0.1"
###############################################################################
# Check for command line arguments
for arg in $*; do
optarg=`echo $arg | sed 's/[-a-z]*=//'`
case $arg in
--prefix=*)
PREFIX="$optarg"
;;
*)
echo "w32x build configuration script"
echo
echo "Target directories:"
echo " --prefix=PREFIX path to install to"
echo
exit 1
;;
esac
done
printf "checking for valid C compiler... "
# Try with the simplest possible test program. Actually, test static
# variables as well, because GXemul uses things like NULL-initialized global
# pointers, and it is important that they work. (GCC on Solaris is known to
# be completely broken, for instance.)
echo '#include <stdio.h>
int main(int argc, char *argv[])
{
static int x = 0;
static int y = 1;
printf("%i,%i", x, y);
return 0;
}
' > _testprog.c
if [ z"$CC" = z ]; then
CC=cc
fi
if $CC $CFLAGS -c -o _testprog _testprog.c > /dev/null 2> /dev/null ; then
: C compiler works ok
else
# try gcc
CC=gcc
if $CC $CFLAGS -c -o _testprog _testprog.c > /dev/null 2> /dev/null ; then
: C compiler works ok
else
echo "ERROR: \"$CC\" either does not exist or does not work"
exit 1
fi
fi
rm -f _testprog*
printf "$CC\n"
printf "checking for X11 headers and libs\n"
# Try to compile a small X11 test program:
printf "#include <X11/Xlib.h>
#include <stdio.h>
Display *dis;
void f(void) {
dis = XOpenDisplay(NULL);
}
int main(int argc, char *argv[])
{ return 0; }
" > _test_x11.c
XOK=0
# Base case where X11 is inside /usr/include
XINCLUDE=
XLIB=-lX11
if [ -e /usr/include/X11/Xlib.h ]; then
$CC $CFLAGS _test_x11.c -c -o _test_x11.o 2> /dev/null
$CC $CFLAGS _test_x11.o -o _test_x11 $XLIB 2> /dev/null
if [ -x _test_x11 ]; then
XOK=1
fi
rm -f _test_x11 _test_x11.o
fi
# Try explicitly providing a link library directory hint.
if [ z$XOK = z0 ]; then
XINCLUDE="/usr/X11R6/include"
if [ -e $XINCLUDE/X11/Xlib.h ]; then
XLIB="-L/usr/X11R6/lib -lX11"
$CC $CFLAGS -I$XINCLUDE _test_x11.c -c -o _test_x11.o 2> /dev/null
$CC $CFLAGS _test_x11.o -o _test_x11 $XLIB 2> /dev/null
if [ -x _test_x11 ]; then
XOK=1
fi
rm -f _test_x11 _test_x11.o
fi
fi
if [ z$XOK = z0 ]; then
# who does this???
XINCLUDE="/usr/local/include"
if [ -e $XINCLUDE/X11/Xlib.h ]; then
XLIB="-L/usr/local/lib -lX11"
$CC $CFLAGS -I$XINCLUDE _test_x11.c -c -o _test_x11.o 2> /dev/null
$CC $CFLAGS _test_x11.o -o _test_x11 $XLIB 2> /dev/null
if [ -x _test_x11 ]; then
XOK=1
fi
rm -f _test_x11 _test_x11.o
fi
fi
# Special case for some 64-bit Linux/x86_64 systems:
if [ z$XOK = z0 ]; then
XINCLUDE="/usr/X11R6/include"
if [ -e $XINCLUDE/X11/Xlib.h ]; then
XLIB="-L/usr/X11R6/lib64 -lX11"
$CC $CFLAGS -I$XINCLUDE _test_x11.c -c -o _test_x11.o 2> /dev/null
$CC $CFLAGS _test_x11.o -o _test_x11 $XLIB 2> /dev/null
if [ -x _test_x11 ]; then
XOK=1
fi
rm -f _test_x11 _test_x11.o
fi
fi
# Solaris
if [ z$XOK = z0 ]; then
XINCLUDE=""
# -lsocket for Solaris
XLIB="-lX11 -lsocket"
$CC $CFLAGS _test_x11.c -c -o _test_x11.o 2> /dev/null
$CC $CFLAGS _test_x11.o -o _test_x11 $XLIB 2> /dev/null
if [ -x _test_x11 ]; then
XOK=1
fi
rm -f _test_x11 _test_x11.o
fi
if [ z`uname` = zNetBSD ]; then
echo "Using NetBSD hack for X11 libs..."
XLIB="$XLIB -Wl,-rpath,/usr/X11R6/lib"
fi
if [ z$XOK = z0 ]; then
echo "Failed to compile X11 test program." \
"Exiting.."
exit 1
fi
###############################################################################
# Build the config.mak file
echo "# Generated by $0 $*" > config.mak
echo >> config.mak
echo "PREFIX=${PREFIX}" >> config.mak
echo >> config.mak
if [ z"$XINCLUDE" = z ]; then
printf " X11 headers: (none needed)\n"
else
printf " X11 headers: -I$XINCLUDE\n"
fi
printf " X11 libraries: $XLIB\n"
if [ z"$XINCLUDE" != z ]; then
echo "XINCLUDE=-I$XINCLUDE" >> config.mak
fi
echo "XLIB=$XLIB" >> config.mak
rm -f _test_x11.c
####
# Create config.h
# Head of config.h:
printf "/*
* THIS FILE IS AUTOMATICALLY CREATED BY configure!
* DON'T EDIT THIS FILE MANUALLY, IT WILL BE OVERWRITTEN.
*/
\n#ifndef __CONFIG_H__\n#define __CONFIG_H__\n\n" > include/config.h
printf "#define VERSION \"${VERSION}\"\n" >> include/config.h
if [ z"$XINCLUDE" = z ]; then
XINCLUDE=/usr/include
fi
# Do we have Xft?
XFTOK=0
XFTHEADER=0
printf "checking for Xft headers and libs\n"
printf "checking if you have Xft.h... "
if [ -e $XINCLUDE/X11/Xft/Xft.h ]; then
printf "yes\n"
printf "#define HAVE_XFT_H 1\n" >> include/config.h
else
printf "no\n"
fi
# Try to compile a small Xft test program:
printf "#include <X11/Xft/Xft.h>
#include <stdio.h>
FcPattern *pattern;
void f(void) {
pattern = FcPatternCreate();
}
int main(int argc, char *argv[])
{ return 0; }
" > _test_xft.c
XFTINCLUDE=
XFTLIB=-lXft
# Some operating systems dont need us to explicitly add the Xft
# include flags, so lets see if we can do that here.
$CC $CFLAGS _test_xft.c -c -o _test_xft.o 2> /dev/null
$CC $CFLAGS _test_xft.o -o _test_xft $XFTLIB 2> /dev/null
if [ -x _test_xft ]; then
XFTOK=1
fi
rm -f _test_xft _test_xft.o
if [ z$XFTOK = z0 ]; then
XFTINCLUDE=-I/usr/include/freetype2
$CC $CFLAGS $XFTINCLUDE _test_xft.c -c -o _test_xft.o 2> /dev/null
$CC $CFLAGS _test_xft.o -o _test_xft $XFTLIB 2> /dev/null
if [ -x _test_xft ]; then
XFTOK=1
fi
rm -f _test_xft _test_xft.o
fi
if [ z$XFTOK = z0 ]; then
XFTLIB="-lXft -lfontconfig"
XFTINCLUDE=-I$XINCLUDE/freetype2
$CC $CFLAGS -I$XINCLUDE $XFTINCLUDE _test_xft.c -c -o _test_xft.o 2> /dev/null
$CC $CFLAGS _test_xft.o -o _test_xft $XFTLIB $XLIB 2> /dev/null
if [ -x _test_xft ]; then
XFTOK=1
fi
rm -f _test_xft _test_xft.o
fi
if [ z$XFTOK = z0 ]; then
echo " No Xft detected on this system."
else
printf " XFT headers: $XFTINCLUDE\n"
printf " XFT libraries: $XFTLIB\n"
echo "XFTINCLUDE=$XFTINCLUDE" >> config.mak
echo "XFTLIB=$XFTLIB" >> config.mak
fi
rm -f _test_xft.c
printf "checking if you have Xrandr.h... "
if [ -e $XINCLUDE/X11/extensions/Xrandr.h ]; then
printf "yes\n"
printf "#define HAVE_XRANDR_H 1\n" >> include/config.h
else
printf "no\n"
fi
XRANDROK=0
XRANDRINCLUDE=
XRANDRLIB=-lXrandr
# Try to compile a small X11 test program that uses Xrandr:
printf "#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
#include <stdio.h>
Display *dis;
int xrreventbase; /* XRR event base */
void f(void) {
int errorbase;
dis = XOpenDisplay(NULL);
if (XRRQueryExtension(dis, &xrreventbase, &errorbase)) {
XRRSelectInput(dis, XDefaultRootWindow(dis), True);
}
}
int main(int argc, char *argv[])
{
f();
return 0;
}
" > _test_xrandr.c
$CC $CFLAGS -I$XINCLUDE _test_xrandr.c -c -o _test_xrandr.o 2> /dev/null
$CC $CFLAGS _test_xrandr.o -o _test_xrandr $XRANDRLIB $XLIB 2> /dev/null
if [ -x _test_xrandr ]; then
XRANDROK=1
fi
rm -f _test_xrandr _test_xrandr.o
if [ z$XRANDROK = z0 ]; then
echo " No XRandR detected on this system."
else
printf " Xrandr headers: $XRANDRINCLUDE\n"
printf " Xrandr libraries: $XRANDRLIB\n"
echo "XRANDRINCLUDE=$XRANDRINCLUDE" >> config.mak
echo "XRANDRLIB=$XRANDRLIB" >> config.mak
fi
rm -f _test_xrandr.c
printf "\n#endif /* __CONFIG_H__ */\n" >> include/config.h
# Build the top level Makefile
echo "Creating Makefile"
echo '# w32x master makefile
.PHONY: test
PREFIX = /usr/local
include config.mak
all:
@(cd src && $(MAKE))
test:
@(cd test && $(MAKE))
clean:
@(cd src && $(MAKE) clean)
@(cd test && $(MAKE) clean)
pristine: clean
@(cd src && $(MAKE) pristine)
rm -f Makefile config.mak include/config.h
' > Makefile
# Build the src level Makefile
echo "Creating src/Makefile"
cp src/Makefile.in src/Makefile
echo "Creating test/Makefile"
cp test/Makefile.in test/Makefile
echo
echo "Configuration:"
echo " Install to: ${PREFIX}"
echo
echo "Now type: make (or gmake on a BSD system)"
echo