Makefile 2.8 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# ----------------------------------------------------------------------
# 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: 
#    -lc -lm -lstdc++ -lgcc -lgcc_s
# but this wasn't required for these examples on Centos 5.2 using
# gcc 4.1.2.
21
22
23
24

# Check whether this is the right capitalization for your install directory.
OpenMM_INSTALL_DIR=/usr/local/OpenMM
CFLAGS = -g 
Michael Sherman's avatar
Michael Sherman committed
25
FFLAGS = -g
26
27
28

LIB_DIR=$(OpenMM_INSTALL_DIR)/lib
INCLUDE_DIR=$(OpenMM_INSTALL_DIR)/include
Michael Sherman's avatar
Michael Sherman committed
29
# assume local directory for C and Fortran wrappers
30
WRAPPER_DIR=.
31
LIBS= -lOpenMM
32
33
34
35
36

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

Michael Sherman's avatar
Michael Sherman committed
37
38
ALL_PROGS = $(ALL_CPP_EXAMPLES) $(ALL_C_EXAMPLES) $(ALL_F95_EXAMPLES)

39
40
41
42
default: HelloArgon

all : $(ALL_PROGS)

Michael Sherman's avatar
Michael Sherman committed
43
44
# Treat all .cpp source files the same way (except the one that 
# implements the C Wrappers).
45
46
47
.cpp : 
	g++ $(CFLAGS) $< -I$(INCLUDE_DIR) -L$(LIB_DIR) $(LIBS) -o $*

Michael Sherman's avatar
Michael Sherman committed
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
HelloArgonInC: HelloArgonInC.c OpenMM_CWrapper.o
	g++ $(CFLAGS) -I$(WRAPPER_DIR) HelloArgonInC.c OpenMM_CWrapper.o \
        -L$(LIB_DIR) $(LIBS) -o HelloArgonInC

HelloSodiumChlorideInC: HelloSodiumChlorideInC.c OpenMM_CWrapper.o
	g++ $(CFLAGS) -I$(WRAPPER_DIR) HelloSodiumChlorideInC.c OpenMM_CWrapper.o \
        -L$(LIB_DIR) $(LIBS) -o HelloSodiumChlorideInC

HelloArgonInFortran: HelloArgonInFortran.f90 openmm.mod
	gfortran $(FFLAGS) HelloArgonInFortran.f90 OpenMM_CWrapper.o \
	    -L$(LIB_DIR) $(LIBS) -o HelloArgonInFortran

HelloSodiumChlorideInFortran: HelloSodiumChlorideInFortran.f90 openmm.mod
	gfortran $(FFLAGS) HelloSodiumChlorideInFortran.f90 OpenMM_CWrapper.o \
	    -L$(LIB_DIR) $(LIBS) -o HelloSodiumChlorideInFortran

# Build C Wrappers (Fortran depends on this too)
OpenMM_CWrapper.o: 
	g++ -c $(CFLAGS) -I$(WRAPPER_DIR) -I$(INCLUDE_DIR) \
         $(WRAPPER_DIR)/OpenMM_CWrapper.cpp -o OpenMM_CWrapper.o
68

Michael Sherman's avatar
Michael Sherman committed
69
70
71
# Build Fortran 95 Module file
openmm.mod:
	gfortran -c $(FFLAGS) $(WRAPPER_DIR)/OpenMM_Module.f90
72
73

clean : 
Michael Sherman's avatar
Michael Sherman committed
74
	rm $(ALL_PROGS) *.o *.mod
75