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

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

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

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

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

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

40
41
42
43
default: HelloArgon

all : $(ALL_PROGS)

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

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

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

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

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

64

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

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