Unverified Commit d9d22658 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer Committed by GitHub
Browse files

Merge pull request #62 from giacomofiorin/fix-compiler-warnings

Enable COLVARS_LEPTON for make, update build doc for USER-COLVARS
parents 27d3d442 693e34b5
Loading
Loading
Loading
Loading
+44 −16
Changes for doc/src/Build_extras.txt: 44 added lines, 16 removed lines.
Original line number Diff line number Diff line
@@ -642,33 +642,61 @@ make lib-linalg args="-m gfortran" # build with GNU Fortran compiler :pre

USER-COLVARS package :h4,link(user-colvars)

This package includes into the LAMMPS distribution the Colvars library, which
can be built for the most part with all major versions of the C++ language.

A few of the most recent features require C++11 support.  In particular, the
library is optionally built together with the
"Lepton"_https://simtk.org/projects/lepton library, a copy of which is also
included in the LAMMPS distribution.  Lepton implements the
"customFunction"_http://colvars.github.io/colvars-refman-lammps/colvars-refman-lammps.html#colvar|customFunction
feature, and requires C++11 support.

See "here"_https://colvars.github.io/README-c++11.html for a detailed list of
C++11-only features.

[CMake build]:

The USER-COLVARS package requires the use of a C++11 compiler to compile
the included Lepton library. You can set the flag "-D COLVARS_LEPTON=no"
in addition to "-D PKG_USER-COLVARS=yes" in order to instruct CMake to
skip building and including the Lepton library into the USER-COLVARS code.
This is the recommended build recipe: no additional settings are normally
needed besides "-D PKG_USER-COLVARS=yes".

Building and linking of Lepton (or other C++11-only features) is enabled
automatically when compilation is carried out with C++11 support, and disabled
otherwise.  Optionally, Lepton build may be manually controlled with the flag
"-D COLVARS_LEPTON=yes|no".

[Traditional make]:

Before building LAMMPS, you must build the COLVARS library in
lib/colvars.  You can do this manually if you prefer; follow the
instructions in lib/colvars/README.  You can also do it in one step
from the lammps/src dir, using a command like these, which simply
invoke the lib/colvars/Install.py script with the specified args:
Before building LAMMPS, one must build the Colvars library in lib/colvars.

This can be done manually in the same folder by using or adapting one of the
provided Makefiles: for example, Makefile.g++ for the GNU compiler.

In general, it is safer to use build setting consistent with the rest of
LAMMPS.  This is best carried out from the LAMMPS src directory using a
command like these, which simply invoke the lib/colvars/Install.py script with
the specified args:

make lib-colvars                      # print help message
make lib-colvars args="-m serial"     # build with GNU g++ compiler (settings as with "make serial")
make lib-colvars args="-m mpi"        # build with default MPI compiler (settings as with "make mpi")
make lib-colvars args="-m g++-debug"  # build with GNU g++ compiler and colvars debugging enabled :pre

The build should produce two files: lib/colvars/libcolvars.a and
lib/colvars/Makefile.lammps.  The latter is copied from an existing
Makefile.lammps.* and has settings needed to build LAMMPS with the
COLVARS library (though typically the settings are just blank).  If
necessary, you can edit/create a new lib/colvars/Makefile.machine file
for your system, which should define an EXTRAMAKE variable to specify
a corresponding Makefile.lammps.machine file.
The "machine" argument of the "-m" flag is used to find a Makefile.machine to
use as build recipe.  If it does not already exist in lib/colvars, it will be
auto-generated by using compiler flags consistent with those parsed from the
core LAMMPS makefiles.

Optional flags may be specified as environment variables:

COLVARS_DEBUG=yes make lib-colvars args="-m machine"  # Build with debug code (much slower)
COLVARS_LEPTON=no make lib-colvars args="-m machine"  # Build without Lepton (included otherwise)

The build should produce two files: the library lib/colvars/libcolvars.a
(which also includes Lepton objects if enabled) and the specification file
lib/colvars/Makefile.lammps.  The latter is auto-generated, and normally does
not need to be edited.


:line

+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)
+1 −1
Changes for lib/colvars/Makefile.common: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ LEPTON_SRCS = \


# Allow to selectively turn off Lepton
ifeq ($(ENABLE_LEPTON),no)
ifeq ($(COLVARS_LEPTON),no)
LEPTON_INCFLAGS = 
COLVARS_OBJS = $(COLVARS_SRCS:.cpp=.o)
else
+1 −1
Changes for lib/colvars/Makefile.g++-debug: 1 added line, 1 removed line.
Original line number Diff line number Diff line
# -*- makefile -*- to build Colvars module with GNU compiler

COLVARS_DEBUG = "YES"
COLVARS_DEBUG = yes

include Makefile.g++
+5 −0
Changes for lib/colvars/Makefile.g++-no-lepton: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
# -*- makefile -*- to build Colvars module with GNU compiler

COLVARS_LEPTON = no

include Makefile.g++
Loading