Makefile 3.37 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# ----------------------------------------------------------------------
# Makefile for OpenMM Preview Release 3 workshop "hello world" examples.
# June 24, 2009.
# See https://simtk.org/home/openmm.
# ----------------------------------------------------------------------
# This assumes you have gcc compilers for whatever language you are
# using: g++ for C++ and C, gfortran for Fortran 95.
# 
# Note: the C Wrappers and Fortran Module are just prototypes. They are
# incomplete but have enough functionality to get through these examples.
# We would like more complete and better-thought-out interfaces; if you
# have code or ideas please post to the OpenMM forum at the above URL
# (select "Advanced/Public Forums").
#
# This has had only minimal testing, although it has been known to
# work. It is likely to work fine for C and C++. For Fortran, you
# may need to add some of the C/C++ libraries: 
18
#    -lc -lm -lstdc++ (or -lstdc++.6) -lgcc -lgcc_s
19
20
# but this wasn't required for these examples on Centos 5.2 using
# gcc 4.1.2.
21
22

# Check whether this is the right capitalization for your install directory.
23
OpenMM_INSTALL_DIR=/usr/local/openmm
24
CFLAGS = -g 
25
FFLAGS = -g -ffree-line-length-none
26

27
# Extra libraries required when gfortran links with a C++ module.
28
29
30
31
# If this doesn't work, look in /usr/lib to
# see what versions of libstdc++.so you have and try different
# versions.
FCPPLIBS = -lstdc++
32

33
34
LIB_DIR=$(OpenMM_INSTALL_DIR)/lib
INCLUDE_DIR=$(OpenMM_INSTALL_DIR)/include
Michael Sherman's avatar
Michael Sherman committed
35
# assume local directory for C and Fortran wrappers
36
WRAPPER_DIR=.
37
LIBS= -lOpenMM
38
39
40
41
42

ALL_CPP_EXAMPLES = HelloArgon HelloSodiumChloride HelloEthane HelloWaterBox
ALL_C_EXAMPLES   = HelloArgonInC HelloSodiumChlorideInC
ALL_F95_EXAMPLES = HelloArgonInFortran HelloSodiumChlorideInFortran

Michael Sherman's avatar
Michael Sherman committed
43
44
ALL_PROGS = $(ALL_CPP_EXAMPLES) $(ALL_C_EXAMPLES) $(ALL_F95_EXAMPLES)

45
46
47
48
default: HelloArgon

all : $(ALL_PROGS)

Michael Sherman's avatar
Michael Sherman committed
49
50
# Treat all .cpp source files the same way (except the one that 
# implements the C Wrappers).
51
.cpp : 
52
	g++ $(CFLAGS) -I$(INCLUDE_DIR) $< -L$(LIB_DIR) $(LIBS) -o $*
53

54
55
HelloArgonInC: HelloArgonInC.c OpenMMCWrapper.o
	g++ $(CFLAGS) -I$(WRAPPER_DIR) HelloArgonInC.c OpenMMCWrapper.o \
Michael Sherman's avatar
Michael Sherman committed
56
57
        -L$(LIB_DIR) $(LIBS) -o HelloArgonInC

58
59
HelloSodiumChlorideInC: HelloSodiumChlorideInC.c OpenMMCWrapper.o
	g++ $(CFLAGS) -I$(WRAPPER_DIR) HelloSodiumChlorideInC.c OpenMMCWrapper.o \
Michael Sherman's avatar
Michael Sherman committed
60
61
        -L$(LIB_DIR) $(LIBS) -o HelloSodiumChlorideInC

62
63
HelloArgonInFortran: HelloArgonInFortran.f90 openmm.mod OpenMMFortranWrapper.o OpenMMCWrapper.o
	gfortran $(FFLAGS) HelloArgonInFortran.f90 OpenMMFortranWrapper.o OpenMMCWrapper.o \
64
	    -L$(LIB_DIR) $(LIBS) $(FCPPLIBS) -o HelloArgonInFortran
Michael Sherman's avatar
Michael Sherman committed
65

66
67
HelloSodiumChlorideInFortran: HelloSodiumChlorideInFortran.f90 openmm.mod OpenMMFortranWrapper.o OpenMMCWrapper.o
	gfortran $(FFLAGS) HelloSodiumChlorideInFortran.f90 OpenMMFortranWrapper.o OpenMMCWrapper.o \
68
	    -L$(LIB_DIR) $(LIBS) $(FCPPLIBS) -o HelloSodiumChlorideInFortran
Michael Sherman's avatar
Michael Sherman committed
69
70

# Build C Wrappers (Fortran depends on this too)
71
OpenMMCWrapper.o: 
Michael Sherman's avatar
Michael Sherman committed
72
	g++ -c $(CFLAGS) -I$(WRAPPER_DIR) -I$(INCLUDE_DIR) \
73
74
75
76
77
78
         $(WRAPPER_DIR)/OpenMMCWrapper.cpp -o OpenMMCWrapper.o

# Build Fortran Wrappers
OpenMMFortranWrapper.o: 
	g++ -c $(CFLAGS) -I$(WRAPPER_DIR) -I$(INCLUDE_DIR) \
         $(WRAPPER_DIR)/OpenMMFortranWrapper.cpp -o OpenMMFortranWrapper.o
79

Michael Sherman's avatar
Michael Sherman committed
80
81
# Build Fortran 95 Module file
openmm.mod:
82
	gfortran -c $(FFLAGS) $(WRAPPER_DIR)/OpenMMFortranModule.f90
83
84

clean : 
85
	rm $(ALL_PROGS) *.o *.mod *.obj *.exe
86