File: config_makeFileIN.py

package info (click to toggle)
syrthes 4.3.0-dfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 84,148 kB
  • sloc: ansic: 49,309; python: 25,790; makefile: 265; sh: 215; xml: 153
file content (581 lines) | stat: -rwxr-xr-x 17,993 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#-----------------------------------------------------------------------
#
#                         SYRTHES version 4.X.X.
#                         -------------------
#
#     This file is part of the SYRTHES Kernel, element of the
#     thermal code SYRTHES.
#
#     Copyright (C) 2009 EDF S.A., France
#
#     contact: syrthes-support@edf.fr
#
#
#     The SYRTHES Kernel is free software; you can redistribute it
#     and/or modify it under the terms of the GNU General Public License
#     as published by the Free Software Foundation; either version 2 of
#     the License, or (at your option) any later version.
#
#     The SYRTHES Kernel is distributed in the hope that it will be
#     useful, but WITHOUT ANY WARRANTY; without even the implied warranty
#     of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
#
#
#     You should have received a copy of the GNU General Public License;
#     if not, write to the
#     Free Software Foundation, Inc.,
#     51 Franklin St, Fifth Floor,
#     Boston, MA  02110-1301  USA
#
#-----------------------------------------------------------------------

#-------------------------------------------------------------------------------
# Library modules import
# 
#-------------------------------------------------------------------------------
import sys
#
if sys.version_info[:2] < (2,3):
    sys.stderr.write("This script needs Python 2.3 at least\n")
    
import os, re, os.path, shutil
import time, getpass
#
import platform
#
if platform.system == 'Windows':
    sys.stderr.write("This script only works on Unix-like platforms\n")


#-------------------------------------------------------------------------------
# Global methods
#-------------------------------------------------------------------------------
def main():
    #
    #
    # install
    # -------
    setupmakefilein = Setupmakefilein()


