-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
55 lines (44 loc) · 1.28 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Comp 4510 - Sample MPI Makefile
###############################################
# Change these files names to match your own: #
###############################################
# name of the executable to be generated
PROG = dijkstra
# space-delimited list of header files
HDRS = dijkstra.h
# space-delimited list of source files
SRCS = dijkstra.c
#######################
# Don't change these: #
#######################
# directory to store object files
OBJDIR = object
# names of object files
OBJS = $(patsubst %.c, $(OBJDIR)/%.o, $(SRCS))
# name of the compiler
CC = mpicc
# additional compiler flags to pass in
CFLAGS = -Wall --std=c99 -L.
# libraries for the linker
LIBS = -lm
####################
# Compiling rules: #
####################
# WARNING: *must* have a tab before each definition
# invoked when "make" is run
all : $(OBJDIR) $(PROG)
# links object files into executable
$(PROG) : $(OBJS)
$(CC) $(CFLAGS) $^ -o $(PROG) $(LIBS)
# compiles source files into object files
object/%.o : %.c $(HDRS)
$(CC) -c $(CFLAGS) $< -o $@ $(LIBS)
# creates directory to store object files
$(OBJDIR) :
mkdir -p $@/
# cleans up object files and executable
# type "make clean" to use
# Note: you can add your own commands to remove other things (e.g. output files)
clean:
rm -rf object/
rm -f $(PROG)