[CSC 435] Makefile Example

Andrew J. Pounds pounds_aj at mercer.edu
Thu Feb 27 08:00:06 EST 2014


Bryan asked to see how my makefile to build the code with multiple 
targets was structured -- here it is...

# Makefile to build multiversioned babyBLAS
#
# Andrew J. Pounds, Ph.D.
# Departments of Chemistry and Computer Science
# Mercer University
# Fall 2011
#

F95 = gfortran
CC = gcc
FFLAGS = -O2 -frepack-arrays -finline-functions  -Wall
CFLAGS = -Wall
OLDFORMAT = -fixed-form
LIBFLAG =
GCCOPT = -param l2-cache-size=2048
ATLAS = /usr/local/ATLAS/lib/libf77blas.a 
/usr/local/ATLAS/lib/libcblas.a /usr/local/ATLAS/lib/libatlas.a


debug ?= n
ifeq ($(debug), y)
     CFLAGS += -g -DDEBUG
else
     CFLAGS += -O3 -mtune=native -march=native  -ffast-math 
-fprefetch-loop-arrays \
               -ftree-vectorize -ftree-vectorizer-verbose=7
endif

openmp ?= n
ifeq ($(openmp), y)
     CFLAGS += -fopenmp -DOPENMP
     LIBFLAG += -lgomp
endif

pthreads ?= n
ifeq ($(pthreads), y)
     CFLAGS += -pthread -DPTHREADS
     LIBFLAG += -lpthread
endif

OBJS = array.o zeromat.o walltime.o cputime.o mmm.o  \
        vvm.o dot.o

all: mdriver accuracytest

mdriver : mdriver.o $(OBJS)
     $(F95) -o mdriver mdriver.o $(OBJS) $(LIBFLAG) #$(ATLAS)

mdriver.o : mdriver.f90 array.o
     $(F95) $(FFLAGS) -c mdriver.f90

accuracytest : accuracytest.o $(OBJS)
     $(F95) -o accuracytest accuracytest.o $(OBJS) $(LIBFLAG) #$(ATLAS)

accuracytest.o : accuracytest.f90 array.o
     $(F95) $(FFLAGS) -c accuracytest.f90

walltime.o : walltime.c
     $(CC) $(CFLAGS) -c walltime.c

cputime.o : cputime.c
     $(CC) $(CFLAGS) -c cputime.c

zeromat.o : zeromat.f90
     $(F95) $(FFLAGS)  -c zeromat.f90

array.o : array.f90
     $(F95) -c array.f90

mmm.o : mmm.c
     $(CC) $(CFLAGS)  -c mmm.c

dot.o : dot.c
     $(CC) $(CFLAGS) -c dot.c

vvm.o : vvm.c
     $(CC) $(CFLAGS) -c vvm.c

# Default Targets for Cleaning up the Environment
clean :
     rm *.o

pristine :
     rm *.o
     touch *.cc *.c *.f *.f90
     rm *.mod

ctags :
     ctags *.f90

-- 
Andrew J. Pounds, Ph.D.  (pounds_aj at mercer.edu)
Professor of Chemistry and Computer Science
Mercer University,  Macon, GA 31207   (478) 301-5627
http://faculty.mercer.edu/pounds_aj

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://theochem.mercer.edu/pipermail/csc435/attachments/20140227/2d199c4e/attachment.html>


More information about the csc435 mailing list