#-------------------------------------------------------------------------------
# Class definition Setupmakefilein
#
# 
#-------------------------------------------------------------------------------
class Setupmakefilein(object):

    #----------------------------------------------------------------------------    
    #  Fonction configuration_make 
    #  Adjust libraries location and environment variables 
    #----------------------------------------------------------------------------
    def configuration_make(self, Setupmakefilein, my_arch = None):
        #
        # Makefile.in file update
        #
	makefileinFile = file('Makefile.in', mode='w')

        makefileinFile.write("""SHELL = /bin/sh
# ******************************************************
# ******************************************************
#      Initialisation
# ******************************************************
# ******************************************************
# pour appeler le makefile qui va bien 
#(les options se cumulent quand c'est possible) 
# make                --> version MPI, sans BLAS, sans CFD  avec DEBUG
# make MPI=no        --> version sequentielle sans MPI
# make BLAS=yes       --> version avec les BLAS
# make CFD=yes        --> version avec couplage CFD
# make DEBUG=no      --> version compilee en +O2
# make PROF=yes       --> version compilee avec -pg
# make MED=no        --> version compilee sans MED
# make PART_METIS=yes --> version compilee avec METIS
# make PART_SCOTCH=yes --> version compilee avec SCOTCH


#--------------
# Default setup
#--------------

BLAS=no
CFD=no
DEBUG=no
PROF=no
PART_METIS=no
PART_SCOTCH=no

""")
        if self.dicolib['med'].has_key('PATH'):
            makefileinFile.write("MED=yes\n")
        else :
            makefileinFile.write("MED=no\n")

        if self.dicolib['mpi'].has_key('PATH'):
            makefileinFile.write("MPI=yes\n")
        else :
            makefileinFile.write("MPI=no\n")
	    
        if self.dicolib['metis'].has_key('PATH'):
            makefileinFile.write("PART_METIS=yes\n")
        else :
            makefileinFile.write("PART_METIS=no\n")	    
	    
        if self.dicolib['scotch'].has_key('PATH'):
            makefileinFile.write("PART_SCOTCH=yes\n")
        else :
            makefileinFile.write("PART_SCOTCH=no\n")	    
	    
        if self.dicospeci['specific_inc'].has_key('PATH'):
            makefileinFile.write("INC += "+self.dicospeci['specific_inc']['PATH']+"\n")
        else :
            makefileinFile.write("INC=\n")
	      
        if self.dicospeci['specific_lib'].has_key('PATH'):
            makefileinFile.write("LIB += "+self.dicospeci['specific_lib']['PATH']+"\n")
        else :
            makefileinFile.write("LIB=\n")

        if self.dicospeci['specific_debug'].has_key('PATH'):
            makefileinFile.write("DEBUG=yes\n")
            makefileinFile.write("COPTIM= "+self.dicospeci['specific_debug']['PATH']+"\n")
        else:
            makefileinFile.write("COPTIM= \n")

        makefileinFile.write("# Sources and build directories\n")
        makefileinFile.write("DIR_SYRTHES=%s"%self.syrthesDir+"\n") 
        makefileinFile.write("BUILD_SYRTHES=%s"%self.syrthesDir+"/arch/"+self.arch+"\n") 

        makefileinFile.write("""
#-----------------
# Building options
#-----------------

CFLAG = -D _FILE_OFFSET_BITS=64 $(CFLAGS)
LDFLAG= -D _FILE_OFFSET_BITS=64 $(LDFLAGS)

ifeq ($(MPI),yes)
	CFLAG  += -D_SYRTHES_MPI_
	LDFLAG += -D_SYRTHES_MPI_
endif

ifeq ($(BLAS),yes)
	CFLAG += -D_SYRTHES_BLAS_
endif

ifeq ($(CFD),yes)
        CFLAG += -D_SYRTHES_CFD_
endif

ifeq ($(PROF),yes)
	COPTIM = -pg
endif

""")
        if self.dicospeci['specific_option'].has_key('PATH'):
            makefileinFile.write("CFLAG += "+self.dicospeci['specific_option']['PATH']+"\n")
            
        makefileinFile.write("""

#-----------------------------------
# Names of libraries and executables
#-----------------------------------

NAME_PPSYR=syrthes-pp
NAME_POSTSYR=syrthes-post
NAME_PPFUNCSYR=syrthes-ppfunc

NAME_CONVERT=convert2syrthes4
NAME_SYRTHES2ENSIGHT=syrthes4ensight
NAME_SYRTHES2MED=syrthes4med30

NAMELIB = libsyrthes_mpi.a

ifeq ($(MPI),no)
	NAMELIB = libsyrthes_seq.a
endif

ifeq ($(CFD),yes)
	NAMELIB = libsyrthes_cfd.a
endif

ifeq ($(DEBUG),yes)
	NAMELIB = libsyrthes_mpi.a
	ifeq ($(MPI),no)
		NAMELIB = libsyrthes_seq.a
	endif
	ifeq ($(CFD),yes)
		NAMELIB = libsyrthes_cfd.a
	endif
endif

LIB_SYRTHES = $(NAMELIB)


# ******************************************************
# ******************************************************
#      SYSTEM DEPENDENT OPTIONS
# ******************************************************
# ******************************************************

""")


                
##  Compiler       
        makefileinFile.write("# Compiler path for gcc\n")
        makefileinFile.write("FRONT_CC="+self.comp+"\n")

        if self.dicolib['mpi']['USE'].upper()=='YES':
            makefileinFile.write("# Compiler path for mpicc\n")
            makefileinFile.write("CC="+self.dicolib['mpi']['PATH']+"/bin/"+self.wrapperc+"\n"+"\n")
        else:
            makefileinFile.write("CC="+self.comp+"\n")

##  Compiler  CC whith out mpi    
        makefileinFile.write("ifeq ($(MPI),no)\n")
        makefileinFile.write("        CC="+self.comp+"\n")
        makefileinFile.write("endif\n"+"\n")

