summaryrefslogtreecommitdiff
path: root/Makefile
blob: d4b459800e8474ad250008f1ba3e08d1b65e76f1 (plain)
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
# /*@@  
#   @file      Makefile
#   @date      Sun Jan 17 22:26:05 1999
#   @author    Tom Goodale
#   @desc 
#   gnu Makefile for the CCTK.
#
# WARNING: This makefile may not function with "make".  Errors like
# make: file `Makefile' line 36: Must be a separator (: or ::) for rules (bu39)
# mean you should have used gmake.  gmake is available free
# from ftp://prep.ai.mit.edu/ and should be installed on all production
# systems.
#
# For information on how to use this makefile, type
# gmake help
#
#   
#   @enddesc 
#   @version $Id: Makefile,v 1.96 2000-07-22 17:22:28 goodale Exp $
# @@*/

##################################################################################
# Version number
##################################################################################
CCTK_VERSION_MAJOR = 4
CCTK_VERSION_MINOR = 0
CCTK_VERSION_OTHER = b8
##################################################################################
CCTK_VERSION=$(CCTK_VERSION_MAJOR).$(CCTK_VERSION_MINOR).$(CCTK_VERSION_OTHER)
##################################################################################
export CCTK_VERSION_MAJOR CCTK_VERSION_MINOR CCTK_VERSION_OTHER CCTK_VERSION
##################################################################################

# Stop with prompts unless told not to
ifeq ($(strip $(PROMPT)), )
PROMPT = "yes"
endif

export PROMPT

# Make quietly unless told not to
ifneq ($(strip $(SILENT)),no)
.SILENT:
endif

# Stuff for parallel makes
# TJOBS is the number of thorns to compile in parallel
ifeq ($(strip $(TJOBS)), )
TPARFLAGS = 
else
TPARFLAGS = -j $(TJOBS)
endif

# FJOBS is the number of files within a thorn to compile in parallel
ifeq ($(strip $(FJOBS)), )
FPARFLAGS = 
else
FPARFLAGS = -j $(FJOBS)
endif

export TPARFLAGS FPARFLAGS

# Directory for configuration options
ifeq ($(strip $(THORNLIST_DIR)), )
THORNLIST_DIR = "."
endif

# End of parallel make stuff


# Set the options to pass to the setup script
ifneq ($(strip $(options)),)
SETUP_OPTIONS = -config_file=$(options)
else
SETUP_OPTIONS = 
endif


# Allow various options to be passed to the configure script

SETUP_ENV = 

ifdef CC
ifneq ($(strip $(origin CC)), default)
SETUP_ENV += CC=$(CC) ; export CC ;
endif
endif

ifdef F90
ifneq ($(strip $(origin F90)), default)
SETUP_ENV += F90=$(F90) ; export F90 ;
endif
endif

ifdef F77
ifneq ($(strip $(origin F77)), default)
SETUP_ENV += F77=$(F77) ; export F77 ;
endif
endif

ifdef LD
ifneq ($(strip $(origin LD)), default)
SETUP_ENV += LD=$(LD) ; export LD ;
endif
endif

ifdef CFLAGS
ifneq ($(strip $(origin CFLAGS)), default)
SETUP_ENV += CFLAGS=$(CFLAGS) ; export CFLAGS;
endif
endif

ifdef F90FLAGS
ifneq ($(strip $(origin F90FLAGS)), default)
SETUP_ENV += F90FLAGS=$(F90FLAGS) ; export F90FLAGS ;
endif
endif

ifdef F77FLAGS
ifneq ($(strip $(origin F77FLAGS)), default)
SETUP_ENV += F77FLAGS=$(F77FLAGS) ; export F90FLAGS ;
endif
endif

ifdef LDFLAGS
ifneq ($(strip $(origin LDFLAGS)), default)
SETUP_ENV += LDFLAGS=$(LDFLAGS) ; export LDFLAGS ;
endif
endif

ifdef REAL_PRECISION
ifneq ($(strip $(origin REAL_PRECISION)), default)
SETUP_ENV += REAL_PRECISION=$(REAL_PRECISION) ; export REAL_PRECISION ;
endif
endif

