Makefile 2.54 KB
Newer Older
1
# ----------------------------------------------------------------------
2
3
# Makefile for OpenMM Preview Release 4 workshop "hello world" examples.
# August 18, 2009
4
5
6
7
8
# 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.
# 
9
10
11
# For the C and Fortran examples, we're depending on your version of
# OpenMM to have been built with the automatically-generated API
# wrappers.
12
13
14
15
#
# 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: 
16
#    -lc -lm -lstdc++ (or -lstdc++.6) -lgcc -lgcc_s
17
18
# but this wasn't required for these examples on Centos 5.2 using
# gcc 4.1.2.
19
20

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

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

31
32
LIB_DIR=$(OpenMM_INSTALL_DIR)/lib
INCLUDE_DIR=$(OpenMM_INSTALL_DIR)/include
33
LIBS= -lOpenMM
34
35
36
37
38

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

Michael Sherman's avatar
Michael Sherman committed
39
40
ALL_PROGS = $(ALL_CPP_EXAMPLES) $(ALL_C_EXAMPLES) $(ALL_F95_EXAMPLES)

41
42
43
44
default: HelloArgon

all : $(ALL_PROGS)

45
# Treat all .cpp source files the same way.
46
.cpp : 
47
	g++ $(CFLAGS) -I$(INCLUDE_DIR) $< -L$(LIB_DIR) $(LIBS) -o $*
48

49
HelloArgonInC: HelloArgonInC.c 
50
	g++ $(CFLAGS) -I$(INCLUDE_DIR) HelloArgonInC.c \
Michael Sherman's avatar
Michael Sherman committed
51
52
        -L$(LIB_DIR) $(LIBS) -o HelloArgonInC

53
HelloSodiumChlorideInC: HelloSodiumChlorideInC.c 
54
	g++ $(CFLAGS) -I$(INCLUDE_DIR) HelloSodiumChlorideInC.c \
Michael Sherman's avatar
Michael Sherman committed
55
56
        -L$(LIB_DIR) $(LIBS) -o HelloSodiumChlorideInC

57
58
HelloArgonInFortran: HelloArgonInFortran.f90 openmm.mod 
	gfortran $(FFLAGS) HelloArgonInFortran.f90 \
peastman's avatar
peastman committed
59
	    -I$(INCLUDE_DIR) -L$(LIB_DIR) $(LIBS) $(FCPPLIBS) -o HelloArgonInFortran
Michael Sherman's avatar
Michael Sherman committed
60

61
62
HelloSodiumChlorideInFortran: HelloSodiumChlorideInFortran.f90 openmm.mod 
	gfortran $(FFLAGS) HelloSodiumChlorideInFortran.f90 \
peastman's avatar
peastman committed
63
	    -I$(INCLUDE_DIR) -L$(LIB_DIR) $(LIBS) $(FCPPLIBS) -o HelloSodiumChlorideInFortran
Michael Sherman's avatar
Michael Sherman committed
64

65

Michael Sherman's avatar
Michael Sherman committed
66
67
# Build Fortran 95 Module file
openmm.mod:
68
	gfortran -c $(FFLAGS) $(INCLUDE_DIR)/OpenMMFortranModule.f90
69
70

clean : 
71
	rm $(ALL_PROGS) *.o *.mod *.obj *.exe
72