-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·1662 lines (1495 loc) · 50.4 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
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#! /bin/bash +x
######
# This preamble uses sh to check for the existence of python, then
# exec's python.
######
python="none"
if ( which python > /dev/null 2>&1 ) ;
then python=`which python` ;
else
if ( which python2 > /dev/null 2>&1 ) ;
then python=`which python2` ;
fi ;
fi
if [ $python = "none" ] ; then
echo 'You must have at least Python v2.0 to build Fiasco'
exit -1 ;
fi
version=`$python -c 'import sys; print(sys.hexversion)'`
echo 'Found python = ' $python ', hexversion ' $version
if [ ${version} -lt 33554432 ]; then
echo 'You must have at least Python v2.0 to build Fiasco'
exit -1 ;
fi
exec $python - $* << EOF
######
# End of preamble; we are now in the land of python.
######
from __future__ import print_function
import six
import sys
import os
import os.path
import string
import getopt
#
# Some globals
#
rcsid = '\$Id: configure,v 1.36 2008/09/19 21:31:56 welling Exp $'
ofile = "config.mk"
debugFlag= 0 # set this to 1 for additional diagnostics
newDict= {} # Will hold the methods we identify
oldDict= {} # Vals read from old config.mk
clDict= {} # Vals from command line
defsOfInterest= ['CC', 'PAR_CFLAGS','PAR_LIBS','FFTW_INCLUDE','FFTW_CFLAGS',\
'FFTW_LIB','LAPACK_LIBS','SPLUSEXE','SPLUSDIRS','AFS_FLAG',\
'PYTHON_INCLUDE','FIFF_CFLAGS',\
'NFFT_LIBS','NFFT_CFLAGS','PNG_LIBS','PNG_CFLAGS',\
'TIFF_LIBS','TIFF_CFLAGS','SWIG',
'FITSIO_LIBS','FITSIO_CFLAGS',
'Z_CFLAGS', 'Z_LIBS']
defsMustHave= ['CC', 'FFTW_INCLUDE','FFTW_CFLAGS',\
'FFTW_LIB','LAPACK_LIBS','AFS_FLAG',\
'PYTHON_INCLUDE']
#
# Short pieces of code used to test various tools
#
cTestProg= \
"""
#include <stdio.h>
int main()
{
printf("Hello World!"); /* no \n to avoid having to quote the backslash */
return 0;
}
"""
parTestProg= \
"""
#include <stdio.h>
#ifdef PVM
#include <pvm3.h>
#endif
#ifdef MPI
#include <mpi.h>
#endif
int main(int argc, char* argv[])
{
#ifdef PVM
int my_tid= pvm_mytid();
pvm_exit();
#endif
#ifdef MPI
(void)MPI_Init(&argc, &argv);
(void)MPI_Finalize();
#endif
}
"""
fftwTestProg= \
"""
#ifdef FFTW3
#include <fftw3.h>
int main()
{
fftw_plan p;
fftw_complex *in, *out;
p= fftw_plan_dft_1d(1000, in, out, FFTW_FORWARD, FFTW_ESTIMATE);
fftw_destroy_plan(p);
}
#else
#include <fftw.h>
int main()
{
fftw_plan p;
p= fftw_create_plan(1000, FFTW_FORWARD, FFTW_ESTIMATE);
fftw_destroy_plan(p);
}
#endif
"""
lapackTestProg= \
"""
#include <stdio.h>
#include "src/fmri/lapack.h"
int main()
{
int hundred = 100;
int info;
double space[100];
DGESVD("N","O",&hundred,&hundred,space,&hundred,space,space,
&hundred,space,&hundred,space,&hundred,&info);
printf("%d",hundred);
}
"""
rTestProg= \
"""
q();
"""
nfftTestProg= \
"""
#ifdef USE_NFFT
#include <nfft.h>
#else
#error("USE_NFFT not defined!")
#endif
int main()
{
static nfft_plan fwd_plan;
nfft_init_1d(&fwd_plan, 64, 64);
}
"""
fiffTestProg= \
"""
#include <stdio.h>
#ifdef USE_FIFF
#include <fiff_types.h>
#include <fiff_file.h>
#else
#error("USE_FIFF not defined!")
#endif
int main()
{
fprintf(stderr,"Hello World!");
}
"""
pngTestProg= \
"""
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#ifdef USE_PNG
#include <png.h>
#else
#error("USE_PNG not defined!")
#endif
int main()
{
#ifdef USE_PNG
png_structp png_ptr;
png_infop info_ptr;
png_text notes[5];
FILE* fp= fopen("configure_tmp.png","w");
png_ptr= png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr) {
fprintf(stderr,"Unable to create png data structure! (1)");
exit(-1);
}
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) {
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
fprintf(stderr,"Unable to create png data structure! (2)");
exit(-1);
}
if (setjmp(png_jmpbuf(png_ptr))) {
png_destroy_write_struct(&png_ptr, &info_ptr);
fprintf(stderr,"Fatal error in png libraries!");
exit(-1);
}
png_init_io(png_ptr,fp);
png_set_IHDR(png_ptr, info_ptr, 10, 10, 8, PNG_COLOR_TYPE_GRAY,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
PNG_FILTER_TYPE_DEFAULT);
notes[0].key= "Title";
notes[0].text= (png_charp)"This is my title";
notes[0].compression= PNG_TEXT_COMPRESSION_zTXt;
png_set_text(png_ptr, info_ptr, notes, 1);
png_write_info(png_ptr,info_ptr);
#endif
return 0;
}
"""
pngTestOutputFname = 'configure_tmp.png'
zTestProg= \
r"""
/* This was cut down from https://github.com/madler/zlib/blob/master/test/example.c */
/* example.c -- usage example of the zlib compression library
* Copyright (C) 1995-2006, 2011, 2016 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
#include "zlib.h"
#include <stdio.h>
#ifdef STDC
# include <string.h>
# include <stdlib.h>
#endif
#if defined(VMS) || defined(RISCOS)
# define TESTFILE "foo-gz"
#else
# define TESTFILE "foo.gz"
#endif
#define CHECK_ERR(err, msg) { \
if (err != Z_OK) { \
fprintf(stderr, "%s error: %d\n", msg, err); \
exit(1); \
} \
}
static z_const char hello[] = "hello, hello!";
/* "hello world" would be more standard, but the repeated "hello"
* stresses the compression code better, sorry...
*/
static const char dictionary[] = "hello";
static uLong dictId; /* Adler32 value of the dictionary */
int main OF((int argc, char *argv[]));
#ifdef Z_SOLO
void *myalloc OF((void *, unsigned, unsigned));
void myfree OF((void *, void *));
void *myalloc(q, n, m)
void *q;
unsigned n, m;
{
(void)q;
return calloc(n, m);
}
void myfree(void *q, void *p)
{
(void)q;
free(p);
}
static alloc_func zalloc = myalloc;
static free_func zfree = myfree;
#else /* !Z_SOLO */
static alloc_func zalloc = (alloc_func)0;
static free_func zfree = (free_func)0;
void test_compress OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
void test_gzio OF((const char *fname,
Byte *uncompr, uLong uncomprLen));
/* ===========================================================================
* Test read/write of .gz files
*/
void test_gzio(fname, uncompr, uncomprLen)
const char *fname; /* compressed file name */
Byte *uncompr;
uLong uncomprLen;
{
#ifdef NO_GZCOMPRESS
fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n");
#else
int err;
int len = (int)strlen(hello)+1;
gzFile file;
z_off_t pos;
file = gzopen(fname, "wb");
if (file == NULL) {
fprintf(stderr, "gzopen error\n");
exit(1);
}
gzputc(file, 'h');
if (gzputs(file, "ello") != 4) {
fprintf(stderr, "gzputs err: %s\n", gzerror(file, &err));
exit(1);
}
if (gzprintf(file, ", %s!", "hello") != 8) {
fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err));
exit(1);
}
gzseek(file, 1L, SEEK_CUR); /* add one zero byte */
gzclose(file);
file = gzopen(fname, "rb");
if (file == NULL) {
fprintf(stderr, "gzopen error\n");
exit(1);
}
strcpy((char*)uncompr, "garbage");
if (gzread(file, uncompr, (unsigned)uncomprLen) != len) {
fprintf(stderr, "gzread err: %s\n", gzerror(file, &err));
exit(1);
}
if (strcmp((char*)uncompr, hello)) {
fprintf(stderr, "bad gzread: %s\n", (char*)uncompr);
exit(1);
} else {
printf("gzread(): %s\n", (char*)uncompr);
}
pos = gzseek(file, -8L, SEEK_CUR);
if (pos != 6 || gztell(file) != pos) {
fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n",
(long)pos, (long)gztell(file));
exit(1);
}
if (gzgetc(file) != ' ') {
fprintf(stderr, "gzgetc error\n");
exit(1);
}
if (gzungetc(' ', file) != ' ') {
fprintf(stderr, "gzungetc error\n");
exit(1);
}
gzgets(file, (char*)uncompr, (int)uncomprLen);
if (strlen((char*)uncompr) != 7) { /* " hello!" */
fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err));
exit(1);
}
if (strcmp((char*)uncompr, hello + 6)) {
fprintf(stderr, "bad gzgets after gzseek\n");
exit(1);
} else {
printf("gzgets() after gzseek: %s\n", (char*)uncompr);
}
gzclose(file);
#endif
}
#endif /* Z_SOLO */
/* ===========================================================================
* Usage: example [output.gz [input.gz]]
*/
int main(argc, argv)
int argc;
char *argv[];
{
Byte *compr, *uncompr;
uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */
uLong uncomprLen = comprLen;
static const char* myVersion = ZLIB_VERSION;
if (zlibVersion()[0] != myVersion[0]) {
fprintf(stderr, "incompatible zlib version\n");
exit(1);
} else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) {
fprintf(stderr, "warning: different zlib version\n");
}
printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n",
ZLIB_VERSION, ZLIB_VERNUM, zlibCompileFlags());
compr = (Byte*)calloc((uInt)comprLen, 1);
uncompr = (Byte*)calloc((uInt)uncomprLen, 1);
/* compr and uncompr are cleared to avoid reading uninitialized
* data and to ensure that uncompr compresses well.
*/
if (compr == Z_NULL || uncompr == Z_NULL) {
printf("out of memory\n");
exit(1);
}
#ifdef Z_SOLO
(void)argc;
(void)argv;
#else
test_gzio((argc > 1 ? argv[1] : TESTFILE),
uncompr, uncomprLen);
#endif
return 0;
}
"""
zTestOutputFname = 'foo.gz'
tiffTestProg= \
"""
#include <stdio.h>
#ifdef USE_TIFF
#include <tiff.h>
#include <tiffio.h>
#else
#error("USE_TIFF not defined!")
#endif
int main()
{
#ifdef USE_TIFF
printf("%s\n",TIFFGetVersion());
#endif
return 0;
}
"""
fitsioTestProg= \
"""
#include <stdio.h>
#ifdef USE_FITSIO
#include <fitsio.h>
#else
#error("USE_FITSIO not defined!")
#endif
int main()
{
#ifdef USE_FITSIO
int status= 0;
fitsfile *fptr;
fits_open_file(&fptr, "somefile.fits", READONLY, &status);
#endif
return 0;
}
"""
#
# Some utility functions
#
def debugMessage(s):
if debugFlag: sys.stdout.write("%s\n"%s)
def Message(s):
sys.stdout.write("%s\n"%s)
def runCmd(cmd):
debugMessage("running <%s>"%cmd)
cmdout= os.popen(cmd+" 2>/dev/null")
result= cmdout.readlines()
return ( cmdout.close(), result )
def runCompiledExe(cmd,arch):
if arch.find('CYGWIN')>=0:
debugMessage("running <%s.exe>"%cmd)
cmdout= os.popen(cmd+".exe 2>/dev/null")
result= cmdout.readlines()
else:
debugMessage("running <%s>"%cmd)
cmdout= os.popen(cmd+" 2>/dev/null")
result= cmdout.readlines()
return ( cmdout.close(), result )
def compiledExeExists(exeName,arch):
if arch.find('CYGWIN')>=0:
return os.access("%s.exe"%exeName,os.W_OK)
else:
return os.access("%s"%exeName,os.W_OK)
def deleteCompiledExe(exeName,arch):
if arch.find('CYGWIN')>=0:
if os.access("%s.exe"%exeName,os.W_OK):
debugMessage("Deleting <%s.exe>"%exeName)
os.unlink("%s.exe"%exeName)
else:
if os.access("%s"%exeName,os.W_OK):
debugMessage("Deleting <%s>"%exeName)
os.unlink("%s"%exeName)
libsWarnedAbout= {}
def libExists(libName,path,arch):
debugMessage("Looking for lib %s in %s on %s"%(libName,path,arch))
result= 0
fullName= None
if os.access(os.path.join(path,"lib%s.a"%libName),os.R_OK): result=1
if os.access(os.path.join(path,"lib%s.la"%libName),os.R_OK): result=1
if os.access(os.path.join(path,"lib%s.dylib"%libName),os.R_OK): result=1
if os.access(os.path.join(path,"lib%s.so"%libName),os.R_OK): result=1
if not result:
# Try it the hard way
if os.access(path,os.R_OK):
fullName= "lib%s.so."%libName
for fname in os.listdir(path):
if fname.find(fullName)==0:
if arch=='LINUX':
# Sometimes, shared libs under Linux lack symbol defs
fullPath= os.path.join(path,fname)
(rc,lines)= runCmd("nm %s"%fullPath)
if len(lines)!=0:
result=1
break
else:
if fullPath not in libsWarnedAbout:
Message("%s exists but has no symbols"%\
fullPath)
libsWarnedAbout[fullPath]= 1
else:
result=1
break
return result
def incExists(incName,path,arch):
debugMessage("Looking for %s in %s on %s"%(incName,path,arch))
return os.access(os.path.join(path,incName),os.R_OK)
def libLocRequiresExplicitPath(path,arch):
# Current LD_LIBRARY_PATH might be user-specific. Be conservative.
return (path!='/usr/lib' and path!='/usr/local/lib')
def incLocRequiresExplicitPath(path,arch):
# Current LD_LIBRARY_PATH might be user-specific. Be conservative.
return (path != '/include' and path!='/usr/include' \
and path!='/usr/local/include')
def maybeWrite(o,dict,key):
if key in dict:
o.write("%s = %s\n"%(key,dict[key]))
else:
o.write("#%s = ????\n"%key)
def describeSelf():
Message(\
"""
This script configures Fiasco for compilation. It gets initial
values from the values in %s, and from the command line. After
that, it will search your system for any additional needed packages.
To provide input, you can edit %s or use any of the following
command line arguments:
"""%(ofile,ofile))
for key in defsOfInterest:
Message(" --%s"%key)
Message(\
"""
For example, --FFTW_LIB=-lfftw3
Alternately, any of the above keys (for example, FFTW_LIB) can be
set as an environment variable before running the script.
Setting multi-word values from the command line may be tricky, so
it's easiest to edit %s or set an environment variable in such cases.
"""%ofile)
########
# Main
########
Message( "This is configure for Fiasco, RCS version %s"%rcsid )
optParseList= ["help"]
for key in defsOfInterest:
optParseList.append(key+"=")
try:
(opts,pargs) = getopt.getopt(sys.argv[1:],"dh",optParseList)
except:
print("%s: Invalid command line parameter" % sys.argv[0])
describeSelf();
sys.exit()
#Check calling syntax; parse args
if len(pargs) != 0 :
Message("Invalid command line argument")
describeSelf()
sys.exit()
for a,b in opts:
if a=="-d": debugFlag= 1
elif a=="-h":
describeSelf()
sys.exit()
elif a=="--help":
describeSelf()
sys.exit()
else:
for key in defsOfInterest:
if a=="--"+key:
clDict[key]= b
#
# Are we at the top of the FIASCO source tree?
#
if (not os.access("src/fiat_scripts/test_in_subshell.csh",os.X_OK)) \
or (not os.access("src/fiat_scripts/fiasco_getarch.csh",os.X_OK)):
sys.exit("Either %s is not being run from the top of the FIASCO\n"\
%sys.argv[0] \
+"source tree, or the scripts in src/fiat_scripts are not executable.")
if (not os.access("src/fmri/lapack.h",os.R_OK)):
sys.exit("Either %s is not being run from the top of the FIASCO\n"\
%sys.argv[0] \
+"source tree, or src/fmri/lapack.h is missing")
#
# Where are we?
#
newDict['topdir']=os.path.dirname(os.path.abspath(__file__))
#
# What type of machine is this?
#
(rc, lines)= runCmd("src/fiat_scripts/fiasco_getarch.csh")
if rc != None:
sys.exit("I can't figure out this machine's architecture!")
else:
arch= lines[0].strip()
if arch == "UNKNOWN":
sys.exit("I can't figure out this machine's architecture!")
else:
Message("This machine seems to be %s"%arch)
newDict['arch']= arch
possibleLibLocs= [ os.path.join(os.environ['HOME'],'lib'),\
os.path.join(os.environ['HOME'],'lib',newDict['arch']),\
'/usr/lib','/usr/local/lib','/usr/statlocal/lib',
'/sw/lib','/usr/lib64','/opt/local/lib']
possibleIncLocs= [os.path.join(os.environ['HOME'],'include'),
os.path.join(os.environ['HOME'],'include',newDict['arch']),
'/usr/local/include','/usr/include','/usr/statlocal/include',
'/sw/include','/opt/local/include']
#
# Grab old values from the existing config.mk
#
if os.access(ofile,os.R_OK):
f= open(ofile,"r")
lines= f.readlines()
f.close()
for line in lines:
if line.find('This file was generated for architecture')>=0:
words= line.split()
oldDict['arch']= words[-1]
elif line.find(': configure,v')>=0:
oldDict['configure_version']= line.split()[3]
else:
words= line.split()
if len(words)>=2 and words[1]=='=' and words[0][0]!='#':
s= ""
for word in words[2:]:
s += ( word + " ")
# strip old quotes. We avoid just using strip() because
# of worries about the python version.
if len(s)>0:
for iStart in range(len(s)):
if not s[iStart] in string.whitespace \
and s[iStart]!='"' \
and s[iStart]!="'": break
for iEnd in range(len(s)):
if not s[-(iEnd+1)] in string.whitespace \
and s[-(iEnd+1)]!='"' \
and s[-(iEnd+1)]!="'": break
iEnd -= 1
if iEnd>=0:
oldDict[words[0]]= s[iStart:-(iEnd+1)]
else:
oldDict[words[0]]= s[iStart:]
else:
oldDict[words[0]]= ""
# Update old entries appropriately for obsolete versions of config.mk
# If FFTW_INCLUDE came from a pre-1.27 revision, prepend -I
if 'configure_version' in oldDict and \
float(oldDict['configure_version'])<1.27:
if 'FFTW_INCLUDE' in oldDict:
oldDict['FFTW_INCLUDE']= '-I'+oldDict['FFTW_INCLUDE']
else:
pass
#
# Try to find useful things in old config or command line, or
# finally in the environment.
#
if 'arch' in oldDict:
Message("Previous version of %s was generated for %s"%\
(ofile,oldDict['arch']))
if oldDict['arch'] == newDict['arch']:
Message("Looking for values in old %s"%ofile)
for key in defsOfInterest:
if key in oldDict:
Message(" %s found"%key)
newDict[key]= oldDict[key]
else:
Message("Architecture has changed; I don't trust old %s"%ofile)
for key in defsOfInterest:
if key in os.environ:
Message("Using environment value for %s"%key)
newDict[key]= os.environ[key]
for key in defsOfInterest:
if key in clDict:
Message("Using command line value for %s"%key)
newDict[key]= clDict[key]
if debugFlag: Message("imported and command line values: %s"%newDict)
#
# If the old config specified a C compiler, does it work?
#
if 'CC' in newDict:
Message("Testing C compiler from previous version of %s"%ofile)
tfile= open("configure_tmp.c","w")
tfile.write(cTestProg)
tfile.close()
(rc,lines)= runCmd("%s -o configure_tmp configure_tmp.c"%newDict['CC'])
os.unlink("configure_tmp.c")
deleteCompiledExe("configure_tmp",arch)
if rc != None:
Message("%s does not appear to be a working C compiler!"%newDict['CC'])
del newDict['CC']
#
# Can we find the C compiler?
#
if 'CC' not in newDict:
Message("Finding the C compiler")
tfile= open("configure_tmp.c","w")
tfile.write(cTestProg)
tfile.close()
for cc in ["cc", "gcc"]:
Message(" Trying %s"%cc)
(rc,lines)= runCmd("%s -o configure_tmp configure_tmp.c"%cc)
if rc==None:
newDict['CC']= cc
break
os.unlink("configure_tmp.c")
deleteCompiledExe("configure_tmp",arch)
if 'CC' in newDict:
Message("Found that %s is a working C compiler."%newDict['CC'])
else:
sys.exit("Unable to find the C compiler! You must have a working\n"+\
"C compiler to build Fiasco.")
#
# First look for PVM
#
if 'PAR_LIBS' not in newDict or 'PAR_CFLAGS' not in newDict:
Message("Looking for a parallelism method")
if 'PVM_ROOT' in os.environ:
if os.access(os.path.join(os.environ['PVM_ROOT'],"lib",\
newDict['arch']),
os.R_OK):
Message("PVM_ROOT environment variable seems valid")
newDict['PAR_LIBS']= "-L${PVM_ROOT}/lib/%s -lgpvm3 -lpvm3"%\
newDict['arch']
if os.access(os.path.join(os.environ['PVM_ROOT'],'include'),
os.R_OK):
newDict['PAR_CFLAGS']= "-DPVM -I${PVM_ROOT}/include"
if 'PAR_LIBS' not in newDict or 'PAR_CFLAGS' not in newDict:
if newDict['arch']=='CRAY':
Message("Selecting parallelism method based on architecture")
newDict['PAR_LIBS']= "-L/afs/psc/packages/pvm/@sys/lib"
newDict['PAR_CFLAGS']= "-DPVM"
#
# Look for MPI
#
oldCC= None
if 'PAR_LIBS' not in newDict or 'PAR_CFLAGS' not in newDict:
(rc1,lines1)= runCmd("which mpirun")
(rc2,lines2)= runCmd("which mpicc")
if rc1==None and len(lines1[0].split())==1 \
and rc2==None and len( lines2[0].split())==1:
Message("Found mpirun and mpicc")
newDict['PAR_LIBS']= ""
newDict['PAR_CFLAGS']= "-DMPI"
oldCC= newDict['CC'] # in case test below fails
newDict['CC']= "mpicc"
#
# Test guesses about parallelism
#
if 'PAR_LIBS' in newDict and 'PAR_CFLAGS' in newDict:
Message("Testing parallelism")
cflags= newDict['PAR_CFLAGS']
libs= newDict['PAR_LIBS'] + " -lm"
if not newDict['arch'] in ["HPPA", "HPPA20", "CRAY", "T3D", "T3E"]:
cflags += " -DFORTRAN_ADD_UNDERSCORE"
tfile= open("configure_tmp.c","w")
tfile.write(parTestProg)
tfile.close()
(rc,lines)= runCmd("%s -o configure_tmp %s configure_tmp.c %s"%\
(newDict['CC'],cflags,libs))
os.unlink("configure_tmp.c")
deleteCompiledExe("configure_tmp",arch)
if rc!=None:
Message("cannot find parallel libraries. My guess of %s %s failed."%\
(newDict['PAR_CFLAGS'],newDict['PAR_LIBS']))
del newDict['PAR_CFLAGS']
del newDict['PAR_LIBS']
if oldCC != None:
newDict['CC']= oldCC
#
# Did we find a parallelism method?
#
if 'PAR_CFLAGS' not in newDict or 'PAR_LIBS' not in newDict:
Message("I can't find PVM or MPI. If PVM is installed, set the environment")
Message(" variable PVM_ROOT to point to the appropriate directory and")
Message(" re-run configure. If MPI is installed, make sure mpirun and")
Message(" mpicc are in your path and re-run configure. Without PVM or")
Message(" MPI, FIASCO will still work but it will be installed without")
Message(" parallelism.")
newDict['PAR_CFLAGS']= ""
newDict['PAR_LIBS']= ""
#
# Location of FFTW library
#
if 'FFTW_LIB' not in newDict:
Message("Looking for FFTW library")
for loc in possibleLibLocs:
if libExists('fftw',loc,newDict['arch']):
newDict['fftwversion']= 2
if libLocRequiresExplicitPath(loc,newDict['arch']):
newDict['FFTW_LIB']= "-L%s -lfftw"%loc
else:
newDict['FFTW_LIB']= "-lfftw"
break
elif libExists('fftw3',loc,newDict['arch']):
newDict['fftwversion']= 3
if libLocRequiresExplicitPath(loc,newDict['arch']):
newDict['FFTW_LIB']= "-L%s -lfftw3"%loc
else:
newDict['FFTW_LIB']= "-lfftw3"
break
if 'FFTW_LIB' not in newDict:
if 'FFTW_LIB' in oldDict:
Message("I will try the old location for the FFTW library.")
newDict['FFTW_LIB']= oldDict['FFTW_LIB']
if 'FFTW_LIB' in newDict and 'fftwversion' not in newDict:
if newDict['FFTW_LIB'].find('fftw3')>=0:
newDict['fftwversion']= 3
else:
newDict['fftwversion']= 2
if 'FFTW_LIB' not in newDict:
Message("I can't find the FFTW library! This library is required.")
if 'FFTW_LIB' in newDict and 'fftwversion' not in newDict:
sys.exit("I can't figure out what version of FFTW you are using!")
#
# Location of FFTW includes
#
if 'FFTW_INCLUDE' not in newDict:
if 'fftwversion' in newDict:
Message("Looking for FFTW includes")
if newDict['fftwversion']==2: incName= "fftw.h"
elif newDict['fftwversion']==3: incName= "fftw3.h"
else: sys.exit("configure internal error: fftwversion should be 2 or 3!")
for loc in possibleIncLocs:
if incExists(incName,loc,newDict['arch']):
if incLocRequiresExplicitPath(loc,newDict['arch']):
newDict['FFTW_INCLUDE']= "-I%s"%loc
else:
newDict['FFTW_INCLUDE']= ""
break
else:
Message("I can't look for FFTW includes because I don't know the FFTW version!")
if 'FFTW_INCLUDE' not in newDict:
if 'FFTW_INCLUDE' in oldDict:
Message("I will try the old location for the FFTW library.")
newDict['FFTW_INCLUDE']= oldDict['FFTW_INCLUDE']
if 'FFTW_INCLUDE' not in newDict:
Message("I can't find the FFTW include file! This file is required.")
if 'FFTW_CFLAGS' not in newDict:
if 'fftwversion' in newDict:
if newDict['fftwversion']==2: newDict['FFTW_CFLAGS']= '-DFFTW2'
elif newDict['fftwversion']==3: newDict['FFTW_CFLAGS']= '-DFFTW3'
else: sys.exit("configure internal error: fftwversion should be 2 or 3!")
else:
Message("I can't predict FFTW_CFLAGS without knowing FFTW version!")
#
# Test guesses about FFTW
#
if 'FFTW_INCLUDE' in newDict and 'FFTW_LIB' in newDict\
and 'FFTW_CFLAGS' in newDict:
Message("Testing locations for FFTW")
cflags= ""
if len(newDict['FFTW_INCLUDE'])>0:
cflags= cflags + newDict['FFTW_INCLUDE']
cflags += " " + newDict['FFTW_CFLAGS']
libs= newDict['FFTW_LIB'] + " -lm"
if not newDict['arch'] in ["HPPA", "HPPA20", "CRAY", "T3D", "T3E"]:
cflags += " -DFORTRAN_ADD_UNDERSCORE"
tfile= open("configure_tmp.c","w")
tfile.write(fftwTestProg)
tfile.close()
(rc,lines)= runCmd("%s -o configure_tmp %s configure_tmp.c %s"%\
(newDict['CC'],cflags,libs))
os.unlink("configure_tmp.c")
deleteCompiledExe("configure_tmp",arch)
if rc!=None:
Message("cannot find FFTW libraries. My guess of %s %s %s failed."%\
(newDict['FFTW_INCLUDE'],newDict['FFTW_CFLAGS'], \
newDict['FFTW_LIB']))
del newDict['FFTW_CFLAGS']
del newDict['FFTW_LIB']
del newDict['FFTW_INCLUDE']
#
# Location of LAPACK and BLAS
#
if 'LAPACK_LIBS' not in newDict:
Message("Looking for LAPACK and BLAS libraries")
if newDict['arch']=='DARWIN':
newDict['LAPACK_LIBS']= '-framework vecLib -lm'
elif newDict['arch'].find('SGIMP')==0:
newDict['LAPACK_LIBS']= '-lcomplib.sgimath_mp'
elif newDict['arch'].find('SGI')==0:
newDict['LAPACK_LIBS']= '-lcomplib.sgimath'
else:
libNamesListList= [ ['lapack-3'], \
['lapack', 'f77blas', 'cblas', 'atlas', 'g2c'], \
['lapack', 'f77blas', 'cblas', 'atlas'], \
['lapack', 'blas', 'g2c'],
['lapack', 'blas'] ]
guess= None
for nameList in libNamesListList:
guess= ""
success= 1
debugMessage("Looking for the following set of libs: %s"%nameList)
for name in nameList:
found= 0
for loc in possibleLibLocs:
if libExists(name,loc,newDict['arch']):
if libLocRequiresExplicitPath(loc,newDict['arch']):
guess= "%s -L%s -l%s"%(guess,loc,name)
else:
guess= "%s -l%s"%(guess,name)
found= 1
break
if not found:
success= 0
break
if success: break
if guess:
newDict['LAPACK_LIBS']= guess
if 'LAPACK_LIBS' not in newDict:
if 'LAPACK_LIBS' in oldDict:
Message("I will try the old location for the LAPACK libraries.")
newDict['LAPACK_LIBS']= oldDict['LAPACK_LIBS']
if 'LAPACK_LIBS' not in newDict:
Message("I can't find the LAPACK and BLAS libraries! They are required.")
#
# Test guesses about LAPACK and BLAS
#
if 'LAPACK_LIBS' in newDict:
Message("Testing locations for LAPACK and BLAS")
cflags= ""
libs= newDict['LAPACK_LIBS'] + " -lm"
if not newDict['arch'] in ["HPPA", "HPPA20", "CRAY", "T3D", "T3E"]:
cflags += " -DFORTRAN_ADD_UNDERSCORE"
tfile= open("configure_tmp.c","w")
tfile.write(lapackTestProg)
tfile.close()
(rc,lines)= runCmd("%s -o configure_tmp %s configure_tmp.c %s"%\
(newDict['CC'],cflags,libs))
os.unlink("configure_tmp.c")
deleteCompiledExe("configure_tmp",arch)
if rc!=None:
Message("cannot find LAPACK library. My guess of %s failed."%\