##  Library
        if  self.dicolib['metis'].has_key('PATH'):
             makefileinFile.write("DIR_METIS="+self.dicolib['metis']['PATH']+"\n")
        
        if  self.dicolib['scotch'].has_key('PATH'):
             makefileinFile.write("DIR_SCOTCH="+self.dicolib['scotch']['PATH']+"\n")
        
        if  self.dicolib['med'].has_key('PATH'):
             makefileinFile.write("DIR_MED="+self.dicolib['med']['PATH']+"\n")
        
	if  self.dicolib['hdf5'].has_key('PATH'):
             makefileinFile.write("DIR_HDF5="+self.dicolib['hdf5']['PATH']+"\n")
	
	makefileinFile.write("\nifeq ($(CFD),yes)\n")
	if  self.dicolib['ple'].has_key('PATH'):
             makefileinFile.write("       DIR_PLE="+self.dicolib['ple']['PATH']+"\n")
       	makefileinFile.write("endif\n")

        makefileinFile.write("\nifeq ($(BLAS),yes)\n")
	if  self.dicolib['blas'].has_key('PATH'):
             makefileinFile.write("       DIR_BLAS="+self.dicolib['blas']['PATH']+"\n")
	makefileinFile.write("endif\n"+"\n")


        makefileinFile.write("""
#
# ******************************************************
# ******************************************************
#      LOCAL DIRECTORIES
# ******************************************************
# ******************************************************
# kernel library directory, MAkefile.in path, material library
DIRLIB_KERNEL =$(BUILD_SYRTHES)/lib
MAKEINC = $(DIR_SYRTHES)
INC_SYRTHES_LIBMAT = -I$(DIR_SYRTHES)/src/syrthes-kernel/lib_material_syrthes

# for choosing your own SYRTHES libraries :
#DIRLIB_KERNEL =/home/foo/mylib
#MAKEINC = /home/foo/mymake
#INC_SYRTHES_LIBMAT = -I/home/foo/mymateriallib

#.....................................................................


# create build directory if needed
#$(shell mkdir -p $(BUILDDIR))


INC_SYRTHES           = -I$(DIR_SYRTHES)/src/syrthes-kernel/include
SRC_SYRTHES           = $(DIR_SYRTHES)/src/syrthes-kernel/src

INC_PPSYR= -I$(DIR_SYRTHES)/src/syrthes-pp/include
INC_PPFUNCSYR= -I$(DIR_SYRTHES)/src/syrthes-ppfunc/include
INC_POSTSYR= -I$(DIR_SYRTHES)/src/syrthes-post/include

LIB_SYRTHES=   $(DIRLIB_KERNEL)/$(NAMELIB)
PPSYR=         $(BUILD_SYRTHES)/bin/$(NAME_PPSYR)
PPFUNCSYR=     $(BUILD_SYRTHES)/bin/$(NAME_PPFUNCSYR)
POSTSYR=       $(BUILD_SYRTHES)/bin/$(NAME_POSTSYR)

SYRENSIGHT=    $(BUILD_SYRTHES)/bin/$(NAME_SYRTHES2ENSIGHT)
CONVERTSYR=    $(BUILD_SYRTHES)/bin/$(NAME_CONVERT)
SYRREFINE=     $(BUILD_SYRTHES)/bin/$(NAME_SYRTHESREFINE)
CONVERTMED=    $(BUILD_SYRTHES)/bin/$(NAME_SYRTHES2MED)

# med
LIBMED=-L $(DIR_MED)/lib -L$(DIR_HDF5)/lib -lmedC -lhdf5 -L.
INC_MED= -I$(DIR_MED)/include -I$(DIR_HDF5)/include

# ensight
LIBENSIGHT=-lm -lz -lpthread

ifeq ($(CFD),yes)   
        INC += -I$(DIR_PLE)/include
        INC += -I$(DIR_SYRTHES)/src/syrthes-kernel/include
        LIB_PLE = -L$(DIR_PLE)/lib -lple -Wl,-rpath -Wl,$(DIR_PLE)/lib
endif

ifeq ($(BLAS),yes)
	LDFLAG += -lcblas -latlas 
	INC += -I$(DIR_BLAS)/??? isa
endif
""")

        # If metis or scotch are used
        # ---------------------------
        if  self.dicolib['metis'].has_key('PATH'):
            
            makefileinFile.write("LIBMETIS=-lmetis\n")
            makefileinFile.write("INC_METIS=-I$(DIR_METIS)/include\n")

        if  self.dicolib['scotch'].has_key('PATH'):
            
            makefileinFile.write("LIBSCOTCH=-L $(DIR_SCOTCH)/lib -lscotch -L $(DIR_SCOTCH)/lib -lscotcherr\n")
            makefileinFile.write("INC_SCOTCH=-I$(DIR_SCOTCH)/include/scotch\n")

        makefileinFile.close()

