-
Notifications
You must be signed in to change notification settings - Fork 23
/
makefile
81 lines (60 loc) · 1.88 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# MAKE FILE
PROGRAM = KlustaKwik
OBJS = io.o linalg.o log.o parameters.o precomputations.o util.o memorytracking.o klustakwik.o
CC = g++
DEBUG = -g
PROFILE = -pg
OPTIMISATIONS = -O3 -ffast-math -march=native
GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags)
ifdef NOOPENMP
OPENMPFLAG =
else
OPENMPFLAG = -fopenmp
endif
# If the git command failed, GIT_VERSION will be empty, so don't pass a DVERSION flag (fallback)
ifeq ($(strip $(GIT_VERSION)),)
CFLAGS = -Wall -c -Wno-write-strings $(OPTIMISATIONS) $(OPENMPFLAG)
else
CFLAGS = -Wall -c -Wno-write-strings $(OPTIMISATIONS) $(OPENMPFLAG) -DVERSION=\"$(GIT_VERSION)\"
endif
LFLAGS = -Wall $(OPENMPFLAG)
all: executable
# Remove -march=native from optimisations for older gcc versions
oldgcc: OPTIMISATIONS = -O3 -ffast-math
oldgcc: executable
# Adds debug flags
debug: CFLAGS += $(DEBUG)
debug: LFLAGS += $(DEBUG)
debug: executable
# Adds profiling flags
profile: CFLAGS += $(PROFILE)
profile: LFLAGS += $(PROFILE)
profile: executable
.PHONY: all debug native executable clean noopenmp
executable: $(OBJS)
$(CC) $(LFLAGS) $(OBJS) -o $(PROGRAM)
clean:
\rm *.o $(PROGRAM)
######## DEPENDENCIES FOR FILES IN PROJECT ###################################
linalg.h: numerics.h
klustakwik.h: parameters.h log.h util.h numerics.h linalg.h memorytracking.h
numerics.h: globalswitches.h
parameters.h: numerics.h
util.h: numerics.h
memorytracking.h: numerics.h
io.o: io.cpp klustakwik.h
$(CC) $(CFLAGS) $<
linalg.o: linalg.cpp linalg.h
$(CC) $(CFLAGS) $<
log.o: log.cpp log.h parameters.h
$(CC) $(CFLAGS) $<
klustakwik.o: klustakwik.cpp klustakwik.h
$(CC) $(CFLAGS) $<
parameters.o: parameters.cpp parameters.h log.h util.h
$(CC) $(CFLAGS) $<
precomputations.o: precomputations.cpp klustakwik.h
$(CC) $(CFLAGS) $<
util.o: util.cpp util.h
$(CC) $(CFLAGS) $<
memorytracking.o: memorytracking.cpp memorytracking.h
$(CC) $(CFLAGS) $<