ifdef INTEGER_PRECISION
ifneq ($(strip $(origin INTEGER_PRECISION)), default)
SETUP_ENV += INTEGER_PRECISION=$(INTEGER_PRECISION) ; export INTEGER_PRECISION ;
endif
endif

# Arrangement options

ifdef MPI
ifneq ($(strip $(origin MPI)), default)
SETUP_ENV += MPI=$(MPI) ; export MPI ;
endif
endif

# Debug options
ifdef DEBUG
ifneq ($(strip $(origin DEBUG)), default)
SETUP_ENV += DEBUG=$(DEBUG) ; export DEBUG ;
endif
endif

# Optimisation options
ifdef OPTIMISE
ifneq ($(strip $(origin OPTIMISE)), default)
SETUP_ENV += OPTIMISE=$(OPTIMISE) ; export OPTIMISE ;
endif
endif

# Compile-time options

# Warning options
ifdef WARN
CCTK_WARN_MODE=$(WARN)
else
CCTK_WARN_MODE=no
endif

export CCTK_WARN_MODE

# Various auxilary programs
PERL = perl
SETUP    = lib/make/setup_configuration.pl
NEWTHORN = lib/make/new_thorn.pl
BUILD_ACTIVETHORNS = lib/sbin/BuildActiveThorns.pl

# Dividers to make the screen output slightly nicer
DIVEL   =  __________________
DIVIDER =  $(DIVEL)$(DIVEL)$(DIVEL)$(DIVEL)

# Work out where we are
export CCTK_HOME := $(shell pwd | sed 's,^//\(.\)/,\1:/,' )

# Work out where the configuration directory is
ifdef CACTUS_CONFIGS_DIR
CONFIGS_DIR = $(CACTUS_CONFIGS_DIR)
else
CONFIGS_DIR = $(CCTK_HOME)/configs
endif

export CONFIGS_DIR

