/
configure
executable file
·696 lines (610 loc) · 18.6 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
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
#!/bin/sh
#------------------------------------------------------------------------
# Configure script for wxHaskell
#
# Copyright 2003, Daan Leijen.
#
# See license.txt for details.
#------------------------------------------------------------------------
# $Id: configure,v 1.13 2003/09/29 14:21:24 dleijen Exp $
#--------------------------------------------------------------------
# Variables
#--------------------------------------------------------------------
version="0.3"
enablestrip="no"
enableupx="no"
withmsc="no"
wxclibname="wxc"
# haskell
hc="ghc"
hcpkg="ghc-pkg"
hcpkglocal=""
hdoc="haddock"
hdocbase="base.haddock"
# directories
prefix="/usr"
execprefix=""
libdir=""
# dll extension and lib prefix
exe=""
dll=".so"
lib="lib"
# c++ compiler, flags and libraries
cxx="c++"
wxwincxxflags=""
wxwinlibs=""
# wxwindows
wxconfig="wx-config"
wxtoolkit=""
wxwinlib=""
extraldopts=""
# macosx: wx-config might be not in the path
if sh ./config.search "$wxconfig"; then :; else
if test -f "/usr/local/wxhaskell/bin/wx-config"; then
wxconfig="/usr/local/wxhaskell/bin/wx-config"
fi
fi
# see if wx-config is the first argument
case "$1" in
-wx-config=*|--wx-config=*)
wxconfig=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`;;
esac
#--------------------------------------------------------------------
# Improve guesses
#--------------------------------------------------------------------
# improve guess prefix
if test -d "/usr/local"; then
prefix="/usr/local"
fi
# does 'cygpath' exist?
cygpathfound=""
if sh ./config.search "cygpath"; then
cygpathfound="yes"
fi
# guess username
if test "$USERNAME"; then
username="$USERNAME"
else if test "$HOME"; then
username=`echo $HOME | sed -e 's|.*[/\\]||'`
else
username="username"
fi
fi
# guess base.haddock location
if sh ./config.search "ghc"; then
guesshdocbase="`which ghc | sed -e 's|/bin/ghc|/doc/html/base/base.haddock|'`"
if test -f "$guesshdocbase"; then
hdocbase="$guesshdocbase"
fi
fi
# improve the guesses if wx-config is present.
if sh ./config.search "$wxconfig"; then
# improve prefix guess
prefix="`$wxconfig --prefix`"
# guess toolkit
wxtoolkit="`$wxconfig --cxxflags | sed -e 's|.*-D__WX\([A-Z]*\)__.*|\1|'`"
# flaky way to guess library extensions
if test "$wxtoolkit" = "MSW"; then
dll=".dll"
lib=""
else if test "$wxtoolkit" = "MAC"; then
dll=".dylib"
lib="lib"
# use a standard prefix on MacOS X for the installer
prefix="/usr/local/wxhaskell"
fi
fi
# guess wxwindows library
# extraction process is a bit flaky: it expects a single -llibname option.
# wxwinlibdir="`wx-config --libs | sed -e 's|.*-L\([^ ]*\).*|\1|'`"
wxwinexecprefix="`$wxconfig --exec-prefix`"
wxwinlibname="`$wxconfig --libs | sed -e 's|.*-lwx\([^ ]*\).*|wx\1|'`"
wxwinlib="$wxwinexecprefix/lib/$lib$wxwinlibname$dll"
# guess extra link options
extraldopts="`$wxconfig --ldflags`"
pthread="`$wxconfig --libs | sed -e \"s|.* -pthread .*|yes|\"`"
if test "$pthread" = "yes"; then
if test -z "$extraldopts"; then
extraldopts="-pthread"
else
extraldopts="$extraldopts -pthread"
fi
fi
fi
# initial completion rules
execprefix_doc="<prefix>"
libdir_doc="<exec-prefix>/lib"
wxclib_doc="<libdir>/${lib}wxc${dll}"
#--------------------------------------------------------------------
# Parse command-line arguments
#--------------------------------------------------------------------
arg=""
while : ; do
# put optional argument in the $arg variable
case "$1" in
-*=*) arg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) arg="";;
esac
# match on the arguments
case "$1" in
"") break;;
-?|--help)
echo "usage:"
echo " ./configure [options]"
echo ""
echo "options: [defaults in brackets]"
echo " --help show this information"
echo " --hc=<program> the haskell compiler [$hc]"
echo " --hcpkg=<program> package compiler [$hcpkg]"
echo " --package-conf=<file> optional local package configuration [$hcpkglocal]"
echo " --version=<version> library version [$version]"
echo ""
echo "install options:"
echo " --prefix=<dir> platform independent install directory [$prefix]"
echo " --exec-prefix=<dir> platform dependent install directory [$execprefix_doc]"
echo " --libdir=<dir> library files install directory [$libdir_doc]"
echo " --enable-strip remove symbols from the libraries [$enablestrip]"
echo " --enable-upx compress the dynamic libraries with upx [$enableupx]"
echo ""
echo "documentation options:"
echo " --username=<name> username on sourceforge [$username]"
echo " --haddock=<program> haddock documentation tool [$hdoc]"
echo " --haddock-base=<file> haddock interface for the base libraries"
echo " [$hdocbase]"
echo ""
echo "wxwindows options:"
echo " --wx-lib=<library> wxWindows library [$wxwinlib]"
echo " --wx-toolkit=<name> wxWindows gui toolkit [$wxtoolkit]"
echo " --wx-config=<program> wxWindows configure script (must be the first option!)"
echo " [$wxconfig]"
echo ""
echo "platform options:"
echo " --dllext=<extension> dynamic link library extension [$dll]"
echo " --libprefix=<prefix> library prefix [$lib]"
echo " --extra-ld-opts=<opts> extra link options [$extraldopts]"
echo " --with-msc compile wxWindows and wxc with microsoft vc++ [$withmsc]"
echo " --wxc-libname=<name> wxc library name [$wxclibname]"
echo ""
exit 1;;
-hc=*|--hc=*)
hc="$arg";;
-hcpkg=*|--hcpkg=*)
hcpkg="$arg";;
-package-conf=*|--package-conf=*)
hcpkglocal="$arg";;
-version=*|--version=*)
version="$arg";;
-prefix=*|--prefix=*)
prefix="$arg";;
-exec-prefix=*|--exec-prefix=*)
execprefix="$arg"
execprefix_doc="$arg";;
-libdir=*|--libdir=*)
libdir="$arg"
libdir_doc="$arg";;
-enable-strip|--enable-strip)
enablestrip="yes";;
-disable-strip|--disable-strip)
enablestrip="no";;
-enable-upx|--enable-upx)
enableupx="yes";;
-disable-upx|--disable-upx)
enableupx="no";;
-username=*|--username=*)
username="$arg";;
-haddock-base=*|--haddock-base=*)
hdocbase="$arg";;
-haddock=*|--haddock=*)
hdoc="$arg";;
-wx-lib=*|--wx-lib=*)
wxwinlib="$arg";;
-wx-toolkit=*|--wx-toolkit=*)
wxtoolkit="$arg";;
-wx-config=*|--wx-config=*)
wxconfig="$arg";;
-dllext=*|--dllext=*)
dll="$arg"
wxclib_doc="<libdir>/${lib}wxc${dll}";;
-libprefix=*|--libprefix=*)
lib="$arg"
wxclib_doc="<libdir>/${lib}wxc${dll}";;
-extra-ld-opts=*|--extra-ld-opts=*)
extraldopts="$arg";;
-with-msc|--with-msc)
withmsc="yes"
lib=""
dll=".dll"
wxtoolkit="MSW"
wxwinlib="";;
-wxc-libname=*|--wxc-libname=*)
if test "$withmsc" = "yes"; then
wxclibname="$arg"
else
echo "warning:"
echo " option --wxc-libname is only valid if preceded with --with-msc."
fi;;
*) echo "error: Unknown option \"$1\". Use \"--help\" to show valid options." 1>&2
echo "" 1>&2
exit 2;;
esac
# process next argument
shift
done
#--------------------------------------------------------------------
# directories
#--------------------------------------------------------------------
# complete arguments
if test -z "$execprefix"; then
execprefix="$prefix"
fi
if test -z "$libdir"; then
libdir="$execprefix/lib"
fi
if test "$dll" = ".dll"; then
exe=".exe"
fi
# normalize the library and imports directory since ghc-pkg doesn't like unix names
if test "$cygpathfound"; then
libdir="`cygpath -w $libdir | sed -e 's|\\\\|/|g'`"
fi
echo "install libraries at : $libdir"
#--------------------------------------------------------------------
# wxc: only initialized if not --with-msc
#--------------------------------------------------------------------
if test "$withmsc" != "yes"; then
# we need wx-config
if sh ./config.search "$wxconfig"; then
echo "wx-config found"
else
echo "error:"
echo " Unable to find the 'wx-config' program: $wxconfig"
echo " Maybe you forgot to run 'make install' on wxWindows?"
echo " Otherwise, add the install directory of wx-config to your path."
if test "$WINDIR"; then
echo " Or maybe you are trying to compile with Microsoft Visual C++?"
echo " If so, you can specify that on the command line:"
echo " For example: ./configure --with-msc"
fi
echo ""
exit 2
fi
# initialize options for wxc
cxx="`$wxconfig --cxx`"
wxwincxxflags="`$wxconfig --cxxflags`"
wxwinlibs="`$wxconfig --libs`"
# extract the wxWindows wxtoolkit: MSW, MAC, GTK etc.
if test -z "$wxtoolkit"; then
wxtoolkit="`$wxconfig --cxxflags | sed -e 's|.*-D__WX\([A-Z]*\)__.*|\1|'`"
fi
# windows: we append $prefix/include to the include directories
if test "$wxtoolkit" = "MSW"; then
wxwincxxflags="-I$prefix/include $wxwincxxflags"
fi
# windows: we normalize $prefix and $exec-prefix include directories and libraries
if test "$cygpathfound"; then
wxprefix="`$wxconfig --prefix`"
wxexecprefix="`$wxconfig --exec-prefix`"
wwxprefix="`cygpath -w $wxprefix | sed -e 's|\\\\|/|g'`"
wwxexecprefix="`cygpath -w $wxexecprefix | sed -e 's|\\\\|/|g'`"
wxwincxxflags="`echo $wxwincxxflags | sed -e \"s|$wxprefix|$wwxprefix|g\"`"
wxwinlibs="`echo $wxwinlibs | sed -e \"s|$wxexecprefix|$wwxexecprefix|g\"`"
fi
# macosx: we get the resource compiler flags
if test "$wxtoolkit" = "MAC"; then
wxrezcomp="`$wxconfig --rezflags`"
wxrezfile=""
for word in $wxrezcomp; do
temp="`echo $word | grep '[^_]*_mac-[^r]*r'`"
if test "$temp"; then
wxrezfile="$temp"
fi
done
echo "resource file: $wxrezfile"
fi
fi
#--------------------------------------------------------------------
# haskell compiler and package manager
#--------------------------------------------------------------------
# Do we have ghc?
if sh ./config.search "$hc"; then
echo "$hc found"
else
echo "error:"
echo " Unable to find: $hc"
echo " Pleasy specify the path to GHC."
echo " For example: ./configure --hc=/c/ghc/ghc-6.0/bin/ghc"
exit 2
fi
# check ghc version
ghcversion="`$hc --version | sed -e 's|[A-Za-z \t,]*||'`"
case "$ghcversion" in
0* | 1* | 2* | 3* | 4* | 5.*)
echo "WARNING:"
echo " You seem to have an older ghc installed, namely $ghcversion"
echo " Ghc versions prior to 6.0 have garbage collector bugs that make wxHaskell"
echo " applications *crash* and contain incompatible libraries."
echo " It is strongly advised to upgrade to a newer version."
echo "";;
6.*) ;;
7.*) ;;
8.*) ;;
9.*) ;;
*) echo "warning:"
echo " Unable to recognise the ghc version ($ghcversion ?)"
echo " Be careful: ghc versions prior to 6.0 have bugs that make wxHaskell"
echo " applications *crash* and contain incompatible libraries."
echo "";;
esac
# Do we have ghc-pkg?
if sh ./config.search "$hcpkg"; then
echo "$hcpkg found"
else
echo "error:"
echo " Unable to find: $hcpkg"
echo " Pleasy specify the path to ghc-pkg."
echo " For example: ./configure --hcpkg=/c/ghc/ghc-6.0/bin/ghc-pkg"
hcpkg=echo
exit 2
fi
# Add local package flags
if test "$hcpkglocal"; then
hc="$hc -package-conf $hcpkglocal"
hcpkg="$hcpkg -f $hcpkglocal"
fi
#--------------------------------------------------------------------
# Haddock
#--------------------------------------------------------------------
# Do we have haddock?
if sh ./config.search "$hdoc"; then
echo "$hdoc found"
hdocfound="yes"
else
echo "warning:"
echo " Unable to find: $hdoc"
echo " You won't be able to generate documentation."
echo " You can specify the haddock executable on the command line."
echo " For example: ./configure --haddock=/usr/local/bin/haddock"
echo ""
hdocbase=""
hdocfound="no"
fi
# find base.haddock
if test "$hdocfound" = "yes"; then
if test "$cygpathfound"; then
hdocbase="`cygpath -w $hdocbase | sed -e 's|\\\\|/|g'`"
fi
if test -f "$hdocbase"; then
echo "base.haddock found"
else
echo "warning"
echo " Could not find haddock interface: $hdocbase"
echo " The haddock documentation will be incomplete"
echo " Please specify the haddock interface for the base libraries."
echo " For example: ./configure --haddock-base=/c/ghc/doc/html/base/base.haddock"
echo ""
hdocbase=""
fi
fi
#--------------------------------------------------------------------
# wxWindows
#--------------------------------------------------------------------
# Find the wxwindows library (if it is specified).
if test "$wxwinlib"; then
if test -f "$wxwinlib"; then
echo "wxwindows library found"
else
echo "error:"
echo " Unable to find the specified wxwindows library: $wxwinlib"
echo " Maybe you forgot to run 'make install' for wxWindows?"
echo " Otherwise, specify the full path to the library on the command line."
echo " For example: ./configure --wx-lib=/usr/local/lib/wxmsw241.dll"
if test "$WINDIR"; then
echo " Or maybe you are trying to compile with Microsoft Visual C++?"
echo " For example: ./configure --with-msc"
fi
exit 2
fi
fi
#--------------------------------------------------------------------
# install
#--------------------------------------------------------------------
if sh ./config.search "install"; then
echo "install program found"
installdir="install -d"
install="install -c"
else
echo "warning:"
echo " Unable to find 'install' (using 'cp' and 'mkdir' instead)."
echo ""
installdir="mkdir -p"
install="cp -u"
fi
#--------------------------------------------------------------------
# strip and upx
#--------------------------------------------------------------------
if test "$enablestrip" = "yes"; then
if sh ./config.search "strip"; then
echo "strip found"
else
echo "warning:"
echo " Unable to find 'strip'. Libraries will not be stripped."
echo ""
enablestrip="no"
fi
fi
if test "$enableupx" = "yes"; then
if sh ./config.search "upx"; then
echo "upx found"
else
echo "warning:"
echo " Unable to find 'upx'. Dynamic libraries will not be compressed."
echo ""
enableupx="no"
fi
fi
runcompress=":"
if test "$enableupx" = "yes"; then
runcompress="config/compress \$(1)"
else
if test "$enablestrip" = "yes"; then
runcompress="echo strip \$(1); strip \$(1)"
fi
fi
#--------------------------------------------------------------------
# toolkit
#--------------------------------------------------------------------
if test -z "$wxtoolkit"; then
echo "warning:"
echo " Unable to determine the wxWindow toolkit."
echo " Defaulting to 'MSW'."
echo ""
wxtoolkit="MSW"
fi
# to lowercase
wxtoolkit="`echo "$wxtoolkit" | sed -e 'y|ABCDEFGHIJKLMNOPQRSTUVWXYZ|abcdefghijklmnopqrstuvwxyz|'`"
#--------------------------------------------------------------------
# Generate configuration
#--------------------------------------------------------------------
# Create directories
echo "creating build directories:"
echo " - config"
mkdir -p config
# Finish generated files
topdir="`pwd`"
if sh ./config.search "date"; then
date="`date`"
else
date="<unknown>"
fi
echo "creating makefile configuration"
echo " - config/config.mk"
cat > config/config.mk << EOF
# Generated by configure on $date
TOPDIR=$topdir
VERSION=$version
TOOLKIT=$wxtoolkit
# The Haskell compiler
HC=$hc
HCFLAGS=
HCPKG=$hcpkg
# C compiler
CXX=$cxx
# Installation
BINDIR=$execprefix/bin
LIBDIR=$libdir
# Compression function
run-compress=$runcompress
# Wxc
WITHMSC=$withmsc
WXC-LIBNAME=$wxclibname
# WxWindows
WXWINLIB=$wxwinlib
WXWIN-LIBS=$wxwinlibs
WXWIN-CXXFLAGS=$wxwincxxflags
# Platform
EXE=$exe
DLL=$dll
LIB=$lib
# Documentation
HDOCFOUND=$hdocfound
HDOC=$hdoc
HDOCBASE=$hdocbase
USERNAME=$username
# Standard programs
INSTALL=$install
INSTALLDIR=$installdir
LD=ld
AR=ar
CP=cp -f
MV=mv
CD=cd
RM=rm -f
MKDIR=mkdir -p
RMDIR=rmdir
ZIP=zip
TAR=tar
GZIP=gzip
EOF
# put quotes around extra-ld-opts of non-empty
if test "$extraldopts"; then
extraldopts="\"$extraldopts\""
fi
# create packages
echo "creating package descriptions"
echo " - config/wxcore.pkg"
cat > config/wxcore.pkg << EOF
Package
{ name="wxcore"
, import_dirs=["\${installdir}/imports"]
, library_dirs=["\${installdir}"]
, hs_libraries=["wxcore","wxcore0"]
, extra_libraries=["$wxclibname"]
, package_deps = ["base","data"]
, extra_ld_opts=[$extraldopts]
}
EOF
echo " - config/wx.pkg"
cat > config/wx.pkg << EOF
Package
{ name="wx"
, import_dirs=["\${installdir}/imports"]
, library_dirs=["\${installdir}"]
, hs_libraries=["wx"]
, package_deps=["wxcore"]
}
EOF
echo "creating utility scripts"
# generate compress utility
if test "$enableupx" = "yes"; then
echo " - config/compress"
echo "#!/bin/sh" > config/compress
echo "upx -t \$1 > /dev/null 2> /dev/null" >> config/compress
echo "if test \"\$?\" != \"0\"; then" >> config/compress
if test "$enablestrip" = "yes"; then
echo " echo \"strip \$1\"" >> config/compress
echo " strip \$1" >> config/compress
fi
echo " upx \$1" >> config/compress
echo "fi" >> config/compress
fi
# generate maxosx installer files.
echo " - config/macosx-install.info"
cat > config/macosx-install.info << EOF
Title wxHaskell
Version $version
Description wxHaskell library
DefaultLocation $prefix
DeleteWarning
NeedsAuthorization YES
Required NO
Relocatable NO
RequiresReboot NO
UseUserMask YES
OverwritePermissions NO
InstallFat NO
RootVolumeOnly YES
EOF
# generate macosx post-install files.
echo " - config/macosx-postinstall"
cat > config/macosx-postinstall << EOF
#!/bin/sh
env installdir="$libdir" /usr/local/bin/ghc-pkg -u -i "\$1/Contents/Resources/wxcore.pkg"
env installdir="$libdir" /usr/local/bin/ghc-pkg -u -i "\$1/Contents/Resources/wx.pkg"
EOF
chmod a+x config/macosx-postinstall
# generate macosx application builder script
echo " - config/macosx-app"
cat > config/macosx-app-temp << EOF
#!/bin/sh
rezcomp="$wxrezcomp"
rezfile="$wxrezfile"
EOF
cat config/macosx-app-temp bin/macosx-app-template > config/macosx-app
rm -f config/macosx-app-temp
chmod a+x config/macosx-app
# we are done.
echo ""
echo "done:"
echo " - type 'make' to build the libraries."
echo " - type 'make install' to install the libraries."
echo ""