#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#           second fichier
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


	makefileinFile = file('Makefile2.in', mode='w')

        makefileinFile.write("""SHELL = /bin/sh
# ******************************************************
# ******************************************************
#      Initialisation
# ******************************************************
# ******************************************************
# pour appeler le makefile qui va bien 
#(les options se cumulent quand c'est possible) 
# make                --> version MPI, sans BLAS, sans CFD  avec DEBUG
# make MPI=no        --> version sequentielle sans MPI
# make BLAS=yes       --> version avec les BLAS
# make CFD=yes        --> version avec couplage CFD
# make DEBUG=no      --> version compilee en +O2
# make PROF=yes       --> version compilee avec -pg
# make MED=no        --> versin compilee sans MED
# make PART_METIS=yes --> version compilee avec METIS
# make PART_SCOTCH=yes --> version compilee avec SCOTCH


#--------------
# Default setup
#--------------

BLAS=no
CFD=no
DEBUG=no
PROF=no
PART_METIS=no
PART_SCOTCH=no
""")
        if self.dicolib['med'].has_key('PATH'):
              makefileinFile.write("MED=yes\n")
        else :
              makefileinFile.write("MED=no\n")

        if self.dicolib['mpi'].has_key('PATH'):
              makefileinFile.write("MPI=yes\n")
        else :
              makefileinFile.write("MPI=no\n")
	    
        if self.dicolib['metis'].has_key('PATH'):
            makefileinFile.write("PART_METIS=yes\n")
        else :
            makefileinFile.write("PART_METIS=no\n")	    
	    
        if self.dicolib['scotch'].has_key('PATH'):
            makefileinFile.write("PART_SCOTCH=yes\n")
        else :
            makefileinFile.write("PART_SCOTCH=no\n")	    
      
        if self.dicospeci['specific_inc'].has_key('PATH'):
              makefileinFile.write("INC += -I"+self.dicospeci['specific_inc']['PATH']+"\n")
        else :
              makefileinFile.write("INC=\n")
	      
        if self.dicospeci['specific_lib'].has_key('PATH'):
              makefileinFile.write("LIB += -L"+self.dicospeci['specific_lib']['PATH']+"\n")
        else :
              makefileinFile.write("LIB=\n")

        if self.dicospeci['specific_debug'].has_key('PATH'):
            makefileinFile.write("DEBUG=yes\n")
            makefileinFile.write("COPTIM= "+self.dicospeci['specific_debug']['PATH']+"\n")
        else:
            makefileinFile.write("COPTIM= \n")

        makefileinFile.write("# Sources and build directories\n")
        makefileinFile.write("BUILD_SYRTHES=%s"%self.syrthesDir+"/arch/"+self.arch+"\n")

        makefileinFile.write("""
#-----------------
# Building options
#-----------------

CFLAG = -D _FILE_OFFSET_BITS=64 $(CFLAGS)
LDFLAG= -D _FILE_OFFSET_BITS=64 $(LDFLAGS)

ifeq ($(MPI),yes)
	CFLAG  += -D_SYRTHES_MPI_
	LDFLAG += -D_SYRTHES_MPI_
endif

ifeq ($(BLAS),yes)
	CFLAG += -D_SYRTHES_BLAS_
endif

ifeq ($(CFD),yes)
        CFLAG += -D_SYRTHES_CFD_
endif

ifeq ($(PROF),yes)
	COPTIM = -pg
endif


""")
        if self.dicospeci['specific_option'].has_key('PATH'):
            makefileinFile.write("CFLAG += "+self.dicospeci['specific_option']['PATH']+"\n")
            
        makefileinFile.write("""


#-----------------------------------
# Names of libraries and executables
#-----------------------------------

NAMELIB = libsyrthes_mpi.a

ifeq ($(MPI),no)
	NAMELIB = libsyrthes_seq.a
endif

ifeq ($(CFD),yes)
	NAMELIB = libsyrthes_cfd.a
endif

ifeq ($(DEBUG),yes)
	NAMELIB = libsyrthes_mpi.a
	ifeq ($(MPI),no)
		NAMELIB = libsyrthes_seq.a
	endif
	ifeq ($(CFD),yes)
		NAMELIB = libsyrthes_cfd.a
	endif
endif

LIB_SYRTHES = $(NAMELIB)


# ******************************************************
# ******************************************************
#      SYSTEM DEPENDENT OPTIONS
# ******************************************************
# ******************************************************

""")


                
##  Compiler       
        makefileinFile.write("# Compiler path for gcc\n")
        makefileinFile.write("FRONT_CC="+self.comp+"\n")

        if self.dicolib['mpi']['USE'].upper()=='YES':
            makefileinFile.write("# Compiler path for mpicc\n")
            makefileinFile.write("CC="+self.dicolib['mpi']['PATH']+"/bin/"+self.wrapperc+"\n"+"\n")
        else:
            makefileinFile.write("CC="+self.comp+"\n")
            