# Work out which configurations are available
CONFIGURATIONS = $(patsubst $(CONFIGS_DIR)/%,%,$(wildcard $(CONFIGS_DIR)/*))

# Default target does nothing. 
# Used to set up a default based upon uname or something.
.PHONY:default-target

default-target:
ifeq ($(strip $(CONFIGURATIONS)),)
	@echo $(DIVIDER)
	@echo No configurations defined. 
	@echo Please use \'$(MAKE) \<name\>\' to setup a configuration called \<name\>.
	@echo $(DIVIDER)
	@echo \'$(MAKE) help\' lists all $(MAKE) options.
else
ifeq ($(words $(CONFIGURATIONS)), 1)
	@echo Please use $(MAKE) $(CONFIGURATIONS) 
	@echo $(DIVIDER)
	@echo \'$(MAKE) help\' lists all $(MAKE) options.
else
	@echo Known configurations are: $(CONFIGURATIONS)
	@echo Please use $(MAKE) \<configuration\>
	@echo $(DIVIDER)
	@echo \'$(MAKE) help\' lists all $(MAKE) options.
endif
endif
	@echo $(DIVIDER)

# Target to build a configuration
.PHONY: $(CONFIGURATIONS)

$(CONFIGURATIONS):
	cd $(CONFIGS_DIR)/$@ 
	$(MAKE) -f $(CCTK_HOME)/lib/make/make.configuration TOP=$(CONFIGS_DIR)/$@ CCTK_HOME=$(CCTK_HOME) $(TPARFLAGS)

# Clean target
.PHONY: distclean

distclean:
	@echo $(DIVIDER)
	@echo Deleting all your configurations !
	rm -rf $(CONFIGS_DIR)
	@echo $(DIVIDER)

# Targets to make tags files

# Mark these targets phony to force an update when gmake TAGS is done.
.PHONY: TAGS tags

TAGS:
	@echo $(DIVIDER)
	@echo Updating the Emacs TAGS file
	rm -f TAGS ; touch TAGS 
	find src arrangements \( -name '*.[chCF]' -o -name '*.F77' -o -name '*.cc' -o -name '*.[ch]pp' \) \
          -exec etags -a {} \;
#	find src arrangements \( -name '*.[cChF]' -o -name '*.F77' -o -name '*.cc'\) \
#          -exec etags --append --regex '/[a-z A-Z \t]*FORTRAN_NAME[^)]*/' {} \;
	$(PERL) -pi -e 's/(subroutine\s*)([a-zA-Z0-9_]+)/\1\L\2/g;' TAGS
	@echo $(DIVIDER)

tags:
	@echo $(DIVIDER)
	@echo Updating the vi tags file
	rm -f tags ; touch tags 
	find src arrangements \( -name '*.[cChF]' -o -name '*.F77' -o -name '*.cc' -o -name '*.[ch]pp' \) \
          -exec ctags -a {} \;
	$(PERL) -pi -e 's/(subroutine\s*)([a-zA-Z0-9_]+)/\1\L\2/g;' tags
	sort tags > sortedtags ; mv sortedtags tags
	@echo $(DIVIDER)

# Make a new configuration with a default name
.PHONY: default

default:
	@echo $(DIVIDER)
	@echo Running the configuration program
	$(SETUP_ENV) $(PERL) -s $(SETUP) $(SETUP_OPTIONS)
	@echo $(DIVIDER)
	@echo You are now ready to build the CCTK.
	@echo This is done by $(MAKE) \<configuration\>
	@echo $(DIVIDER)

# The help system.
.PHONY: help

help:
	@echo $(DIVIDER)
	@echo "****************************** "
	@echo "* Welcome to the Cactus Code *"
	@echo "******************************"
ifeq ($(strip $(CONFIGURATIONS)),)
	@echo There are no configurations currently specified.
	@echo \'$(MAKE) \<name\>\' will run a setup script to setup a configuration called \'\<name\>\'.
else
	@echo The following configurations are currently specified
	@echo 
	@echo "  $(CONFIGURATIONS)"
	@echo $(DIVIDER)
	@echo "To build a configuration: "
	@echo "  run $(MAKE) followed by the name of a configuration."
	@echo $(DIVIDER)
	@echo There is a range of options available to act on a configuration.
	@echo These are activated by $(MAKE) \<conf-name\>-\<option\>
	@echo Valid options are
	@echo "  -clean         : to clean a configuration."
	@echo "                  (deletes all object and dependency files in "
	@echo "                   the configuration)."
	@echo "  -cleandeps     : to clean a configuration's dependency files."
	@echo "  -cleanobjs     : to clean a configuration's object files."
	@echo "  -config        : to (re)configure a configuration. "
	@echo "                  (runs or reruns the configuration scripts)."
	@echo "  -delete        : to delete a configuration." 
	@echo "  -editthorns    : edits the ThornList file. "
	@echo "  -realclean     : to restore a configuration to almost a new state. "
	@echo "                  (deletes all but the config-data directory "
	@echo "                   and the ThornList file)."
	@echo "  -rebuild       : to rebuild a configuration." 
	@echo "                  (forces the CST to be rerun)."
	@echo "  -testsuite     : run the test program."
	@echo "  -thornlist     : regenerates the ThornList file. "
	@echo "  -examples      : copies thorn parameter files to examples directory."
endif
	@echo $(DIVIDER)
	@echo $(MAKE) also knows the following targets
	@echo
	@echo "  checkout         - checkout public arrangements/thorns."
	@echo "  cvsdiff          - differences between installed Cactus and"
	@echo "	                    version in CVS repository."
	@echo "  cvsstatus        - reports on status of Cactus when installed"
	@echo "	                    from CVS."
	@echo "  default          - creates a new configuration with "
	@echo "			    a default name."
	@echo "  distclean        - deletes all existing configurations."
	@echo "  downsize         - remove non-essential files."
	@echo "  MaintGuide       - creates maintainers manual, MaintGuide.ps."
	@echo "  newthorn         - creates a new thorn."
	@echo "  TAGS             - creates an Emacs TAGS file."
	@echo "  tags             - creates a Vi TAGS file."
	@echo "  thorninfo        - give information about all available "
	@echo "                     thorns."
	@echo "  UsersGuide       - creates users manual UsersGuide.ps."
	@echo "  <anything else>  - prompts to create such a configuration."
	@echo $(DIVIDER)

# Clean a configuration

.PHONY clean:

clean:
	@echo $(DIVIDER)
	@echo Please specify a configuration to clean.
	@echo $(DIVIDER)

ifneq ($strip($(CONFIGURATIONS)),)
.PHONY $(addsuffix -clean,$(CONFIGURATIONS)):

$(addsuffix -clean,$(CONFIGURATIONS)):
	@echo $(DIVIDER)
	@echo Cleaning configuration $(@:%-clean=%)
	cd $(CONFIGS_DIR)/$(@:%-clean=%)  
	$(MAKE) -f $(CCTK_HOME)/lib/make/make.configuration TOP=$(CONFIGS_DIR)/$(@:%-clean=%) CCTK_HOME=$(CCTK_HOME) clean
	@echo $(DIVIDER)

endif

%-clean:
	@echo $(DIVIDER)
	@echo Configuration $(@:%-clean=%) does not exist.
	@echo Cleaning aborted.


# Clean just dependency files

.PHONY cleandeps:

cleandeps:
	@echo $(DIVIDER)
	@echo Please specify a configuration to clean the dependencies of.
	@echo $(DIVIDER)

ifneq ($strip($(CONFIGURATIONS)),)
.PHONY $(addsuffix -cleandeps,$(CONFIGURATIONS)):

$(addsuffix -cleandeps,$(CONFIGURATIONS)):
	@echo $(DIVIDER)
	@echo Cleaning configuration $(@:%-cleandeps=%)
	cd $(CONFIGS_DIR)/$(@:%-cleandeps=%)  
	$(MAKE) -f $(CCTK_HOME)/lib/make/make.configuration TOP=$(CONFIGS_DIR)/$(@:%-cleandeps=%) CCTK_HOME=$(CCTK_HOME) cleandeps
	@echo $(DIVIDER)

endif

%-cleandeps:
	@echo $(DIVIDER)
	@echo Configuration $(@:%-cleandeps=%) does not exist.
	@echo Cleaning dependencies aborted.


# Clean just object files

.PHONY cleanobjs:

cleanobjs:
	@echo $(DIVIDER)
	@echo Please specify a configuration to clean the object files of.
	@echo $(DIVIDER)


ifneq ($strip($(CONFIGURATIONS)),)
.PHONY $(addsuffix -cleanobjs,$(CONFIGURATIONS)):

$(addsuffix -cleanobjs,$(CONFIGURATIONS)):
	@echo $(DIVIDER)
	@echo Cleaning configuration $(@:%-cleanobjs=%)
	cd $(CONFIGS_DIR)/$(@:%-cleanobjs=%)  
	$(MAKE) -f $(CCTK_HOME)/lib/make/make.configuration TOP=$(CONFIGS_DIR)/$(@:%-cleanobjs=%) CCTK_HOME=$(CCTK_HOME) cleanobjs
	@echo $(DIVIDER)

endif

%-cleanobjs:
	@echo $(DIVIDER)
	@echo Configuration $(@:%-cleanobjs=%) does not exist.
	@echo Cleaning object files aborted.


# Clean away all produced files (doesn't delete ThornList)

.PHONY realclean:

realclean:
	@echo $(DIVIDER)
	@echo Please specify a configuration to really clean.
	@echo $(DIVIDER)


ifneq ($strip($(CONFIGURATIONS)),)
.PHONY $(addsuffix -realclean,$(CONFIGURATIONS)):

$(addsuffix -realclean,$(CONFIGURATIONS)):
	@echo $(DIVIDER)
	@echo Cleaning configuration $(@:%-realclean=%)
	cd $(CONFIGS_DIR)/$(@:%-realclean=%)  
	$(MAKE) -f $(CCTK_HOME)/lib/make/make.configuration TOP=$(CONFIGS_DIR)/$(@:%-realclean=%) CCTK_HOME=$(CCTK_HOME) realclean
	@echo $(DIVIDER)

endif

%-realclean:
	@echo $(DIVIDER)
	@echo Configuration $(@:%-realclean=%) does not exist.
	@echo Cleaning aborted.

# Delete a configuration

.PHONY delete:

delete:
	@echo $(DIVIDER)
	@echo Please specify a configuration to delete.
	@echo $(DIVIDER)


ifneq ($strip($(CONFIGURATIONS)),)
.PHONY $(addsuffix -delete,$(CONFIGURATIONS)):

$(addsuffix -delete,$(CONFIGURATIONS)):
	@echo $(DIVIDER)
	if test "x$(DELETE_CONFIRMATION)" = "xyes" ; then          \
	  echo "Really delete configuration $(@:%-delete=%) (no)?";\
	  read yesno rest ;                                        \
	  if test "x$$yesno" = "xyes" ; then                       \
	    confirm=yes ;                                          \
	  else                                                     \
	    confirm=no ;                                           \
	  fi ;                                                     \
	else                                                       \
	  confirm=yes ;                                            \
	fi ;                                                       \
	if test "x$$confirm" = "xyes" ; then                       \
	  echo Deleting configuration $(@:%-delete=%);             \
	  cd $(CONFIGS_DIR) ; rm -rf $(@:%-delete=%) ;             \
	fi 
	@echo $(DIVIDER)
endif

%-delete:
	@echo $(DIVIDER)
	@echo Configuration $(@:%-delete=%) does not exist.
	@echo Deletion aborted.

# Rebuild a configuration

.PHONY rebuild:

rebuild:
	@echo $(DIVIDER)
	@echo Please specify a configuration to rebuild.
	@echo $(DIVIDER)

ifneq ($strip($(CONFIGURATIONS)),)
.PHONY $(addsuffix -rebuild,$(CONFIGURATIONS)):

$(addsuffix -rebuild,$(CONFIGURATIONS)):
	@echo $(DIVIDER)
	@echo Rebuilding $(@:%-rebuild=%)
	if [ -r $(CONFIGS_DIR)/$(@:%-rebuild=%)/config-data/make.thornlist ] ; then rm  $(CONFIGS_DIR)/$(@:%-rebuild=%)/config-data/make.thornlist ; fi
	$(MAKE) $(@:%-rebuild=%)
endif

%-rebuild:
	@echo $(DIVIDER)
	@echo Configuration $(@:%-rebuild=%) does not exist.
	@echo Rebuild aborted.

# Regenerate the compiled thorns list

.PHONY thornlist:

thornlist:
	@echo $(DIVIDER)
	@echo Please specify a configuration to regenerate the thornlist of.
	@echo $(DIVIDER)


ifneq ($strip($(CONFIGURATIONS)),) 
.PHONY $(addsuffix -thornlist,$(CONFIGURATIONS)):

$(addsuffix -thornlist,$(CONFIGURATIONS)):
	@echo $(DIVIDER)
	@echo Regenerating compiled ThornList $(@:%-thornlist=%)
	if [ -r $(CONFIGS_DIR)/$(@:%-thornlist=%)/ThornList ] ; then rm $(CONFIGS_DIR)/$(@:%-thornlist=%)/ThornList ; fi
	$(MAKE) $(@:%-thornlist=%)
endif

%-thornlist:
	@echo $(DIVIDER)
	@echo Configuration $(@:%-thornlist=%) does not exist.
	@echo Regeneration of compiled ThornList aborted.

# Edit the thornlist

.PHONY editthorn:

editthorns:
	@echo $(DIVIDER)
	@echo Please specify a configuration to edit the thornlist of.
	@echo $(DIVIDER)


ifneq ($strip($(CONFIGURATIONS)),) 
.PHONY $(addsuffix -editthorns,$(CONFIGURATIONS)):

$(addsuffix -editthorns,$(CONFIGURATIONS)):
	@echo $(DIVIDER)
	@echo Editing compiled ThornList $(@:%-editthorn=%)
	$(MAKE) -f $(CCTK_HOME)/lib/make/make.configuration TOP=$(CONFIGS_DIR)/$(@:%-editthorns=%) CCTK_HOME=$(CCTK_HOME) editthorns
endif

%-editthorns:
	@echo $(DIVIDER)
	@echo Configuration $(@:%-editthorns=%) does not exist.
	@echo Editing of compiled ThornList aborted.

# Rerun the configuration script

.PHONY config:

config:
	@echo $(DIVIDER)
	@echo Please specify a configuration to configure.
	@echo $(DIVIDER)


ifneq ($strip($(CONFIGURATIONS)),)
.PHONY $(addsuffix -config,$(CONFIGURATIONS)):

$(addsuffix -config,$(CONFIGURATIONS)):
	echo $(DIVIDER)
	if test -z "$(THORNLIST)" || (test -n "$(THORNLIST)" && test -r "$(THORNLIST_DIR)/$(THORNLIST)") ; \
	then \
	  if ($(SETUP_ENV) $(PERL) -s $(SETUP) -reconfig=1 $(SETUP_OPTIONS) $(@:%-config=%)) ; then : ; else \
            echo "" ;                                                      \
            echo "Error reconfiguring $@" ;                                \
            exit 2                                 ;                       \
          fi ;                                                             \
	  if test -n "$(THORNLIST)" ; \
	  then \
	    cp $(THORNLIST_DIR)/$(THORNLIST) $(CONFIGS_DIR)/$(@:%-config=%)/ThornList;\
	  fi ; \
	  echo $(DIVIDER) ; \
	  if test "x$(PROMPT)" = "xno" ; then \
	    $(MAKE) $(@:%-config=%) WARN=$(WARN); \
	  else \
	    echo Use $(MAKE) $(@:%-config=%) to build the configuration. ; \
	  fi; \
	  else \
	  echo "ThornList $(THORNLIST_DIR)/$(THORNLIST) does not exist" ; \
	fi 
	@echo $(DIVIDER)
endif

%-config:
	@echo $(DIVIDER)
	@echo Configuration $(@:%-config=%) does not exist.; 
	if test "x$(PROMPT)" = "xyes" ; then \
	  echo Setup configuration $(@:%-config=%) \(yes\)?; \
	  read yesno rest ; \
	fi; \
	if [ "x$$yesno" = "xno" -o "x$$yesno" = "xn" -o "x$$yesno" = "xNO" -o "x$$yesno" = "xN" ] ;\
	then \
	  echo Setup cancelled ;     \
	else \
	  echo Setting up new configuration $(@:%-config=%); \
	  if test -z "$(THORNLIST)" || (test -n "$(THORNLIST)" && test -r "$(THORNLIST_DIR)/$(THORNLIST)") ; \
	  then \
	    if ($(SETUP_ENV) $(PERL) -s $(SETUP) $(SETUP_OPTIONS) $(@:%-config=%)) ; then : ; else \
              echo "" ;                                                      \
              echo "Error creating configuration $(@;%-config=%)" ;                       \
              exit 2                                 ;                       \
            fi ;                                                             \
	    if test -n "$(THORNLIST)"; \
	    then \
	      cp $(THORNLIST_DIR)/$(THORNLIST) $(CONFIGS_DIR)/$(@:%-config=%)/ThornList;\
	    fi ;\
	    echo $(DIVIDER)   ;  \
	    if test "x$(PROMPT)" = "xno" ; then \
	      $(MAKE) $(@:%-config=%) WARN=$(WARN); \
	    else \
	      echo Use $(MAKE) $(@:%-config=%) to build the configuration.; \
	    fi; \
	  else \
	    echo "ThornList $(THORNLIST_DIR)/$(THORNLIST) does not exist" ; \
	  fi ; \
	fi 
	@echo $(DIVIDER)

.PHONY utils:

utils:
	@echo $(DIVIDER)
	@echo Please specify a configuration to build the utilities of.
	@echo $(DIVIDER)


ifneq ($strip($(CONFIGURATIONS)),)
.PHONY $(addsuffix -utils,$(CONFIGURATIONS)):

$(addsuffix -utils,$(CONFIGURATIONS)):
	@echo $(DIVIDER)
	@echo Building utilities for $(@:%-utils=%)
	cd $(CONFIGS_DIR)/$(@:%-utils=%)  
	$(MAKE) -f $(CCTK_HOME)/lib/make/make.configuration TOP=$(CONFIGS_DIR)/$(@:%-utils=%) CCTK_HOME=$(CCTK_HOME) utils UTILS=$(UTILS) CONFIG_NAME=$(@:%-utils=%)
	@echo $(DIVIDER)

endif

%-utils:
	@echo $(DIVIDER)
	@echo Configuration $(@:%-utils=%) does not exist.
	@echo Building of utilities aborted.

# Make a new thorn

.PHONY: newthorn
newthorn:
	@echo $(DIVIDER)
	@echo Creating a new thorn
	$(PERL) -s $(NEWTHORN);
	@echo $(DIVIDER)


# Run the testsuite

.PHONY testsuite:

testsuite:
	@echo $(DIVIDER)
	@echo Please specify a configuration to test.
	@echo $(DIVIDER)


ifneq ($strip($(CONFIGURATIONS)),) 
.PHONY $(addsuffix -testsuite,$(CONFIGURATIONS)):

$(addsuffix -testsuite,$(CONFIGURATIONS)):
	@echo $(DIVIDER)
	@echo Running test suite $(@:%-thornlist=%)
	if [ -r $(CONFIGS_DIR)/$(@:%-testsuite=%)/ThornList ] ; then $(PERL) lib/sbin/Runtest.pl $(PROMPT) $(@:%-testsuite=%) ; fi
endif

%-testsuite:
	@echo $(DIVIDER)
	@echo Configuration $(@:%-testsuite=%) does not exist.
	@echo Test suite aborted.


ifneq ($strip($(CONFIGURATIONS)),) 
.PHONY $(addsuffix -examples,$(CONFIGURATIONS)):

# Copy thorn parameter files
.PHONY examples:

examples:
	@echo $(DIVIDER)
	@echo Please specify a configuration.
	@echo $(DIVIDER)


$(addsuffix -examples,$(CONFIGURATIONS)):
	@echo $(DIVIDER)
	@echo Copying parameter files $(@:%-examples=%)
	if [ -r $(CONFIGS_DIR)/$(@:%-examples=%)/ThornList ] ; then $(PERL) lib/sbin/CopyParFiles.pl $(@:%-examples=%) ; fi
endif

%-examples:
	@echo $(DIVIDER)
	@echo Configuration $(@:%-examples=%) does not exist.
	@echo Parameter file copying aborted.


# Checkout public thorns and arrangements

.PHONY: checkout
checkout:
	@echo $(DIVIDER)
	@echo Running app/arrangement/thorn checkout script
	$(PERL) ./lib/sbin/checkout.pl

# Create sysinfo file

.PHONY sysinfo:

sysinfo:
	@echo $(DIVIDER)
	@echo Please specify a configuration to run sysinfo with.
	@echo $(DIVIDER)

ifneq ($strip($(CONFIGURATIONS)),) 
.PHONY $(addsuffix -sysinfo,$(CONFIGURATIONS)):

$(addsuffix -sysinfo,$(CONFIGURATIONS)):
	@echo $(DIVIDER)
	@echo Running SystemInfo
	$(PERL) ./lib/sbin/SystemInfo.pl $(@:%-sysinfo=%) 
endif


# Create bugreport

.PHONY bugreport:

bugreport:
	$(SHELL) ./lib/sbin/cctkbug


ifneq ($strip($(CONFIGURATIONS)),) 
.PHONY $(addsuffix -bugreport,$(CONFIGURATIONS)):

$(addsuffix -bugreport,$(CONFIGURATIONS)):
	$(SHELL) ./lib/sbin/cctkbug -c $(CONFIGS_DIR)/$(@:%-bugreport=%) 
endif

# Make the users manuals

.PHONY: UsersGuide
UsersGuide:
	@echo $(DIVIDER)
	@echo Creating user documentation UsersGuide.ps
	(cd doc/UsersGuide; latex UsersGuide.tex; latex UsersGuide.tex; dvips ./UsersGuide.dvi -o $(CCTK_HOME)/UsersGuide.ps) ; cd $(CCTK_HOME);
	@echo $(DIVIDER)

.PHONY: MaintGuide
MaintGuide:
	@echo $(DIVIDER)
	@echo Creating maintainers documentation MaintGuide.ps
	(cd doc/MaintGuide; latex MaintGuide.tex; latex MaintGuide.tex; dvips ./MaintGuide.dvi -o $(CCTK_HOME)/MaintGuide.ps) ; cd $(CCTK_HOME);
	@echo $(DIVIDER)

# Rule to show thorn information

.PHONY: thorninfo
thorninfo:
	@echo $(DIVIDER)
	@echo Displaying info for all thorns in the arrangements directory
	$(PERL) -s $(BUILD_ACTIVETHORNS) $(CCTK_HOME)/arrangements | cat;
	@echo $(DIVIDER)

# Processed CVS information

.PHONY: 
cvsstatus:
	$(PERL) -s $(CCTK_HOME)/lib/sbin/CVSStatus.pl     

.PHONY: 
cvsdiff:
	$(PERL) -s $(CCTK_HOME)/lib/sbin/CVSStatus.pl -case=diff

# Remove non-essential files

.PHONY: downsize
downsize:
	@echo $(DIVIDER)
	@echo Remove flesh and thorn documentation \(\no\)?
	read yesno rest ;\
	if [ "x$$yesno" = "xyes" -o "x$$yesno" = "xy" -o "x$$yesno" = "xYES" -o "x$$yesno" = "xY" ] ;\
	then  \
	rm -rf doc; rm -rf arrangements/*/*/doc; \
	echo $(DIVIDER)   ;  \
	fi 
	@echo Remove thorn testsuites \(\no\)?
	read yesno rest ;\
	if [ "x$$yesno" = "xyes" -o "x$$yesno" = "xy" -o "x$$yesno" = "xYES" -o "x$$yesno" = "xY" ] ;\
	then  \
	rm -rf arrangements/*/*/test; \
	echo $(DIVIDER)   ;  \
	fi 
	@echo Remove all configurations \(\no\)?
	read yesno rest ;\
	if [ "x$$yesno" = "xyes" -o "x$$yesno" = "xy" -o "x$$yesno" = "xYES" -o "x$$yesno" = "xY" ] ;\
	then  \
	$(MAKE) distclean; \
	echo $(DIVIDER)   ;  \
	fi 

# Last resort rule.  Assume it is the name of a configuration

%::
	@echo $(DIVIDER)
	if test "x$(PROMPT)" = "xyes" ; then \
	  echo Setup configuration $@ \(yes\)?; \
	  read yesno rest ; \
	fi; \
	if [ "x$$yesno" = "xno" -o "x$$yesno" = "xn" -o "x$$yesno" = "xNO" -o "x$$yesno" = "xN" ] ; \
	then  \
	  echo Setup cancelled ; \
	else \
	  echo Setting up new configuration $@ ; \
	  if test -z "$(THORNLIST)" || (test -n "$(THORNLIST)" && test -r "$(THORNLIST_DIR)/$(THORNLIST)") ; \
	  then \
	  if ($(SETUP_ENV) $(PERL) -s $(SETUP) $(SETUP_OPTIONS) $@) ; then : ; else\
            echo "" ;                                                      \
            echo "Error creating configuration $@" ;                       \
            exit 2                                 ;                       \
          fi ;                                                             \
	  if test -n "$(THORNLIST)" ; \
	  then \
	    echo Using ThornList $(THORNLIST_DIR)/$(THORNLIST) ; \
	    cp $(THORNLIST_DIR)/$(THORNLIST) $(CONFIGS_DIR)/$@/ThornList ; \
	  fi ; \
	  echo $(DIVIDER) ;  \
	  if test "x$(PROMPT)" = "xno" ; then \
	    $(MAKE) $(@:%-config=%) WARN=$(WARN); \
	  else \
	    echo Use $(MAKE) $@ to build the configuration. ; \
	  fi; \
	  else \
	    echo "ThornList $(THORNLIST_DIR)/$(THORNLIST) does not exist" ; \
	  fi ; \
	fi 
	@echo $(DIVIDER)