-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·594 lines (549 loc) · 25.7 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
#! /usr/bin/perl -w
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# GENIE configuration script
#
# For help, type ./configure --help
#
# Costas Andreopoulos <costas.andreopoulos \at stfc.ac.uk>
# University of Liverpool & STFC Rutherford Appleton Lab
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# print out info & exit if any of the command-line arguments was --help
#
if(($match = grep(/--help/i, @ARGV)) > 0) {
print "\n";
print "*** GENIE configure script *** \n\n";
print "Usage: ./configure [option]... [flag=value]... \n\n";
print " FLAG DESCRIPTION DEFAULT\n\n";
print " --prefix Installation location (for 'make install') /usr/local/\n";
print "\n enable/disable options with either --enable- or --disable- (eg --enable-lhapdf5 --disable-flux-drivers)\n\n";
print " profiler GENIE code profiling using Google PerfTools default: disabled \n";
print " doxygen-doc Generate doxygen documentation at build time default: disabled \n";
print " dylibversion Adds version number in library names (recommended) default: enabled \n";
print " lowlevel-mesg Disable (rather than filter out at run time) prolific default: disabled \n";
print " debug/info level messages known to slow GENIE down \n";
print " debug Adds -g in the compiler options to request debug info default: disabled \n";
print " lhapdf5 Use the LHAPDF5 parton density function library default: enabled \n";
print " lhapdf6 Use the LHAPDF6 parton density function library default: disabled \n";
print " t2k T2K-specific event generation app default: disabled \n";
print " fnal FNAL-specific event generation app default: disabled \n";
print " atmo Atmospheric neutrino event generation app default: disabled \n";
print " nucleon-decay Nucleon decay simulation default: disabled \n";
print " nnbar-oscillation Simulation of nbar annihilation [n-nbar oscillation] default: disabled \n";
print " boosted-dark-matter Boosted dark matter simulation default: disabled \n";
print " flux-drivers Built-in flux drivers default: enabled \n";
print " geom-drivers Built-in detector geometry drivers default: enabled \n";
print " masterclass Enable GENIE neutrino masterclass app default: disabled (Experimental) \n";
print " test Build test programs default: disabled \n";
print "\n options for 3rd party software, prefix with --with- (eg --with-lhapdf5-lib=/some/path/)\n\n";
print " compiler Compiler to use (any of clang,gcc) default: gcc \n";
print " optimiz-level Compiler optimization any of O,O2,O3,OO,Os / default: O2 \n";
print " profiler-lib Path to profiler library needed if you --enable-profiler \n";
print " doxygen-path Doxygen binary path needed if you --enable-doxygen-doc (if unset: checks for a \$DOXYGENPATH env.var.) \n";
print " pythia6-lib PYTHIA6 library path always needed (if unset: checks for a \$PYTHIA6 env.var., then tries to auto-detect it) \n";
print " lhapdf5-inc Path to LHAPDF5 includes needed if you --enable-lhapdf5 (if unset: checks for a \$LHAPDF5_INC env.var., then tries to auto-detect it) \n";
print " lhapdf5-lib Path to LHAPDF5 libraries needed if you --enable-lhapdf5 (if unset: checks for a \$LHAPDF5_INC env.var.. then tries to auto-detect it) \n";
print " lhapdf6-inc Path to LHAPDF6 includes needed if you --enable-lhapdf6 (if unset: checks for a \$LHAPDF6_INC env.var., then tries to auto-detect it) \n";
print " lhapdf6-lib Path to LHAPDF6 libraries needed if you --enable-lhapdf6 (if unset: checks for a \$LHAPDF6_INC env.var.. then tries to auto-detect it) \n";
print " libxml2-inc Path to libxml2 includes always needed (if unset: tries to auto-detect it) \n";
print " libxml2-lib Path to libxml2 library always needed (if unset: tries to auto-detect it) \n";
print " log4cpp-inc Path to log4cpp includes always needed (if unset: tries to auto-detect it) \n";
print " log4cpp-lib Path to log4cpp library always needed (if unset: tries to auto-detect it) \n\n";
print "If the printout was too long then pipe it through a pager, eg: \n";
print "./configure --help | more \n";
exit 0;
}
# Check that $GENIE is set
#
$GENIE = $ENV{'GENIE'};
die ("*** Error *** The GENIE environmental variable (pointing to the top level GENIE directory) is not defined")
unless defined $GENIE;
# Print GENIE banner
#
$BANNER_FILE = "$GENIE/data/logo/genie_banner_short.txt";
if(-e $BANNER_FILE) {
open(BANNER, "<$BANNER_FILE");
@hdr=<BANNER>;
print @hdr;
close(BANNER);
}
# Check that $ROOTSYS is set
#
$ROOTSYS = $ENV{'ROOTSYS'};
die ("*** Error *** The ROOTSYS environmental variable is not defined. Is ROOT installed?")
unless defined $ROOTSYS;
# Check whether ROOT itself was build with GSL enabled
# (GENIE uses GSL via ROOT's MathMore library.)
#
{
$mathmore_lib = "$ROOTSYS/lib/libMathMore.so";
if( ! -f $mathmore_lib ) {
die ("*** Error *** ROOT needs to be built with GSL/MathMore enabled.");
}
}
# Enable auto-detection?
#
system("find $GENIE/configure");
print "\n";
$auto_detect = ($?==0) ? 1 : 0;
if(! $auto_detect) {
print "\n*** Warning *** Path auto-detection is turned off. You need the 'find' utility to use that feature\n\n";
}
# Open Make.config to write configuration options
#
$MKCONF_FILE = "$GENIE/src/make/Make.config";
open(MKCONF, ">$MKCONF_FILE") or die("Can not write out the Make.config file!");
print MKCONF "# \n";
print MKCONF "# Make.config \n";
print MKCONF "# This file was automatically generated by the 'configure' script \n";
print MKCONF "# and is included into the project Makefiles \n";
print MKCONF "# \n";
# Create a string by joining all the command line arguments
#
my $options = join(" ", @ARGV);
# Get & save installation location (--prefix) or set default
#
my $prefix="/usr/local/";
if(($match = grep(/--prefix/i, @ARGV)) > 0) {
$options=~m/--prefix=(\S*)/i;
$prefix = $1;
if( $GENIE eq $prefix ) {
print "*** Error *** --prefix can not point to the GENIE top level directory!\n\n";
exit 1;
}
}
print MKCONF "GENIE_INSTALLATION_PATH=$prefix\n";
# Default --enable/--disable config options (for a minimal genie build)
#
my $gopt_enable_profiler = "NO";
my $gopt_enable_doxygen_doc = "NO";
my $gopt_enable_dylibversion = "YES";
my $gopt_enable_lowlevel_mesg = "NO";
my $gopt_enable_debug = "NO";
my $gopt_enable_lhapdf5 = "YES";
my $gopt_enable_lhapdf6 = "NO";
my $gopt_enable_flux_drivers = "YES";
my $gopt_enable_geom_drivers = "YES";
my $gopt_enable_test = "NO";
my $gopt_enable_t2k = "NO";
my $gopt_enable_fnal = "NO";
my $gopt_enable_atmo = "NO";
my $gopt_enable_nucleon_decay = "NO";
my $gopt_enable_nnbar_oscillation = "NO";
my $gopt_enable_boosted_dark_mat = "NO";
my $gopt_enable_masterclass = "NO";
# Check configure's command line arguments for non-default values
#
if(($match = grep(/--enable-profiler/i, @ARGV)) > 0) { $gopt_enable_profiler = "YES"; }
if(($match = grep(/--enable-doxygen-doc/i, @ARGV)) > 0) { $gopt_enable_doxygen_doc = "YES"; }
if(($match = grep(/--disable-dylibversion/i, @ARGV)) > 0) { $gopt_enable_dylibversion = "NO"; }
if(($match = grep(/--enable-lowlevel-mesg/i, @ARGV)) > 0) { $gopt_enable_lowlevel_mesg = "YES"; }
if(($match = grep(/--enable-debug/i, @ARGV)) > 0) { $gopt_enable_debug = "YES"; }
if(($match = grep(/--enable-lhapdf5/i, @ARGV)) > 0) { $gopt_enable_lhapdf5 = "YES"; }
if(($match = grep(/--disable-lhapdf5/i, @ARGV)) > 0) { $gopt_enable_lhapdf5 = "NO"; }
if(($match = grep(/--enable-lhapdf6/i, @ARGV)) > 0) { $gopt_enable_lhapdf6 = "YES"; }
if(($match = grep(/--disable-lhapdf6/i, @ARGV)) > 0) { $gopt_enable_lhapdf6 = "NO"; }
if(($match = grep(/--disable-flux-drivers/i, @ARGV)) > 0) { $gopt_enable_flux_drivers = "NO"; }
if(($match = grep(/--disable-geom-drivers/i, @ARGV)) > 0) { $gopt_enable_geom_drivers = "NO"; }
if(($match = grep(/--enable-test/i, @ARGV)) > 0) { $gopt_enable_test = "YES"; }
if(($match = grep(/--enable-t2k/i, @ARGV)) > 0) { $gopt_enable_t2k = "YES"; }
if(($match = grep(/--enable-fnal/i, @ARGV)) > 0) { $gopt_enable_fnal = "YES"; }
if(($match = grep(/--enable-atmo/i, @ARGV)) > 0) { $gopt_enable_atmo = "YES"; }
if(($match = grep(/--enable-nucleon-decay/i, @ARGV)) > 0) { $gopt_enable_nucleon_decay = "YES"; }
if(($match = grep(/--enable-nnbar-oscillation/i, @ARGV)) > 0) { $gopt_enable_nnbar_oscillation = "YES"; }
if(($match = grep(/--enable-boosted-dark-matter/i, @ARGV)) > 0) { $gopt_enable_boosted_dark_mat = "YES"; }
if(($match = grep(/--enable-masterclass/i, @ARGV)) > 0) { $gopt_enable_masterclass = "YES"; }
# LHAPDF6 and 5 are mutually exlusive
if ($gopt_enable_lhapdf6 eq "YES") { $gopt_enable_lhapdf5 = "NO";}
my $gopt_with_cxx_debug_flag="";
if($gopt_enable_debug eq "YES") { $gopt_with_cxx_debug_flag = "-g"; }
# Check compiler
#
my $gopt_with_compiler="gcc"; # default
if( $options=~m/--with-compiler=(\S*)/i ) {
$gopt_with_compiler = $1;
}
# Check compiler optimization level
#
my $gopt_with_cxx_optimiz_flag="O2"; # default
if( $options=~m/--with-optimiz-level=(\S*)/i ) {
$gopt_with_cxx_optimiz_flag = $1;
}
# If --enable-profiler was set then the full path to the profiler library must be specified
#
my $gopt_with_profiler_lib = "";
if($gopt_enable_profiler eq "YES") {
if(($match = grep(/--with-profiler-lib/i, @ARGV)) > 0) {
$options=~m/--with-profiler-lib=(\S*)/i;
$gopt_with_profiler_lib = $1;
}
}
# If --enable-doxygen-doc was set then the full path to the doxygen binary path must be specified
# unless it is in the $PATH
#
my $gopt_with_doxygen_path = "";
if($gopt_enable_doxygen_doc eq "YES") {
if(($match = grep(/--with-doxygen-path/i, @ARGV)) > 0) {
$options=~m/--with-doxygen-path=(\S*)/i;
$gopt_with_doxygen_path = $1;
}
# if it was not set, try to pick it up from the environment
if(! -d $gopt_with_doxygen_path && defined $ENV{'DOXYGENPATH'}) { $gopt_with_doxygen_path = $ENV{'DOXYGENPATH'}; }
# complain
if(! -d $gopt_with_doxygen_path) {
print "*** Error *** You need to specify the path to doxygen using --with-doxygen-path=/some/path/\n";
print "*** Error *** Otherwise, you should --disable-doxygen-doc\n\n";
exit 1;
}
}
# If --enable-lhapdf5 was set then the full path to the LHAPDF5 library must be specified
#
my $gopt_with_lhapdf5_lib = "";
if($gopt_enable_lhapdf5 eq "YES") {
if(($match = grep(/--with-lhapdf5-lib/i, @ARGV)) > 0) {
$options=~m/--with-lhapdf5-lib=(\S*)/i;
$gopt_with_lhapdf5_lib = $1;
}
if(! -d $gopt_with_lhapdf5_lib) {
print "\n*** Warning *** LHAPDF5 has been enabled but you didn't specify the LHAPDF5 library path \n";
}
# if it was not set, try to pick it up from the environment
if($gopt_with_lhapdf5_lib eq "" && defined $ENV{'LHAPDF5_LIB'}) {
$gopt_with_lhapdf5_lib = $ENV{'LHAPDF5_LIB'};
print "The \$LHAPDF5_LIB env var is defined. I will pick that and use --with-lhapdf5-lib=$gopt_with_lhapdf5_lib\n";
}
# if it still not set, try autodetecting it
if(! -d $gopt_with_lhapdf5_lib && $auto_detect) {
print "Auto-detecting LHAPDF5 library path...\n";
$matched = auto_detect("libLHAPDF.a");
if( $matched=~m/(\S*)\/libLHAPDF.a/i ) {
$gopt_with_lhapdf5_lib = $1;
}
print "Setting --with-lhapdf5-inc=$gopt_with_lhapdf5_lib\n";
}
# check
my $fileso = "$gopt_with_lhapdf5_lib/libLHAPDF.so";
my $filedylib = "$gopt_with_lhapdf5_lib/libLHAPDF.dylib";
if(! -e $fileso && ! -e $filedylib) {
print "*** Error *** You need to specify the path to LHAPDF5 library using --with-lhapdf5-lib=/some/path/\n";
print "*** Error *** Otherwise, you should --disable-lhapdf5\n\n";
exit 1;
}
}
# If --enable-lhapdf5 was set then the full path to the LHAPDF5 includes must be specified
#
my $gopt_with_lhapdf5_inc = "";
if($gopt_enable_lhapdf5 eq "YES") {
if(($match = grep(/--with-lhapdf5-inc/i, @ARGV)) > 0) {
$options=~m/--with-lhapdf5-inc=(\S*)/i;
$gopt_with_lhapdf5_inc = $1;
}
if(! -d $gopt_with_lhapdf5_inc) {
print "\n*** Warning *** LHAPDF5 has been enabled but you didn't specify the LHAPDF5 include path \n";
}
# if it was not set, try to pick it up from the environment
if($gopt_with_lhapdf5_inc eq "" && defined $ENV{'LHAPDF5_INC'}) {
$gopt_with_lhapdf5_inc = $ENV{'LHAPDF5_INC'};
print "The \$LHAPDF5_INC env var is defined. I will pick that and use --with-lhapdf5-inc=$gopt_with_lhapdf5_inc\n";
}
# if it still not set, try autodetecting it
if(! -d $gopt_with_lhapdf5_inc && $auto_detect) {
print "Auto-detecting the LHAPDF5 include path...\n";
$matched = auto_detect("LHAPDF.h","LHAPDF/LHAPDF.h");
print "$gopt_with_lhapdf5_inc \n";
if( $matched=~m/(\S*)\/LHAPDF\/LHAPDF.h/i ) {
$gopt_with_lhapdf5_inc = $1;
}
print "Setting --with-lhapdf5-inc=$gopt_with_lhapdf5_inc\n";
}
# check
my $file = "$gopt_with_lhapdf5_inc/LHAPDF/LHAPDF.h";
if(! -e $file) {
print "*** Error *** You need to specify the LHAPDF5 includes path using --with-lhapdf5-inc=/some/path/\n";
print "*** Error *** Otherwise, you should --disable-lhapdf5\n\n";
exit 1;
}
}
# If --enable-lhapdf6 was set then the full path to the LHAPDF6 library must be specified
#
my $gopt_with_lhapdf6_lib = "";
if($gopt_enable_lhapdf6 eq "YES") {
if(($match = grep(/--with-lhapdf6-lib/i, @ARGV)) > 0) {
$options=~m/--with-lhapdf6-lib=(\S*)/i;
$gopt_with_lhapdf6_lib = $1;
}
if(! -d $gopt_with_lhapdf6_lib) {
print "\n*** Warning *** LHAPDF6 has been enabled but you didn't specify the LHAPDF6 library path \n";
}
# if it was not set, try to pick it up from the environment
if($gopt_with_lhapdf6_lib eq "" && defined $ENV{'LHAPDF6_LIB'}) {
$gopt_with_lhapdf6_lib = $ENV{'LHAPDF6_LIB'};
print "The \$LHAPDF6_LIB env var is defined. I will pick that and use --with-lhapdf6-lib=$gopt_with_lhapdf6_lib\n";
}
# if it still not set, try autodetecting it
if(! -d $gopt_with_lhapdf6_lib && $auto_detect) {
print "Auto-detecting LHAPDF6 library path...\n";
$matched = auto_detect("libLHAPDF.a");
if( $matched=~m/(\S*)\/libLHAPDF.a/i ) {
$gopt_with_lhapdf6_lib = $1;
}
print "Setting --with-lhapdf6-inc=$gopt_with_lhapdf6_lib\n";
}
# check
my $fileso = "$gopt_with_lhapdf6_lib/libLHAPDF.so";
my $filedylib = "$gopt_with_lhapdf6_lib/libLHAPDF.dylib";
if(! -e $fileso && ! -e $filedylib) {
print "*** Error *** You need to specify the path to LHAPDF6 library using --with-lhapdf6-lib=/some/path/\n";
print "*** Error *** Otherwise, you should --disable-lhapdf6\n\n";
exit 1;
}
}
# If --enable-lhapdf6 was set then the full path to the LHAPDF6 includes must be specified
#
my $gopt_with_lhapdf6_inc = "";
if($gopt_enable_lhapdf6 eq "YES") {
if(($match = grep(/--with-lhapdf6-inc/i, @ARGV)) > 0) {
$options=~m/--with-lhapdf6-inc=(\S*)/i;
$gopt_with_lhapdf6_inc = $1;
}
if(! -d $gopt_with_lhapdf6_inc) {
print "\n*** Warning *** LHAPDF6 has been enabled but you didn't specify the LHAPDF6 include path \n";
}
# if it was not set, try to pick it up from the environment
if($gopt_with_lhapdf6_inc eq "" && defined $ENV{'LHAPDF6_INC'}) {
$gopt_with_lhapdf6_inc = $ENV{'LHAPDF6_INC'};
print "The \$LHAPDF6_INC env var is defined. I will pick that and use --with-lhapdf6-inc=$gopt_with_lhapdf6_inc\n";
}
# if it still not set, try autodetecting it
if(! -d $gopt_with_lhapdf6_inc && $auto_detect) {
print "Auto-detecting the LHAPDF6 include path...\n";
$matched = auto_detect("LHAPDF.h","LHAPDF/LHAPDF.h");
print "$gopt_with_lhapdf6_inc \n";
if( $matched=~m/(\S*)\/LHAPDF\/LHAPDF.h/i ) {
$gopt_with_lhapdf6_inc = $1;
}
print "Setting --with-lhapdf6-inc=$gopt_with_lhapdf6_inc\n";
}
# check
my $file = "$gopt_with_lhapdf6_inc/LHAPDF/LHAPDF.h";
if(! -e $file) {
print "*** Error *** You need to specify the LHAPDF6 includes path using --with-lhapdf6-inc=/some/path/\n";
print "*** Error *** Otherwise, you should --disable-lhapdf6\n\n";
exit 1;
}
}
# Get pythia6 library path
#
my $gopt_with_pythia6_lib = "";
if($options=~m/--with-pythia6=\S*/i) {
print "*** Error *** Note that the option --with-pythia6 has been renamed to --with-pythia6-lib \n";
print "*** Error *** Please see './configure --help' for all config option updates \n\n";
exit 1;
}
if($options=~m/--with-pythia6-lib=(\S*)/i) {
$gopt_with_pythia6_lib = $1;
} else {
print "\n*** Warning *** You didn't specify the PYTHIA6 path \n";
}
# if it was not set, try to pick it up from the environment
if(! -d $gopt_with_pythia6_lib && defined $ENV{'PYTHIA6'}) {
$gopt_with_pythia6_lib = $ENV{'PYTHIA6'};
print "The \$PYTHIA6 env var is defined. I will pick that and set --with-pythia6-lib=$gopt_with_pythia6_lib\n";
}
# if it still not set, try autodetecting it
if(! -d $gopt_with_pythia6_lib && $auto_detect)
{
print "Auto-detecting the PYTHIA6 path...\n";
$matched = auto_detect("libPythia6*");
if( $matched=~m/(\S*)\/libPythia6\S*/i ) {
$gopt_with_pythia6_lib = $1;
}
print "Setting --with-pythia6-lib=$gopt_with_pythia6_lib\n";
}
if(! -d $gopt_with_pythia6_lib) {
print "*** Error *** Could not locate the PYTHIA6 library path. Please specify it using --with-pythia6=/some/path/\n\n";
exit 1;
}
# Get libxml2 and log4cpp include and library paths
#
my $gopt_with_libxml2_inc = "";
my $gopt_with_libxml2_lib = "";
my $gopt_with_log4cpp_inc = "";
my $gopt_with_log4cpp_lib = "";
#
# --with-libxml2-inc=
#
if($options=~m/--with-libxml2-inc=(\S*)/i) {
$gopt_with_libxml2_inc = $1;
}
if(! -d $gopt_with_libxml2_inc && $auto_detect) {
print "\n*** Warning *** You didn't specify the libxml2 include path \n";
print "Auto-detecting...\n";
$matched = auto_detect("xmlmemory.h");
if( $matched=~m/(\S*)\/libxml\/xmlmemory.h/i ) {
$gopt_with_libxml2_inc = $1;
}
print "Setting --with-libxml2-inc=$gopt_with_libxml2_inc\n";
}
if(! -d $gopt_with_libxml2_inc) {
print "*** Error *** You need to specify the libxml2 include path using --with-libxml2-inc=/some/path/\n\n";
exit 1;
}
#
# --with-libxml2-lib=
#
if($options=~m/--with-libxml2-lib=(\S*)/i) {
$gopt_with_libxml2_lib = $1;
}
if(! -d $gopt_with_libxml2_lib && $auto_detect) {
print "\n*** Warning *** You didn't specify the libxml2 library path \n";
print "Auto-detecting...\n";
$matched = auto_detect("libxml2.*");
if( $matched=~m/(\S*)\/libxml2\S*/i ) {
$gopt_with_libxml2_lib = $1;
}
print "Setting --with-libxml2-lib=$gopt_with_libxml2_lib\n";
}
if(! -d $gopt_with_libxml2_lib) {
print "*** Error *** You need to specify the libxml2 library path using --with-libxml2-lib=/some/path/\n\n";
exit 1;
}
#
# --with-log4cpp-inc=
#
if($options=~m/--with-log4cpp-inc=(\S*)/i) {
$gopt_with_log4cpp_inc = $1;
}
if(! -d $gopt_with_log4cpp_inc && $auto_detect) {
print "\n*** Warning *** You didn't specify the log4cpp include path \n";
print "Auto-detecting...\n";
$matched = auto_detect("OstreamAppender.hh");
if( $matched=~m/(\S*)\/log4cpp\/OstreamAppender.hh/i ) {
$gopt_with_log4cpp_inc = $1;
}
print "Setting --with-log4cpp-inc=$gopt_with_log4cpp_inc\n";
}
if(! -d $gopt_with_log4cpp_inc) {
print "*** Error *** You need to specify the log4cpp include path using --with-log4cpp-inc=/some/path/\n\n";
exit 1;
}
#
# --with-log4cpp-lib=
#
if($options=~m/--with-log4cpp-lib=(\S*)/i) {
$gopt_with_log4cpp_lib = $1;
}
if(! -d $gopt_with_log4cpp_lib && $auto_detect) {
print "\n*** Warning *** You didn't specify the log4cpp library path \n";
print "Auto-detecting...\n";
$matched = auto_detect("liblog4cpp.*");
if( $matched=~m/(\S*)\/liblog4cpp\S*/i ) {
$gopt_with_log4cpp_lib = $1;
}
print "Setting --with-log4cpp-lib=$gopt_with_log4cpp_lib\n";
}
if(! -d $gopt_with_log4cpp_lib) {
print "*** Error *** You need to specify the log4cpp library path using --with-log4cpp-lib=/some/path/\n\n";
exit 1;
}
# Save config options
#
print MKCONF "GOPT_ENABLE_LHAPDF5=$gopt_enable_lhapdf5\n";
print MKCONF "GOPT_ENABLE_LHAPDF6=$gopt_enable_lhapdf6\n";
print MKCONF "GOPT_ENABLE_T2K=$gopt_enable_t2k\n";
print MKCONF "GOPT_ENABLE_FNAL=$gopt_enable_fnal\n";
print MKCONF "GOPT_ENABLE_ATMO=$gopt_enable_atmo\n";
print MKCONF "GOPT_ENABLE_NUCLEON_DECAY=$gopt_enable_nucleon_decay\n";
print MKCONF "GOPT_ENABLE_NNBAR_OSCILLATION=$gopt_enable_nnbar_oscillation\n";
print MKCONF "GOPT_ENABLE_BOOSTED_DARK_MATTER=$gopt_enable_boosted_dark_mat\n";
print MKCONF "GOPT_ENABLE_FLUX_DRIVERS=$gopt_enable_flux_drivers\n";
print MKCONF "GOPT_ENABLE_GEOM_DRIVERS=$gopt_enable_geom_drivers\n";
print MKCONF "GOPT_ENABLE_MASTERCLASS=$gopt_enable_masterclass\n";
print MKCONF "GOPT_ENABLE_TEST=$gopt_enable_test\n";
print MKCONF "GOPT_ENABLE_PROFILER=$gopt_enable_profiler\n";
print MKCONF "GOPT_ENABLE_DOXYGEN_DOC=$gopt_enable_doxygen_doc\n";
print MKCONF "GOPT_ENABLE_DYLIBVERSION=$gopt_enable_dylibversion\n";
print MKCONF "GOPT_ENABLE_LOW_LEVEL_MESG=$gopt_enable_lowlevel_mesg\n";
print MKCONF "GOPT_WITH_COMPILER=$gopt_with_compiler\n";
print MKCONF "GOPT_WITH_CXX_DEBUG_FLAG=$gopt_with_cxx_debug_flag\n";
print MKCONF "GOPT_WITH_CXX_OPTIMIZ_FLAG=-$gopt_with_cxx_optimiz_flag\n";
print MKCONF "GOPT_WITH_PROFILER_LIB=$gopt_with_profiler_lib\n";
print MKCONF "GOPT_WITH_DOXYGEN_PATH=$gopt_with_doxygen_path\n";
print MKCONF "GOPT_WITH_PYTHIA6_LIB=$gopt_with_pythia6_lib\n";
print MKCONF "GOPT_WITH_LHAPDF5_LIB=$gopt_with_lhapdf5_lib\n";
print MKCONF "GOPT_WITH_LHAPDF5_INC=$gopt_with_lhapdf5_inc\n";
print MKCONF "GOPT_WITH_LHAPDF6_LIB=$gopt_with_lhapdf6_lib\n";
print MKCONF "GOPT_WITH_LHAPDF6_INC=$gopt_with_lhapdf6_inc\n";
print MKCONF "GOPT_WITH_LIBXML2_INC=$gopt_with_libxml2_inc\n";
print MKCONF "GOPT_WITH_LIBXML2_LIB=$gopt_with_libxml2_lib\n";
print MKCONF "GOPT_WITH_LOG4CPP_INC=$gopt_with_log4cpp_inc\n";
print MKCONF "GOPT_WITH_LOG4CPP_LIB=$gopt_with_log4cpp_lib\n";
close(MKCONF);
print "\nYour input configuration options were: @ARGV";
if($#ARGV < 0) { print "(none)" };
print "\n\n";
if(-e $MKCONF_FILE) {
print "The $MKCONF_FILE file has been succesfully generated! \n";
print "The following config options were set: \n";
open(MKCONFR, "<$MKCONF_FILE") or die("Can not read back the $GENIE/src/make/Make.config!");
@make_conf=<MKCONFR>;
close(MKCONFR);
# print "@make_conf\n" unless ;
foreach $setting (@make_conf) {
chomp($setting);
if ($setting=~m/\=/) {print " $setting\n";}
}
# Copy only the enable/disable options, excluding paths, in a separate file for genie-config.
# This is needed for FNAL relocatable releases.
system("cat $MKCONF_FILE | grep GOPT_ENABLE_ > $MKCONF_FILE\_no_paths");
print "\n";
print "*** To continue building GENIE type: make ";
# Warning for SRT users
if(defined $ENV{'SRT_ENV_SET'}) {
print "(Don't forget to 'srt_setup --unsetup' first)";
}
print "\n\n";
exit 0;
}
sub auto_detect {
# First place to look when autodetecting is in the directories in LD_LIBRARY_PATH
my @libdirs = ( );
push (@libdirs,split(":",$ENV{LD_LIBRARY_PATH})) if defined $ENV{LD_LIBRARY_PATH};
push (@libdirs,split(":",$ENV{DYLD_LIBRARY_PATH})) if defined $ENV{DYLD_LIBRARY_PATH}; #and the mac equivalent
my @search_dir = ();
foreach my $libdir (unique_entries(@libdirs)) {
chomp($libdir);
if (not $libdir) {next;}
push (@search_dir, $libdir); # Append the LD library path directory
@pathdirs = split("/",$libdir);
$lastdir = pop(@pathdirs);
$basedir = join("/",@pathdirs);
if ($lastdir =~ m/lib/) {# If the LD_LIBRARY_PATH has "lib" in it, append "../include"
push (@search_dir, $basedir."/include");
}
}
push (@search_dir,"/usr"); # Add usr
push (@search_dir,"/lib"); # Add opt
push (@search_dir,"/opt"); # Add opt
push (@search_dir,"$ENV{'HOME'}")
if defined $ENV{'HOME'}; # add $HOME
push (@search_dir,"/hep"); # add where I add ext apps in my mac book air
push (@search_dir,"$ENV{'RSD_TOP_DIR'}")
if defined $ENV{'RSD_TOP_DIR'}; # add where RSD puts ext supporting libs
@search_dir = unique_entries(@search_dir); # Search each dir only once
$search_file = shift;
$optional_fullpath_substr = shift; # extra help in locating the correct file
$optional_fullpath_substr = "" unless defined $optional_fullpath_substr;
foreach(@search_dir) {
$curr_dir = $_;
if(! -d $curr_dir) {next;}
@matches = `find $curr_dir/ -type f -maxdepth 7 -name \"$search_file\" 2> /dev/null | grep \"$optional_fullpath_substr\"`;
$nmatches = @matches;
if( $nmatches > 0) { return $matches[0]; }
}
return "";
}
# Get unique entries in an array
sub unique_entries {
my %seen;
return grep { !$seen{$_}++ } @_;
}