Commit 693e34b5 authored by Giacomo Fiorin's avatar Giacomo Fiorin
Browse files

Print parsed compiler flags, some cosmetic changes for added consistency

parent c578e4e7
Loading
Loading
Loading
Loading
+13 −9
Changes for lib/colvars/Install.py: 13 added lines, 9 removed lines.
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ suffix = args.extramake
def get_lammps_machine_flags(machine):
  """Parse Makefile.machine from LAMMPS, return dictionary of compiler flags"""
  if not os.path.exists("../../src/MAKE/MACHINES/Makefile.%s" % machine):
    sys.exit("Cannot locate src/MAKE/MACHINES/Makefile.%s" % machine)
    sys.exit("ERROR: Cannot locate src/MAKE/MACHINES/Makefile.%s" % machine)
  lines = open("../../src/MAKE/MACHINES/Makefile.%s" % machine,
               'r').readlines()
  machine_flags = {}
@@ -70,6 +70,8 @@ def get_lammps_machine_flags(machine):
          (words[0] == 'SHFLAGS') or (words[0] == 'ARCHIVE') or
          (words[0] == 'ARFLAGS') or (words[0] == 'SHELL')):
        machine_flags[words[0]] = ' '.join(words[2:])
  if machine_flags:
    print("Detected the following flags: ", machine_flags)
  return machine_flags

def gen_colvars_makefile_machine(machine, machine_flags):
@@ -103,7 +105,7 @@ if not os.path.exists("Makefile.%s" % machine):
  machine_flags = get_lammps_machine_flags(machine)
  gen_colvars_makefile_machine(machine, machine_flags)
if not os.path.exists("Makefile.%s" % machine):
  sys.exit("lib/%s/Makefile.%s does not exist" % (lib,machine))
  sys.exit("ERROR: lib/%s/Makefile.%s does not exist" % (lib,machine))

# create Makefile.auto as copy of Makefile.machine
# reset EXTRAMAKE if requested
@@ -123,15 +125,17 @@ fp.close()
n_cpus = get_cpus()

print("Building lib%s.a ..." % lib)
cmd = ["make -f Makefile.auto clean; make -f Makefile.auto -j%d" % n_cpus]
cmd = "make -f Makefile.auto clean; make -f Makefile.auto -j%d" % n_cpus
try:
  txt = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True);
  txt = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT);
  print(txt.decode('UTF-8'))
except subprocess.CalledProcessError as e:
  print("Make failed with:\n %s" % e.output.decode('UTF-8'))
  sys.exit(1)
  sys.exit("Make failed with:\n %s" % e.output.decode('UTF-8'))

if os.path.exists("lib%s.a" % lib):
  print("Build was successful")
else:
  sys.exit("Build of lib/%s/lib%s.a was NOT successful" % (lib, lib))

if os.path.exists("lib%s.a" % lib): print("Build was successful")
else: sys.exit("Build of lib/%s/lib%s.a was NOT successful" % (lib,lib))
if not os.path.exists("Makefile.lammps"):
  print("lib/%s/Makefile.lammps was NOT created" % lib)
  print("WARNING: lib/%s/Makefile.lammps was NOT created" % lib)