-
Notifications
You must be signed in to change notification settings - Fork 8
/
configure
executable file
·488 lines (413 loc) · 15.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
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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
#!/bin/bash
# --help
# --prefix=/blah/blah
CONFIGCOMMAND="./configure $@"
LAIDOUTVERSION=0.097.1
# finalprefix is where things eventually get installed. For deb packaging, this is different than prefix.
# To be relocatable, set to "".
PREFIX="/usr/local"
FINALPREFIX=""
##Use the first if you are using an installed LAXKIT.
##Use the second if laxkit is located in same dir as this file, which is true for releases.
#LAXDIR="/usr/local/include/lax"
LAXDIR="`pwd`/laxkit/lax"
# in case no Laxkit found, download manually (down below)
LAXREPO="https://github.com/Laidout/laxkit.git"
# for some plugins:
GEGLVERSION='gegl-0.4'
PYTHONVERSION='python3.6'
LAIDOUT_NOGL=""
USINGGL="yes"
USESQLITE="yes"
ONAMAC="no"
FORCE="no"
RELOCATABLE="no"
ALLOWED_PLATFORMS="x11 headless"
PLATFORM="x11"
EXTRA_CPPFLAGS=""
EXTRA_LDFLAGS=""
EXTRA_PKG=
##
## Parse options
##
while true ; do
ARG=$1;
# echo "arg: $ARG"
if [ "x$ARG" == x ] ; then break; fi
option=`expr "x$ARG" : 'x\([^=]*\)=.*'`;
if [ x$option == x ] ; then
option="$ARG";
fi
optarg=`expr "x$ARG" : 'x[^=]*=\(.*\)'`;
# echo "option=$option, optarg=$optarg"
# echo
case "$option" in
-h | --help)
echo "Whizbang Laidout configuration script options:" ;
echo ""
echo " --help Show this stuff"
echo " --prefix=/where/to/install Default /usr/local"
echo " --finalprefix=/really/where Optional, final install destination, when prefix is just a"
echo " temporary staging area, before actual installation."
echo " --laxkit=/laxkit/headers Default in releases is ./laxkit/lax, since the Laxkit"
echo " is currently included in release downloads"
echo " --version=OtherVersionNum You may force Laidout to compile with a different"
echo " version string. This will make ~/.config/laidout/(version)"
echo " and the executable becomes laidout-(version) and will"
echo " save system stuff in prefix/share/laidout-(version)."
echo " --language=path/to/langs The path where translation files should be installed."
echo " This will normally be 'share/locale', and the files"
echo " themselves then get put in prefix/share/locale/*."
echo " --extra-cppflags Any extra compile flags, such as location of includes not"
echo " otherwise detected"
echo " --extra-ldflags Any extra linking flags, such as -I/usr/lib64/glib-2.0/include/"
echo " for Fedora includes"
echo " --pkg-config-path Any directories to tack onto environment PKG_CONFIG_PATH,"
echo " for configuring convenience. Should be a colon separated list."
echo " --relocatable If present, do not configure with hardcoded paths. All resource paths"
echo " will be determined at runtime relative to the executable."
echo " --disable-sqlite Optional. Used to get font tags in Fontmatrix database (if it exists)"
echo " --gegl-version Default is $GEGLVERSION"
# echo " --python-version Default is python3.6"
echo " --platform Can be one of $ALLOWED_PLATFORMS. Default is $PLATFORM."
echo " --nogl Do not compile with gl based features"
echo " --force Try to compile even if libraries are not detected"
echo ""
exit 1 ;;
--force)
FORCE="yes";
shift ;;
--relocatable)
RELOCATABLE="yes";
shift ;;
--extra-cppflags)
if [ -z $optarg ] ; then
optarg=$2
shift
fi
EXTRA_CPPFLAGS=$optarg
shift ;;
--extra-ldflags)
if [ -z "$optarg" ] ; then
optarg=$2
shift
fi
EXTRA_LDFLAGS=$optarg
shift ;;
--pkg-config-path)
if [ -z $optarg ] ; then
optarg=$2
shift
fi
EXTRA_PKG=$optarg
#echo "extra_pkg = $EXTRA_PKG"
shift ;;
--disable-sqlite)
unset USESQLITE
shift;;
--gegl-version)
if [ -z $optarg ] ; then
optarg=$2
shift
fi
GEGLVERSION="$optarg"
#echo gegl version $optarg ;
shift ;;
--python-version)
if [ -z $optarg ] ; then
optarg=$2
shift
fi
PYTHONVERSION="$optarg"
#echo gegl version $optarg ;
shift ;;
--finalprefix)
if [ -z $optarg ] ; then
optarg=$2
shift
fi
FINALPREFIX="$optarg"
#echo finalprefix $optarg ;
shift ;;
-p | --prefix)
if [ -z $optarg ] ; then
optarg=$2
shift
fi
PREFIX="$optarg"
#echo prefix $optarg ;
shift ;;
--version | -v)
if [ -z $optarg ] ; then
optarg=$2
shift
fi
LAIDOUTVERSION="$optarg"
#echo version $optarg ;
shift ;;
--laxkit)
if [ -z $optarg ] ; then
optarg=$2
shift
fi
LAXDIR="$optarg"
#echo laxkit $optarg;
if [ ! -e $LAXDIR ] ; then
echo "Missing Laxkit at $LAXDIR"
exit 1
fi
shift ;;
--language)
if [ -z $optarg ] ; then
optarg=$2
shift
fi
LANGUAGE_PATH="$optarg"
echo language path $optarg;
shift ;;
--platform)
PLATFORM=$optarg;
shift
shift ;;
--nogl)
LAIDOUT_NOGL="#define LAIDOUT_NOGL"
USINGGL="no"
shift ;;
--onamac)
ONAMAC="yes"
shift ;;
*) echo "Unrecognized option $option $optarg" ; break ;;
esac
done
if [ $PLATFORM != "x11" -a $PLATFORM != "headless" ] ; then
echo "Platform must be one of: $ALLOWED_PLATFORMS"
exit 1
fi
#if [ xxx$FINALPREFIX == xxx ] ; then FINALPREFIX=$PREFIX; fi
if [ $RELOCATABLE == "yes" ] ; then
FINALPREFIX="";
else
if [ x$FINALPREFIX = x ] ; then FINALPREFIX=$PREFIX; fi
fi
if [ xxx$EXTRA_PKG != xxx ] ; then
# if [ xxx$PKG_CONFIG_PATH != xxx ] ; then
# export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$EXTRA_PKG;
# else
export PKG_CONFIG_PATH=$EXTRA_PKG;
# fi
fi
echo "Done parsing options.";
##
## Configure Laxkit if necessary, and pass in relevant flags
##
if [ ! -d $LAXDIR ] ; then
#clone if not found
git clone $LAXREPO
$LAXDIR = `pwd`/laxkit/lax
fi
# path to laxkit.pc, used by the linker
LAXKIT_PC=$LAXDIR/../laxkit.pc
if [ ! -e $LAXDIR/configured.h ] ; then
LAXTRAS=()
if [ $USESQLITE == "no" ] ; then LAXTRAS+=("--disable-sqlite"); fi
if [ $RELOCATABLE == "yes" ] ; then LAXTRAS+=("--relocatable"); fi
if [ "$EXTRA_CPPFLAGS" != "" ] ; then LAXTRAS+=(--extra-cppflags "$EXTRA_CPPFLAGS"); fi
echo "Laxkit not configured, configuring: ${LAXTRAS[@]}";
CURDIR=`pwd`
cd $LAXDIR/.. && ./configure "${LAXTRAS[@]}"
cd $CURDIR
fi
# do check for required libraries:
## todo:
## to make this actually useful, sometimes need to do a version check, or override the default link.
## so, each lib needs [libname, minimum version, linking text]
##
## The stuff in NEED can be checked with pkg-config. Not all libraries
## can be checked this way! (notably cups, apparently)
NEED="x11 xext freetype2 libssl imlib2 cairo harfbuzz $GEGLVERSION"
NEEDGL='ftgl GraphicsMagick++'
NUM='1'
for NAME in $NEED; do
echo -n Checking for $NAME......;
if [ "`pkg-config --exists --print-errors --errors-to-stdout $NAME`"xxx != "xxx" ] ; then
echo "You may need to install the development package of $NAME.";
NUM="";
else
echo "ok";
fi
done
#echo NUM=$NUM
if [ $USINGGL == "yes" ]; then
for NAME in $NEEDGL; do
echo -n Checking for $NAME......;
if [ "`pkg-config --exists --print-errors --errors-to-stdout $NAME`"xxx != "xxx" ] ; then
echo "You may need to install the development package of $NAME.";
NUM="";
else
echo "ok";
fi
done
fi
OPTIONAL='sqlite3'
for NAME in $OPTIONAL; do
echo -n Checking for $NAME......;
if [ "`pkg-config --exists --print-errors --errors-to-stdout $NAME`"xxx != "xxx" ] ; then
if [ $NAME == 'sqlite3' ] ; then
echo "Didn't find optional $NAME. Install that to get access to Fontmatrix tags.";
fi
else
echo "ok";
fi
done
#EXTRAINCLUDEPATHS=("/usr/local/include/" "/usr/include/")
## readline doesn't seem to have a pkg-config entry, so do this hackier check
echo -n Checking for readline......;
#---attempt 3, check for existence of cups-config program:
if [ ! -e /usr/local/opt/readline/include/readline/readline.h -a \
! -e /usr/local/include/readline/readline.h -a \
! -e /usr/include/readline/readline.h ] ; then
echo "Can't find libreadline headers.";
NUM="";
else echo "ok";
fi
## cups doesn't seem to have a pkg-config entry, so do this hackier check
echo -n Checking for cups......;
#---attempt 3, check for existence of cups-config program:
if [ ! `builtin type -p cups-config` ] ; then
echo "Can't find Cups headers.";
NUM="";
else echo "ok";
fi
echo
if [ "$NUM" != "1" -a $FORCE=="no" ]; then
echo "Too many problems to proceed!"
echo "Use --force to override. You may have to adjust CPPFLAGS and LDFLAGS in Makefiles,"
echo "or pass in includes with --extra-cppflags."
echo
echo "On debian based systems, you might try installing all dependencies with this:"
echo " apt-get install g++ pkg-config libpng12-dev libreadline-dev libx11-dev libxext-dev libxi-dev libxft-dev libcups2-dev libimlib2-dev libfontconfig-dev libfreetype6-dev libssl-dev libgraphicsmagick++1-dev mesa-common-dev libglu1-mesa-dev libftgl-dev libcairo2-dev libharfbuzz-dev"
exit 1
fi
if [ x$LANGUAGE_PATH == x ]; then
LANGUAGE_PATH=share/locale
fi
##
## generate src/version.h
##
echo "Generating src/version.h... from `pwd`"
echo " // ---- THIS FILE IS AUTOMATICALLY GENERATED -----" > src/version.h
echo " // ---- BY ../configure -----" >> src/version.h
echo "#ifndef VERSION_H" >> src/version.h
echo "#define VERSION_H" >> src/version.h
echo "" >> src/version.h
echo "#define LAIDOUT_VERSION \"$LAIDOUTVERSION\"" >> src/version.h
echo "" >> src/version.h
echo "#endif" >> src/version.h
echo "" >> src/version.h
if [ x$FINALPREFIX == x ] ; then FINALPREFIX=".."; fi #relative to the binary at runtime
##
## generate src/configured.h by putting install_prefix where the code can access it!
##
echo "Generating src/configured.h..."
echo " // ---- THIS FILE IS AUTOMATICALLY GENERATED -----" > src/configured.h
echo " // ---- BY ../configure -----" >> src/configured.h
echo "#ifndef CONFIGURED_H" >> src/configured.h
echo "#define CONFIGURED_H" >> src/configured.h
echo "" >> src/configured.h
echo "#define INSTALL_PREFIX \"$FINALPREFIX/\"" >> src/configured.h
echo "#define SHARED_DIRECTORY \"$FINALPREFIX/share/laidout/$LAIDOUTVERSION/\"" >> src/configured.h
echo "#define ICON_DIRECTORY \"$FINALPREFIX/share/laidout/$LAIDOUTVERSION/icons/\"" >> src/configured.h
echo "#define LANGUAGE_PATH \"$FINALPREFIX/$LANGUAGE_PATH\"" >> src/configured.h
echo "#define LAIDOUT_PLATFORM \"$PLATFORM\"" >> src/configured.h
if [ $PLATFORM == "x11" ] ; then echo "#define _LAX_PLATFORM_XLIB" >> src/configured.h ; fi
if [ $PLATFORM == "qt" ] ; then echo "#define _LAX_PLATFORM_QT" >> src/configured.h ; fi
if [ $PLATFORM == "headless" ] ; then echo "#define _LAX_PLATFORM_HEADLESS" >> src/configured.h ; fi
echo $LAIDOUT_NOGL >> src/configured.h
echo "" >> src/configured.h
echo "#endif" >> src/configured.h
echo "" >> src/configured.h
##
## generate Makefile-toinclude
##
echo "Generating ./Makefile-toinclude..."
echo " # ---- THIS FILE IS AUTOMATICALLY GENERATED -----" > Makefile-toinclude
echo " # ---- BY ./configure -----" >> Makefile-toinclude
echo "" >> Makefile-toinclude
echo "PREFIX=$PREFIX" >> Makefile-toinclude
echo "LAIDOUTVERSION=$LAIDOUTVERSION" >> Makefile-toinclude
echo "LAXDIR=$LAXDIR" >> Makefile-toinclude
echo "LAXKIT_PC=$LAXKIT_PC" >> Makefile-toinclude
echo "LAXIDIR=$LAXDIR/interfaces" >> Makefile-toinclude
echo "LANGUAGE_PATH=$PREFIX/$LANGUAGE_PATH" >> Makefile-toinclude
echo "POLYPTYCHBASEDIR="`pwd`"/src" >> Makefile-toinclude
echo "LAIDOUT_USING_GL=$USINGGL" >> Makefile-toinclude
if [ x$USESQLITE != x ] ; then echo "LAIDOUT_USES_SQLITE=yes" >> Makefile-toinclude; fi
echo "EXTRA_CPPFLAGS=$EXTRA_CPPFLAGS" >> Makefile-toinclude
echo "EXTRA_LDFLAGS=$EXTRA_LDFLAGS" >> Makefile-toinclude
echo "EXTRA_PKG=$EXTRA_PKG" >> Makefile-toinclude
echo "" >> Makefile-toinclude
echo "GEGLVERSION=$GEGLVERSION" >> Makefile-toinclude
#echo "PYTHONVERSION=$PYTHONVERSION" >> Makefile-toinclude
echo "" >> Makefile-toinclude
echo 'ifeq ($(PKG_CONFIG_PATH)xxx, xxx)' >> Makefile-toinclude
echo 'export PKG_CONFIG_PATH=$(EXTRA_PKG)' >> Makefile-toinclude
echo "else" >> Makefile-toinclude
echo 'PKG_CONFIG_PATH+=:$(EXTRA_PKG)' >> Makefile-toinclude
echo 'export PKG_CONFIG_PATH' >> Makefile-toinclude
echo "endif" >> Makefile-toinclude
# install on macos do not support -D option, use install in coreutils instead
HOMEBREW_COREUTILS_INSTALL=/usr/local/opt/coreutils/libexec/gnubin/install
if [ -f $HOMEBREW_COREUTILS_INSTALL ]
then
echo "INSTALLEXE=$HOMEBREW_COREUTILS_INSTALL" >> Makefile-toinclude
else
echo "INSTALLEXE=install" >> Makefile-toinclude
fi
echo "" >> Makefile-toinclude
if [ x$USESQLITE != x ] ; then USESQLITE="yes"; else USESQLITE="no"; fi
##
## generate config.log
##
echo "$CONFIGCOMMAND" > config.log
echo >> config.log
echo " Laidout Configuration Summary" >> config.log
echo " generated by ./configure" >> config.log
echo "----`date`---" >> config.log
echo "-----------------------------------" >> config.log
echo " Laidout version: $LAIDOUTVERSION" >> config.log
echo " Install here: $PREFIX" >> config.log
echo " Runtime prefix: $FINALPREFIX" >> config.log
echo " Language Path: $PREFIX/$LANGUAGE_PATH" >> config.log
echo " Laxkit headers: $LAXDIR" >> config.log
echo " laxkit.pc: $LAXKIT_PC" >> config.log
echo " Enable GL: $USINGGL" >> config.log
echo " Sqlite: $USESQLITE" >> config.log
echo " Extra cppflags: $EXTRA_CPPFLAGS" >> config.log
echo " Extra ldflags: $EXTRA_LDFLAGS" >> config.log
echo " Pkgconfig path: $EXTRA_PKG" >> config.log
echo " Gegl version: $GEGLVERSION" >> config.log
echo " Relocatable: $RELOCATABLE" >> config.log
echo " Platform: $PLATFORM" >> config.log
#echo " Python version: $PYTHONVERSION" >> config.log
echo
echo " Laidout Configuration Summary"
echo "----------------------------------"
echo " Laidout version: $LAIDOUTVERSION"
echo " Install here: $PREFIX"
echo " Runtime prefix: $FINALPREFIX"
echo " Language Path: $PREFIX/$LANGUAGE_PATH"
echo " Laxkit headers: $LAXDIR"
echo " laxkit.pc: $LAXKIT_PC"
echo " Enable GL: $USINGGL"
echo " Sqlite: $USESQLITE"
echo " Extra cppflags: $EXTRA_CPPFLAGS"
echo " Extra ldflags: $EXTRA_LDFLAGS"
echo " Pkgconfig path: $EXTRA_PKG"
echo " Gegl version: $GEGLVERSION"
echo " Relocatable: $RELOCATABLE"
echo " Platform: $PLATFORM"
#echo " Python version: $PYTHONVERSION"
echo
echo "If compiling from git, please follow \"COMPILING FROM SOURCE\" in README.md.";
echo
echo "Otherwise, now type make to build.";