##  Compiler  CC whith out mpi    
        makefileinFile.write("ifeq ($(MPI),no)\n")
        makefileinFile.write("        CC="+self.comp+"\n")
	makefileinFile.write("endif\n"+"\n")

##  Library
	makefileinFile.write("\nifeq ($(CFD),yes)\n")
	if  self.dicolib['ple'].has_key('PATH'):
             makefileinFile.write("       DIR_PLE="+self.dicolib['ple']['PATH']+"\n")
       	makefileinFile.write("endif\n")

        makefileinFile.write("\nifeq ($(BLAS),yes)\n")
	if  self.dicolib['blas'].has_key('PATH'):
             makefileinFile.write("       DIR_BLAS="+self.dicolib['blas']['PATH']+"\n")
	makefileinFile.write("endif\n"+"\n")


        makefileinFile.write("""
# ******************************************************
# ******************************************************
#      LOCAL DIRECTORIES
# ******************************************************
# ******************************************************

# kernel library directory, MAkefile.in path, material library
DIRLIB_KERNEL =$(BUILD_SYRTHES)/lib
MAKEINC = $(DIR_SYRTHES)
INC_SYRTHES_LIBMAT    = -I$(BUILD_SYRTHES)/include

# for choosing your own SYRTHES libraries :
#DIRLIB_KERNEL =/home/foo/mylib
#MAKEINC = /home/foo/mymake
#INC_SYRTHES_LIBMAT = -I/home/foo/mymateriallib


# kernel library directory
DIRLIB_KERNEL =$(BUILD_SYRTHES)/lib
# for choosing your own library : DIRLIB_KERNEL = /home/myhome/w/mylib

# path for include
MAKEINC = $(DIR_SYRTHES)/include
# example :  MAKEINC = /home/myhome/w/myinclude

# Name of the material propreties directory
INC_SYRTHES_LIBMAT    = -I$(BUILD_SYRTHES)/lib_material_syrthes
# for choosing your own library : INC_SYRTHES_LIBMAT    = -I/home/myhome/w/mylib_material
#.....................................................................

INC_SYRTHES= -I$(BUILD_SYRTHES)/include
LIB_SYRTHES=$(DIRLIB_KERNEL)/$(NAMELIB)

ifeq ($(CFD),yes)   
        INC += -I$(DIR_PLE)/include
        INC += -I$(BUILD_SYRTHES)/include
        LIB_PLE = -L$(DIR_PLE)/lib -lple -Wl,-rpath -Wl,$(DIR_PLE)/lib
endif

ifeq ($(BLAS),yes)
	LDFLAG += -lcblas -latlas 
	INC += -I$(DIR_BLAS)/??? isa
endif
""")
        makefileinFile.close()











#-------------------------------------------------------------------------------
# 
# Progam principal
# 
#
#
#-------------------------------------------------------------------------------
if __name__ == '__main__':
        main()