5 import pluto_files_IO
as pfIO
6 from define_problem
import DefineProblem
9 def __init__(self, work_dir, pluto_dir, auto_update_def, auto_update_mkfl):
10 """Create the makefile for the PLUTO code from the defintions header file.
12 This class creates a makefile with all necessary information
13 that would compile the code based on the problem defined by user
15 In case the makefile is already present, this class will
16 read those default values to re-create the file.
19 1. work_dir = Path to PLUTO code working directory
20 2. pluto_dir = Path to PLUTO source directory
21 3. auto-update_def = Boolean that indicates auto-update of defintions.h.
22 4. auto-update_mkfl = Boolean that indicates auto-update of makefile.
25 It generates a makefile for compilation.
40 menu.Print (
"> Generating makefile... ["+self.
arch+
"]", row=self.
row,sleep=1)
52 """Sets the Architecture for compilation of code.
54 This attribute of the MakeProblem class looks for the
55 'ARCH' keyword in makefile and if not defined will define it
56 based on user's choice of the Makefile configuration
57 from the Config/ folder. If already defined then will use
58 that architecture for compilation of Makefile.
60 mkfl_exits = os.path.exists(self.
mkfl_name)
63 scrh = pf.LocateString(
'ARCH')
65 if self.
auto_update == 0
or not mkfl_exits
or len(scrh[0]) == 0:
67 entries = os.listdir(self.
pluto_dir +
'/Config')
68 for def_file
in entries:
69 if (def_file.endswith(
'.defs')): def_list.append(def_file)
77 self.
arch = self.arch_string.split()[2]
80 """Adds CHOMBO specific vars in the Makefile.
82 This method of the MakeProblem class does necessary
83 modification to the makefile so as to accomodate
84 compilation of chombo (AMR) specific variables.
86 pf = pfIO.PlutoFiles(self.
work_dir+
'/definitions.h')
87 scrh = pf.LocateString(
'DIMENSIONS')
88 dims = scrh[0][1].split()[2]
89 chombo_config_string =
'DIM='+dims
91 if '--with-chombo:' in sys.argv:
92 i = sys.argv.index(
'--with-chombo:') + 1
96 print "Additional Configration Details Required for '--with-chombo:' flag"
99 for y
in sys.argv[i:]:
100 chombo_config_string +=
' '+y
103 menu.Print(
" - Chombo config string: "+chombo_config_string,row=self.
row)
106 os.chdir(self.
pluto_dir+
"/Lib/Chombo-3.2/lib")
107 os.system(
"make "+chombo_config_string+
" vars > make.vars\n")
108 os.system(
"cp make.vars "+self.
work_dir+
"\n")
114 Updates Makefile with additional flags, files and modular makefile paths.
118 pf.ReplaceWord(
'PLUTO_DIR',
'PLUTO_DIR = '+self.
pluto_dir+
'\n',DelOld=
True)
119 pf.ReplaceWord(
'ARCH',self.
arch_string, DelOld=
True)
121 scrh = pf.LocateString(
'Additional_header_files_here')
122 ipos = scrh[0][0] + 3
124 pf.InsertLine(
'HEADERS += '+ x +
'\n',ipos)
127 scrh = pf.LocateString(
'Additional_object_files_here')
128 ipos = scrh[0][0] + 3
130 pf.InsertLine(
'OBJ += '+x +
'\n', ipos)
134 pf.InsertLine(
'include $(SRC)/' + x +
'makefile' +
'\n',ipos)
138 pf.InsertLine(
'CFLAGS += '+x+
'\n', ipos)
def UpdateMkflTemplate(self)
def __init__(self, work_dir, pluto_dir, auto_update_def, auto_update_mkfl)